Centralize AutofillAI authentication and server-side fetching logic. [chromium/src : main]

0 views
Skip to first unread message

Karol Sygiet (Gerrit)

unread,
Apr 22, 2026, 10:48:09 AM (13 days ago) Apr 22
to Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
Attention needed from Florian Leimgruber

Karol Sygiet added 1 comment

Patchset-level comments
File-level comment, Patchset 9 (Latest):
Karol Sygiet . resolved

Hi Florian, could you take a look?

Open in Gerrit

Related details

Attention is currently required from:
  • Florian Leimgruber
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
Gerrit-Change-Number: 7786130
Gerrit-PatchSet: 9
Gerrit-Owner: Karol Sygiet <syg...@google.com>
Gerrit-Reviewer: Florian Leimgruber <fleim...@google.com>
Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
Gerrit-Comment-Date: Wed, 22 Apr 2026 14:47:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Florian Leimgruber (Gerrit)

unread,
Apr 23, 2026, 6:00:36 AM (12 days ago) Apr 23
to Karol Sygiet, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
Attention needed from Karol Sygiet

Florian Leimgruber added 1 comment

File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
Line 79, Patchset 9 (Latest):MaybeAuthenticateAndFetchForFilling(
Florian Leimgruber . unresolved

Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

Especially the `show_loading_state_callback` feels really weird.

Open in Gerrit

Related details

Attention is currently required from:
  • Karol Sygiet
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
    Gerrit-Change-Number: 7786130
    Gerrit-PatchSet: 9
    Gerrit-Owner: Karol Sygiet <syg...@google.com>
    Gerrit-Reviewer: Florian Leimgruber <fleim...@google.com>
    Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
    Gerrit-Attention: Karol Sygiet <syg...@google.com>
    Gerrit-Comment-Date: Thu, 23 Apr 2026 10:00:17 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Karol Sygiet (Gerrit)

    unread,
    Apr 27, 2026, 4:55:45 AM (8 days ago) Apr 27
    to Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
    Attention needed from Florian Leimgruber

    Karol Sygiet added 1 comment

    File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
    Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
    Florian Leimgruber . resolved

    Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

    Especially the `show_loading_state_callback` feels really weird.

    Karol Sygiet

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Florian Leimgruber
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
      Gerrit-Change-Number: 7786130
      Gerrit-PatchSet: 20
      Gerrit-Owner: Karol Sygiet <syg...@google.com>
      Gerrit-Reviewer: Florian Leimgruber <fleim...@google.com>
      Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
      Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
      Gerrit-Comment-Date: Mon, 27 Apr 2026 08:55:32 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Florian Leimgruber <fleim...@google.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Karol Sygiet (Gerrit)

      unread,
      Apr 28, 2026, 3:28:09 AM (7 days ago) Apr 28
      to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
      Attention needed from Florian Leimgruber and Jihad Hanna

      Karol Sygiet added 1 comment

      Patchset-level comments
      File-level comment, Patchset 20 (Latest):
      Karol Sygiet . resolved

      Hi Jihad, Since florian is OOO, could you take a look instead?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Florian Leimgruber
      • Jihad Hanna
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
      Gerrit-Change-Number: 7786130
      Gerrit-PatchSet: 20
      Gerrit-Owner: Karol Sygiet <syg...@google.com>
      Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
      Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
      Gerrit-CC: Florian Leimgruber <fleim...@google.com>
      Gerrit-Attention: Jihad Hanna <jihad...@google.com>
      Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
      Gerrit-Comment-Date: Tue, 28 Apr 2026 07:27:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Jihad Hanna (Gerrit)

      unread,
      Apr 28, 2026, 4:32:27 AM (7 days ago) Apr 28
      to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
      Attention needed from Florian Leimgruber and Karol Sygiet

      Jihad Hanna added 10 comments

      File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
      Line 90, Patchset 21 (Latest): const Suggestion& suggestion,
      Jihad Hanna . unresolved

      super nit: Move up, as usually we leave bools and enums in the end.

      Line 88, Patchset 21 (Latest): AutofillClient& client,
      Jihad Hanna . unresolved

      const?

      Line 77, Patchset 21 (Latest): AutofillClient& client,
      Jihad Hanna . unresolved

      const?

      File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
      Line 197, Patchset 21 (Latest):CreateAutofillAiReauthConverter(const FieldTypeSet& ai_field_types,
      Jihad Hanna . unresolved

      document

      Line 203, Patchset 21 (Latest): return auth_succeeded ? std::move(entity)
      : std::optional<EntityInstance>();
      Jihad Hanna . unresolved

      optional nit:

      ```
      return auth_succeeded ? std::optional<EntityInstance>(std::move(entity))
      : std::nullopt;
      ```

      seemed more intuitive to me.

      Line 209, Patchset 21 (Latest):std::unique_ptr<device_reauth::DeviceAuthenticator> StartAutofillAiReauth(
      Jihad Hanna . unresolved

      document

      Line 215, Patchset 21 (Latest):#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) || \
      BUILDFLAG(IS_IOS)
      const std::u16string origin = base::UTF8ToUTF16(field.origin().host());
      message = l10n_util::GetStringFUTF16(IDS_AUTOFILL_AI_FILLING_REAUTH, origin);
      #endif
      Jihad Hanna . unresolved

      Could you document why this is different on android?

      Line 226, Patchset 21 (Latest): std::move(callback).Run(/*auth_succeeded=*/true);
      Jihad Hanna . unresolved

      Since authentication didn't really succeed, add a comment explaining why we're passing true.

      Line 377, Patchset 21 (Latest): return base::BindOnce(
      [](base::WeakPtr<AutofillClient> client,
      base::OnceCallback<void(std::optional<EntityInstance>)>
      fill_form_callback,
      std::optional<EntityInstance> masked_entity) {
      if (!masked_entity || !client ||
      !client->GetWalletPassAccessManager()) {
      std::move(fill_form_callback).Run(std::nullopt);
      return;
      }
      auto maybe_notify_of_unmasking_error = base::BindOnce(
      [](base::WeakPtr<AutofillClient> client,
      std::optional<EntityInstance> entity) {
      if (client && !entity) {
      client->ShowAutofillAiFetchFromWalletFailureNotification();
      }
      return entity;
      },
      client);
      client->GetWalletPassAccessManager()->GetUnmaskedWalletEntityInstance(
      masked_entity->guid(), std::move(maybe_notify_of_unmasking_error)
      .Then(std::move(fill_form_callback)));
      },
      client.GetWeakPtr(), std::move(fill_form_callback));
      Jihad Hanna . unresolved

      What do you think about creating two lambdas `maybe_notify_of_unmasking_error` and `fetch_callback` before `return base::BindOnce(...)` so that the code is more readable?

      File components/autofill/core/browser/ui/autofill_external_delegate.cc
      Line 1349, Patchset 21 (Latest): if (!entity || !autofill_field) {
      Jihad Hanna . unresolved

      `|| !form_structure`? We shouldn't implicitly assume that one implies the other.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Florian Leimgruber
      • Karol Sygiet
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
        Gerrit-Change-Number: 7786130
        Gerrit-PatchSet: 21
        Gerrit-Owner: Karol Sygiet <syg...@google.com>
        Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
        Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
        Gerrit-CC: Florian Leimgruber <fleim...@google.com>
        Gerrit-Attention: Karol Sygiet <syg...@google.com>
        Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
        Gerrit-Comment-Date: Tue, 28 Apr 2026 08:32:09 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Karol Sygiet (Gerrit)

        unread,
        Apr 28, 2026, 5:19:59 AM (7 days ago) Apr 28
        to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
        Attention needed from Florian Leimgruber and Jihad Hanna

        Karol Sygiet added 10 comments

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
        Line 90, Patchset 21: const Suggestion& suggestion,
        Jihad Hanna . resolved

        super nit: Move up, as usually we leave bools and enums in the end.

        Karol Sygiet

        Done

        Line 88, Patchset 21: AutofillClient& client,
        Jihad Hanna . unresolved

        const?

        Karol Sygiet

        In the implementation `StartAutofillAiReauth` calls `client.GetDeviceAuthenticator(` which is not const.

        Line 77, Patchset 21: AutofillClient& client,
        Jihad Hanna . unresolved

        const?

        Karol Sygiet

        This function uses WeakPtr and IIUC typically we don't want const `GetWeakPtr` methods

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
        Line 197, Patchset 21:CreateAutofillAiReauthConverter(const FieldTypeSet& ai_field_types,
        Jihad Hanna . resolved

        document

        Karol Sygiet

        Done

        Line 203, Patchset 21: return auth_succeeded ? std::move(entity)
        : std::optional<EntityInstance>();
        Jihad Hanna . resolved

        optional nit:

        ```
        return auth_succeeded ? std::optional<EntityInstance>(std::move(entity))
        : std::nullopt;
        ```

        seemed more intuitive to me.

        Karol Sygiet

        Done

        Line 209, Patchset 21:std::unique_ptr<device_reauth::DeviceAuthenticator> StartAutofillAiReauth(
        Jihad Hanna . resolved

        document

        Karol Sygiet

        Done

        Line 215, Patchset 21:#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) || \

        BUILDFLAG(IS_IOS)
        const std::u16string origin = base::UTF8ToUTF16(field.origin().host());
        message = l10n_util::GetStringFUTF16(IDS_AUTOFILL_AI_FILLING_REAUTH, origin);
        #endif
        Jihad Hanna . resolved

        Could you document why this is different on android?

        Karol Sygiet

        Done

        Line 226, Patchset 21: std::move(callback).Run(/*auth_succeeded=*/true);
        Jihad Hanna . unresolved

        Since authentication didn't really succeed, add a comment explaining why we're passing true.

        Karol Sygiet

        Added. I think this was the state of things before this CL, added a todo to evaluate whether it is the correct behavior.

        Line 377, Patchset 21: return base::BindOnce(

        [](base::WeakPtr<AutofillClient> client,
        base::OnceCallback<void(std::optional<EntityInstance>)>
        fill_form_callback,
        std::optional<EntityInstance> masked_entity) {
        if (!masked_entity || !client ||
        !client->GetWalletPassAccessManager()) {
        std::move(fill_form_callback).Run(std::nullopt);
        return;
        }
        auto maybe_notify_of_unmasking_error = base::BindOnce(
        [](base::WeakPtr<AutofillClient> client,
        std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
        return entity;
        },
        client);
        client->GetWalletPassAccessManager()->GetUnmaskedWalletEntityInstance(
        masked_entity->guid(), std::move(maybe_notify_of_unmasking_error)
        .Then(std::move(fill_form_callback)));
        },
        client.GetWeakPtr(), std::move(fill_form_callback));
        Jihad Hanna . unresolved

        What do you think about creating two lambdas `maybe_notify_of_unmasking_error` and `fetch_callback` before `return base::BindOnce(...)` so that the code is more readable?

        Karol Sygiet

        Let me know if it looks better now :)

        File components/autofill/core/browser/ui/autofill_external_delegate.cc
        Line 1349, Patchset 21: if (!entity || !autofill_field) {
        Jihad Hanna . resolved

        `|| !form_structure`? We shouldn't implicitly assume that one implies the other.

        Karol Sygiet

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Florian Leimgruber
        • Jihad Hanna
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
        Gerrit-Change-Number: 7786130
        Gerrit-PatchSet: 22
        Gerrit-Owner: Karol Sygiet <syg...@google.com>
        Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
        Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
        Gerrit-CC: Florian Leimgruber <fleim...@google.com>
        Gerrit-Attention: Jihad Hanna <jihad...@google.com>
        Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
        Gerrit-Comment-Date: Tue, 28 Apr 2026 09:19:43 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Jihad Hanna <jihad...@google.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Jihad Hanna (Gerrit)

        unread,
        Apr 28, 2026, 5:53:02 AM (7 days ago) Apr 28
        to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
        Attention needed from Florian Leimgruber and Karol Sygiet

        Jihad Hanna added 7 comments

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
        Line 88, Patchset 21: AutofillClient& client,
        Jihad Hanna . unresolved

        const?

        Karol Sygiet

        In the implementation `StartAutofillAiReauth` calls `client.GetDeviceAuthenticator(` which is not const.

        Line 77, Patchset 21: AutofillClient& client,
        Jihad Hanna . resolved

        const?

        Karol Sygiet

        This function uses WeakPtr and IIUC typically we don't want const `GetWeakPtr` methods

        Jihad Hanna

        Oh that is true, my bad 👍

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
        Line 226, Patchset 21: std::move(callback).Run(/*auth_succeeded=*/true);
        Jihad Hanna . resolved

        Since authentication didn't really succeed, add a comment explaining why we're passing true.

        Karol Sygiet

        Added. I think this was the state of things before this CL, added a todo to evaluate whether it is the correct behavior.

        Jihad Hanna

        Acknowledged

        Line 390, Patchset 22 (Latest): auto maybe_notify_of_unmasking_error = base::BindOnce(

        [](base::WeakPtr<AutofillClient> client,
        std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
        return entity;
        },
        client.GetWeakPtr());
        Jihad Hanna . unresolved

        Since this does not mutate the input, I believe the `.Then()` below is just added complexity.

        If we make this:

        ```
        // Notifies the client in case of fetch failure, and calls `fill_form_callback`.
        auto unmasking_callback = base::BindOnce(
        [](base::WeakPtr<AutofillClient> client,

        base::OnceCallback<void(std::optional<EntityInstance>)>
        fill_form_callback,
                 std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
                std::move(fill_form_callback).Run(entity);
        },
        client.GetWeakPtr(), std::move(fill_form_callback));
        ```

        And then we could remove one of the callbacks from the parameters of the other one.

        (If this seems useless to you, feel free to close this comment, I'm just finding the second callback a little cumbersome and this way felt a little easier to parse to me),

        Line 377, Patchset 21: return base::BindOnce(
        [](base::WeakPtr<AutofillClient> client,
        base::OnceCallback<void(std::optional<EntityInstance>)>
        fill_form_callback,
        std::optional<EntityInstance> masked_entity) {
        if (!masked_entity || !client ||
        !client->GetWalletPassAccessManager()) {
        std::move(fill_form_callback).Run(std::nullopt);
        return;
        }
        auto maybe_notify_of_unmasking_error = base::BindOnce(
        [](base::WeakPtr<AutofillClient> client,
        std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
        return entity;
        },
        client);
        client->GetWalletPassAccessManager()->GetUnmaskedWalletEntityInstance(
        masked_entity->guid(), std::move(maybe_notify_of_unmasking_error)
        .Then(std::move(fill_form_callback)));
        },
        client.GetWeakPtr(), std::move(fill_form_callback));
        Jihad Hanna . resolved

        What do you think about creating two lambdas `maybe_notify_of_unmasking_error` and `fetch_callback` before `return base::BindOnce(...)` so that the code is more readable?

        Karol Sygiet

        Let me know if it looks better now :)

        Jihad Hanna

        Yes thank you 👍

        Line 453, Patchset 22 (Latest): convert_auth_response = CreateAutofillAiReauthConverter(
        Jihad Hanna . unresolved

        Optional nit: I'd inline this.

        File components/autofill/core/browser/ui/autofill_external_delegate.cc
        Line 1379, Patchset 22 (Latest): if (should_fetch_from_server) {
        fill_and_hide =
        CreateAutofillAiFetchingCallback(client, std::move(fill_and_hide));
        }
        Jihad Hanna . unresolved

        We pass both `should_fetch_from_server` and `fill_and_hide` to `HandleAutofillAiReauthAndLoadingState()` below, can we move this to the function, and move `CreateAutofillAiFetchingCallback()` to the anonymous namespace?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Florian Leimgruber
        • Karol Sygiet
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
        Gerrit-Change-Number: 7786130
        Gerrit-PatchSet: 22
        Gerrit-Owner: Karol Sygiet <syg...@google.com>
        Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
        Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
        Gerrit-CC: Florian Leimgruber <fleim...@google.com>
        Gerrit-Attention: Karol Sygiet <syg...@google.com>
        Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
        Gerrit-Comment-Date: Tue, 28 Apr 2026 09:52:48 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Karol Sygiet <syg...@google.com>
        Comment-In-Reply-To: Jihad Hanna <jihad...@google.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Karol Sygiet (Gerrit)

        unread,
        Apr 28, 2026, 7:49:55 AM (7 days ago) Apr 28
        to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
        Attention needed from Florian Leimgruber and Jihad Hanna

        Karol Sygiet added 4 comments

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
        Line 88, Patchset 21: AutofillClient& client,
        Jihad Hanna . unresolved

        const?

        Karol Sygiet

        In the implementation `StartAutofillAiReauth` calls `client.GetDeviceAuthenticator(` which is not const.

        Jihad Hanna

        That's not [what I see](https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/core/browser/foundations/autofill_client.h;l=665-668;drc=868ed9b7d285b249a3b6dddde4f5fb0f80f608db). Am I missing something?

        Karol Sygiet

        Ah right, but still I'm not sure it will work since it now the non-const CreateAutofillAiFetchingCallback is called by this function.

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
        Line 390, Patchset 22: auto maybe_notify_of_unmasking_error = base::BindOnce(

        [](base::WeakPtr<AutofillClient> client,
        std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
        return entity;
        },
        client.GetWeakPtr());
        Jihad Hanna . unresolved

        Since this does not mutate the input, I believe the `.Then()` below is just added complexity.

        If we make this:

        ```
        // Notifies the client in case of fetch failure, and calls `fill_form_callback`.
        auto unmasking_callback = base::BindOnce(
        [](base::WeakPtr<AutofillClient> client,
        base::OnceCallback<void(std::optional<EntityInstance>)>
        fill_form_callback,
        std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
        std::move(fill_form_callback).Run(entity);
        },
        client.GetWeakPtr(), std::move(fill_form_callback));
        ```

        And then we could remove one of the callbacks from the parameters of the other one.

        (If this seems useless to you, feel free to close this comment, I'm just finding the second callback a little cumbersome and this way felt a little easier to parse to me),

        Karol Sygiet

        Done. PTAL if it looks better to you now

        Line 453, Patchset 22: convert_auth_response = CreateAutofillAiReauthConverter(
        Jihad Hanna . resolved

        Optional nit: I'd inline this.

        Karol Sygiet

        Done

        File components/autofill/core/browser/ui/autofill_external_delegate.cc
        Line 1379, Patchset 22: if (should_fetch_from_server) {

        fill_and_hide =
        CreateAutofillAiFetchingCallback(client, std::move(fill_and_hide));
        }
        Jihad Hanna . resolved

        We pass both `should_fetch_from_server` and `fill_and_hide` to `HandleAutofillAiReauthAndLoadingState()` below, can we move this to the function, and move `CreateAutofillAiFetchingCallback()` to the anonymous namespace?

        Karol Sygiet

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Florian Leimgruber
        • Jihad Hanna
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
        Gerrit-Change-Number: 7786130
        Gerrit-PatchSet: 23
        Gerrit-Owner: Karol Sygiet <syg...@google.com>
        Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
        Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
        Gerrit-CC: Florian Leimgruber <fleim...@google.com>
        Gerrit-Attention: Jihad Hanna <jihad...@google.com>
        Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
        Gerrit-Comment-Date: Tue, 28 Apr 2026 11:49:42 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Jihad Hanna (Gerrit)

        unread,
        Apr 28, 2026, 9:02:35 AM (7 days ago) Apr 28
        to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
        Attention needed from Karol Sygiet

        Jihad Hanna added 5 comments

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
        Line 86, Patchset 24: base::OnceCallback<void(std::optional<EntityInstance>)> fill_form_callback,
        Jihad Hanna . unresolved

        Can we call this `fill_form_and_hide_popup`?

        File components/autofill/core/browser/ui/autofill_external_delegate.cc
        Line 1356, Patchset 24: base::OnceCallback<void(std::optional<EntityInstance>)> fill_and_hide =
        Jihad Hanna . unresolved

        `fill_form_and_hide_popup`

        Line 1370, Patchset 24: .Then(base::BindOnce(&AutofillClient::HideAutofillSuggestions,
        client.GetWeakPtr(),
        SuggestionHidingReason::kAcceptSuggestion));
        Jihad Hanna . unresolved

        Just call the function in the lambda?

        Line 1374, Patchset 24: const bool should_fetch_from_server =
        suggestion.GetPayload<Suggestion::AutofillAiPayload>()
        .requires_server_fetch;
        Jihad Hanna . unresolved

        This can be moved to the function as well.

        Line 1378, Patchset 24: auto show_loading_suggestions_callback = base::BindOnce(
        [](base::WeakPtr<AutofillExternalDelegate> delegate,
        std::vector<Suggestion> suggestions) {
        if (delegate) {
        delegate->AttemptToDisplayAutofillSuggestions(
        std::move(suggestions), delegate->trigger_source_,
        /*is_update=*/true, AutofillSuggestionsIgnoreFocusLoss(true));
        }
        },
        GetWeakPtr());
        Jihad Hanna . unresolved

        This makes it feel like this will happen somehow asynchronously, whereas it doesn't.

        Can the newly created function just be a private method in AED instead, so that we don't have to define this here altogether?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Karol Sygiet
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
        Gerrit-Change-Number: 7786130
        Gerrit-PatchSet: 24
        Gerrit-Owner: Karol Sygiet <syg...@google.com>
        Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
        Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
        Gerrit-CC: Florian Leimgruber <fleim...@google.com>
        Gerrit-Attention: Karol Sygiet <syg...@google.com>
        Gerrit-Comment-Date: Tue, 28 Apr 2026 13:02:16 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Karol Sygiet (Gerrit)

        unread,
        Apr 29, 2026, 4:20:05 AM (6 days ago) Apr 29
        to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
        Attention needed from Jihad Hanna

        Karol Sygiet added 5 comments

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
        Line 86, Patchset 24: base::OnceCallback<void(std::optional<EntityInstance>)> fill_form_callback,
        Jihad Hanna . resolved

        Can we call this `fill_form_and_hide_popup`?

        Karol Sygiet

        Done

        File components/autofill/core/browser/ui/autofill_external_delegate.cc
        Line 1356, Patchset 24: base::OnceCallback<void(std::optional<EntityInstance>)> fill_and_hide =
        Jihad Hanna . resolved

        `fill_form_and_hide_popup`

        Karol Sygiet

        Done

        Line 1370, Patchset 24: .Then(base::BindOnce(&AutofillClient::HideAutofillSuggestions,
        client.GetWeakPtr(),
        SuggestionHidingReason::kAcceptSuggestion));
        Jihad Hanna . resolved

        Just call the function in the lambda?

        Karol Sygiet

        Done

        Line 1374, Patchset 24: const bool should_fetch_from_server =
        suggestion.GetPayload<Suggestion::AutofillAiPayload>()
        .requires_server_fetch;
        Jihad Hanna . resolved

        This can be moved to the function as well.

        Karol Sygiet

        Done

        Line 1378, Patchset 24: auto show_loading_suggestions_callback = base::BindOnce(
        [](base::WeakPtr<AutofillExternalDelegate> delegate,
        std::vector<Suggestion> suggestions) {
        if (delegate) {
        delegate->AttemptToDisplayAutofillSuggestions(
        std::move(suggestions), delegate->trigger_source_,
        /*is_update=*/true, AutofillSuggestionsIgnoreFocusLoss(true));
        }
        },
        GetWeakPtr());
        Jihad Hanna . unresolved

        This makes it feel like this will happen somehow asynchronously, whereas it doesn't.

        Can the newly created function just be a private method in AED instead, so that we don't have to define this here altogether?

        Karol Sygiet

        Made it a `base::FunctionRef` instead, does it look better?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Jihad Hanna
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
        Gerrit-Change-Number: 7786130
        Gerrit-PatchSet: 27
        Gerrit-Owner: Karol Sygiet <syg...@google.com>
        Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
        Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
        Gerrit-CC: Florian Leimgruber <fleim...@google.com>
        Gerrit-Attention: Jihad Hanna <jihad...@google.com>
        Gerrit-Comment-Date: Wed, 29 Apr 2026 08:19:51 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Jihad Hanna <jihad...@google.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Jihad Hanna (Gerrit)

        unread,
        Apr 29, 2026, 9:35:01 AM (6 days ago) Apr 29
        to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
        Attention needed from Jihad Hanna

        Jihad Hanna added 3 comments

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
        Line 88, Patchset 21: AutofillClient& client,
        Jihad Hanna . resolved

        const?

        Karol Sygiet

        In the implementation `StartAutofillAiReauth` calls `client.GetDeviceAuthenticator(` which is not const.

        Jihad Hanna

        That's not [what I see](https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/core/browser/foundations/autofill_client.h;l=665-668;drc=868ed9b7d285b249a3b6dddde4f5fb0f80f608db). Am I missing something?

        Karol Sygiet

        Ah right, but still I'm not sure it will work since it now the non-const CreateAutofillAiFetchingCallback is called by this function.

        Jihad Hanna

        Acknowledged

        File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
        Line 390, Patchset 22: auto maybe_notify_of_unmasking_error = base::BindOnce(
        [](base::WeakPtr<AutofillClient> client,
        std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
        return entity;
        },
        client.GetWeakPtr());
        Jihad Hanna . resolved

        Since this does not mutate the input, I believe the `.Then()` below is just added complexity.

        If we make this:

        ```
        // Notifies the client in case of fetch failure, and calls `fill_form_callback`.
          auto unmasking_callback = base::BindOnce(
        [](base::WeakPtr<AutofillClient> client,

        base::OnceCallback<void(std::optional<EntityInstance>)>
        fill_form_callback,
                 std::optional<EntityInstance> entity) {
        if (client && !entity) {
        client->ShowAutofillAiFetchFromWalletFailureNotification();
        }
        std::move(fill_form_callback).Run(entity);
        },
        client.GetWeakPtr(), std::move(fill_form_callback));
        ```

        And then we could remove one of the callbacks from the parameters of the other one.

        (If this seems useless to you, feel free to close this comment, I'm just finding the second callback a little cumbersome and this way felt a little easier to parse to me),

        Karol Sygiet

        Done. PTAL if it looks better to you now

        Jihad Hanna

        Acknowledged

        File components/autofill/core/browser/ui/autofill_external_delegate.cc
        Line 1378, Patchset 24: auto show_loading_suggestions_callback = base::BindOnce(
        [](base::WeakPtr<AutofillExternalDelegate> delegate,
        std::vector<Suggestion> suggestions) {
        if (delegate) {
        delegate->AttemptToDisplayAutofillSuggestions(
        std::move(suggestions), delegate->trigger_source_,
        /*is_update=*/true, AutofillSuggestionsIgnoreFocusLoss(true));
        }
        },
        GetWeakPtr());
        Jihad Hanna . resolved

        This makes it feel like this will happen somehow asynchronously, whereas it doesn't.

        Can the newly created function just be a private method in AED instead, so that we don't have to define this here altogether?

        Karol Sygiet

        Made it a `base::FunctionRef` instead, does it look better?

        Jihad Hanna

        Yes 👍

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Jihad Hanna
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
          Gerrit-Change-Number: 7786130
          Gerrit-PatchSet: 28
          Gerrit-Owner: Karol Sygiet <syg...@google.com>
          Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
          Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
          Gerrit-CC: Florian Leimgruber <fleim...@google.com>
          Gerrit-Attention: Jihad Hanna <jihad...@google.com>
          Gerrit-Comment-Date: Wed, 29 Apr 2026 13:34:46 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Jihad Hanna (Gerrit)

          unread,
          Apr 30, 2026, 3:02:02 AM (5 days ago) Apr 30
          to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
          Attention needed from Karol Sygiet

          Jihad Hanna added 2 comments

          File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
          Line 263, Patchset 28: auto unmasking_callback = base::BindOnce(

          [](base::WeakPtr<AutofillClient> client,
          base::OnceCallback<void(std::optional<EntityInstance>)>
          fill_form_and_hide_popup,

          std::optional<EntityInstance> entity) {
          if (client && !entity) {
          client->ShowAutofillAiFetchFromWalletFailureNotification();
          }
          std::move(fill_form_and_hide_popup).Run(entity);
          },
          client, std::move(fill_form_and_hide_popup));
          Jihad Hanna . unresolved

          We agreed on moving this out of the other lambda

          Line 448, Patchset 29 (Latest): if ((should_fetch_from_server || should_reauth) &&
          base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
          show_loading_suggestions_callback(PrepareLoadingStateSuggestions(
          base::ToVector(client.GetAutofillSuggestions()), suggestion));
          }
          Jihad Hanna . unresolved

          WDYT about calling this regardless whether `(should_fetch_from_server || should_reauth)` is true or false? I imagine that otherwise it wouldn't even show to the user because it would be very fast. We could then call it directly in AED and not pass it at all to this function, making things simpler.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Karol Sygiet
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 29
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Comment-Date: Thu, 30 Apr 2026 07:01:44 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            Apr 30, 2026, 3:16:07 AM (5 days ago) Apr 30
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Florian Leimgruber added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . resolved

            Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

            Especially the `show_loading_state_callback` feels really weird.

            Karol Sygiet

            Done

            Florian Leimgruber

            Drive-by: Why did we end up with a single function again? :)

            Gerrit-Comment-Date: Thu, 30 Apr 2026 07:15:45 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Karol Sygiet <syg...@google.com>
            Comment-In-Reply-To: Florian Leimgruber <fleim...@google.com>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            Apr 30, 2026, 4:27:05 AM (5 days ago) Apr 30
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . unresolved

            Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

            Especially the `show_loading_state_callback` feels really weird.

            Karol Sygiet

            Done

            Florian Leimgruber

            Drive-by: Why did we end up with a single function again? :)

            Jihad Hanna

            I believe ideally we have:

            • `StartFillingProcess()` --> Pretty much does nothing besides calling the next function.
            • `MaybeAuthenticateForFilling()` --> takes the callback, possibly augments it for authentication and then either directly call or authenticate and call the next function.
            • `MaybeFetchForFilling()` --> takes the callback, possibly augments it for fetching and then either directly call or fetch and call `fill_form_and_hide_popup`.
            Gerrit-Comment-Date: Thu, 30 Apr 2026 08:26:52 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            Apr 30, 2026, 7:07:43 AM (5 days ago) Apr 30
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 3 comments

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . unresolved

            Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

            Especially the `show_loading_state_callback` feels really weird.

            Karol Sygiet

            Done

            Florian Leimgruber

            Drive-by: Why did we end up with a single function again? :)

            Jihad Hanna

            I believe ideally we have:

            • `StartFillingProcess()` --> Pretty much does nothing besides calling the next function.
            • `MaybeAuthenticateForFilling()` --> takes the callback, possibly augments it for authentication and then either directly call or authenticate and call the next function.
            • `MaybeFetchForFilling()` --> takes the callback, possibly augments it for fetching and then either directly call or fetch and call `fill_form_and_hide_popup`.
            Karol Sygiet

            Yeah, I first did what you've suggested Florian (or at least tried) and then changed the approach.

            Jihad, could you take a look whether it looks more like your proposal now?

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
            Line 263, Patchset 28: auto unmasking_callback = base::BindOnce(
            [](base::WeakPtr<AutofillClient> client,
            base::OnceCallback<void(std::optional<EntityInstance>)>
            fill_form_and_hide_popup,
            std::optional<EntityInstance> entity) {
            if (client && !entity) {
            client->ShowAutofillAiFetchFromWalletFailureNotification();
            }
            std::move(fill_form_and_hide_popup).Run(entity);
            },
            client, std::move(fill_form_and_hide_popup));
            Jihad Hanna . unresolved

            We agreed on moving this out of the other lambda

            Karol Sygiet

            I tired moving this out of lambda but caused problems and test failures, as this requires moving the `fill_form_and_hide_popup` which the return callback may need on its own.

            I've tried designing this better with Gemini but it believes this is the cleanest approach. LMK if you have some idea to move it out of here.

            Line 448, Patchset 29: if ((should_fetch_from_server || should_reauth) &&

            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            show_loading_suggestions_callback(PrepareLoadingStateSuggestions(
            base::ToVector(client.GetAutofillSuggestions()), suggestion));
            }
            Jihad Hanna . unresolved

            WDYT about calling this regardless whether `(should_fetch_from_server || should_reauth)` is true or false? I imagine that otherwise it wouldn't even show to the user because it would be very fast. We could then call it directly in AED and not pass it at all to this function, making things simpler.

            Karol Sygiet

            I'd prefer to avoid modifying the prod logic as this CL ideally should be a noop.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 31
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Thu, 30 Apr 2026 11:07:28 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Karol Sygiet <syg...@google.com>
            Comment-In-Reply-To: Jihad Hanna <jihad...@google.com>
            Comment-In-Reply-To: Florian Leimgruber <fleim...@google.com>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            Apr 30, 2026, 7:50:34 AM (5 days ago) Apr 30
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 7 comments

            Patchset-level comments
            File-level comment, Patchset 31 (Latest):
            Jihad Hanna . resolved

            Almost there

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
            Line 217, Patchset 31 (Latest):std::unique_ptr<device_reauth::DeviceAuthenticator> StartAutofillAiReauth(
            Jihad Hanna . unresolved

            Should we just inline this now?

            The authenticate function does not do much and so inlining might reduce the hopping factor while trying to understand this flow.

            Line 257, Patchset 31 (Latest): if (!masked_entity) {
            // Re-auth failed, do not show notification.
            std::move(fill_form_and_hide_popup).Run(std::nullopt);
            return;
            }
            Jihad Hanna . unresolved

            This is not needed anymore? It is already treated in the Authenticate phase.

            Line 263, Patchset 28: auto unmasking_callback = base::BindOnce(
            [](base::WeakPtr<AutofillClient> client,
            base::OnceCallback<void(std::optional<EntityInstance>)>
            fill_form_and_hide_popup,
            std::optional<EntityInstance> entity) {
            if (client && !entity) {
            client->ShowAutofillAiFetchFromWalletFailureNotification();
            }
            std::move(fill_form_and_hide_popup).Run(entity);
            },
            client, std::move(fill_form_and_hide_popup));
            Jihad Hanna . unresolved

            We agreed on moving this out of the other lambda

            Karol Sygiet

            I tired moving this out of lambda but caused problems and test failures, as this requires moving the `fill_form_and_hide_popup` which the return callback may need on its own.

            I've tried designing this better with Gemini but it believes this is the cleanest approach. LMK if you have some idea to move it out of here.

            Jihad Hanna

            I think with the comment above this wouldn't be a problem anymore.

            Line 300, Patchset 31 (Latest): std::move(fill_form_and_hide_popup).Run(entity);
            Jihad Hanna . unresolved

            You don't need to write stuff this way anymore, you can just define the `fetch_callback` as what you call `unmasking_callback` above and simply call `GetUnmaskedWalletEntityInstance()` here.

            Line 314, Patchset 31 (Latest): const bool should_reauth =
            Jihad Hanna . unresolved

            (just curious) Why "re"auth? wouldn't `should_authenticate` be more accurate here?

            Line 314, Patchset 31 (Latest): const bool should_reauth =
            WillFillSensitiveAttributes(entity, form, field.section(),
            client.GetAppLocale()) &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client.GetPrefs());
            Jihad Hanna . unresolved
            ```
            if (const bool should_reauth =
            WillFillSensitiveAttributes(entity, form, field.section(),
            client.GetAppLocale()) &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client.GetPrefs());
            !should_reauth){
            // No authentication is needed, simply forward the signal to the next phase.
            MaybeFetchForFilling(entity, client, suggestion,
            std::move(fill_form_and_hide_popup));
            return nullptr;
            }
            ```

            Then you could call the thing below `authentication_callback` and we wouldn't have to fake successful authentication when the boolean is false.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 31
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Thu, 30 Apr 2026 11:50:13 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            Apr 30, 2026, 7:54:19 AM (5 days ago) Apr 30
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Florian Leimgruber added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . unresolved

            Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

            Especially the `show_loading_state_callback` feels really weird.

            Karol Sygiet

            Done

            Florian Leimgruber

            Drive-by: Why did we end up with a single function again? :)

            Jihad Hanna

            I believe ideally we have:

            • `StartFillingProcess()` --> Pretty much does nothing besides calling the next function.
            • `MaybeAuthenticateForFilling()` --> takes the callback, possibly augments it for authentication and then either directly call or authenticate and call the next function.
            • `MaybeFetchForFilling()` --> takes the callback, possibly augments it for fetching and then either directly call or fetch and call `fill_form_and_hide_popup`.
            Karol Sygiet

            Yeah, I first did what you've suggested Florian (or at least tried) and then changed the approach.

            Jihad, could you take a look whether it looks more like your proposal now?

            Florian Leimgruber

            Wait, why `StartFillingProcess()`? The function name sounds super generic, it returns a `DeviceAuthenticator` and takes a `show_loading_suggestions_callback`. I'm definitely not a fan of this interface :)

            What speaks against having just two functions `MaybeAuthenticateForFilling()` and `MaybeFetchForFilling()`?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 31
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Comment-Date: Thu, 30 Apr 2026 11:54:01 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Karol Sygiet <syg...@google.com>
            Comment-In-Reply-To: Jihad Hanna <jihad...@google.com>
            Comment-In-Reply-To: Florian Leimgruber <fleim...@google.com>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            Apr 30, 2026, 8:01:49 AM (5 days ago) Apr 30
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . unresolved

            Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

            Especially the `show_loading_state_callback` feels really weird.

            Karol Sygiet

            Done

            Florian Leimgruber

            Drive-by: Why did we end up with a single function again? :)

            Jihad Hanna

            I believe ideally we have:

            • `StartFillingProcess()` --> Pretty much does nothing besides calling the next function.
            • `MaybeAuthenticateForFilling()` --> takes the callback, possibly augments it for authentication and then either directly call or authenticate and call the next function.
            • `MaybeFetchForFilling()` --> takes the callback, possibly augments it for fetching and then either directly call or fetch and call `fill_form_and_hide_popup`.
            Karol Sygiet

            Yeah, I first did what you've suggested Florian (or at least tried) and then changed the approach.

            Jihad, could you take a look whether it looks more like your proposal now?

            Florian Leimgruber

            Wait, why `StartFillingProcess()`? The function name sounds super generic, it returns a `DeviceAuthenticator` and takes a `show_loading_suggestions_callback`. I'm definitely not a fan of this interface :)

            What speaks against having just two functions `MaybeAuthenticateForFilling()` and `MaybeFetchForFilling()`?

            Jihad Hanna

            I have made a suggestion on how to get rid of `show_loading_suggestions_callback` somewhere below.

            My reasoning for this is that having a generic function gives us a single place to document the whole flow in the header file, while the individual steps are hidden in the anonymous namespace.

            I like `Maybe[Authenticate|Fetch]ForFilling`, but in the public API their names would not be ideal, as they don't reflect that more is happening (Authenticate calls Fetch and Fetch calls filling, but that's not visible in the names)

            Gerrit-Comment-Date: Thu, 30 Apr 2026 12:01:34 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            Apr 30, 2026, 9:01:08 AM (5 days ago) Apr 30
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Florian Leimgruber added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . unresolved

            Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

            Especially the `show_loading_state_callback` feels really weird.

            Karol Sygiet

            Done

            Florian Leimgruber

            Drive-by: Why did we end up with a single function again? :)

            Jihad Hanna

            I believe ideally we have:

            • `StartFillingProcess()` --> Pretty much does nothing besides calling the next function.
            • `MaybeAuthenticateForFilling()` --> takes the callback, possibly augments it for authentication and then either directly call or authenticate and call the next function.
            • `MaybeFetchForFilling()` --> takes the callback, possibly augments it for fetching and then either directly call or fetch and call `fill_form_and_hide_popup`.
            Karol Sygiet

            Yeah, I first did what you've suggested Florian (or at least tried) and then changed the approach.

            Jihad, could you take a look whether it looks more like your proposal now?

            Florian Leimgruber

            Wait, why `StartFillingProcess()`? The function name sounds super generic, it returns a `DeviceAuthenticator` and takes a `show_loading_suggestions_callback`. I'm definitely not a fan of this interface :)

            What speaks against having just two functions `MaybeAuthenticateForFilling()` and `MaybeFetchForFilling()`?

            Jihad Hanna

            I have made a suggestion on how to get rid of `show_loading_suggestions_callback` somewhere below.

            My reasoning for this is that having a generic function gives us a single place to document the whole flow in the header file, while the individual steps are hidden in the anonymous namespace.

            I like `Maybe[Authenticate|Fetch]ForFilling`, but in the public API their names would not be ideal, as they don't reflect that more is happening (Authenticate calls Fetch and Fetch calls filling, but that's not visible in the names)

            Florian Leimgruber

            My concern is that a function shouldn't have 8 parameters and do so many different things at once.

            Gerrit-Comment-Date: Thu, 30 Apr 2026 13:00:49 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            Apr 30, 2026, 9:04:09 AM (5 days ago) Apr 30
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 75, Patchset 31 (Latest):// Starts the filling process. It is responsible for authentication and fetching
            // when needed by calling the subsequent functions.
            Jihad Hanna . unresolved

            Please document the flow with bullets for clarity.

            Gerrit-Comment-Date: Thu, 30 Apr 2026 13:03:53 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            Apr 30, 2026, 10:27:27 AM (5 days ago) Apr 30
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Jihad Hanna added 2 comments

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 83, Patchset 31 (Latest): AutofillTriggerSource trigger_source,
            Jihad Hanna . unresolved

            This is unused, remove

            Jihad Hanna

            My concern is that a function shouldn't have 8 parameters

            I understand, and I made a suggestion on how to get rid of the loading callback, and one parameter was unused, bringing the number down to 7 or 6, but besides that, every parameter is needed.

            What can be done, is that we could replace some parameters with simpler ones:

            • `form_structure` can be replaced with `requires_authentication` boolean. That would also help Karol getting rid of the cache dependency.
            • `autofill_field` can be replaced with `origin` if we make the `requires_authentication` boolean a parameter. It will also help Karol getting rid of the cache dependency. A slight problem here is that some metric needs the field types deep in the callbacks, I would suggest discussing with some leads and removing this metric which is a little invasive.
            • `suggestion` can be replaced with `requires_server_fetch` boolean.

            ---

            My concern is that a function shouldn't do so many different things at once.

            Besides the cumbersome `show_loading_suggestions_callback`, I don't see how the function is doing many things at once.

            I think I initially saw `show_loading_suggestions_callback` inside the function and suggested trying to move the stuff it needs from AED to inside the function, maybe that was bad and I should have instead suggested moving `show_loading_suggestions_callback` out of the function altogether.

            ---

            If my suggestions can all be implemented, we can reach the following signature:

            ```

            // Starts the filling process. It is responsible for authentication and fetching
            // when needed by calling the subsequent functions.
            std::unique_ptr<device_reauth::DeviceAuthenticator> StartFillingProcess(
            const EntityInstance& entity,
            AutofillClient& client,
            const url::Origin& origin,
            bool requires_authentication,
            bool requires_server_fetch,

            base::OnceCallback<void(std::optional<EntityInstance>)>
                    fill_form_and_hide_popup);
            ```

            Which seems lighter and more relevant to the function. (We might still need `autofill_field` though if we don't make progress on getting rid of the per-field-type authentication metric).

            Gerrit-Comment-Date: Thu, 30 Apr 2026 14:27:07 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            May 4, 2026, 3:49:19 AM (yesterday) May 4
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org

            Florian Leimgruber added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Florian Leimgruber

            While this interface would definitely be an improvement, I'm still not a fan of it. Just form looking at the interface, I'm asking myself:

            • `StartFillingProcess()` can mean a lot of things. Just from the name, I wouldn't be surprised if it just sets up some loggers for metrics :) Something like `AuthenticateAndFetchForFilling()` seems more precise?
            • Why would `StartFillingProcess()` return a `DeviceAuthenticator`? Since I'm providing a `requires_authentication` boolean, wouldn't I expect that the function handles authentication? Why does the caller need it?
            • What about error handling? From the interface, the nullopt callback parameter can only distinguish between success/failure. It has no way to distinguish between "re-auth failed" vs "fetch failed", even though these cases are treated differently (when fetching fails, we show a toast).
            • `fill_form_and_hide_popup`: Why is hiding the popup even relevant in this context? Shouldn't this be a detail on the caller side? The caller knows the status of the popup. A filling related function shouldn't care.
            • `requires_authentication` and `requires_server_fetch`: Shouldn't both of these properties be derivable from the entity + client?

            ---

            I don't see how the function is doing many things at once

            It does at least two things - re-auth and filling? My preference is still splitting this into two steps.

            [[not very relevant] This will also make testing easier. Otherwise, tests for re-auth need to set up fetching and vice versa]

            Regarding your earlier comment:


            > My reasoning for this is that having a generic function gives us a single place to document the whole flow in the header file, while the individual steps are hidden in the anonymous namespace.

            There's nothing preventing is from leaving a comment above these two functions, describing how the two functions interact?

            Open in Gerrit

            Related details

            Attention set is empty
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 32
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 07:49:05 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 4:12:33 AM (yesterday) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Jihad Hanna

            Something like `AuthenticateAndFetchForFilling()` seems more precise?

            I do not mind, the function starts an async flow, and it could be that the flow becomes longer and does more things in the future, which is why I suggested a generic name. Your suggested name SGTM too.

            Why would `StartFillingProcess()` return a `DeviceAuthenticator`?

            The `DeviceAuthenticator` needs to be persisted somewhere while authentication is happening, and there is no clear place to persist it given that it was chosen to implement this as free functions instead of classes (not that classes would be better, CCAccessManager currently looks very ugly as well).

            What about error handling?

            The client is passed around to be able to notify of different errors. What is the problem?

            Why is hiding the popup even relevant in this context?

            I agree it's not relevant.

            `requires_authentication` and `requires_server_fetch`: Shouldn't both of these properties be derivable from the entity + client?

            I have no idea why `requries_server_fetch` was part of the `Suggestion` and not derivable from the `EntityInstance`, and I agree that ideally you would be able to tell from the entity, but for the authentication one you would also need the form and field.

            There's nothing preventing is from leaving a comment

            True, personally as a matter of taste I would've prefered to document it in a single public function that hides the details from the public API, but I wouldn't mind otherwise.

            ---

            Overall, I think we shouldn't try to solve all problems at once, because this logic grew to become hard to understand and interpret. Unless Karol or you have a suggestion on how to cleanly resolve everything in a single CL, I suggest we first start by converting this logic into a process like this CL is doing, and leaving TODOs around the places we dislike and then Karol, you or me can follow up on these.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 32
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 08:12:18 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            May 4, 2026, 4:27:33 AM (yesterday) May 4
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Florian Leimgruber added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Florian Leimgruber

            I do not mind, the function starts an async flow, and it could be that the flow becomes longer and does more things in the future, which is why I suggested a generic name. Your suggested name SGTM too.

            Agreed, the flow might become more complicated in the future. With a generic function name, people are invited to just add it to this one huge function and it might grow into hard to maintain code. I think that's another reason why I generally prefer separate functions.

            The DeviceAuthenticator needs to be persisted somewhere while authentication is happening, and there is no clear place to persist it given that it was chosen to implement this as free functions instead of classes (not that classes would be better, CCAccessManager currently looks very ugly as well).

            Have we actually considered a class? Maybe this would give us the best of both worlds:

            • Separate (maybe private) functions for each step, separately testable.
            • One public function orchestrating the flow.
            • No strange return values, since the class can have members.

            The client is passed around to be able to notify of different errors. What is the problem?

            Ah, so the function does error handling. That works, but then I find it strange that the callback still does error handling as well. Would it suffice to have a callback that takes a non-optional entity, which is only called when filling should happen?

            I have no idea why requries_server_fetch was part of the Suggestion

            I think because Android UI needs it - see [this CL](https://chromium-review.git.corp.google.com/c/chromium/src/+/7705838).

            and not derivable from the EntityInstance

            It is derivable from the EntityInstance. But I guess given that it's in the suggestion, we want to reuse that :/

            and I agree that ideally you would be able to tell from the entity, but for the authentication one you would also need the form and field.

            That'd still be my preference, I think. Otherwise, we'll have the logic whether authentication is required in two places.

            Overall, I think we shouldn't try to solve all problems at once, because this logic grew to become hard to understand and interpret. Unless Karol or you have a suggestion on how to cleanly resolve everything in a single CL, I suggest we first start by converting this logic into a process like this CL is doing, and leaving TODOs around the places we dislike and then Karol, you or me can follow up on these.

            Generally agreed. But looking at the current implementation, it is split into multiple steps: First `MaybeAuthenticateBeforeFilling()`, which executes a callback that fetches, which executes a callback that fills.

            Couldn't we just mirror this structure in the free functions?

            Gerrit-Comment-Date: Mon, 04 May 2026 08:27:21 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 4:41:44 AM (yesterday) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Jihad Hanna added 3 comments

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Jihad Hanna

            Have we actually considered a class?

            We could give it a try creating an `AutofillAiAccessManager` 👍

            Would it suffice to have a callback that takes a non-optional entity, which is only called when filling should happen?

            I think it would work 👍

            That'd still be my preference

            I don't think I agree with this, authentication for normal filling is about whether or not form filling will fill anything sensitive. For AtMemory, it's about whether the value to fill in the trigger field is sensitive (which is slightly different).

            Generally agreed. But ... Couldn't we just mirror this structure in the free functions?

            I did not understand this part.

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
            Line 202, Patchset 32 (Latest): if (!should_fetch_from_server) {
            Jihad Hanna . unresolved

            Get the access manager from now and add the `|| !access_manager` case here

            Line 260, Patchset 32 (Latest): if (!auth_succeeded) {
            Jihad Hanna . unresolved

            `|| !client`?

            Gerrit-Comment-Date: Mon, 04 May 2026 08:41:30 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            May 4, 2026, 4:49:01 AM (yesterday) May 4
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Florian Leimgruber added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Florian Leimgruber

            I don't think I agree with this, authentication for normal filling is about whether or not form filling will fill anything sensitive. For AtMemory, it's about whether the value to fill in the trigger field is sensitive (which is slightly different).

            Ah, I didn't realise that AtMemory has different re-auth requirements. In this case, the parameter makes sense to me as well.

            I did not understand this part.

            IIUC, we have multiple options:
            1. [current CL] Create one free function that does re-auth + fetching and split it later.
            2. Create one free function, one for re-auth and one for fetching [more closely mirroring the current code structure], and later try to refactor it into a class.
            3. Try creating a class now.

            I meant that my preferences are 3 > 2 > 1.

            Gerrit-Comment-Date: Mon, 04 May 2026 08:48:48 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            May 4, 2026, 5:29:35 AM (yesterday) May 4
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Karol Sygiet

            I can try implementing the `AutofillAiAccessManager` (similar to `CreditCardAccessManager`), and try mimicking the CC's logic but for AutofillAi there. Does that sound good to both of you?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 32
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 09:29:21 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            May 4, 2026, 5:33:33 AM (yesterday) May 4
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Jihad Hanna and Karol Sygiet

            Florian Leimgruber added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Florian Leimgruber

            Yes, it does! Thanks :)

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Jihad Hanna
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 32
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 09:33:00 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 5:46:02 AM (yesterday) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . resolved
            Jihad Hanna

            SGTM too 👍

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 32
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 09:45:45 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            May 4, 2026, 7:44:16 AM (yesterday) May 4
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . unresolved
            Karol Sygiet

            @fleim...@google.com @jihad...@google.com could you take a look if the new architecture looks good?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 35
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 11:43:57 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Florian Leimgruber (Gerrit)

            unread,
            May 4, 2026, 7:56:50 AM (yesterday) May 4
            to Karol Sygiet, Jihad Hanna, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Jihad Hanna and Karol Sygiet

            Florian Leimgruber added 7 comments

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 58, Patchset 35 (Latest): client->ShowAutofillAiFetchFromWalletFailureNotification();
            Florian Leimgruber . unresolved

            (for discussion) Would it make sense to instead introduce a "FailureReason" enum and have a callback with a variant of EntityInstance and FailureReason. When, depending on whether the failure reason is re-auth failure or fetch failure, the caller can act accordingly. Showing the right error seems like a strange responsbility for the access manager.

            Line 85, Patchset 35 (Latest): const Suggestion& suggestion,
            Florian Leimgruber . unresolved

            Can we have some CHECK() that this is an AutofillAi suggestion?

            Line 104, Patchset 35 (Latest): base::OnceCallback<void(std::optional<EntityInstance>)> on_fetch_complete =
            Florian Leimgruber . unresolved

            Why not just stick with `on_entity_fetched`?

            Line 106, Patchset 35 (Latest):
            Florian Leimgruber . unresolved

            I think ideally, all the logic below should be split up into two private functions. But I guess that can be a follow-up, given that you're mostly just moving code.

            Line 130, Patchset 35 (Latest): client.UpdateAutofillSuggestions(
            Florian Leimgruber . unresolved

            (for discussion) It does seem a little weird that the access manager has to update the suggestion state. Is this what we want?

            Line 180, Patchset 35 (Latest): std::unique_ptr<device_reauth::DeviceAuthenticator> authenticator =
            Florian Leimgruber . unresolved

            Can we initialise the authenticator in the constructor and always just always have it be non-null?

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Florian Leimgruber

            Looks much better to me now!

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Jihad Hanna
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 35
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 11:56:34 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 8:12:21 AM (yesterday) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Karol Sygiet

            Jihad Hanna added 8 comments

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.h
            Line 69, Patchset 35 (Latest): const raw_ref<BrowserAutofillManager> manager_;
            Jihad Hanna . unresolved

            I think we can store the client instead if some cleanups are done.

            Line 61, Patchset 35 (Latest): void MaybeAuthenticateBeforeFilling(const std::u16string& reauth_message,
            Jihad Hanna . unresolved

            Fetching

            Line 54, Patchset 35 (Latest): // Extracts `EntityInstance` from suggestion payload.
            base::optional_ref<const EntityInstance> GetEntityInstance(
            const Suggestion& suggestion) const;
            Jihad Hanna . unresolved

            We should rather pass the masked entity directly and not need to fetch it here.

            Line 31, Patchset 35 (Latest):// Manages authentication and fetching for Autofill AI suggestions prior to
            // filling a form.
            Jihad Hanna . unresolved

            entities (no need to mention suggestions and filling here, you could consider reusing this for other purposes requiring authentication and server fetching)

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 84, Patchset 35 (Latest):void AutofillAiAccessManager::FetchEntityInstance(
            Jihad Hanna . unresolved

            Why did we get rid of the two phases introduced previously? We seemed to have agreed on that

            Line 107, Patchset 35 (Latest): const bool should_fetch_from_server =

            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . unresolved

            This doesn't belong here too this should be passed to the class directly so that the class doesn't care about the concept of `Suggestion`.

            This was mentioned before.

            Line 119, Patchset 35 (Latest): // Before running `on_fetch_complete`, potentially ask for a re-auth.
            const bool is_sensitive = WillFillSensitiveAttributes(
            *entity, *form_structure, autofill_field->section(),
            client.GetAppLocale());
            const bool should_reauth =
            is_sensitive &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client.GetPrefs());
            Jihad Hanna . unresolved

            This doesn't belong here.

            You're extracting this logic to reuse it for AtMemory, but AtMemory will have a different check for reauth since you cannot assume having a cached form/field.

            This was mentioned before.

            Line 127, Patchset 35 (Latest): // Show a loading state during fetching or reauth.

            if ((should_fetch_from_server || should_reauth) &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            client.UpdateAutofillSuggestions(
            PrepareLoadingStateSuggestions(
            base::ToVector(client.GetAutofillSuggestions()), suggestion),
            FillingProduct::kAutofillAi, trigger_source,
            AutofillSuggestionsIgnoreFocusLoss(true));
            }
            Jihad Hanna . unresolved

            This logic belongs to the delegate.

            This was mentioned before.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 35
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 12:11:58 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            May 4, 2026, 9:52:26 AM (23 hours ago) May 4
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 14 comments

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.h
            Line 69, Patchset 35: const raw_ref<BrowserAutofillManager> manager_;
            Jihad Hanna . resolved

            I think we can store the client instead if some cleanups are done.

            Karol Sygiet

            Done

            Line 61, Patchset 35: void MaybeAuthenticateBeforeFilling(const std::u16string& reauth_message,
            Jihad Hanna . resolved

            Fetching

            Karol Sygiet

            Done

            Line 54, Patchset 35: // Extracts `EntityInstance` from suggestion payload.

            base::optional_ref<const EntityInstance> GetEntityInstance(
            const Suggestion& suggestion) const;
            Jihad Hanna . resolved

            We should rather pass the masked entity directly and not need to fetch it here.

            Karol Sygiet

            Done

            Line 31, Patchset 35:// Manages authentication and fetching for Autofill AI suggestions prior to
            // filling a form.
            Jihad Hanna . resolved

            entities (no need to mention suggestions and filling here, you could consider reusing this for other purposes requiring authentication and server fetching)

            Karol Sygiet

            Done

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 58, Patchset 35: client->ShowAutofillAiFetchFromWalletFailureNotification();
            Florian Leimgruber . unresolved

            (for discussion) Would it make sense to instead introduce a "FailureReason" enum and have a callback with a variant of EntityInstance and FailureReason. When, depending on whether the failure reason is re-auth failure or fetch failure, the caller can act accordingly. Showing the right error seems like a strange responsbility for the access manager.

            Karol Sygiet

            I modeled `AutofillAiAccessManager` to closely mirror the existing payments `CreditCardAccessManager` and IbanAccessManager. In those classes, the access controller is considered the central hub that orchestrates the unmasking flow, including instructing the client to show specific error notifications if FIDO/CVC/Wallet fetching fails.

            Keeping the error trigger here preserves code encapsulation for the access orchestration flow, though returning an expected/FailureReason could definitely be considered if we refactor the other access managers down the road.

            Line 84, Patchset 35:void AutofillAiAccessManager::FetchEntityInstance(
            Jihad Hanna . resolved

            Why did we get rid of the two phases introduced previously? We seemed to have agreed on that

            Karol Sygiet

            Done

            Line 85, Patchset 35: const Suggestion& suggestion,
            Florian Leimgruber . resolved

            Can we have some CHECK() that this is an AutofillAi suggestion?

            Karol Sygiet

            Done

            Line 104, Patchset 35: base::OnceCallback<void(std::optional<EntityInstance>)> on_fetch_complete =
            Florian Leimgruber . resolved

            Why not just stick with `on_entity_fetched`?

            Karol Sygiet

            Done

            Florian Leimgruber . unresolved

            I think ideally, all the logic below should be split up into two private functions. But I guess that can be a follow-up, given that you're mostly just moving code.

            Karol Sygiet

            Yes, I planned to do that in a followup which brings the memory support as this will touch them.

            Line 107, Patchset 35: const bool should_fetch_from_server =

            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . unresolved

            This doesn't belong here too this should be passed to the class directly so that the class doesn't care about the concept of `Suggestion`.

            This was mentioned before.

            Karol Sygiet

            Since having the `Suggestion` is needed for the UI update sake (following the CCAM patterns). there's no point in passing the bool directly (especially since (also following the CCAM) the method is named `FetchEntityInstance` following the pattern from payments access managers

            Line 119, Patchset 35: // Before running `on_fetch_complete`, potentially ask for a re-auth.

            const bool is_sensitive = WillFillSensitiveAttributes(
            *entity, *form_structure, autofill_field->section(),
            client.GetAppLocale());
            const bool should_reauth =
            is_sensitive &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client.GetPrefs());
            Jihad Hanna . unresolved

            This doesn't belong here.

            You're extracting this logic to reuse it for AtMemory, but AtMemory will have a different check for reauth since you cannot assume having a cached form/field.

            This was mentioned before.

            Karol Sygiet

            I think it now does belong here. Since we have an AccessMananger class it should be the one that knows how to handle and when to authenticate depending on the form/field/EntityInstance.

            This check will be modified slighlty when the memory support comes along and extracted to a helper utility function in an anonymous namespace(as requested by florian below).

            Line 130, Patchset 35: client.UpdateAutofillSuggestions(
            Florian Leimgruber . unresolved

            (for discussion) It does seem a little weird that the access manager has to update the suggestion state. Is this what we want?

            Karol Sygiet

            Yes, this is intentional and mirrors how `CreditCardAccessManager` instructs the client to display challenge selection dialogs, SMS OTP input views, and FIDO prompts.

            Since the access manager controls the long-lived asynchronous operations (device re-auth and server unmasking requests), it's the most natural place to signal the client to show the throbber/loading state during this transition.

            Line 127, Patchset 35: // Show a loading state during fetching or reauth.

            if ((should_fetch_from_server || should_reauth) &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            client.UpdateAutofillSuggestions(
            PrepareLoadingStateSuggestions(
            base::ToVector(client.GetAutofillSuggestions()), suggestion),
            FillingProduct::kAutofillAi, trigger_source,
            AutofillSuggestionsIgnoreFocusLoss(true));
            }
            Jihad Hanna . unresolved

            This logic belongs to the delegate.

            This was mentioned before.

            Karol Sygiet
            Line 180, Patchset 35: std::unique_ptr<device_reauth::DeviceAuthenticator> authenticator =
            Florian Leimgruber . unresolved

            Can we initialise the authenticator in the constructor and always just always have it be non-null?

            Karol Sygiet

            DeviceAuthenticators are context-bound. Initializing them lazily on-demand when authentication ensures we are obtaining a fresh, valid, and properly parented UI authenticator, rather than holding a stale reference in a manager that lasts the life of the frame document.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 41
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 13:52:13 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 10:05:14 AM (23 hours ago) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 107, Patchset 35: const bool should_fetch_from_server =
            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . unresolved

            This doesn't belong here too this should be passed to the class directly so that the class doesn't care about the concept of `Suggestion`.

            This was mentioned before.

            Karol Sygiet

            Since having the `Suggestion` is needed for the UI update sake (following the CCAM patterns). there's no point in passing the bool directly (especially since (also following the CCAM) the method is named `FetchEntityInstance` following the pattern from payments access managers

            Jihad Hanna

            Since having the Suggestion is needed for the UI update sake

            I don't see it, `suggestion` is just used so that the delegate can show a loading suggestion. I don't think this should be the responsibility of the access manager, and if CCAM does something along those lines then the problem would be there and not here.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 14:05:02 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            May 4, 2026, 10:19:17 AM (22 hours ago) May 4
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 107, Patchset 35: const bool should_fetch_from_server =
            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . unresolved

            This doesn't belong here too this should be passed to the class directly so that the class doesn't care about the concept of `Suggestion`.

            This was mentioned before.

            Karol Sygiet

            Since having the `Suggestion` is needed for the UI update sake (following the CCAM patterns). there's no point in passing the bool directly (especially since (also following the CCAM) the method is named `FetchEntityInstance` following the pattern from payments access managers

            Jihad Hanna

            Since having the Suggestion is needed for the UI update sake

            I don't see it, `suggestion` is just used so that the delegate can show a loading suggestion. I don't think this should be the responsibility of the access manager, and if CCAM does something along those lines then the problem would be there and not here.

            Karol Sygiet

            The alternative would be that the client of this manager passes another callback that will be executed when the suggestions are loading?

            I'm not sure which one I like more, I'd love to keep this CL as small as possible, and IMO the current implementation does so, with the added benefit of being in line with what CCAM uses.

            However if you or @fleim...@google.com feels strongly about your proposal I can do so.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 14:19:06 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 10:26:12 AM (22 hours ago) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 107, Patchset 35: const bool should_fetch_from_server =
            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . unresolved

            This doesn't belong here too this should be passed to the class directly so that the class doesn't care about the concept of `Suggestion`.

            This was mentioned before.

            Karol Sygiet

            Since having the `Suggestion` is needed for the UI update sake (following the CCAM patterns). there's no point in passing the bool directly (especially since (also following the CCAM) the method is named `FetchEntityInstance` following the pattern from payments access managers

            Jihad Hanna

            Since having the Suggestion is needed for the UI update sake

            I don't see it, `suggestion` is just used so that the delegate can show a loading suggestion. I don't think this should be the responsibility of the access manager, and if CCAM does something along those lines then the problem would be there and not here.

            Karol Sygiet

            The alternative would be that the client of this manager passes another callback that will be executed when the suggestions are loading?

            I'm not sure which one I like more, I'd love to keep this CL as small as possible, and IMO the current implementation does so, with the added benefit of being in line with what CCAM uses.

            However if you or @fleim...@google.com feels strongly about your proposal I can do so.

            Jihad Hanna

            I'm not sure I understand the alternative.

            Why not just compute `should_fetch` and `should_authenticate` in AED and move this whole block there as it is?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 14:25:59 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            May 4, 2026, 11:06:01 AM (22 hours ago) May 4
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 107, Patchset 35: const bool should_fetch_from_server =
            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . unresolved

            This doesn't belong here too this should be passed to the class directly so that the class doesn't care about the concept of `Suggestion`.

            This was mentioned before.

            Karol Sygiet

            Since having the `Suggestion` is needed for the UI update sake (following the CCAM patterns). there's no point in passing the bool directly (especially since (also following the CCAM) the method is named `FetchEntityInstance` following the pattern from payments access managers

            Jihad Hanna

            Since having the Suggestion is needed for the UI update sake

            I don't see it, `suggestion` is just used so that the delegate can show a loading suggestion. I don't think this should be the responsibility of the access manager, and if CCAM does something along those lines then the problem would be there and not here.

            Karol Sygiet

            The alternative would be that the client of this manager passes another callback that will be executed when the suggestions are loading?

            I'm not sure which one I like more, I'd love to keep this CL as small as possible, and IMO the current implementation does so, with the added benefit of being in line with what CCAM uses.

            However if you or @fleim...@google.com feels strongly about your proposal I can do so.

            Jihad Hanna

            I'm not sure I understand the alternative.

            Why not just compute `should_fetch` and `should_authenticate` in AED and move this whole block there as it is?

            Karol Sygiet

            I think it is bad because then why do you need this class at all, if the clients dictate when authentication is needed and when its not.

            IMO there should be only one source of truth that determines when to fetch and when to authenticate. We probably can do that without the `Suggestion` argument in the long term, but IMO it shouldn't be done in the same CL.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 15:05:41 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 11:17:43 AM (21 hours ago) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 107, Patchset 35: const bool should_fetch_from_server =
            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . unresolved

            This doesn't belong here too this should be passed to the class directly so that the class doesn't care about the concept of `Suggestion`.

            This was mentioned before.

            Karol Sygiet

            Since having the `Suggestion` is needed for the UI update sake (following the CCAM patterns). there's no point in passing the bool directly (especially since (also following the CCAM) the method is named `FetchEntityInstance` following the pattern from payments access managers

            Jihad Hanna

            Since having the Suggestion is needed for the UI update sake

            I don't see it, `suggestion` is just used so that the delegate can show a loading suggestion. I don't think this should be the responsibility of the access manager, and if CCAM does something along those lines then the problem would be there and not here.

            Karol Sygiet

            The alternative would be that the client of this manager passes another callback that will be executed when the suggestions are loading?

            I'm not sure which one I like more, I'd love to keep this CL as small as possible, and IMO the current implementation does so, with the added benefit of being in line with what CCAM uses.

            However if you or @fleim...@google.com feels strongly about your proposal I can do so.

            Jihad Hanna

            I'm not sure I understand the alternative.

            Why not just compute `should_fetch` and `should_authenticate` in AED and move this whole block there as it is?

            Karol Sygiet

            I think it is bad because then why do you need this class at all, if the clients dictate when authentication is needed and when its not.

            IMO there should be only one source of truth that determines when to fetch and when to authenticate. We probably can do that without the `Suggestion` argument in the long term, but IMO it shouldn't be done in the same CL.

            Jihad Hanna

            I'm open to suggestions, but the way I see it the flow can either be:

            • Get a local entity directly
            • Get a local entity after authentication
            • Unmask an entity directly
            • Unmask an entity after authentication

            And this can involve up to two rounds of asynchronous operations.

            The callers responsibility is to tell the AM which flow it wants and the AM handles the actual flow.

            Having the AM also decide which flow to use can get more complicated: For regular suggestions, authentication is computed by looking at the cached form. This might not exist for AtMemory. Will we add needless information in the payload just to support the AM? I think passing those two booleans and disconnecting the class from any concept other than `EntityInstance` (which it definitely needs) and possibly the `AutofillClient` (and hopefully something less generic) would be best to keep this as generic and simple as possible.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 15:17:23 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            May 4, 2026, 11:40:09 AM (21 hours ago) May 4
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Karol Sygiet

            In CCAM it is exactly the credit card's AM to understand the needs of a given credit card, whether it is local or from server, needs payments authentication or chrome authentication and so on. IMO we shouldn't change this for AutofillAi's AM.

            Why do you think that AccessManager needs to be separated from things other than `EntityInstance`? IMO it makes sense that it checks for various requirements depending on the website's context of what and where gets filled. The interface in CCs case is simpler since pretty much any CC fill includes some sort of SPII, so they could have generalized that out, before the call to CCAM. Memory won't complicate things that much more, since the `Suggestion` is already be there (and contains all that we need) we can just extract the `is_sensitive` to a helper and do the is_SPII computation there (to keep the main function lean).

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 15:39:49 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            May 4, 2026, 3:53:18 PM (17 hours ago) May 4
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 1 comment

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Jihad Hanna

            In CCAM it is exactly the credit card's AM to understand the needs of a given credit card.

            I think that's wrong. See [the CC filling logic](https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/core/browser/foundations/browser_autofill_manager.cc;l=2057;drc=fff91ab83449bbfa0790f18e00e68384a3a1365d).

            Why do you think that AccessManager needs to be separated from things other than `EntityInstance`?

            Because the less dependencies a class has on other Autofill concepts, the easier it can be used in various settings (again, the example would be regular-autofill/at-memory/(eventually)bluedog).

            IMO it makes sense that it checks for various requirements depending on the website's context of what and where gets filled...

            I'll think more about this 👍

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 19:52:57 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Christoph Schwering (Gerrit)

            unread,
            May 4, 2026, 6:29:18 PM (14 hours ago) May 4
            to Karol Sygiet, Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Florian Leimgruber and Karol Sygiet

            Christoph Schwering added 6 comments

            Patchset-level comments
            File-level comment, Patchset 42 (Latest):
            Christoph Schwering . unresolved

            Dri

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.h
            Line 45, Patchset 42 (Latest): virtual void FetchEntityInstance(
            Christoph Schwering . unresolved

            (Why) Do we need a class? The only necessary member variable appears to be `authenticator_`, which should not survive one flow anyway.

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 58, Patchset 35: client->ShowAutofillAiFetchFromWalletFailureNotification();
            Florian Leimgruber . unresolved

            (for discussion) Would it make sense to instead introduce a "FailureReason" enum and have a callback with a variant of EntityInstance and FailureReason. When, depending on whether the failure reason is re-auth failure or fetch failure, the caller can act accordingly. Showing the right error seems like a strange responsbility for the access manager.

            Karol Sygiet

            I modeled `AutofillAiAccessManager` to closely mirror the existing payments `CreditCardAccessManager` and IbanAccessManager. In those classes, the access controller is considered the central hub that orchestrates the unmasking flow, including instructing the client to show specific error notifications if FIDO/CVC/Wallet fetching fails.

            Keeping the error trigger here preserves code encapsulation for the access orchestration flow, though returning an expected/FailureReason could definitely be considered if we refactor the other access managers down the road.

            Christoph Schwering

            Came here because Jihad asked me for an opinion.

            From this and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/72ca5728_9325bbc9/) and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/4125aabd_b0612cc3/), it sounds like the basic question is whether we prefer

            • decoupling AutofillAiAccessManager or
            • consistency with CreditCardAccessManager and IbanAccessManager.

            If we take the first option, I assume it's unlikely that CCAM and IAM will be refactored analogously. OTOH, I'm not sure if CCAM is a good model to follow because in the past I've found it rather difficult to understand.

            Intuitively, I'd prefer cleanly decoupling AAAM. Not a massively strong opinion though because I haven't worked through what that'd actually look like.

            Line 180, Patchset 35: std::unique_ptr<device_reauth::DeviceAuthenticator> authenticator =
            Florian Leimgruber . unresolved

            Can we initialise the authenticator in the constructor and always just always have it be non-null?

            Karol Sygiet

            DeviceAuthenticators are context-bound. Initializing them lazily on-demand when authentication ensures we are obtaining a fresh, valid, and properly parented UI authenticator, rather than holding a stale reference in a manager that lasts the life of the frame document.

            Christoph Schwering

            What does "valid" and "properly parented" mean in this context?

            At first I thought the (or a?) critical scenario (in both the old and the new code) is when the user moves the tab to another window during authentication. But the `window` appears to [matter only on Android](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/device_reauth/chrome_device_authenticator_factory.cc;l=57-58;drc=91861f7ddfab07ec80ffea4b5968350a4170e8b6), where AFAIK there are no multiple windows.

            File components/autofill/core/browser/foundations/browser_autofill_manager.h
            Line 662, Patchset 42 (Latest): // Lazily initialized: access only through GetAutofillAiAccessManager().
            Christoph Schwering . unresolved

            Lazy initialization is not a good default. If there's no strong reason for it, we sohuldn't use it IMO. (AFAIK there's no reason for the other ones either.)

            Do we even need a `std::unique_ptr`?

            Line 378, Patchset 42 (Latest): friend class AutofillAiAccessManager;
            Christoph Schwering . unresolved

            Why do we need this?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 42
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Christoph Schwering <schw...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Comment-Date: Mon, 04 May 2026 22:28:57 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Karol Sygiet <syg...@google.com>
            Comment-In-Reply-To: Florian Leimgruber <fleim...@google.com>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            4:49 AM (4 hours ago) 4:49 AM
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Christoph Schwering and Jihad Hanna

            Karol Sygiet added 6 comments

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.h
            Line 45, Patchset 42: virtual void FetchEntityInstance(
            Christoph Schwering . unresolved

            (Why) Do we need a class? The only necessary member variable appears to be `authenticator_`, which should not survive one flow anyway.

            Karol Sygiet

            The tab is not freezed when the authentication is in progress, user can still interact with the page and do all kinds of stuff, so the authenticator object has to be persisted somewhere. IMO a dedicated class its best for this, otherwise either `AutofillExternalDelegate` or `BAM` needs to keep it which IMO is even worse (as then it is not clear what filling product created the authenticator)

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 58, Patchset 35: client->ShowAutofillAiFetchFromWalletFailureNotification();
            Florian Leimgruber . unresolved

            (for discussion) Would it make sense to instead introduce a "FailureReason" enum and have a callback with a variant of EntityInstance and FailureReason. When, depending on whether the failure reason is re-auth failure or fetch failure, the caller can act accordingly. Showing the right error seems like a strange responsbility for the access manager.

            Karol Sygiet

            I modeled `AutofillAiAccessManager` to closely mirror the existing payments `CreditCardAccessManager` and IbanAccessManager. In those classes, the access controller is considered the central hub that orchestrates the unmasking flow, including instructing the client to show specific error notifications if FIDO/CVC/Wallet fetching fails.

            Keeping the error trigger here preserves code encapsulation for the access orchestration flow, though returning an expected/FailureReason could definitely be considered if we refactor the other access managers down the road.

            Christoph Schwering

            Came here because Jihad asked me for an opinion.

            From this and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/72ca5728_9325bbc9/) and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/4125aabd_b0612cc3/), it sounds like the basic question is whether we prefer

            • decoupling AutofillAiAccessManager or
            • consistency with CreditCardAccessManager and IbanAccessManager.

            If we take the first option, I assume it's unlikely that CCAM and IAM will be refactored analogously. OTOH, I'm not sure if CCAM is a good model to follow because in the past I've found it rather difficult to understand.

            Intuitively, I'd prefer cleanly decoupling AAAM. Not a massively strong opinion though because I haven't worked through what that'd actually look like.

            Karol Sygiet

            Okey, If I understood you correctly, I removed the showing suggestion from the AAiAM and a closure is passed instead.

            Karol Sygiet

            1. Fair point, passed the bool directly and removed the suggestion argument.

            Line 180, Patchset 35: std::unique_ptr<device_reauth::DeviceAuthenticator> authenticator =
            Florian Leimgruber . unresolved

            Can we initialise the authenticator in the constructor and always just always have it be non-null?

            Karol Sygiet

            DeviceAuthenticators are context-bound. Initializing them lazily on-demand when authentication ensures we are obtaining a fresh, valid, and properly parented UI authenticator, rather than holding a stale reference in a manager that lasts the life of the frame document.

            Christoph Schwering

            What does "valid" and "properly parented" mean in this context?

            At first I thought the (or a?) critical scenario (in both the old and the new code) is when the user moves the tab to another window during authentication. But the `window` appears to [matter only on Android](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/device_reauth/chrome_device_authenticator_factory.cc;l=57-58;drc=91861f7ddfab07ec80ffea4b5968350a4170e8b6), where AFAIK there are no multiple windows.

            Karol Sygiet

            It's exactly the same case on other platforms, but the Mac and Windows (IIUC) OSes are smart enough to know from which process/tab/chrome browser window a request was made to show the dialog, and thus which one the dialog should be bounded to.

            File components/autofill/core/browser/foundations/browser_autofill_manager.h
            Line 662, Patchset 42: // Lazily initialized: access only through GetAutofillAiAccessManager().
            Christoph Schwering . unresolved

            Lazy initialization is not a good default. If there's no strong reason for it, we sohuldn't use it IMO. (AFAIK there's no reason for the other ones either.)

            Do we even need a `std::unique_ptr`?

            Karol Sygiet

            unique_ptr is preferred as when the navigation happens `BrowserAutofillManager::Reset()` destroyed the previous AAiAM and cancels any ongoing reauth operations (this could be implemented directly in the `BAM::Reset()`, but using unique_ptr follows the CCAM implementation).

            Line 378, Patchset 42: friend class AutofillAiAccessManager;
            Christoph Schwering . resolved

            Why do we need this?

            Karol Sygiet

            Done

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Christoph Schwering
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 43
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Christoph Schwering <schw...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Christoph Schwering <schw...@google.com>
            Gerrit-Comment-Date: Tue, 05 May 2026 08:49:36 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Karol Sygiet <syg...@google.com>
            Comment-In-Reply-To: Jihad Hanna <jihad...@google.com>
            Comment-In-Reply-To: Florian Leimgruber <fleim...@google.com>
            Comment-In-Reply-To: Christoph Schwering <schw...@google.com>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            6:36 AM (2 hours ago) 6:36 AM
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Christoph Schwering, Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 24 comments

            Patchset-level comments
            File-level comment, Patchset 42:
            Christoph Schwering . resolved

            Dri

            Jihad Hanna

            Acknowledged

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.h
            Line 46, Patchset 43 (Latest): const FormStructure& form_structure,
            const AutofillField& autofill_field,
            Jihad Hanna . unresolved

            These can be replaced with `will_fill_sensitive_info` or something

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 58, Patchset 35: client->ShowAutofillAiFetchFromWalletFailureNotification();
            Florian Leimgruber . unresolved

            (for discussion) Would it make sense to instead introduce a "FailureReason" enum and have a callback with a variant of EntityInstance and FailureReason. When, depending on whether the failure reason is re-auth failure or fetch failure, the caller can act accordingly. Showing the right error seems like a strange responsbility for the access manager.

            Karol Sygiet

            I modeled `AutofillAiAccessManager` to closely mirror the existing payments `CreditCardAccessManager` and IbanAccessManager. In those classes, the access controller is considered the central hub that orchestrates the unmasking flow, including instructing the client to show specific error notifications if FIDO/CVC/Wallet fetching fails.

            Keeping the error trigger here preserves code encapsulation for the access orchestration flow, though returning an expected/FailureReason could definitely be considered if we refactor the other access managers down the road.

            Christoph Schwering

            Came here because Jihad asked me for an opinion.

            From this and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/72ca5728_9325bbc9/) and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/4125aabd_b0612cc3/), it sounds like the basic question is whether we prefer

            • decoupling AutofillAiAccessManager or
            • consistency with CreditCardAccessManager and IbanAccessManager.

            If we take the first option, I assume it's unlikely that CCAM and IAM will be refactored analogously. OTOH, I'm not sure if CCAM is a good model to follow because in the past I've found it rather difficult to understand.

            Intuitively, I'd prefer cleanly decoupling AAAM. Not a massively strong opinion though because I haven't worked through what that'd actually look like.

            Karol Sygiet

            Okey, If I understood you correctly, I removed the showing suggestion from the AAiAM and a closure is passed instead.

            Jihad Hanna

            Discussed offline: We will adopt the `FailureReason` approach

            Line 98, Patchset 43 (Latest): const bool should_reauth =
            is_sensitive &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client_->GetPrefs());


            // Show a loading state during fetching or reauth.
            if ((should_fetch || should_reauth) &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            if (show_loading_state_callback) {
            std::move(show_loading_state_callback).Run();
            }
            }
            Jihad Hanna . unresolved

            Discussed with Bruno, and he's okay with decoupling this from `should_[fetch|reauth]` behind a killswitch.

            WDYT about moving this whole block to AED

            ```
            const bool should_show_loading = should_fetch || (is_sensitive &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client_->GetPrefs())) ||
            base::IsEnabled(kFooKillswitch));
            if (should_show_loading &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            ...
            }
            ```

            This way when the killswitch is cleaned up we can remove the pref logic from there.

            Line 107, Patchset 35: const bool should_fetch_from_server =
            suggestion.GetPayload<Suggestion::AutofillAiPayload>()
            .requires_server_fetch;
            Jihad Hanna . resolved
            Jihad Hanna

            Discussed offline and agreed on the next steps:

            • `FormStructure` and `AutofillField` will be removed from the contract.
            • The AM will take care of generic conditions like mandatory reauth.
            • We will push towards moving `show_loading_state_callback` back to AED.
            • The `FetchCallback` will return an optional `FailureReason` so that callers can react accordingly.
            Line 115, Patchset 43 (Latest): std::u16string message;
            // Android is excluded here because the system biometric prompt does not
            // support a custom message.
            #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) || \
            BUILDFLAG(IS_IOS)
            const std::u16string origin =
            base::UTF8ToUTF16(autofill_field.origin().host());
            message = l10n_util::GetStringFUTF16(IDS_AUTOFILL_AI_FILLING_REAUTH, origin);
            #endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) ||
            // BUILDFLAG(IS_IOS)
            Jihad Hanna . unresolved

            I'd pass the origin to the `Authenticate()` method and move this logic there

            Line 119, Patchset 35: // Before running `on_fetch_complete`, potentially ask for a re-auth.
            const bool is_sensitive = WillFillSensitiveAttributes(
            *entity, *form_structure, autofill_field->section(),
            client.GetAppLocale());
            const bool should_reauth =
            is_sensitive &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client.GetPrefs());
            Jihad Hanna . resolved

            This doesn't belong here.

            You're extracting this logic to reuse it for AtMemory, but AtMemory will have a different check for reauth since you cannot assume having a cached form/field.

            This was mentioned before.

            Karol Sygiet

            I think it now does belong here. Since we have an AccessMananger class it should be the one that knows how to handle and when to authenticate depending on the form/field/EntityInstance.

            This check will be modified slighlty when the memory support comes along and extracted to a helper utility function in an anonymous namespace(as requested by florian below).

            Jihad Hanna

            Acknowledged

            Line 130, Patchset 35: client.UpdateAutofillSuggestions(
            Florian Leimgruber . unresolved

            (for discussion) It does seem a little weird that the access manager has to update the suggestion state. Is this what we want?

            Karol Sygiet

            Yes, this is intentional and mirrors how `CreditCardAccessManager` instructs the client to display challenge selection dialogs, SMS OTP input views, and FIDO prompts.

            Since the access manager controls the long-lived asynchronous operations (device re-auth and server unmasking requests), it's the most natural place to signal the client to show the throbber/loading state during this transition.

            Jihad Hanna

            Discussed offline: We will try to move this to AED.

            Line 130, Patchset 43 (Latest): LogReauthToFillResultPerFieldType(ai_field_types, auth_succeeded);
            Jihad Hanna . unresolved

            Let's move this to AED after introducing the `FailureReason`

            Line 127, Patchset 35: // Show a loading state during fetching or reauth.
            if ((should_fetch_from_server || should_reauth) &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            client.UpdateAutofillSuggestions(
            PrepareLoadingStateSuggestions(
            base::ToVector(client.GetAutofillSuggestions()), suggestion),
            FillingProduct::kAutofillAi, trigger_source,
            AutofillSuggestionsIgnoreFocusLoss(true));
            }
            Jihad Hanna . resolved

            This logic belongs to the delegate.


            It follows the patterns from `CreditCardAccessManager`

            Jihad Hanna

            Acknowledged

            Line 154, Patchset 43 (Latest): FetchUnmaskedEntityFromWallet(client_->GetWeakPtr(), std::move(callback),
            Jihad Hanna . unresolved

            nit: I'd inline this since the above logic seems trivial

            Line 184, Patchset 43 (Latest):void AutofillAiAccessManager::OnReauthCompleted(
            Jihad Hanna . unresolved

            nit: I'd also inline this as it's used once and the logic is trivial

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h
            Line 83, Patchset 31: AutofillTriggerSource trigger_source,
            Jihad Hanna . resolved

            This is unused, remove

            Jihad Hanna

            Acknowledged

            Line 75, Patchset 31:// Starts the filling process. It is responsible for authentication and fetching

            // when needed by calling the subsequent functions.
            Jihad Hanna . resolved

            Please document the flow with bullets for clarity.

            Jihad Hanna

            Acknowledged

            Line 79, Patchset 9:MaybeAuthenticateAndFetchForFilling(
            Florian Leimgruber . resolved

            Can we split this into two function, one that authenticates and one that does fetching? I feel like doing two things in one function creates quite a overloaded interface with three callback parameter.

                base::OnceCallback<void(std::optional<EntityInstance>)>
                    fill_form_and_hide_popup);
            ```
            Jihad Hanna

            +1, thanks!

            File components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.cc
            Line 202, Patchset 32: if (!should_fetch_from_server) {
            Jihad Hanna . resolved

            Get the access manager from now and add the `|| !access_manager` case here

            Jihad Hanna

            Acknowledged

            Line 217, Patchset 31:std::unique_ptr<device_reauth::DeviceAuthenticator> StartAutofillAiReauth(
            Jihad Hanna . resolved

            Should we just inline this now?

            The authenticate function does not do much and so inlining might reduce the hopping factor while trying to understand this flow.

            Jihad Hanna

            Acknowledged

            Line 260, Patchset 32: if (!auth_succeeded) {
            Jihad Hanna . resolved

            `|| !client`?

            Jihad Hanna

            Acknowledged

            Line 257, Patchset 31: if (!masked_entity) {
            // Re-auth failed, do not show notification.
            std::move(fill_form_and_hide_popup).Run(std::nullopt);
            return;
            }
            Jihad Hanna . resolved

            This is not needed anymore? It is already treated in the Authenticate phase.

            Jihad Hanna

            Acknowledged

            Line 263, Patchset 28: auto unmasking_callback = base::BindOnce(
            [](base::WeakPtr<AutofillClient> client,

            base::OnceCallback<void(std::optional<EntityInstance>)>
            fill_form_and_hide_popup,
            std::optional<EntityInstance> entity) {
            if (client && !entity) {
            client->ShowAutofillAiFetchFromWalletFailureNotification();
            }
            std::move(fill_form_and_hide_popup).Run(entity);
            },
            client, std::move(fill_form_and_hide_popup));
            Jihad Hanna . resolved

            We agreed on moving this out of the other lambda

            Karol Sygiet

            I tired moving this out of lambda but caused problems and test failures, as this requires moving the `fill_form_and_hide_popup` which the return callback may need on its own.

            I've tried designing this better with Gemini but it believes this is the cleanest approach. LMK if you have some idea to move it out of here.

            Jihad Hanna

            I think with the comment above this wouldn't be a problem anymore.

            Jihad Hanna

            Acknowledged

            Line 300, Patchset 31: std::move(fill_form_and_hide_popup).Run(entity);
            Jihad Hanna . resolved

            You don't need to write stuff this way anymore, you can just define the `fetch_callback` as what you call `unmasking_callback` above and simply call `GetUnmaskedWalletEntityInstance()` here.

            Jihad Hanna

            Acknowledged

            Line 314, Patchset 31: const bool should_reauth =
            Jihad Hanna . resolved

            (just curious) Why "re"auth? wouldn't `should_authenticate` be more accurate here?

            Jihad Hanna

            Acknowledged

            Line 314, Patchset 31: const bool should_reauth =
            WillFillSensitiveAttributes(entity, form, field.section(),
            client.GetAppLocale()) &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client.GetPrefs());
            Jihad Hanna . resolved
            ```
            if (const bool should_reauth =
            WillFillSensitiveAttributes(entity, form, field.section(),
            client.GetAppLocale()) &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client.GetPrefs());
            !should_reauth){
            // No authentication is needed, simply forward the signal to the next phase.
            MaybeFetchForFilling(entity, client, suggestion,
            std::move(fill_form_and_hide_popup));
            return nullptr;
            }
            ```

            Then you could call the thing below `authentication_callback` and we wouldn't have to fake successful authentication when the boolean is false.

            Jihad Hanna

            Acknowledged

            Line 448, Patchset 29: if ((should_fetch_from_server || should_reauth) &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            show_loading_suggestions_callback(PrepareLoadingStateSuggestions(
            base::ToVector(client.GetAutofillSuggestions()), suggestion));
            }
            Jihad Hanna . resolved

            WDYT about calling this regardless whether `(should_fetch_from_server || should_reauth)` is true or false? I imagine that otherwise it wouldn't even show to the user because it would be very fast. We could then call it directly in AED and not pass it at all to this function, making things simpler.

            Karol Sygiet

            I'd prefer to avoid modifying the prod logic as this CL ideally should be a noop.

            Jihad Hanna

            Acknowledged

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Christoph Schwering
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 43
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Christoph Schwering <schw...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Christoph Schwering <schw...@google.com>
            Gerrit-Comment-Date: Tue, 05 May 2026 10:35:57 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Karol Sygiet (Gerrit)

            unread,
            7:30 AM (1 hour ago) 7:30 AM
            to Jihad Hanna, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Christoph Schwering, Florian Leimgruber and Jihad Hanna

            Karol Sygiet added 8 comments

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.h
            Line 46, Patchset 43: const FormStructure& form_structure,
            const AutofillField& autofill_field,
            Jihad Hanna . resolved

            These can be replaced with `will_fill_sensitive_info` or something

            Karol Sygiet

            Done

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 58, Patchset 35: client->ShowAutofillAiFetchFromWalletFailureNotification();
            Florian Leimgruber . resolved

            (for discussion) Would it make sense to instead introduce a "FailureReason" enum and have a callback with a variant of EntityInstance and FailureReason. When, depending on whether the failure reason is re-auth failure or fetch failure, the caller can act accordingly. Showing the right error seems like a strange responsbility for the access manager.

            Karol Sygiet

            I modeled `AutofillAiAccessManager` to closely mirror the existing payments `CreditCardAccessManager` and IbanAccessManager. In those classes, the access controller is considered the central hub that orchestrates the unmasking flow, including instructing the client to show specific error notifications if FIDO/CVC/Wallet fetching fails.

            Keeping the error trigger here preserves code encapsulation for the access orchestration flow, though returning an expected/FailureReason could definitely be considered if we refactor the other access managers down the road.

            Christoph Schwering

            Came here because Jihad asked me for an opinion.

            From this and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/72ca5728_9325bbc9/) and [this](https://chromium-review.git.corp.google.com/c/chromium/src/+/7786130/comment/4125aabd_b0612cc3/), it sounds like the basic question is whether we prefer

            • decoupling AutofillAiAccessManager or
            • consistency with CreditCardAccessManager and IbanAccessManager.

            If we take the first option, I assume it's unlikely that CCAM and IAM will be refactored analogously. OTOH, I'm not sure if CCAM is a good model to follow because in the past I've found it rather difficult to understand.

            Intuitively, I'd prefer cleanly decoupling AAAM. Not a massively strong opinion though because I haven't worked through what that'd actually look like.

            Karol Sygiet

            Okey, If I understood you correctly, I removed the showing suggestion from the AAiAM and a closure is passed instead.

            Jihad Hanna

            Discussed offline: We will adopt the `FailureReason` approach

            Karol Sygiet

            Done

            Line 98, Patchset 43: const bool should_reauth =

            is_sensitive &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client_->GetPrefs());

            // Show a loading state during fetching or reauth.
            if ((should_fetch || should_reauth) &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            if (show_loading_state_callback) {
            std::move(show_loading_state_callback).Run();
            }
            }
            Jihad Hanna . unresolved

            Discussed with Bruno, and he's okay with decoupling this from `should_[fetch|reauth]` behind a killswitch.

            WDYT about moving this whole block to AED

            ```
            const bool should_show_loading = should_fetch || (is_sensitive &&
            prefs::IsAutofillAiReauthBeforeFillingEnabled(client_->GetPrefs())) ||
            base::IsEnabled(kFooKillswitch));
            if (should_show_loading &&
            base::FeatureList::IsEnabled(features::kAutofillAiWalletPrivatePasses)) {
            ...
            }
            ```

            This way when the killswitch is cleaned up we can remove the pref logic from there.

            Karol Sygiet

            Added a TODO, will do in a followup

            Line 115, Patchset 43: std::u16string message;

            // Android is excluded here because the system biometric prompt does not
            // support a custom message.
            #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) || \
            BUILDFLAG(IS_IOS)
            const std::u16string origin =
            base::UTF8ToUTF16(autofill_field.origin().host());
            message = l10n_util::GetStringFUTF16(IDS_AUTOFILL_AI_FILLING_REAUTH, origin);
            #endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) ||
            // BUILDFLAG(IS_IOS)
            Jihad Hanna . resolved

            I'd pass the origin to the `Authenticate()` method and move this logic there

            Karol Sygiet

            Done

            Line 130, Patchset 35: client.UpdateAutofillSuggestions(
            Florian Leimgruber . resolved

            (for discussion) It does seem a little weird that the access manager has to update the suggestion state. Is this what we want?

            Karol Sygiet

            Yes, this is intentional and mirrors how `CreditCardAccessManager` instructs the client to display challenge selection dialogs, SMS OTP input views, and FIDO prompts.

            Since the access manager controls the long-lived asynchronous operations (device re-auth and server unmasking requests), it's the most natural place to signal the client to show the throbber/loading state during this transition.

            Jihad Hanna

            Discussed offline: We will try to move this to AED.

            Karol Sygiet

            Done

            Line 130, Patchset 43: LogReauthToFillResultPerFieldType(ai_field_types, auth_succeeded);
            Jihad Hanna . resolved

            Let's move this to AED after introducing the `FailureReason`

            Karol Sygiet

            Done

            Line 154, Patchset 43: FetchUnmaskedEntityFromWallet(client_->GetWeakPtr(), std::move(callback),
            Jihad Hanna . resolved

            nit: I'd inline this since the above logic seems trivial

            Karol Sygiet

            Done

            Line 184, Patchset 43:void AutofillAiAccessManager::OnReauthCompleted(
            Jihad Hanna . resolved

            nit: I'd also inline this as it's used once and the logic is trivial

            Karol Sygiet

            Done

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Christoph Schwering
            • Florian Leimgruber
            • Jihad Hanna
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 45
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Christoph Schwering <schw...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Jihad Hanna <jihad...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Christoph Schwering <schw...@google.com>
            Gerrit-Comment-Date: Tue, 05 May 2026 11:30:24 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jihad Hanna (Gerrit)

            unread,
            7:52 AM (1 hour ago) 7:52 AM
            to Karol Sygiet, Florian Leimgruber, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, browser-comp...@chromium.org
            Attention needed from Christoph Schwering, Florian Leimgruber and Karol Sygiet

            Jihad Hanna added 11 comments

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.h
            Line 73, Patchset 46 (Latest): // Handles optional server-side fetching of the unmasked server entity.
            // Invokes `callback` with the unmasked entity, or `std::nullopt` if it fails.
            void MaybeFetchForFilling(
            bool should_fetch,
            base::OnceCallback<void(std::optional<EntityInstance>, FailureReason)>
            callback,
            std::optional<EntityInstance> entity,
            FailureReason failure_reason);

            // Requires user authentication and runs `callback` with an authentication
            // result on completion.
            void Authenticate(const url::Origin& origin,
            base::OnceCallback<void(bool)> callback);
            Jihad Hanna . unresolved

            nitty nit: Swap order, as it makes reading the class more intuitive vis-a-vis the whole flow (Also in the source file).

            Line 57, Patchset 46 (Latest): base::OnceClosure show_loading_state_callback,
            Jihad Hanna . unresolved

            `FunctionRef`

            Line 55, Patchset 46 (Latest): const url::Origin& origin,
            Jihad Hanna . unresolved

            nitty nit: move above so that both booleans are next to each other

            Line 40, Patchset 46 (Latest): enum class FailureReason {
            kNone,
            kReauthFailed,
            kFetchFailed,
            };

            using OnEntityInstanceFetchedCallback =
            base::OnceCallback<void(std::optional<EntityInstance>, FailureReason)>;
            Jihad Hanna . unresolved

            Should we instead remove `kNone` and make the callback take an `std::variant<EntityInstance, FailureReason>`? I think that this was Florian's suggestion and would improve type safety.

            Line 18, Patchset 46 (Latest):#include "components/autofill/core/browser/field_types.h"
            Jihad Hanna . unresolved

            remove?

            Line 16, Patchset 46 (Latest):#include "base/types/optional_ref.h"
            Jihad Hanna . unresolved

            Remove?

            Line 9, Patchset 46 (Latest):#include <string>
            Jihad Hanna . unresolved

            Remove?

            File components/autofill/core/browser/filling/autofill_ai/autofill_ai_access_manager.cc
            Line 19, Patchset 46 (Latest):#include "components/autofill/core/browser/data_manager/autofill_ai/entity_data_manager.h"
            #include "components/autofill/core/browser/filling/autofill_ai/field_filling_entity_util.h"
            Jihad Hanna . unresolved

            Remove?

            Line 22, Patchset 46 (Latest):#include "components/autofill/core/browser/foundations/browser_autofill_manager.h"
            Jihad Hanna . unresolved

            Do we still need thiS?

            Line 26, Patchset 46 (Latest):#include "components/autofill/core/common/form_data.h"
            #include "components/autofill/core/common/form_field_data.h"
            Jihad Hanna . unresolved

            Remove?

            Line 98, Patchset 46 (Latest):void AutofillAiAccessManager::MaybeFetchForFilling(
            Jihad Hanna . unresolved

            `MaybeUnmaskServerEntity`? There's no mention of filling anymore and this way `Fetch` is not used twice (Also used in `FetchEntityInstance`).

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Christoph Schwering
            • Florian Leimgruber
            • Karol Sygiet
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • 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: I7aa80dfbc1fc23905e6c08e04db266d89a384e9e
            Gerrit-Change-Number: 7786130
            Gerrit-PatchSet: 46
            Gerrit-Owner: Karol Sygiet <syg...@google.com>
            Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
            Gerrit-Reviewer: Karol Sygiet <syg...@google.com>
            Gerrit-CC: Christoph Schwering <schw...@google.com>
            Gerrit-CC: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Karol Sygiet <syg...@google.com>
            Gerrit-Attention: Florian Leimgruber <fleim...@google.com>
            Gerrit-Attention: Christoph Schwering <schw...@google.com>
            Gerrit-Comment-Date: Tue, 05 May 2026 11:52:30 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy
            Reply all
            Reply to author
            Forward
            0 new messages