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

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

Issue 2745803003: autofill-try
Patch Set: before I leave Created 3 years, 9 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 a0fed92c8641b8815a7067f8ca77037980b48a2c..be6e31eff0ef995a8bb636d2c862e9fd178586c6 100644
--- a/components/autofill/content/browser/content_autofill_driver.cc
+++ b/components/autofill/content/browser/content_autofill_driver.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/threading/sequenced_worker_pool.h"
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
+#include "components/autofill/content/browser/autofill_provider.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_external_delegate.h"
#include "components/autofill/core/browser/autofill_manager.h"
@@ -33,7 +34,8 @@ 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),
client_(client),
autofill_manager_(new AutofillManager(this,
@@ -41,11 +43,18 @@ ContentAutofillDriver::ContentAutofillDriver(
app_locale,
enable_download_manager)),
autofill_external_delegate_(autofill_manager_.get(), this),
- binding_(this) {
+ binding_(this),
+ provider_(provider) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
autofill_manager_->SetExternalDelegate(&autofill_external_delegate_);
}
-ContentAutofillDriver::~ContentAutofillDriver() {}
+ContentAutofillDriver::~ContentAutofillDriver() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
+ // Provider_ might already be distroyed, might use weak_ptr here.
+ if (provider_)
+ provider_->OnContentAutofillDriverDestroyed(this);
+}
// static
ContentAutofillDriver* ContentAutofillDriver::GetForRenderFrameHost(
@@ -61,18 +70,21 @@ void ContentAutofillDriver::BindRequest(mojom::AutofillDriverRequest request) {
}
bool ContentAutofillDriver::IsOffTheRecord() const {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
return render_frame_host_->GetSiteInstance()
->GetBrowserContext()
->IsOffTheRecord();
}
net::URLRequestContextGetter* ContentAutofillDriver::GetURLRequestContext() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
return content::BrowserContext::GetDefaultStoragePartition(
render_frame_host_->GetSiteInstance()->GetBrowserContext())->
GetURLRequestContext();
}
base::SequencedWorkerPool* ContentAutofillDriver::GetBlockingPool() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
return content::BrowserThread::GetBlockingPool();
}
@@ -84,6 +96,8 @@ void ContentAutofillDriver::SendFormDataToRenderer(
int query_id,
RendererFormDataAction action,
const FormData& data) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__ << this << "id = " << query_id;
+ LOG(ERROR) << "bt:" << data;
if (!RendererIsAvailable())
return;
@@ -99,12 +113,14 @@ void ContentAutofillDriver::SendFormDataToRenderer(
void ContentAutofillDriver::PropagateAutofillPredictions(
const std::vector<FormStructure*>& forms) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
autofill_manager_->client()->PropagateAutofillPredictions(render_frame_host_,
forms);
}
void ContentAutofillDriver::SendAutofillTypePredictionsToRenderer(
const std::vector<FormStructure*>& forms) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kShowAutofillTypePredictions))
return;
@@ -119,18 +135,21 @@ void ContentAutofillDriver::SendAutofillTypePredictionsToRenderer(
void ContentAutofillDriver::RendererShouldAcceptDataListSuggestion(
const base::string16& value) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
if (!RendererIsAvailable())
return;
GetAutofillAgent()->AcceptDataListSuggestion(value);
}
void ContentAutofillDriver::RendererShouldClearFilledForm() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
if (!RendererIsAvailable())
return;
GetAutofillAgent()->ClearForm();
}
void ContentAutofillDriver::RendererShouldClearPreviewedForm() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
if (!RendererIsAvailable())
return;
GetAutofillAgent()->ClearPreviewedForm();
@@ -138,6 +157,7 @@ void ContentAutofillDriver::RendererShouldClearPreviewedForm() {
void ContentAutofillDriver::RendererShouldFillFieldWithValue(
const base::string16& value) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
if (!RendererIsAvailable())
return;
GetAutofillAgent()->FillFieldWithValue(value);
@@ -145,12 +165,14 @@ void ContentAutofillDriver::RendererShouldFillFieldWithValue(
void ContentAutofillDriver::RendererShouldPreviewFieldWithValue(
const base::string16& value) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
if (!RendererIsAvailable())
return;
GetAutofillAgent()->PreviewFieldWithValue(value);
}
void ContentAutofillDriver::PopupHidden() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
// If the unmask prompt is showing, keep showing the preview. The preview
// will be cleared when the prompt closes.
if (!autofill_manager_->IsShowingUnmaskPrompt())
@@ -159,6 +181,7 @@ void ContentAutofillDriver::PopupHidden() {
gfx::RectF ContentAutofillDriver::TransformBoundingBoxToViewportCoordinates(
const gfx::RectF& bounding_box) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
content::RenderWidgetHostView* view = render_frame_host_->GetView();
if (!view)
return bounding_box;
@@ -171,6 +194,7 @@ gfx::RectF ContentAutofillDriver::TransformBoundingBoxToViewportCoordinates(
}
void ContentAutofillDriver::DidInteractWithCreditCardForm() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
// Notify the WebContents about credit card inputs on HTTP pages.
content::WebContents* contents =
content::WebContents::FromRenderFrameHost(render_frame_host_);
@@ -181,27 +205,41 @@ void ContentAutofillDriver::DidInteractWithCreditCardForm() {
// mojom::AutofillDriver:
void ContentAutofillDriver::FirstUserGestureObserved() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
client_->OnFirstUserGestureObserved();
}
void ContentAutofillDriver::FormsSeen(const std::vector<FormData>& forms,
base::TimeTicks timestamp) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__ << forms.size();
+ for(auto form: forms) {
+ LOG(ERROR) << "bt:" << form;
+ }
autofill_manager_->OnFormsSeen(forms, timestamp);
}
void ContentAutofillDriver::WillSubmitForm(const FormData& form,
base::TimeTicks timestamp) {
- autofill_manager_->OnWillSubmitForm(form, timestamp);
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
+ if (provider_)
+ provider_->OnWillSubmitForm(this, form, timestamp);
+ else
+ autofill_manager_->OnWillSubmitForm(form, timestamp);
}
void ContentAutofillDriver::FormSubmitted(const FormData& form) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
autofill_manager_->OnFormSubmitted(form);
}
void ContentAutofillDriver::TextFieldDidChange(const FormData& form,
const FormFieldData& field,
base::TimeTicks timestamp) {
- autofill_manager_->OnTextFieldDidChange(form, field, timestamp);
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
+ if (provider_)
+ provider_->OnTextFieldDidChange(this, form, field, timestamp);
+ else
+ autofill_manager_->OnTextFieldDidChange(form, field, timestamp);
}
void ContentAutofillDriver::QueryFormFieldAutofill(
@@ -209,38 +247,64 @@ void ContentAutofillDriver::QueryFormFieldAutofill(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box) {
- autofill_manager_->OnQueryFormFieldAutofill(id, form, field, bounding_box);
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__ << this << " id:" << id;
+ LOG(ERROR) << "bt:" << form;
+ LOG(ERROR) << "bt:" << field;
+ if (provider_)
+ provider_->OnQueryFormFieldAutofill(this, id, form, field, bounding_box);
+ else
+ autofill_manager_->OnQueryFormFieldAutofill(id, form, field, bounding_box);
}
void ContentAutofillDriver::HidePopup() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
autofill_manager_->OnHidePopup();
}
void ContentAutofillDriver::FocusNoLongerOnForm() {
- autofill_manager_->OnFocusNoLongerOnForm();
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
+ if (provider_)
+ provider_->OnFocusNoLongerOnForm(this);
+ else
+ autofill_manager_->OnFocusNoLongerOnForm();
}
void ContentAutofillDriver::DidFillAutofillFormData(const FormData& form,
base::TimeTicks timestamp) {
- autofill_manager_->OnDidFillAutofillFormData(form, timestamp);
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
+ if (provider_)
+ provider_->OnDidFillAutofillFormData(this, form, timestamp);
+ else
+ autofill_manager_->OnDidFillAutofillFormData(form, timestamp);
}
void ContentAutofillDriver::DidPreviewAutofillFormData() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
autofill_manager_->OnDidPreviewAutofillFormData();
}
void ContentAutofillDriver::DidEndTextFieldEditing() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
autofill_manager_->OnDidEndTextFieldEditing();
}
void ContentAutofillDriver::SetDataList(
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
+ for(auto v : values) {
+ LOG(ERROR) << "bt:" << v;
+ }
+ for(auto l : labels) {
+ LOG(ERROR) << "bt:" << l;
+ }
+
autofill_manager_->OnSetDataList(values, labels);
}
void ContentAutofillDriver::DidNavigateFrame(
content::NavigationHandle* navigation_handle) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
if (navigation_handle->IsInMainFrame() &&
!navigation_handle->IsSameDocument()) {
autofill_manager_->Reset();
@@ -249,15 +313,18 @@ void ContentAutofillDriver::DidNavigateFrame(
void ContentAutofillDriver::SetAutofillManager(
std::unique_ptr<AutofillManager> manager) {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
autofill_manager_ = std::move(manager);
autofill_manager_->SetExternalDelegate(&autofill_external_delegate_);
}
void ContentAutofillDriver::NotifyFirstUserGestureObservedInTab() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
GetAutofillAgent()->FirstUserGestureObservedInTab();
}
const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() {
+ LOG(ERROR) << "bt:" << __PRETTY_FUNCTION__;
// Here is a lazy binding, and will not reconnect after connection error.
if (!autofill_agent_) {
render_frame_host_->GetRemoteInterfaces()->GetInterface(

Powered by Google App Engine
This is Rietveld 408576698