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

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

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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_factory.cc
diff --git a/components/autofill/content/browser/content_autofill_driver_factory.cc b/components/autofill/content/browser/content_autofill_driver_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0911f28e83925ed6066c68fa5497be1f2a99f020
--- /dev/null
+++ b/components/autofill/content/browser/content_autofill_driver_factory.cc
@@ -0,0 +1,108 @@
+// Copyright 2014 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/content_autofill_driver_factory.h"
+
+#include "components/autofill/content/browser/content_autofill_driver.h"
+#include "components/autofill/core/browser/autofill_client.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"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/web_contents.h"
+#include "ipc/ipc_message_macros.h"
+
+namespace autofill {
+
+namespace {
+
+const char kContentAutofillDriverFactoryWebContentsUserDataKey[] =
+ "web_contents_autofill_driver_factory";
+
+} // namespace
+
+// static
+void ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
+ content::WebContents* contents,
+ AutofillClient* client,
+ const std::string& app_locale,
+ AutofillManager::AutofillDownloadManagerState enable_download_manager) {
+ if (FromWebContents(contents))
+ return;
+
+ contents->SetUserData(
+ kContentAutofillDriverFactoryWebContentsUserDataKey,
+ new ContentAutofillDriverFactory(contents, client, app_locale,
+ enable_download_manager));
+}
+
+// static
+ContentAutofillDriverFactory* ContentAutofillDriverFactory::FromWebContents(
+ content::WebContents* contents) {
+ return static_cast<ContentAutofillDriverFactory*>(contents->GetUserData(
+ kContentAutofillDriverFactoryWebContentsUserDataKey));
+}
+
+ContentAutofillDriverFactory::ContentAutofillDriverFactory(
+ content::WebContents* web_contents,
+ AutofillClient* client,
+ const std::string& app_locale,
+ AutofillManager::AutofillDownloadManagerState enable_download_manager)
+ : content::WebContentsObserver(web_contents),
+ client_(client),
+ app_locale_(app_locale),
+ enable_download_manager_(enable_download_manager) {
+ if (web_contents->GetMainFrame())
+ RenderFrameCreated(web_contents->GetMainFrame());
vabr (Chromium) 2014/11/10 14:34:39 It's usually a bad idea to call virtual methods fr
Evan Stade 2014/11/14 23:25:49 Done.
+}
+
+ContentAutofillDriverFactory::~ContentAutofillDriverFactory() {
+}
+
+ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame(
+ content::RenderFrameHost* render_frame_host) {
+ return frame_driver_map_[render_frame_host];
vabr (Chromium) 2014/11/10 14:34:39 Note that this creates a new entry in the map, if
Evan Stade 2014/11/14 23:25:49 actually it initializes with null
vabr (Chromium) 2014/11/17 15:08:48 You are right, sorry fir spreading misinformation.
+}
+
+bool ContentAutofillDriverFactory::OnMessageReceived(
+ const IPC::Message& message,
+ content::RenderFrameHost* render_frame_host) {
+ ContentAutofillDriver* driver = frame_driver_map_[render_frame_host];
+ DCHECK(driver);
vabr (Chromium) 2014/11/10 14:34:39 Again, in addition to checking driver, the retriev
Evan Stade 2014/11/14 23:25:49 see other comments
vabr (Chromium) 2014/11/17 15:08:48 Acknowledged. Using the NULL-dereference to signal
+ return driver->HandleMessage(message);
+}
+
+void ContentAutofillDriverFactory::RenderFrameCreated(
+ content::RenderFrameHost* render_frame_host) {
+ frame_driver_map_[render_frame_host] = new ContentAutofillDriver(
+ render_frame_host, client_, app_locale_, enable_download_manager_);
+}
+
+void ContentAutofillDriverFactory::RenderFrameDeleted(
+ content::RenderFrameHost* render_frame_host) {
+ ContentAutofillDriver* driver = frame_driver_map_[render_frame_host];
+ DCHECK(driver);
vabr (Chromium) 2014/11/10 14:34:39 DCHECKing driver does not do much here -- if drive
Evan Stade 2014/11/14 23:25:49 see other comments
vabr (Chromium) 2014/11/17 15:08:48 Acknowledged.
+ delete driver;
+ frame_driver_map_.erase(render_frame_host);
+}
+
+void ContentAutofillDriverFactory::DidNavigateAnyFrame(
+ content::RenderFrameHost* render_frame_host,
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) {
+ ContentAutofillDriver* driver = frame_driver_map_[render_frame_host];
vabr (Chromium) 2014/11/10 14:34:39 Please check the existence of the key, to avoid in
Evan Stade 2014/11/14 23:25:49 a) it's not inserting trash, it's inserting null b
vabr (Chromium) 2014/11/17 15:08:49 Acknowledged.
+ DCHECK(driver);
+ driver->DidNavigateFrame(details, params);
+}
+
+void ContentAutofillDriverFactory::NavigationEntryCommitted(
+ const content::LoadCommittedDetails& load_details) {
+ client_->HideAutofillPopup();
+}
+
+void ContentAutofillDriverFactory::WasHidden() {
+ client_->HideAutofillPopup();
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698