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

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: Response to review 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..f1002fc1ebf4266ade64e1fd53e3ad46dc07f7c5
--- /dev/null
+++ b/components/autofill/content/browser/autofill_driver_impl.cc
@@ -0,0 +1,83 @@
+// 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_manager_.reset(
+ new AutofillManager(this, delegate, app_locale, enable_download_manager));
+ if (enable_native_ui) {
+ // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD and
+ // transfer ownership of it to this class.
+ AutofillExternalDelegate::CreateForWebContentsAndManager(
+ web_contents, autofill_manager_.get());
+ autofill_manager_->SetExternalDelegate(
+ AutofillExternalDelegate::FromWebContents(web_contents));
+ }
+}
+
+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