Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Unified Diff: components/autofill/content/browser/content_autofill_driver.cc

Issue 2745803003: autofill-try
Patch Set: autofill-try Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/browser/content_autofill_driver.cc
diff --git a/components/autofill/content/browser/content_autofill_driver.cc b/components/autofill/content/browser/content_autofill_driver.cc
index d897ff3cb7fa1b9a79b453489e6f07f4d308f678..467648996efd3c48265a62d162ef78b60ec93570 100644
--- a/components/autofill/content/browser/content_autofill_driver.cc
+++ b/components/autofill/content/browser/content_autofill_driver.cc
@@ -10,6 +10,7 @@
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_external_delegate.h"
+#include "components/autofill/core/browser/autofill_handler_proxy.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/common/autofill_switches.h"
@@ -32,16 +33,24 @@ ContentAutofillDriver::ContentAutofillDriver(
content::RenderFrameHost* render_frame_host,
AutofillClient* client,
const std::string& app_locale,
- AutofillManager::AutofillDownloadManagerState enable_download_manager)
+ AutofillManager::AutofillDownloadManagerState enable_download_manager,
+ AutofillProvider* provider)
: render_frame_host_(render_frame_host),
- autofill_manager_(new AutofillManager(this,
- client,
- app_locale,
- enable_download_manager)),
- autofill_external_delegate_(autofill_manager_.get(), this),
+ autofill_manager_(nullptr),
key_press_handler_manager_(this),
binding_(this) {
- autofill_manager_->SetExternalDelegate(&autofill_external_delegate_);
+ // AutofillManager isn't used if provider is valid, Autofill provider is
+ // currently used by Android only.
+ if (provider) {
+ autofill_handler_ = base::MakeUnique<AutofillHandlerProxy>(this, provider);
+ } else {
+ autofill_handler_ = base::MakeUnique<AutofillManager>(
+ this, client, app_locale, enable_download_manager);
+ autofill_manager_ = static_cast<AutofillManager*>(autofill_handler_.get());
+ autofill_external_delegate_ =
+ base::MakeUnique<AutofillExternalDelegate>(autofill_manager_, this);
+ autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get());
+ }
}
ContentAutofillDriver::~ContentAutofillDriver() {}
@@ -148,7 +157,7 @@ void ContentAutofillDriver::RendererShouldPreviewFieldWithValue(
void ContentAutofillDriver::PopupHidden() {
// If the unmask prompt is showing, keep showing the preview. The preview
// will be cleared when the prompt closes.
- if (!autofill_manager_->IsShowingUnmaskPrompt())
+ if (autofill_manager_ && !autofill_manager_->IsShowingUnmaskPrompt())
RendererShouldClearPreviewedForm();
}
@@ -176,22 +185,22 @@ void ContentAutofillDriver::DidInteractWithCreditCardForm() {
void ContentAutofillDriver::FormsSeen(const std::vector<FormData>& forms,
base::TimeTicks timestamp) {
- autofill_manager_->OnFormsSeen(forms, timestamp);
+ autofill_handler_->OnFormsSeen(forms, timestamp);
}
void ContentAutofillDriver::WillSubmitForm(const FormData& form,
base::TimeTicks timestamp) {
- autofill_manager_->OnWillSubmitForm(form, timestamp);
+ autofill_handler_->OnWillSubmitForm(form, timestamp);
}
void ContentAutofillDriver::FormSubmitted(const FormData& form) {
- autofill_manager_->OnFormSubmitted(form);
+ autofill_handler_->OnFormSubmitted(form);
}
void ContentAutofillDriver::TextFieldDidChange(const FormData& form,
const FormFieldData& field,
base::TimeTicks timestamp) {
- autofill_manager_->OnTextFieldDidChange(form, field, timestamp);
+ autofill_handler_->OnTextFieldDidChange(form, field, timestamp);
}
void ContentAutofillDriver::QueryFormFieldAutofill(
@@ -199,48 +208,50 @@ void ContentAutofillDriver::QueryFormFieldAutofill(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box) {
- autofill_manager_->OnQueryFormFieldAutofill(id, form, field, bounding_box);
+ autofill_handler_->OnQueryFormFieldAutofill(id, form, field, bounding_box);
}
void ContentAutofillDriver::HidePopup() {
- autofill_manager_->OnHidePopup();
+ autofill_handler_->OnHidePopup();
}
void ContentAutofillDriver::FocusNoLongerOnForm() {
- autofill_manager_->OnFocusNoLongerOnForm();
+ autofill_handler_->OnFocusNoLongerOnForm();
}
void ContentAutofillDriver::DidFillAutofillFormData(const FormData& form,
base::TimeTicks timestamp) {
- autofill_manager_->OnDidFillAutofillFormData(form, timestamp);
+ autofill_handler_->OnDidFillAutofillFormData(form, timestamp);
}
void ContentAutofillDriver::DidPreviewAutofillFormData() {
- autofill_manager_->OnDidPreviewAutofillFormData();
+ autofill_handler_->OnDidPreviewAutofillFormData();
}
void ContentAutofillDriver::DidEndTextFieldEditing() {
- autofill_manager_->OnDidEndTextFieldEditing();
+ autofill_handler_->OnDidEndTextFieldEditing();
}
void ContentAutofillDriver::SetDataList(
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
- autofill_manager_->OnSetDataList(values, labels);
+ autofill_handler_->OnSetDataList(values, labels);
}
void ContentAutofillDriver::DidNavigateFrame(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsInMainFrame() &&
!navigation_handle->IsSameDocument()) {
- autofill_manager_->Reset();
+ autofill_handler_->Reset();
}
}
void ContentAutofillDriver::SetAutofillManager(
std::unique_ptr<AutofillManager> manager) {
- autofill_manager_ = std::move(manager);
- autofill_manager_->SetExternalDelegate(&autofill_external_delegate_);
+ CHECK(autofill_manager_);
+ autofill_handler_ = std::move(manager);
+ autofill_manager_ = static_cast<AutofillManager*>(autofill_handler_.get());
+ autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get());
}
const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() {

Powered by Google App Engine
This is Rietveld 408576698