[Signin][SAS] Return std::optional from GetPreferredAccountForPromo [chromium/src : main]

0 views
Skip to first unread message

Menghan Yang (Gerrit)

unread,
Jul 23, 2026, 9:03:19 AM (22 hours ago) Jul 23
to Pâris Meuleman, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Pâris Meuleman

Menghan Yang voted and added 1 comment

Votes added by Menghan Yang

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Menghan Yang . resolved

Hi Pâris,

Here is the CL I mentioned earlier, would you mind having a look?

I feel that I don't have enough context yet and am not used to work in this part of code, please don't hesitate to be as picky as you want so I can better learn!

Thank you in advance🙏

Open in Gerrit

Related details

Attention is currently required from:
  • Pâris Meuleman
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
Gerrit-Change-Number: 8131615
Gerrit-PatchSet: 6
Gerrit-Owner: Menghan Yang <my...@google.com>
Gerrit-Reviewer: Menghan Yang <my...@google.com>
Gerrit-Reviewer: Pâris Meuleman <pmeu...@chromium.org>
Gerrit-Attention: Pâris Meuleman <pmeu...@chromium.org>
Gerrit-Comment-Date: Thu, 23 Jul 2026 13:03:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Pâris Meuleman (Gerrit)

unread,
4:36 AM (2 hours ago) 4:36 AM
to Menghan Yang, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Menghan Yang

Pâris Meuleman voted and added 1 comment

Votes added by Pâris Meuleman

Code-Review+1

1 comment

File components/signin/core/browser/account_preview_data_service.h
Line 40, Patchset 6 (Latest): // fetched yet, the first account is returned by default. Returns std::nullopt
Pâris Meuleman . resolved
not your change but this is not true given 
```
AccountPreviewDataService::AccountPreviewPreference
AccountPreviewDataServiceImpl::ComputePreferredAccount() const {
CHECK(base::FeatureList::IsEnabled(
switches::kEnableAccountPreviewPreferredAccount));
  // TODO(crbug.com/530144650): Implement heuristic to compute the preferred
// account and preferred data types.
return AccountPreviewPreference();
}
```

https://source.chromium.org/chromium/chromium/src/+/main:components/signin/core/browser/account_preview_data_service_impl.cc;l=231;drc=2c2e022b251a82064c60e67b17f9103162a501aa;bpv=1;bpt=1

Open in Gerrit

Related details

Attention is currently required from:
  • Menghan Yang
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
    Gerrit-Change-Number: 8131615
    Gerrit-PatchSet: 6
    Gerrit-Owner: Menghan Yang <my...@google.com>
    Gerrit-Reviewer: Menghan Yang <my...@google.com>
    Gerrit-Reviewer: Pâris Meuleman <pmeu...@chromium.org>
    Gerrit-Attention: Menghan Yang <my...@google.com>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 08:36:12 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Menghan Yang (Gerrit)

    unread,
    4:44 AM (2 hours ago) 4:44 AM
    to Pâris Meuleman, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Pâris Meuleman

    Menghan Yang voted and added 1 comment

    Votes added by Menghan Yang

    Auto-Submit+1

    1 comment

    File components/signin/core/browser/account_preview_data_service.h
    Line 40, Patchset 6 (Latest): // fetched yet, the first account is returned by default. Returns std::nullopt
    Pâris Meuleman . unresolved
    not your change but this is not true given 
    ```
    AccountPreviewDataService::AccountPreviewPreference
    AccountPreviewDataServiceImpl::ComputePreferredAccount() const {
    CHECK(base::FeatureList::IsEnabled(
    switches::kEnableAccountPreviewPreferredAccount));
      // TODO(crbug.com/530144650): Implement heuristic to compute the preferred
    // account and preferred data types.
    return AccountPreviewPreference();
    }
    ```

    https://source.chromium.org/chromium/chromium/src/+/main:components/signin/core/browser/account_preview_data_service_impl.cc;l=231;drc=2c2e022b251a82064c60e67b17f9103162a501aa;bpv=1;bpt=1

    Menghan Yang

    Thanks a lot for the review! 😊
    Indeed, the comment was here before the CL, I though it was still the plan even if it's not implemented yet (I guess it makes sense to return the first account to avoid custom handling at the platform UI level to simplify the code, but it can also reduce flexibility in the future if we want to add custom logic at the os level)

    Wdyt about leaving it here for now, and update if the implementation changes direction in the future? (re-opening this comment for confirming before submit)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Pâris Meuleman
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
      Gerrit-Change-Number: 8131615
      Gerrit-PatchSet: 6
      Gerrit-Owner: Menghan Yang <my...@google.com>
      Gerrit-Reviewer: Menghan Yang <my...@google.com>
      Gerrit-Reviewer: Pâris Meuleman <pmeu...@chromium.org>
      Gerrit-Attention: Pâris Meuleman <pmeu...@chromium.org>
      Gerrit-Comment-Date: Fri, 24 Jul 2026 08:43:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Pâris Meuleman <pmeu...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Pâris Meuleman (Gerrit)

      unread,
      4:50 AM (2 hours ago) 4:50 AM
      to Menghan Yang, Chromium LUCI CQ, chromium...@chromium.org
      Attention needed from Menghan Yang

      Pâris Meuleman added 1 comment

      File components/signin/core/browser/account_preview_data_service.h
      Line 40, Patchset 6 (Latest): // fetched yet, the first account is returned by default. Returns std::nullopt
      Pâris Meuleman . resolved
      not your change but this is not true given 
      ```
      AccountPreviewDataService::AccountPreviewPreference
      AccountPreviewDataServiceImpl::ComputePreferredAccount() const {
      CHECK(base::FeatureList::IsEnabled(
      switches::kEnableAccountPreviewPreferredAccount));
        // TODO(crbug.com/530144650): Implement heuristic to compute the preferred
      // account and preferred data types.
      return AccountPreviewPreference();
      }
      ```

      https://source.chromium.org/chromium/chromium/src/+/main:components/signin/core/browser/account_preview_data_service_impl.cc;l=231;drc=2c2e022b251a82064c60e67b17f9103162a501aa;bpv=1;bpt=1

      Menghan Yang

      Thanks a lot for the review! 😊
      Indeed, the comment was here before the CL, I though it was still the plan even if it's not implemented yet (I guess it makes sense to return the first account to avoid custom handling at the platform UI level to simplify the code, but it can also reduce flexibility in the future if we want to add custom logic at the os level)

      Wdyt about leaving it here for now, and update if the implementation changes direction in the future? (re-opening this comment for confirming before submit)

      Pâris Meuleman

      SGTM

      I'll try to keep it mind if we implement UI changes before heuristic changes 😊

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Menghan Yang
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
        Gerrit-Change-Number: 8131615
        Gerrit-PatchSet: 6
        Gerrit-Owner: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Pâris Meuleman <pmeu...@chromium.org>
        Gerrit-Attention: Menghan Yang <my...@google.com>
        Gerrit-Comment-Date: Fri, 24 Jul 2026 08:50:38 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Menghan Yang <my...@google.com>
        Comment-In-Reply-To: Pâris Meuleman <pmeu...@chromium.org>
        satisfied_requirement
        open
        diffy

        Menghan Yang (Gerrit)

        unread,
        5:20 AM (2 hours ago) 5:20 AM
        to Pâris Meuleman, Chromium LUCI CQ, chromium...@chromium.org

        Menghan Yang added 1 comment

        File components/signin/core/browser/account_preview_data_service.h
        Line 40, Patchset 6 (Latest): // fetched yet, the first account is returned by default. Returns std::nullopt
        Pâris Meuleman . resolved
        not your change but this is not true given 
        ```
        AccountPreviewDataService::AccountPreviewPreference
        AccountPreviewDataServiceImpl::ComputePreferredAccount() const {
        CHECK(base::FeatureList::IsEnabled(
        switches::kEnableAccountPreviewPreferredAccount));
          // TODO(crbug.com/530144650): Implement heuristic to compute the preferred
        // account and preferred data types.
        return AccountPreviewPreference();
        }
        ```

        https://source.chromium.org/chromium/chromium/src/+/main:components/signin/core/browser/account_preview_data_service_impl.cc;l=231;drc=2c2e022b251a82064c60e67b17f9103162a501aa;bpv=1;bpt=1

        Menghan Yang

        Thanks a lot for the review! 😊
        Indeed, the comment was here before the CL, I though it was still the plan even if it's not implemented yet (I guess it makes sense to return the first account to avoid custom handling at the platform UI level to simplify the code, but it can also reduce flexibility in the future if we want to add custom logic at the os level)

        Wdyt about leaving it here for now, and update if the implementation changes direction in the future? (re-opening this comment for confirming before submit)

        Pâris Meuleman

        SGTM

        I'll try to keep it mind if we implement UI changes before heuristic changes 😊

        Menghan Yang

        Thank you!

        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
        Gerrit-Change-Number: 8131615
        Gerrit-PatchSet: 6
        Gerrit-Owner: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Pâris Meuleman <pmeu...@chromium.org>
        Gerrit-Comment-Date: Fri, 24 Jul 2026 09:20:25 +0000
        satisfied_requirement
        open
        diffy

        Menghan Yang (Gerrit)

        unread,
        5:20 AM (2 hours ago) 5:20 AM
        to Pâris Meuleman, Chromium LUCI CQ, chromium...@chromium.org

        Menghan Yang voted Commit-Queue+2

        Commit-Queue+2
        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
        Gerrit-Change-Number: 8131615
        Gerrit-PatchSet: 6
        Gerrit-Owner: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Pâris Meuleman <pmeu...@chromium.org>
        Gerrit-Comment-Date: Fri, 24 Jul 2026 09:20:29 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        5:26 AM (2 hours ago) 5:26 AM
        to Menghan Yang, Pâris Meuleman, chromium...@chromium.org

        Chromium LUCI CQ submitted the change

        Change information

        Commit message:
        [Signin][SAS] Return std::optional from GetPreferredAccountForPromo

        Previously, GetPreferredAccountForPromo always returns a non-null
        preference object event if the gaiaID string is not valid. This can be
        confusing (preferred data types list is not meaningful if the preferred
        account ID is not valid) and complexifies slightly the data conversion
        from native to java, which forbid conversion when the ID string is empty
        [1].

        This CL updates AccountPreviewDataService::GetPreferredAccountForPromo
        to return std::optional<AccountPreviewPreference> when necessary (e.g.
        no account on the device) or if the saved/computed gaia_id is not valid.

        If we realise that we prefer that the service shouldn't be called in
        cases when it can return null, we can remove the `optional` from the
        return type later.

        [1]
        https://source.chromium.org/chromium/chromium/src/+/main:google_apis/gaia/gaia_id.cc;l=36;drc=60df9044934a2841875904f21e9673afe970da1e
        Bug: 532967033
        Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
        Auto-Submit: Menghan Yang <my...@google.com>
        Commit-Queue: Menghan Yang <my...@google.com>
        Reviewed-by: Pâris Meuleman <pmeu...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#1667734}
        Files:
        • M components/signin/core/browser/account_preview_data_service.h
        • M components/signin/core/browser/account_preview_data_service_impl.cc
        • M components/signin/core/browser/account_preview_data_service_impl.h
        • M components/signin/core/browser/account_preview_data_service_impl_unittest.cc
        Change size: M
        Delta: 4 files changed, 48 insertions(+), 33 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Pâris Meuleman
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I75ddb023faeb76d07b495c6e80111274cf3f29a1
        Gerrit-Change-Number: 8131615
        Gerrit-PatchSet: 7
        Gerrit-Owner: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Menghan Yang <my...@google.com>
        Gerrit-Reviewer: Pâris Meuleman <pmeu...@chromium.org>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages