Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autofill related crash due to our disabling of optimization hints #20415

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
// You can obtain one at https://mozilla.org/MPL/2.0/.

#include "chrome/browser/ui/autofill/chrome_autofill_client.h"

#include "base/memory/ptr_util.h"
#include "brave/components/constants/pref_names.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_controller_impl.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"

namespace autofill {
Expand All @@ -34,6 +36,13 @@ class BraveChromeAutofillClient : public ChromeAutofillClient {
public:
using ChromeAutofillClient::ChromeAutofillClient;

AutofillOptimizationGuide* GetAutofillOptimizationGuide() const override {
if (optimization_guide::features::IsOptimizationHintsEnabled()) {
return ChromeAutofillClient::GetAutofillOptimizationGuide();
}
return nullptr;
Copy link
Collaborator

@mkarolin mkarolin Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking in case we ever decide to flip the feature back on and not necessarily remember about this override it might be good to make this depend on the feature, same as in https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.cc;l=19, like

#include "components/optimization_guide/core/optimization_guide_features.h"

AutofillOptimizationGuide* GetAutofillOptimizationGuide() const override {
  if (optimization_guide::features::IsOptimizationHintsEnabled()) {
    return ChromeAutofillClient::GetAutofillOptimizationGuide();
  }
  return nullptr;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense, fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great call, @mkarolin 😄

}

bool IsAutocompleteEnabled() const override {
auto enabled = ChromeAutofillClient::IsAutocompleteEnabled();
if (!IsPrivateProfile(web_contents())) {
Expand Down