| Index: components/autofill/core/browser/autofill_manager.cc
|
| diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
|
| index 933b7c5dd41a1549fca6c368a1235d2e756ba4c3..6a89df05b1024e4aaac09669b665862d4d4ae4b6 100644
|
| --- a/components/autofill/core/browser/autofill_manager.cc
|
| +++ b/components/autofill/core/browser/autofill_manager.cc
|
| @@ -42,6 +42,7 @@
|
| #include "components/autofill/core/browser/autofill_manager_test_delegate.h"
|
| #include "components/autofill/core/browser/autofill_metrics.h"
|
| #include "components/autofill/core/browser/autofill_profile.h"
|
| +#include "components/autofill/core/browser/autofill_provider.h"
|
| #include "components/autofill/core/browser/autofill_type.h"
|
| #include "components/autofill/core/browser/country_names.h"
|
| #include "components/autofill/core/browser/credit_card.h"
|
| @@ -215,7 +216,8 @@ AutofillManager::AutofillManager(
|
| AutofillDriver* driver,
|
| AutofillClient* client,
|
| const std::string& app_locale,
|
| - AutofillDownloadManagerState enable_download_manager)
|
| + AutofillDownloadManagerState enable_download_manager,
|
| + AutofillProvider* provider)
|
| : driver_(driver),
|
| client_(client),
|
| payments_client_(base::MakeUnique<payments::PaymentsClient>(
|
| @@ -249,6 +251,7 @@ AutofillManager::AutofillManager(
|
| #if defined(OS_ANDROID) || defined(OS_IOS)
|
| autofill_assistant_(this),
|
| #endif
|
| + provider_(provider),
|
| weak_ptr_factory_(this) {
|
| if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {
|
| download_manager_.reset(new AutofillDownloadManager(driver, this));
|
| @@ -367,6 +370,9 @@ void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,
|
| if (!driver_->RendererIsAvailable())
|
| return;
|
|
|
| + if (provider_)
|
| + return;
|
| +
|
| bool enabled = IsAutofillEnabled();
|
| if (!has_logged_autofill_enabled_) {
|
| AutofillMetrics::LogIsAutofillEnabledAtPageLoad(enabled);
|
| @@ -388,6 +394,11 @@ bool AutofillManager::OnWillSubmitForm(const FormData& form,
|
| if (!IsValidFormData(form))
|
| return false;
|
|
|
| + if (provider_) {
|
| + provider_->OnWillSubmitForm(this, form, timestamp);
|
| + return true;
|
| + }
|
| +
|
| // We will always give Autocomplete a chance to save the data.
|
| std::unique_ptr<FormStructure> submitted_form = ValidateSubmittedForm(form);
|
| if (!submitted_form) {
|
| @@ -418,6 +429,9 @@ bool AutofillManager::OnFormSubmitted(const FormData& form) {
|
| if (!IsValidFormData(form))
|
| return false;
|
|
|
| + if (provider_)
|
| + return true;
|
| +
|
| // We will always give Autocomplete a chance to save the data.
|
| std::unique_ptr<FormStructure> submitted_form = ValidateSubmittedForm(form);
|
| if (!submitted_form) {
|
| @@ -512,6 +526,11 @@ void AutofillManager::OnTextFieldDidChange(const FormData& form,
|
| if (!IsValidFormData(form) || !IsValidFormFieldData(field))
|
| return;
|
|
|
| + if (provider_) {
|
| + provider_->OnTextFieldDidChange(this, form, field, timestamp);
|
| + return;
|
| + }
|
| +
|
| if (test_delegate_)
|
| test_delegate_->OnTextFieldChanged();
|
|
|
| @@ -561,6 +580,12 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
|
| gfx::RectF transformed_box =
|
| driver_->TransformBoundingBoxToViewportCoordinates(bounding_box);
|
|
|
| + if (provider_) {
|
| + provider_->OnQueryFormFieldAutofill(this, query_id, form, field,
|
| + transformed_box);
|
| + return;
|
| + }
|
| +
|
| external_delegate_->OnQuery(query_id, form, field, transformed_box);
|
|
|
| // Need to refresh models before using the form_event_loggers.
|
| @@ -810,6 +835,10 @@ void AutofillManager::FillCreditCardForm(int query_id,
|
| }
|
|
|
| void AutofillManager::OnFocusNoLongerOnForm() {
|
| + if (provider_) {
|
| + provider_->OnFocusNoLongerOnForm(this);
|
| + return;
|
| + }
|
| ProcessPendingFormForUpload();
|
| }
|
|
|
| @@ -820,6 +849,11 @@ void AutofillManager::OnDidPreviewAutofillFormData() {
|
|
|
| void AutofillManager::OnDidFillAutofillFormData(const FormData& form,
|
| const TimeTicks& timestamp) {
|
| + if (provider_) {
|
| + provider_->OnDidFillAutofillFormData(this, form, timestamp);
|
| + return;
|
| + }
|
| +
|
| if (test_delegate_)
|
| test_delegate_->DidFillFormData();
|
|
|
| @@ -863,7 +897,7 @@ void AutofillManager::DidShowSuggestions(bool is_new_popup,
|
| }
|
|
|
| void AutofillManager::OnHidePopup() {
|
| - if (!IsAutofillEnabled())
|
| + if (!IsAutofillEnabled() || provider_)
|
| return;
|
|
|
| autocomplete_history_manager_->CancelPendingQuery();
|
| @@ -977,6 +1011,9 @@ void AutofillManager::SetTestDelegate(AutofillManagerTestDelegate* delegate) {
|
|
|
| void AutofillManager::OnSetDataList(const std::vector<base::string16>& values,
|
| const std::vector<base::string16>& labels) {
|
| + if (provider_)
|
| + return;
|
| +
|
| if (!IsValidString16Vector(values) ||
|
| !IsValidString16Vector(labels) ||
|
| values.size() != labels.size())
|
| @@ -1142,6 +1179,8 @@ void AutofillManager::OnDidGetUploadRiskData(const std::string& risk_data) {
|
| }
|
|
|
| void AutofillManager::OnDidEndTextFieldEditing() {
|
| + if (provider_)
|
| + return;
|
| external_delegate_->DidEndTextFieldEditing();
|
| }
|
|
|
| @@ -1723,6 +1762,13 @@ void AutofillManager::FillOrPreviewDataModelForm(
|
| driver_->SendFormDataToRenderer(query_id, action, result);
|
| }
|
|
|
| +void AutofillManager::SendFormDataToRenderer(
|
| + int query_id,
|
| + AutofillDriver::RendererFormDataAction action,
|
| + const FormData& data) {
|
| + driver_->SendFormDataToRenderer(query_id, action, data);
|
| +}
|
| +
|
| std::unique_ptr<FormStructure> AutofillManager::ValidateSubmittedForm(
|
| const FormData& form) {
|
| std::unique_ptr<FormStructure> submitted_form(
|
|
|