diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2022-02-15 17:24:16 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2022-06-10 10:51:24 +0000 |
commit | 33965d3d0d16443457d5f856d46b59d3936f86f7 (patch) | |
tree | 272e6358ffcbd32d43c708bac90811fcb516fb0e | |
parent | 5a8b6f87f6c50bd2ecbf5cb184f738ab97e713c8 (diff) | |
download | qtwebengine-chromium-33965d3d0d16443457d5f856d46b59d3936f86f7.tar.gz |
Adapt autofill component for WebEngine
Only enable minimal code for datalist support and avoid dependencies
which can't be built.
Task-number: QTBUG-54433
Change-Id: I04086e3063a535c65049b563df64f5133acd41d2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
14 files changed, 281 insertions, 3 deletions
diff --git a/chromium/components/autofill/content/browser/content_autofill_driver.cc b/chromium/components/autofill/content/browser/content_autofill_driver.cc index 0dff8fc4f2e..566701268b1 100644 --- a/chromium/components/autofill/content/browser/content_autofill_driver.cc +++ b/chromium/components/autofill/content/browser/content_autofill_driver.cc @@ -155,6 +155,7 @@ bool ContentAutofillDriver::RendererIsAvailable() { return render_frame_host_->GetRenderViewHost() != nullptr; } +#if !defined(TOOLKIT_QT) webauthn::InternalAuthenticator* ContentAutofillDriver::GetOrCreateCreditCardInternalAuthenticator() { if (!authenticator_impl_ && browser_autofill_manager_ && @@ -165,14 +166,17 @@ ContentAutofillDriver::GetOrCreateCreditCardInternalAuthenticator() { } return authenticator_impl_.get(); } +#endif void ContentAutofillDriver::PopupHidden() { +#if !defined(TOOLKIT_QT) // If the unmask prompt is shown, keep showing the preview. The preview // will be cleared when the prompt closes. if (browser_autofill_manager_ && browser_autofill_manager_->ShouldClearPreviewedForm()) { RendererShouldClearPreviewedForm(); } +#endif } gfx::RectF ContentAutofillDriver::TransformBoundingBoxToViewportCoordinates( @@ -287,12 +291,14 @@ void ContentAutofillDriver::RendererShouldSetSuggestionAvailabilityImpl( void ContentAutofillDriver::SendAutofillTypePredictionsToRenderer( const std::vector<FormStructure*>& forms) { +#if !defined(TOOLKIT_QT) std::vector<FormDataPredictions> type_predictions = FormStructure::GetFieldTypePredictions(forms); // TODO(crbug.com/1185232) Send the FormDataPredictions object only if the // debugging flag is enabled. GetAutofillRouter().SendAutofillTypePredictionsToRenderer(this, type_predictions); +#endif } void ContentAutofillDriver::SendFieldsEligibleForManualFillingToRenderer( @@ -349,6 +355,7 @@ void ContentAutofillDriver::SetFormToBeProbablySubmittedImpl( void ContentAutofillDriver::FormSubmittedImpl(const FormData& form, bool known_success, mojom::SubmissionSource source) { +#if !defined(TOOLKIT_QT) // Omit duplicate form submissions. It may be reasonable to take |source| // into account here as well. // TODO(crbug/1117451): Clean up experiment code. @@ -361,6 +368,7 @@ void ContentAutofillDriver::FormSubmittedImpl(const FormData& form, } autofill_manager_->OnFormSubmitted(form, known_success, source); +#endif } void ContentAutofillDriver::TextFieldDidChangeImpl( @@ -434,6 +442,7 @@ void ContentAutofillDriver::FillFormForAssistantImpl( const AutofillableData& fill_data, const FormData& form, const FormFieldData& field) { +#if !defined(TOOLKIT_QT) DCHECK(browser_autofill_manager_); if (fill_data.is_profile()) { browser_autofill_manager_->FillProfileForm(fill_data.profile(), form, @@ -445,6 +454,7 @@ void ContentAutofillDriver::FillFormForAssistantImpl( } else { NOTREACHED(); } +#endif } void ContentAutofillDriver::ProbablyFormSubmitted() { @@ -616,12 +626,14 @@ void ContentAutofillDriver::FillFormForAssistant( void ContentAutofillDriver::DidNavigateFrame( content::NavigationHandle* navigation_handle) { if (navigation_handle->IsSameDocument()) { +#if !defined(TOOLKIT_QT) // On page refresh, reset the rate limiter for fetching authentication // details for credit card unmasking. if (browser_autofill_manager_) { browser_autofill_manager_->credit_card_access_manager() ->SignalCanFetchUnmaskDetails(); } +#endif return; } @@ -741,6 +753,7 @@ bool ContentAutofillDriver::DocumentUsedWebOTP() const { } void ContentAutofillDriver::MaybeReportAutofillWebOTPMetrics() { +#if !defined(TOOLKIT_QT) // In tests, the browser_autofill_manager_ may be unset or destroyed before // |this|. if (!browser_autofill_manager_) @@ -753,10 +766,12 @@ void ContentAutofillDriver::MaybeReportAutofillWebOTPMetrics() { return; ReportAutofillWebOTPMetrics(DocumentUsedWebOTP()); +#endif } void ContentAutofillDriver::ReportAutofillWebOTPMetrics( bool document_used_webotp) { +#if !defined(TOOLKIT_QT) if (browser_autofill_manager_->has_observed_phone_number_field()) phone_collection_metric_state_ |= phone_collection_metric::kPhoneCollected; if (browser_autofill_manager_->has_observed_one_time_code_field()) @@ -774,10 +789,12 @@ void ContentAutofillDriver::ReportAutofillWebOTPMetrics( UMA_HISTOGRAM_ENUMERATION( "Autofill.WebOTP.PhonePlusWebOTPPlusOTC", static_cast<PhoneCollectionMetricState>(phone_collection_metric_state_)); +#endif // !defined(TOOLKIT_QT) } void ContentAutofillDriver::ShowOfferNotificationIfApplicable( content::NavigationHandle* navigation_handle) { +#if !defined(TOOLKIT_QT) if (!navigation_handle->IsInPrimaryMainFrame()) return; @@ -812,6 +829,7 @@ void ContentAutofillDriver::ShowOfferNotificationIfApplicable( } browser_autofill_manager_->client()->ShowOfferNotificationIfApplicable(offer); +#endif // !defined(TOOLKIT_QT) } ContentAutofillRouter& ContentAutofillDriver::GetAutofillRouter() { diff --git a/chromium/components/autofill/content/browser/content_autofill_driver.h b/chromium/components/autofill/content/browser/content_autofill_driver.h index 00a4df54794..668e7168860 100644 --- a/chromium/components/autofill/content/browser/content_autofill_driver.h +++ b/chromium/components/autofill/content/browser/content_autofill_driver.h @@ -155,8 +155,10 @@ class ContentAutofillDriver : public AutofillDriver, ui::AXTreeID GetAxTreeId() const override; scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override; bool RendererIsAvailable() override; +#if !defined(TOOLKIT_QT) webauthn::InternalAuthenticator* GetOrCreateCreditCardInternalAuthenticator() override; +#endif void PropagateAutofillPredictions( const std::vector<autofill::FormStructure*>& forms) override; void HandleParsedForms(const std::vector<const FormData*>& forms) override; diff --git a/chromium/components/autofill/content/renderer/autofill_agent.cc b/chromium/components/autofill/content/renderer/autofill_agent.cc index 213847310bd..746bbad8dc2 100644 --- a/chromium/components/autofill/content/renderer/autofill_agent.cc +++ b/chromium/components/autofill/content/renderer/autofill_agent.cc @@ -376,6 +376,7 @@ void AutofillAgent::AccessibilityModeChanged(const ui::AXMode& mode) { void AutofillAgent::FireHostSubmitEvents(const WebFormElement& form, bool known_success, SubmissionSource source) { +#if !defined(TOOLKIT_QT) DCHECK(IsOwnedByFrame(form, render_frame())); FormData form_data; @@ -383,11 +384,13 @@ void AutofillAgent::FireHostSubmitEvents(const WebFormElement& form, return; FireHostSubmitEvents(form_data, known_success, source); +#endif // !defined(TOOLKIT_QT) } void AutofillAgent::FireHostSubmitEvents(const FormData& form_data, bool known_success, SubmissionSource source) { +#if !defined(TOOLKIT_QT) // We don't want to fire duplicate submission event. if (!base::FeatureList::IsEnabled( features::kAutofillAllowDuplicateFormSubmissions) && @@ -396,6 +399,7 @@ void AutofillAgent::FireHostSubmitEvents(const FormData& form_data, } GetAutofillDriver().FormSubmitted(form_data, known_success, source); +#endif // !defined(TOOLKIT_QT) } void AutofillAgent::Shutdown() { diff --git a/chromium/components/autofill/content/renderer/prefilled_values_detector.cc b/chromium/components/autofill/content/renderer/prefilled_values_detector.cc index 43e427c34f2..f7939a51e58 100644 --- a/chromium/components/autofill/content/renderer/prefilled_values_detector.cc +++ b/chromium/components/autofill/content/renderer/prefilled_values_detector.cc @@ -79,10 +79,12 @@ constexpr auto kKnownUsernamePlaceholders = } // namespace +#if !defined(TOOLKIT_QT) base::span<const base::StringPiece> KnownUsernamePlaceholders() { return base::make_span(kKnownUsernamePlaceholders.begin(), kKnownUsernamePlaceholders.end()); } +#endif bool PossiblePrefilledUsernameValue(const std::string& username_value, const std::string& possible_email_domain) { diff --git a/chromium/components/autofill/content/renderer/prefilled_values_detector.h b/chromium/components/autofill/content/renderer/prefilled_values_detector.h index f8071de7e4d..69c97f22de4 100644 --- a/chromium/components/autofill/content/renderer/prefilled_values_detector.h +++ b/chromium/components/autofill/content/renderer/prefilled_values_detector.h @@ -12,10 +12,12 @@ namespace autofill { +#if !defined(TOOLKIT_QT) // Returns a list of known username placeholders, all guaranteed to be lower // case. // This is only exposed for testing. base::span<const base::StringPiece> KnownUsernamePlaceholders(); +#endif // Checks if the prefilled value of the username element is one of the known // values possibly used as placeholders. The list of possible placeholder diff --git a/chromium/components/autofill/core/browser/BUILD.gn b/chromium/components/autofill/core/browser/BUILD.gn index 6586af59789..1542191057b 100644 --- a/chromium/components/autofill/core/browser/BUILD.gn +++ b/chromium/components/autofill/core/browser/BUILD.gn @@ -11,6 +11,8 @@ if (is_android) { import("//build/config/android/rules.gni") } +import("//build/config/features.gni") + grit("autofill_address_rewriter_resources") { source = "autofill_address_rewriter_resources.grd" outputs = [ @@ -515,6 +517,47 @@ jumbo_static_library("browser") { "//ui/native_theme:native_theme_browser", ] } + + if (use_qt) { + sources = [] + sources = [ + "autofill_client.cc", + "autofill_client.h", + "autofill_driver.h", + "autofill_external_delegate.cc", + "autofill_external_delegate.h", + "autofill_manager.cc", + "autofill_manager.h", + "browser_autofill_manager.cc", + "browser_autofill_manager.h", + "ui/popup_item_ids.h", + "ui/popup_types.h", + "ui/suggestion.cc", + "ui/suggestion.h", + ] + + public_deps = [] + public_deps = [ + "//components/autofill/core/browser/proto", + "//components/autofill/core/common", + "//components/autofill/core/common/mojom:mojo_types", + "//third_party/abseil-cpp:absl", + "//ui/base", + "//ui/gfx/geometry", + "//ui/gfx/range", + "//url", + ] + + deps = [] + deps = [ + "//base", + "//base:i18n", + "//build:branding_buildflags", + "//build:chromeos_buildflags", + "//components/pref_registry", + "//components/prefs", + ] + } } if (is_android) { diff --git a/chromium/components/autofill/core/browser/autofill_client.cc b/chromium/components/autofill/core/browser/autofill_client.cc index 8574bad181c..18eecd59079 100644 --- a/chromium/components/autofill/core/browser/autofill_client.cc +++ b/chromium/components/autofill/core/browser/autofill_client.cc @@ -5,9 +5,11 @@ #include "components/autofill/core/browser/autofill_client.h" #include "base/no_destructor.h" +#if !defined(TOOLKIT_QT) #include "components/autofill/core/browser/autofill_ablation_study.h" #include "components/autofill/core/browser/payments/credit_card_access_manager.h" #include "components/autofill/core/browser/single_field_form_fill_router.h" +#endif // !defined(TOOLKIT_QT) #include "components/autofill/core/browser/ui/suggestion.h" #include "components/version_info/channel.h" @@ -39,6 +41,7 @@ version_info::Channel AutofillClient::GetChannel() const { return version_info::Channel::UNKNOWN; } +#if !defined(TOOLKIT_QT) std::unique_ptr<SingleFieldFormFillRouter> AutofillClient::GetSingleFieldFormFillRouter() { return std::make_unique<SingleFieldFormFillRouter>( @@ -126,6 +129,7 @@ void AutofillClient::CloseAutofillProgressDialog( // This is overridden by platform subclasses. Currently only // ChromeAutofillClient (Chrome Desktop & Android) implements this. } +#endif // !defined(TOOLKIT_QT) bool AutofillClient::IsAutofillAssistantShowing() { return false; @@ -135,10 +139,12 @@ LogManager* AutofillClient::GetLogManager() const { return nullptr; } +#if !defined(TOOLKIT_QT) const AutofillAblationStudy& AutofillClient::GetAblationStudy() const { // As finch configs are profile independent we can use a static instance here. static base::NoDestructor<AutofillAblationStudy> ablation_study; return *ablation_study; } +#endif } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_client.h b/chromium/components/autofill/core/browser/autofill_client.h index 12582c581c2..9eaaa5e9135 100644 --- a/chromium/components/autofill/core/browser/autofill_client.h +++ b/chromium/components/autofill/core/browser/autofill_client.h @@ -20,16 +20,18 @@ #include "components/autofill/core/browser/payments/risk_data_loader.h" #include "components/autofill/core/browser/ui/popup_item_ids.h" #include "components/autofill/core/browser/ui/popup_types.h" +#if !defined(TOOLKIT_QT) #include "components/profile_metrics/browser_profile_type.h" #include "components/security_state/core/security_state.h" #include "components/translate/core/browser/language_state.h" #include "services/metrics/public/cpp/ukm_source_id.h" +#endif #include "ui/base/window_open_disposition.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/image/image.h" #include "url/gurl.h" -#if !defined(OS_IOS) +#if !defined(OS_IOS) && !defined(TOOLKIT_QT) #include "components/webauthn/core/browser/internal_authenticator.h" #endif @@ -92,7 +94,11 @@ class PaymentsClient; // BrowserAutofillManager is used (e.g. a single tab), so when we say "for the // client" below, we mean "in the execution context the client is associated // with" (e.g. for the tab the BrowserAutofillManager is attached to). +#if !defined(TOOLKIT_QT) class AutofillClient : public RiskDataLoader { +#else +class AutofillClient { +#endif public: enum class PaymentsRpcResult { // Empty result. Used for initializing variables and should generally @@ -297,7 +303,9 @@ class AutofillClient : public RiskDataLoader { base::OnceCallback<void(SaveAddressProfileOfferUserDecision, autofill::AutofillProfile profile)>; +#if !defined(TOOLKIT_QT) ~AutofillClient() override = default; +#endif // Returns the channel for the installation. In branded builds, this will be // version_info::Channel::{STABLE,BETA,DEV,CANARY}. In unbranded builds, or @@ -311,14 +319,17 @@ class AutofillClient : public RiskDataLoader { // Gets the AutocompleteHistoryManager instance associate with the client. virtual AutocompleteHistoryManager* GetAutocompleteHistoryManager() = 0; +#if !defined(TOOLKIT_QT) // Creates and returns a SingleFieldFormFillRouter using the // AutocompleteHistoryManager instance associated with the client. std::unique_ptr<SingleFieldFormFillRouter> GetSingleFieldFormFillRouter(); +#endif // Gets the preferences associated with the client. virtual PrefService* GetPrefs() = 0; virtual const PrefService* GetPrefs() const = 0; +#if !defined(TOOLKIT_QT) // Gets the sync service associated with the client. virtual syncer::SyncService* GetSyncService() = 0; @@ -551,6 +562,7 @@ class AutofillClient : public RiskDataLoader { // when a credit card is scanned successfully. Should be called only if // HasCreditCardScanFeature() returns true. virtual void ScanCreditCard(CreditCardScanCallback callback) = 0; +#endif // !defined(TOOLKIT_QT) // Shows an Autofill popup with the given |values|, |labels|, |icons|, and // |identifiers| for the element at |element_bounds|. |delegate| will be @@ -584,6 +596,7 @@ class AutofillClient : public RiskDataLoader { // Hide the Autofill popup if one is currently showing. virtual void HideAutofillPopup(PopupHidingReason reason) = 0; +#if !defined(TOOLKIT_QT) // TODO(crbug.com/1093057): Rename all the "domain" in this flow to origin. // The server is passing down full origin of the // urls. "Domain" is no longer accurate. @@ -615,6 +628,7 @@ class AutofillClient : public RiskDataLoader { virtual void ShowAutofillProgressDialog(base::OnceClosure cancel_callback); virtual void CloseAutofillProgressDialog( bool show_confirmation_before_closing); +#endif // !defined(TOOLKIT_QT) // Returns true if the Autofill Assistant UI is currently being shown. virtual bool IsAutofillAssistantShowing(); @@ -628,6 +642,7 @@ class AutofillClient : public RiskDataLoader { content::RenderFrameHost* rfh, const std::vector<FormStructure*>& forms) = 0; +#if !defined(TOOLKIT_QT) // Inform the client that the field has been filled. virtual void DidFillOrPreviewField( const std::u16string& autofilled_value, @@ -645,12 +660,15 @@ class AutofillClient : public RiskDataLoader { // Handles simple actions for the autofill popups. virtual void ExecuteCommand(int id) = 0; +#endif // !defined(TOOLKIT_QT) // Returns a LogManager instance. May be null for platforms that don't support // this. virtual LogManager* GetLogManager() const; +#if !defined(TOOLKIT_QT) virtual const AutofillAblationStudy& GetAblationStudy() const; +#endif #if defined(OS_IOS) // Checks whether the current query is the most recent one. diff --git a/chromium/components/autofill/core/browser/autofill_driver.h b/chromium/components/autofill/core/browser/autofill_driver.h index 1860516de0a..015b90e2127 100644 --- a/chromium/components/autofill/core/browser/autofill_driver.h +++ b/chromium/components/autofill/core/browser/autofill_driver.h @@ -17,7 +17,7 @@ #include "ui/accessibility/ax_tree_id.h" #include "url/origin.h" -#if !defined(OS_IOS) +#if !defined(OS_IOS) && !defined(TOOLKIT_QT) #include "components/webauthn/core/browser/internal_authenticator.h" #endif @@ -60,7 +60,7 @@ class AutofillDriver { // Returns true iff the renderer is available for communication. virtual bool RendererIsAvailable() = 0; -#if !defined(OS_IOS) +#if !defined(OS_IOS) && !defined(TOOLKIT_QT) // Gets or creates a pointer to an implementation of InternalAuthenticator. virtual webauthn::InternalAuthenticator* GetOrCreateCreditCardInternalAuthenticator() = 0; diff --git a/chromium/components/autofill/core/browser/autofill_external_delegate.cc b/chromium/components/autofill/core/browser/autofill_external_delegate.cc index a6e66c8b47f..f298f06948c 100644 --- a/chromium/components/autofill/core/browser/autofill_external_delegate.cc +++ b/chromium/components/autofill/core/browser/autofill_external_delegate.cc @@ -19,7 +19,9 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" +#if !defined(TOOLKIT_QT) #include "components/autofill/core/browser/autocomplete_history_manager.h" +#endif #include "components/autofill/core/browser/autofill_driver.h" #include "components/autofill/core/browser/browser_autofill_manager.h" #include "components/autofill/core/browser/metrics/autofill_metrics.h" @@ -73,6 +75,7 @@ void AutofillExternalDelegate::OnQuery(int query_id, query_field_ = field; query_id_ = query_id; element_bounds_ = element_bounds; +#if !defined(TOOLKIT_QT) should_show_scan_credit_card_ = manager_->ShouldShowScanCreditCard(query_form_, query_field_); popup_type_ = manager_->GetPopupType(query_form_, query_field_); @@ -80,6 +83,7 @@ void AutofillExternalDelegate::OnQuery(int query_id, manager_->ShouldShowCreditCardSigninPromo(query_form_, query_field_); should_show_cards_from_account_option_ = manager_->ShouldShowCardsFromAccountOption(query_form_, query_field_); +#endif // !defined(TOOLKIT_QT); } void AutofillExternalDelegate::OnSuggestionsReturned( @@ -208,6 +212,7 @@ void AutofillExternalDelegate::SetCurrentDataListValues( } void AutofillExternalDelegate::OnPopupShown() { +#if !defined(TOOLKIT_QT) // Popups are expected to be Autofill or Autocomplete. DCHECK_NE(GetPopupType(), PopupType::kPasswords); @@ -221,6 +226,7 @@ void AutofillExternalDelegate::OnPopupShown() { AutofillMetrics::LogScanCreditCardPromptMetric( AutofillMetrics::SCAN_CARD_ITEM_SHOWN); } +#endif // !defined(TOOLKIT_QT) } void AutofillExternalDelegate::OnPopupHidden() { @@ -228,7 +234,9 @@ void AutofillExternalDelegate::OnPopupHidden() { } void AutofillExternalDelegate::OnPopupSuppressed() { +#if !defined(TOOLKIT_QT) manager_->DidSuppressPopup(query_form_, query_field_); +#endif } void AutofillExternalDelegate::DidSelectSuggestion(const std::u16string& value, @@ -248,6 +256,7 @@ void AutofillExternalDelegate::DidAcceptSuggestion( int frontend_id, const std::string& backend_id, int position) { +#if !defined(TOOLKIT_QT) if (frontend_id == POPUP_ITEM_ID_AUTOFILL_OPTIONS) { // User selected 'Autofill Options'. manager_->ShowAutofillSettings(popup_type_ == PopupType::kCreditCards); @@ -311,6 +320,16 @@ void AutofillExternalDelegate::DidAcceptSuggestion( } else { manager_->client()->HideAutofillPopup(PopupHidingReason::kAcceptSuggestion); } +#else + if (frontend_id == POPUP_ITEM_ID_DATALIST_ENTRY) { + driver_->RendererShouldAcceptDataListSuggestion(query_field_.global_id(), + value); + } else { + // QtWebEngine supports datalist only. + NOTREACHED(); + } + manager_->client()->HideAutofillPopup(PopupHidingReason::kAcceptSuggestion); +#endif // !defined(TOOLKIT_QT) } bool AutofillExternalDelegate::GetDeletionConfirmationText( @@ -318,11 +337,16 @@ bool AutofillExternalDelegate::GetDeletionConfirmationText( int frontend_id, std::u16string* title, std::u16string* body) { +#if !defined(TOOLKIT_QT) return manager_->GetDeletionConfirmationText(value, frontend_id, title, body); +#else + return false; +#endif } bool AutofillExternalDelegate::RemoveSuggestion(const std::u16string& value, int frontend_id) { +#if !defined(TOOLKIT_QT) if (frontend_id > 0) return manager_->RemoveAutofillProfileOrCreditCard(frontend_id); @@ -330,6 +354,7 @@ bool AutofillExternalDelegate::RemoveSuggestion(const std::u16string& value, manager_->RemoveCurrentSingleFieldSuggestion(query_field_.name, value); return true; } +#endif // !defined(TOOLKIT_QT) return false; } @@ -371,12 +396,15 @@ base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() { } void AutofillExternalDelegate::OnCreditCardScanned(const CreditCard& card) { +#if !defined(TOOLKIT_QT) manager_->FillCreditCardForm(query_id_, query_form_, query_field_, card, std::u16string()); +#endif } void AutofillExternalDelegate::FillAutofillFormData(int unique_id, bool is_preview) { +#if !defined(TOOLKIT_QT) // If the selected element is a warning we don't want to do anything. if (IsAutofillWarningEntry(unique_id)) return; @@ -389,6 +417,7 @@ void AutofillExternalDelegate::FillAutofillFormData(int unique_id, // Fill the values for the whole form. manager_->FillOrPreviewForm(renderer_action, query_id_, query_form_, query_field_, unique_id); +#endif // !defined(TOOLKIT_QT) } void AutofillExternalDelegate::PossiblyRemoveAutofillWarnings( @@ -443,6 +472,7 @@ void AutofillExternalDelegate::ApplyAutofillOptions( suggestions->back().icon = "settingsIcon"; } +#if !defined(TOOLKIT_QT) // On Android and Desktop, Google Pay branding is shown along with Settings. // So Google Pay Icon is just attached to an existing menu item. if (is_all_server_suggestions) { @@ -455,6 +485,9 @@ void AutofillExternalDelegate::ApplyAutofillOptions( : "googlePay"; #endif } +#else + DCHECK(!is_all_server_suggestions); +#endif } void AutofillExternalDelegate::InsertDataListValues( diff --git a/chromium/components/autofill/core/browser/autofill_manager.cc b/chromium/components/autofill/core/browser/autofill_manager.cc index b11722f7784..77e1dbee321 100644 --- a/chromium/components/autofill/core/browser/autofill_manager.cc +++ b/chromium/components/autofill/core/browser/autofill_manager.cc @@ -16,12 +16,15 @@ #include "components/autofill/core/common/autofill_payments_features.h" #include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/autofill_tick_clock.h" +#if !defined(TOOLKIT_QT) #include "components/translate/core/common/language_detection_details.h" #include "google_apis/google_api_keys.h" +#endif #include "ui/gfx/geometry/rect_f.h" namespace autofill { +#if !defined(TOOLKIT_QT) namespace { // Returns the AutofillField* corresponding to |field| in |form| or nullptr, @@ -68,9 +71,11 @@ std::string GetAPIKeyForUrl(version_info::Channel channel) { } } // namespace +#endif // !defined(TOOLKIT_QT) using base::TimeTicks; +#if !defined(TOOLKIT_QT) // static void AutofillManager::LogAutofillTypePredictionsAvailable( LogManager* log_manager, @@ -98,6 +103,7 @@ bool AutofillManager::IsRawMetadataUploadingEnabled( return channel == version_info::Channel::CANARY || channel == version_info::Channel::DEV; } +#endif // !defined(TOOLKIT_QT) AutofillManager::AutofillManager( AutofillDriver* driver, @@ -111,6 +117,16 @@ AutofillManager::AutofillManager( DCHECK(client); } +#if defined(TOOLKIT_QT) +AutofillManager::AutofillManager( + AutofillDriver* driver, + AutofillClient* client, + AutofillDownloadManagerState enable_download_manager, + version_info::Channel channel) + : driver_(driver), + client_(client) +{} +#else AutofillManager::AutofillManager( AutofillDriver* driver, AutofillClient* client, @@ -173,10 +189,12 @@ void AutofillManager::OnFormSubmitted(const FormData& form, if (IsValidFormData(form)) OnFormSubmittedImpl(form, known_success, source); } +#endif // defined(TOOLKIT_QT) void AutofillManager::OnFormsSeen( const std::vector<FormData>& updated_forms, const std::vector<FormGlobalId>& removed_forms) { +#if !defined(TOOLKIT_QT) if (base::FeatureList::IsEnabled(features::kAutofillDisplaceRemovedForms)) { // Erase forms that have been removed from the DOM. This prevents // |form_structures_| from growing up its upper bound @@ -225,8 +243,10 @@ void AutofillManager::OnFormsSeen( if (new_forms.empty()) return; OnFormsParsed(new_forms); +#endif // !defined(TOOLKIT_QT) } +#if !defined(TOOLKIT_QT) void AutofillManager::OnFormsParsed(const std::vector<const FormData*>& forms) { DCHECK(!forms.empty()); OnBeforeProcessParsedForms(); @@ -280,6 +300,7 @@ void AutofillManager::OnFormsParsed(const std::vector<const FormData*>& forms) { download_manager()->StartQueryRequest(queryable_forms); } } +#endif // !defined(TOOLKIT_QT) void AutofillManager::OnTextFieldDidChange(const FormData& form, const FormFieldData& field, @@ -330,6 +351,7 @@ void AutofillManager::OnFocusOnFormField(const FormData& form, OnFocusOnFormFieldImpl(form, field, bounding_box); } +#if !defined(TOOLKIT_QT) // Returns true if |live_form| does not match |cached_form|. bool AutofillManager::GetCachedFormAndField(const FormData& form, const FormFieldData& field, @@ -448,12 +470,16 @@ FormStructure* AutofillManager::ParseForm(const FormData& form, return parsed_form_structure; } +#endif // !defined(TOOLKIT_QT) void AutofillManager::Reset() { +#if !defined(TOOLKIT_QT) form_structures_.clear(); form_interactions_ukm_logger_ = CreateFormInteractionsUkmLogger(); +#endif } +#if !defined(TOOLKIT_QT) void AutofillManager::OnLoadedServerPredictions( std::string response, const std::vector<FormSignature>& queried_form_signatures) { @@ -511,5 +537,6 @@ void AutofillManager::OnServerRequestError( FormSignature form_signature, AutofillDownloadManager::RequestType request_type, int http_error) {} +#endif // !defined(TOOLKIT_QT) } // namespace autofill diff --git a/chromium/components/autofill/core/browser/autofill_manager.h b/chromium/components/autofill/core/browser/autofill_manager.h index 8310c82331b..d6be53a97b7 100644 --- a/chromium/components/autofill/core/browser/autofill_manager.h +++ b/chromium/components/autofill/core/browser/autofill_manager.h @@ -25,7 +25,9 @@ #include "components/autofill/core/common/mojom/autofill_types.mojom.h" #include "components/autofill/core/common/signatures.h" #include "components/autofill/core/common/unique_ids.h" +#if !defined(TOOLKIT_QT) #include "components/translate/core/browser/translate_driver.h" +#endif #include "components/version_info/channel.h" namespace gfx { @@ -42,9 +44,14 @@ class LogManager; // This class defines the interface should be implemented by autofill // implementation in browser side to interact with AutofillDriver. +#if !defined(TOOLKIT_QT) class AutofillManager : public AutofillDownloadManager::Observer, public translate::TranslateDriver::LanguageDetectionObserver { +#else +class AutofillManager { +#endif // !defined(TOOLKIT_QT) + public: enum AutofillDownloadManagerState { ENABLE_AUTOFILL_DOWNLOAD_MANAGER, @@ -67,6 +74,7 @@ class AutofillManager const std::string& app_locale, AutofillManager::AutofillDownloadManagerState)>; +#if !defined(TOOLKIT_QT) // Raw metadata uploading enabled iff this Chrome instance is on Canary or Dev // channel. static bool IsRawMetadataUploadingEnabled(version_info::Channel channel); @@ -77,11 +85,14 @@ class AutofillManager static void LogAutofillTypePredictionsAvailable( LogManager* log_manager, const std::vector<FormStructure*>& forms); +#endif // !defined(TOOLKIT_QT) AutofillManager(const AutofillManager&) = delete; AutofillManager& operator=(const AutofillManager&) = delete; +#if !defined(TOOLKIT_QT) ~AutofillManager() override; +#endif // The following will fail a DCHECK if called for a prerendered main frame. AutofillClient* client() { @@ -172,6 +183,7 @@ class AutofillManager // Resets cache. virtual void Reset(); +#if !defined(TOOLKIT_QT) // translate::TranslateDriver::LanguageDetectionObserver: void OnTranslateDriverDestroyed( translate::TranslateDriver* translate_driver) override; @@ -207,10 +219,12 @@ class AutofillManager form_structures() const { return form_structures_; } +#endif // !defined(TOOLKIT_QT) AutofillDriver* driver() { return driver_; } const AutofillDriver* driver() const { return driver_; } +#if !defined(TOOLKIT_QT) AutofillDownloadManager* download_manager() { return download_manager_.get(); } @@ -234,6 +248,7 @@ class AutofillManager int http_error) { OnServerRequestError(form_signature, request_type, http_error); } +#endif // !defined(TOOLKIT_QT) #ifdef UNIT_TEST // A public wrapper that calls |mutable_form_structures| for testing purposes // only. @@ -258,10 +273,12 @@ class AutofillManager AutofillDownloadManagerState enable_download_manager, version_info::Channel channel); +#if !defined(TOOLKIT_QT) LogManager* log_manager() { return log_manager_; } // Retrieves the page language from |client_| LanguageCode GetCurrentPageLanguage(); +#endif // The following do not check for prerendering. These should only used while // constructing or resetting the manager. @@ -315,6 +332,7 @@ class AutofillManager virtual void OnAfterProcessParsedForms( const DenseSet<FormType>& form_types) = 0; +#if !defined(TOOLKIT_QT) // Returns the number of FormStructures with the given |form_signature| and // appends them to |form_structures|. Runs in linear time. size_t FindCachedFormsBySignature( @@ -333,6 +351,7 @@ class AutofillManager mutable_form_structures() { return &form_structures_; } +#endif // !defined(TOOLKIT_QT) #ifdef UNIT_TEST // Exposed for testing. @@ -343,6 +362,7 @@ class AutofillManager #endif // UNIT_TEST private: +#if !defined(TOOLKIT_QT) // AutofillDownloadManager::Observer: void OnLoadedServerPredictions( std::string response, @@ -357,6 +377,7 @@ class AutofillManager std::unique_ptr<AutofillMetrics::FormInteractionsUkmLogger> CreateFormInteractionsUkmLogger(); +#endif // !defined(TOOLKIT_QT) // Provides driver-level context to the shared code of the component. Must // outlive this object. @@ -367,6 +388,7 @@ class AutofillManager // client isn't accessed incorrectly. const raw_ptr<AutofillClient> client_; +#if !defined(TOOLKIT_QT) const raw_ptr<LogManager> log_manager_; // Observer needed to re-run heuristics when the language has been detected. @@ -390,6 +412,7 @@ class AutofillManager // Will be not null only for |SaveCardBubbleViewsFullFormBrowserTest|. raw_ptr<ObserverForTest> observer_for_testing_ = nullptr; +#endif // !defined(TOOLKIT_QT) }; } // namespace autofill diff --git a/chromium/components/autofill/core/browser/browser_autofill_manager.cc b/chromium/components/autofill/core/browser/browser_autofill_manager.cc index a1b9eeff7f9..83f36527088 100644 --- a/chromium/components/autofill/core/browser/browser_autofill_manager.cc +++ b/chromium/components/autofill/core/browser/browser_autofill_manager.cc @@ -44,7 +44,9 @@ #include "base/threading/thread_restrictions.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" +#if !defined(TOOLKIT_QT) #include "components/autofill/core/browser/autocomplete_history_manager.h" +#endif #include "components/autofill/core/browser/autofill_browser_util.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_data_util.h" @@ -60,6 +62,7 @@ #include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/browser/data_model/phone_number.h" #include "components/autofill/core/browser/field_types.h" +#if !defined(TOOLKIT_QT) #include "components/autofill/core/browser/form_data_importer.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/browser/geo/country_names.h" @@ -72,6 +75,7 @@ #include "components/autofill/core/browser/payments/payments_client.h" #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/randomized_encoder.h" +#endif // !defined(TOOLKIT_QT) #include "components/autofill/core/browser/ui/popup_item_ids.h" #include "components/autofill/core/browser/validation.h" #include "components/autofill/core/common/autofill_clock.h" @@ -110,6 +114,7 @@ using base::StartsWith; using base::TimeTicks; using mojom::SubmissionSource; +#if !defined(TOOLKIT_QT) constexpr int kCreditCardSigninPromoImpressionLimit = 3; namespace { @@ -411,6 +416,7 @@ BrowserAutofillManager::FillingContext::FillingContext( } BrowserAutofillManager::FillingContext::~FillingContext() = default; +#endif // !defined(TOOLKIT_QT) BrowserAutofillManager::BrowserAutofillManager( AutofillDriver* driver, @@ -423,6 +429,19 @@ BrowserAutofillManager::BrowserAutofillManager( app_locale, enable_download_manager) {} +#if defined(TOOLKIT_QT) +BrowserAutofillManager::BrowserAutofillManager( + AutofillDriver* driver, + AutofillClient* client, + PersonalDataManager* personal_data, + const std::string app_locale, + AutofillDownloadManagerState enable_download_manager) + : AutofillManager(driver, client, enable_download_manager), + external_delegate_( + std::make_unique<AutofillExternalDelegate>(this, driver)), + app_locale_(app_locale), + personal_data_(personal_data) {} +#else BrowserAutofillManager::BrowserAutofillManager( AutofillDriver* driver, AutofillClient* client, @@ -625,9 +644,11 @@ void BrowserAutofillManager::OnVirtualCardCandidateSelected( // the information in the form. } #endif +#endif // !defined(TOOLKIT_QT) bool BrowserAutofillManager::ShouldParseForms( const std::vector<FormData>& forms) { +#if !defined(TOOLKIT_QT) bool autofill_enabled = IsAutofillEnabled(); sync_state_ = personal_data_ ? personal_data_->GetSyncSigninState() : AutofillSyncSigninState::kNumSyncStates; @@ -642,11 +663,15 @@ bool BrowserAutofillManager::ShouldParseForms( } return autofill_enabled; +#else + return false; +#endif // !defined(TOOLKIT_QT) } void BrowserAutofillManager::OnFormSubmittedImpl(const FormData& form, bool known_success, SubmissionSource source) { +#if !defined(TOOLKIT_QT) base::UmaHistogramEnumeration("Autofill.FormSubmission.PerProfileType", client()->GetProfileType()); if (log_manager()) { @@ -739,8 +764,12 @@ void BrowserAutofillManager::OnFormSubmittedImpl(const FormData& form, client()->GetFormDataImporter()->ImportFormData( *submitted_form, IsAutofillProfileEnabled(), IsAutofillCreditCardEnabled()); +#else + NOTREACHED(); +#endif // !defined(TOOLKIT_QT) } +#if !defined(TOOLKIT_QT) bool BrowserAutofillManager::MaybeStartVoteUploadProcess( std::unique_ptr<FormStructure> form_structure, bool observed_submission) { @@ -856,12 +885,14 @@ void BrowserAutofillManager::DidSuppressPopup(const FormData& form, if (logger) logger->OnPopupSuppressed(*form_structure, *autofill_field); } +#endif // !defined(TOOLKIT_QT) void BrowserAutofillManager::OnTextFieldDidChangeImpl( const FormData& form, const FormFieldData& field, const gfx::RectF& bounding_box, const TimeTicks timestamp) { +#if !defined(TOOLKIT_QT) if (test_delegate_) test_delegate_->OnTextFieldChanged(); @@ -914,11 +945,14 @@ void BrowserAutofillManager::OnTextFieldDidChangeImpl( } UpdateInitialInteractionTimestamp(timestamp); +#endif // !defined(TOOLKIT_QT) } +#if !defined(TOOLKIT_QT) bool BrowserAutofillManager::IsFormNonSecure(const FormData& form) const { return IsFormOrClientNonSecure(client(), form); } +#endif void BrowserAutofillManager::OnAskForValuesToFillImpl( int query_id, @@ -935,6 +969,7 @@ void BrowserAutofillManager::OnAskForValuesToFillImpl( std::vector<Suggestion> suggestions; SuggestionsContext context; +#if !defined(TOOLKIT_QT) GetAvailableSuggestions(form, field, &suggestions, &context); if (context.is_autofill_available) { @@ -1002,11 +1037,13 @@ void BrowserAutofillManager::OnAskForValuesToFillImpl( // Send Autofill suggestions (could be an empty list). single_field_form_fill_router_->CancelPendingQueries(this); +#endif // !defined(TOOLKIT_QT) external_delegate_->OnSuggestionsReturned(query_id, suggestions, autoselect_first_suggestion, context.should_display_gpay_logo); } +#if !defined(TOOLKIT_QT) bool BrowserAutofillManager::WillFillCreditCardNumber( const FormData& form, const FormFieldData& field) { @@ -1149,8 +1186,10 @@ void BrowserAutofillManager::FillVirtualCardInformation( form, field, ©); } } +#endif // !defined(TOOLKIT_QT) void BrowserAutofillManager::OnFocusNoLongerOnForm(bool had_interacted_form) { +#if !defined(TOOLKIT_QT) // For historical reasons, Chrome takes action on this message only if focus // was previously on a form with which the user had interacted. // TODO(crbug.com/1140473): Remove need for this short-circuit. @@ -1170,12 +1209,14 @@ void BrowserAutofillManager::OnFocusNoLongerOnForm(bool had_interacted_form) { mojom::AutofillState::kNoSuggestions); } #endif +#endif // !defined(TOOLKIT_QT) } void BrowserAutofillManager::OnFocusOnFormFieldImpl( const FormData& form, const FormFieldData& field, const gfx::RectF& bounding_box) { +#if !defined(TOOLKIT_QT) // Notify installed screen readers if the focus is on a field for which there // are suggestions to present. Ignore if a screen reader is not present. If // the platform is ChromeOS, then assume ChromeVox is in use as there is no @@ -1195,6 +1236,7 @@ void BrowserAutofillManager::OnFocusOnFormFieldImpl( !suggestions.empty()) ? mojom::AutofillState::kAutofillAvailable : mojom::AutofillState::kNoSuggestions); +#endif // !defined(TOOLKIT_QT) } void BrowserAutofillManager::OnSelectControlDidChangeImpl( @@ -1205,13 +1247,16 @@ void BrowserAutofillManager::OnSelectControlDidChangeImpl( } void BrowserAutofillManager::OnDidPreviewAutofillFormData() { +#if !defined(TOOLKIT_QT) if (test_delegate_) test_delegate_->DidPreviewFormData(); +#endif } void BrowserAutofillManager::OnDidFillAutofillFormData( const FormData& form, const TimeTicks timestamp) { +#if !defined(TOOLKIT_QT) if (test_delegate_) test_delegate_->DidFillFormData(); @@ -1240,8 +1285,10 @@ void BrowserAutofillManager::OnDidFillAutofillFormData( } UpdateInitialInteractionTimestamp(timestamp); +#endif // !defined(TOOLKIT_QT) } +#if !defined(TOOLKIT_QT) void BrowserAutofillManager::DidShowSuggestions(bool has_autofill_suggestions, const FormData& form, const FormFieldData& field) { @@ -1284,15 +1331,19 @@ void BrowserAutofillManager::DidShowSuggestions(bool has_autofill_suggestions, credit_card_access_manager_->PrepareToFetchCreditCard(); } } +#endif // !defined(TOOLKIT_QT) void BrowserAutofillManager::OnHidePopup() { +#if !defined(TOOLKIT_QT) if (!IsAutofillEnabled()) return; single_field_form_fill_router_->CancelPendingQueries(this); +#endif client()->HideAutofillPopup(PopupHidingReason::kRendererEvent); } +#if !defined(TOOLKIT_QT) bool BrowserAutofillManager::GetDeletionConfirmationText( const std::u16string& value, int identifier, @@ -1406,6 +1457,7 @@ void BrowserAutofillManager::SetTestDelegate( BrowserAutofillManagerTestDelegate* delegate) { test_delegate_ = delegate; } +#endif // !defined(TOOLKIT_QT) void BrowserAutofillManager::SetDataList( const std::vector<std::u16string>& values, @@ -1418,6 +1470,7 @@ void BrowserAutofillManager::SetDataList( } void BrowserAutofillManager::SelectFieldOptionsDidChange(const FormData& form) { +#if !defined(TOOLKIT_QT) // Look for a cached version of the form. It will be a null pointer if none is // found, which is fine. FormStructure* cached_form = FindCachedFormByRendererId(form.global_id()); @@ -1430,6 +1483,7 @@ void BrowserAutofillManager::SelectFieldOptionsDidChange(const FormData& form) { if (ShouldTriggerRefill(*form_structure)) TriggerRefill(form); +#endif // !defined(TOOLKIT_QT) } void BrowserAutofillManager::PropagateAutofillPredictions( @@ -1438,6 +1492,7 @@ void BrowserAutofillManager::PropagateAutofillPredictions( client()->PropagateAutofillPredictions(rfh, forms); } +#if !defined(TOOLKIT_QT) void BrowserAutofillManager::OnCreditCardFetched(CreditCardFetchResult result, const CreditCard* credit_card, const std::u16string& cvc) { @@ -1474,6 +1529,7 @@ void BrowserAutofillManager::OnCreditCardFetched(CreditCardFetchResult result, credit_card_access_manager_->CacheUnmaskedCardInfo(*credit_card, cvc); } } +#endif // !defined(TOOLKIT_QT) void BrowserAutofillManager::OnDidEndTextFieldEditing() { external_delegate_->DidEndTextFieldEditing(); @@ -1491,6 +1547,7 @@ bool BrowserAutofillManager::IsAutofillCreditCardEnabled() const { return ::autofill::prefs::IsAutofillCreditCardEnabled(client()->GetPrefs()); } +#if !defined(TOOLKIT_QT) const FormData& BrowserAutofillManager::last_query_form() const { return external_delegate_->query_form(); } @@ -1558,8 +1615,10 @@ void BrowserAutofillManager::UploadFormData(const FormStructure& submitted_form, /*login_form_signature=*/std::string(), observed_submission, client()->GetPrefs()); } +#endif // !defined(TOOLKIT_QT) void BrowserAutofillManager::Reset() { +#if !defined(TOOLKIT_QT) // Note that upload_request_ is not reset here because the prompt to // save a card is shown after page navigation. ProcessPendingFormForUpload(); @@ -1590,8 +1649,12 @@ void BrowserAutofillManager::Reset() { initial_interaction_timestamp_ = TimeTicks(); external_delegate_->Reset(); filling_context_.clear(); +#else + external_delegate_->Reset(); +#endif // !defined(TOOLKIT_QT) } +#if !defined(TOOLKIT_QT) bool BrowserAutofillManager::RefreshDataModels() { if (!IsAutofillEnabled()) return false; @@ -2012,8 +2075,10 @@ std::vector<Suggestion> BrowserAutofillManager::GetCreditCardSuggestions( credit_card_form_event_logger_->set_suggestions(suggestions); return suggestions; } +#endif // !defined(TOOLKIT_QT) void BrowserAutofillManager::OnBeforeProcessParsedForms() { +#if !defined(TOOLKIT_QT) has_parsed_forms_ = true; // Record the current sync state to be used for metrics on this page. @@ -2021,11 +2086,13 @@ void BrowserAutofillManager::OnBeforeProcessParsedForms() { // Setup the url for metrics that we will collect for this form. form_interactions_ukm_logger()->OnFormsParsed(client()->GetUkmSourceId()); +#endif // !defined(TOOLKIT_QT) } void BrowserAutofillManager::OnFormProcessed( const FormData& form, const FormStructure& form_structure) { +#if !defined(TOOLKIT_QT) if (data_util::ContainsPhone(data_util::DetermineGroups(form_structure))) { has_observed_phone_number_field_ = true; } @@ -2071,10 +2138,14 @@ void BrowserAutofillManager::OnFormProcessed( base::BindRepeating(&BrowserAutofillManager::TriggerRefill, weak_ptr_factory_.GetWeakPtr(), form)); } +#else + NOTREACHED(); +#endif // !defined(TOOLKIT_QT) } void BrowserAutofillManager::OnAfterProcessParsedForms( const DenseSet<FormType>& form_types) { +#if !defined(TOOLKIT_QT) AutofillMetrics::LogUserHappinessMetric( AutofillMetrics::FORMS_LOADED, form_types, client()->GetSecurityLevelForUmaHistograms(), @@ -2085,8 +2156,12 @@ void BrowserAutofillManager::OnAfterProcessParsedForms( // directly comparable. KeyboardAccessoryMetricsLogger::OnFormsLoaded(); #endif +#else + NOTREACHED(); +#endif // !defined(TOOLKIT_QT) } +#if !defined(TOOLKIT_QT) int BrowserAutofillManager::BackendIDToInt( const std::string& backend_id) const { if (!base::IsValidGUID(backend_id)) @@ -2785,5 +2860,6 @@ void BrowserAutofillManager::PreProcessStateMatchingTypes( } } } +#endif // !defined(TOOLKIT_QT) } // namespace autofill diff --git a/chromium/components/autofill/core/browser/browser_autofill_manager.h b/chromium/components/autofill/core/browser/browser_autofill_manager.h index 53b2df6b1da..9d66ebf1e79 100644 --- a/chromium/components/autofill/core/browser/browser_autofill_manager.h +++ b/chromium/components/autofill/core/browser/browser_autofill_manager.h @@ -20,7 +20,9 @@ #include "base/time/time.h" #include "base/timer/timer.h" #include "build/build_config.h" +#if !defined(TOOLKIT_QT) #include "components/autofill/core/browser/autocomplete_history_manager.h" +#endif #include "components/autofill/core/browser/autofill_ablation_study.h" #include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_driver.h" @@ -28,6 +30,7 @@ #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/field_filler.h" #include "components/autofill/core/browser/form_types.h" +#if !defined(TOOLKIT_QT) #include "components/autofill/core/browser/metrics/form_events/address_form_event_logger.h" #include "components/autofill/core/browser/metrics/form_events/credit_card_form_event_logger.h" #include "components/autofill/core/browser/payments/autofill_offer_manager.h" @@ -37,6 +40,7 @@ #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/single_field_form_fill_router.h" #include "components/autofill/core/browser/sync_utils.h" +#endif // !defined(TOOLKIT_QT) #include "components/autofill/core/browser/ui/popup_types.h" #include "components/autofill/core/common/dense_set.h" #include "components/autofill/core/common/form_data.h" @@ -75,9 +79,13 @@ enum class ValuePatternsMetric { // Manages saving and restoring the user's personal information entered into web // forms. One per frame; owned by the AutofillDriver. +#if !defined(TOOLKIT_QT) class BrowserAutofillManager : public AutofillManager, public SingleFieldFormFiller::SuggestionsHandler, public CreditCardAccessManager::Accessor { +#else +class BrowserAutofillManager : public AutofillManager { +#endif // !defined(TOOLKIT_QT) public: BrowserAutofillManager(AutofillDriver* driver, AutofillClient* client, @@ -87,6 +95,7 @@ class BrowserAutofillManager : public AutofillManager, BrowserAutofillManager(const BrowserAutofillManager&) = delete; BrowserAutofillManager& operator=(const BrowserAutofillManager&) = delete; +#if !defined(TOOLKIT_QT) ~BrowserAutofillManager() override; void ShowAutofillSettings(bool show_credit_card_settings); @@ -220,6 +229,7 @@ class BrowserAutofillManager : public AutofillManager, // Invoked when the popup view can't be created. Main usage is to collect // metrics. void DidSuppressPopup(const FormData& form, const FormFieldData& field); +#endif // !defined(TOOLKIT_QT) // AutofillManager: void OnFocusNoLongerOnForm(bool had_interacted_form) override; @@ -237,11 +247,13 @@ class BrowserAutofillManager : public AutofillManager, const std::vector<FormStructure*>& forms) override; void Reset() override; +#if !defined(TOOLKIT_QT) // SingleFieldFormFiller::SuggestionsHandler: void OnSuggestionsReturned( int query_id, bool autoselect_first_suggestion, const std::vector<Suggestion>& suggestions) override; +#endif // Returns true if either Profile or CreditCard Autofill is enabled. virtual bool IsAutofillEnabled() const; @@ -254,6 +266,7 @@ class BrowserAutofillManager : public AutofillManager, // the client supports Autofill. virtual bool IsAutofillCreditCardEnabled() const; +#if !defined(TOOLKIT_QT) // Shared code to determine if |form| should be uploaded to the Autofill // server. It verifies that uploading is allowed and |form| meets conditions // to be uploadable. Exposed for testing. @@ -270,6 +283,7 @@ class BrowserAutofillManager : public AutofillManager, bool has_observed_one_time_code_field() const { return has_observed_one_time_code_field_; } +#endif // !defined(TOOLKIT_QT) #if defined(UNIT_TEST) void SetExternalDelegateForTest( @@ -323,6 +337,7 @@ class BrowserAutofillManager : public AutofillManager, AutofillDownloadManagerState enable_download_manager = DISABLE_AUTOFILL_DOWNLOAD_MANAGER); +#if !defined(TOOLKIT_QT) // Uploads the form data to the Autofill server. |observed_submission| // indicates that upload is the result of a submission event. virtual void UploadFormData(const FormStructure& submitted_form, @@ -350,6 +365,7 @@ class BrowserAutofillManager : public AutofillManager, void SplitFrontendID(int frontend_id, std::string* cc_backend_id, std::string* profile_backend_id) const; +#endif // !defined(TOOLKIT_QT) // AutofillManager: void OnFormSubmittedImpl(const FormData& form, @@ -376,8 +392,10 @@ class BrowserAutofillManager : public AutofillManager, const FormStructure& form_structure) override; void OnAfterProcessParsedForms(const DenseSet<FormType>& form_types) override; +#if !defined(TOOLKIT_QT) // Exposed for testing. FormData* pending_form_data() { return pending_form_data_.get(); } +#endif #ifdef UNIT_TEST void set_single_field_form_fill_router_for_test( @@ -401,6 +419,7 @@ class BrowserAutofillManager : public AutofillManager, FRIEND_TEST_ALL_PREFIXES(BrowserAutofillManagerTest, PageLanguageGetsCorrectlyDetected); +#if !defined(TOOLKIT_QT) // Keeps track of the filling context for a form, used to make refill attemps. struct FillingContext { // |profile_or_credit_card| contains either AutofillProfile or CreditCard @@ -433,6 +452,7 @@ class BrowserAutofillManager : public AutofillManager, // The field type groups that were initially filled. std::set<FieldTypeGroup> type_groups_originally_filled; }; +#endif // !defined(TOOLKIT_QT) // Indicates the reason why autofill suggestions are suppressed. enum class SuppressReason { @@ -481,6 +501,7 @@ class BrowserAutofillManager : public AutofillManager, AblationGroup conditional_ablation_group = AblationGroup::kDefault; }; +#if !defined(TOOLKIT_QT) // CreditCardAccessManager::Accessor void OnCreditCardFetched( CreditCardFetchResult result, @@ -671,6 +692,7 @@ class BrowserAutofillManager : public AutofillManager, // May return nullptr. FormEventLoggerBase* GetEventFormLogger( FieldTypeGroup field_type_group) const; +#endif // !defined(TOOLKIT_QT) void SetDataList(const std::vector<std::u16string>& values, const std::vector<std::u16string>& labels); @@ -687,6 +709,7 @@ class BrowserAutofillManager : public AutofillManager, // May be NULL. NULL indicates OTR. raw_ptr<PersonalDataManager> personal_data_; +#if !defined(TOOLKIT_QT) // Used to help fill data into fields. FieldFiller field_filler_; @@ -764,6 +787,7 @@ class BrowserAutofillManager : public AutofillManager, // Used to record metrics. This should be set at the beginning of the // interaction and re-used throughout the context of this manager. AutofillSyncSigninState sync_state_ = AutofillSyncSigninState::kNumSyncStates; +#endif // !defined(TOOLKIT_QT) base::WeakPtrFactory<BrowserAutofillManager> weak_ptr_factory_{this}; |