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

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

Issue 16286020: Abstract WebContentsObserver from Autofill shared code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nit Created 7 years, 6 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/autofill_driver_impl.cc
diff --git a/components/autofill/content/browser/autofill_driver_impl.cc b/components/autofill/content/browser/autofill_driver_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..14fb37f2f2dbd11a2725aeae41c36ab67ce24bf5
--- /dev/null
+++ b/components/autofill/content/browser/autofill_driver_impl.cc
@@ -0,0 +1,90 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/content/browser/autofill_driver_impl.h"
+
+#include "components/autofill/browser/autofill_external_delegate.h"
+#include "components/autofill/browser/autofill_manager.h"
+#include "components/autofill/browser/autofill_manager_delegate.h"
+#include "content/public/browser/web_contents.h"
+
+namespace autofill {
+
+namespace {
+
+const char kAutofillDriverImplWebContentsUserDataKey[] =
+ "web_contents_autofill_driver_impl";
+
+} // namespace
+
+// static
+void AutofillDriverImpl::CreateForWebContentsAndDelegate(
+ content::WebContents* contents,
+ autofill::AutofillManagerDelegate* delegate,
+ const std::string& app_locale,
+ AutofillManager::AutofillDownloadManagerState enable_download_manager,
+ bool enable_native_UI) {
+ if (FromWebContents(contents))
+ return;
+
+ contents->SetUserData(kAutofillDriverImplWebContentsUserDataKey,
+ new AutofillDriverImpl(contents,
+ delegate,
+ app_locale,
+ enable_download_manager,
+ enable_native_UI));
+}
+
+// static
+AutofillDriverImpl* AutofillDriverImpl::FromWebContents(
+ content::WebContents* contents) {
+ return static_cast<AutofillDriverImpl*>(
+ contents->GetUserData(kAutofillDriverImplWebContentsUserDataKey));
+}
+
+AutofillDriverImpl::AutofillDriverImpl(
+ content::WebContents* web_contents,
+ autofill::AutofillManagerDelegate* delegate,
+ const std::string& app_locale,
+ AutofillManager::AutofillDownloadManagerState enable_download_manager,
+ bool enable_native_UI)
+ : content::WebContentsObserver(web_contents),
+ autofill_external_delegate_(NULL) {
+ // TODO(blundell): Eliminate AutofillManager being a WCUD.
+ AutofillManager::CreateForWebContentsAndDelegate(web_contents,
+ this,
+ delegate,
+ app_locale,
+ enable_download_manager);
+ autofill_manager_ = AutofillManager::FromWebContents(web_contents);
+
+ if (enable_native_UI) {
+ // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD.
+ AutofillExternalDelegate::CreateForWebContentsAndManager(
+ web_contents, autofill_manager_);
+ autofill_external_delegate_ =
+ AutofillExternalDelegate::FromWebContents(web_contents);
+ autofill_manager_->SetExternalDelegate(autofill_external_delegate_);
+ }
+}
+
+AutofillDriverImpl::~AutofillDriverImpl() {}
+
+content::WebContents* AutofillDriverImpl::GetWebContents() {
+ return web_contents();
+}
+
+bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) {
+ // TODO(blundell): Move IPC handling into this class.
+ return autofill_manager_->OnMessageReceived(message);
+}
+
+void AutofillDriverImpl::DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) {
+ // TODO(blundell): Move the logic of this method into this class.
+ autofill_manager_->DidNavigateMainFrame(details, params);
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698