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

Side by Side 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: self review Created 6 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
6
7 #include "base/bind.h"
8 #include "components/autofill/content/browser/content_autofill_driver.h"
9 #include "components/autofill/core/browser/autofill_client.h"
10 #include "components/autofill/core/browser/autofill_manager.h"
11 #include "components/autofill/core/browser/form_structure.h"
12 #include "components/autofill/core/common/autofill_switches.h"
13 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/web_contents.h"
15 #include "ipc/ipc_message_macros.h"
16
17 namespace autofill {
18
19 const char ContentAutofillDriverFactory::
20 kContentAutofillDriverFactoryWebContentsUserDataKey[] =
21 "web_contents_autofill_driver_factory";
22
23 // static
24 void ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
25 content::WebContents* contents,
26 AutofillClient* client,
27 const std::string& app_locale,
28 AutofillManager::AutofillDownloadManagerState enable_download_manager) {
29 if (FromWebContents(contents))
30 return;
31
32 contents->SetUserData(
33 kContentAutofillDriverFactoryWebContentsUserDataKey,
34 new ContentAutofillDriverFactory(contents, client, app_locale,
35 enable_download_manager));
36 }
37
38 // static
39 ContentAutofillDriverFactory* ContentAutofillDriverFactory::FromWebContents(
40 content::WebContents* contents) {
41 return static_cast<ContentAutofillDriverFactory*>(contents->GetUserData(
42 kContentAutofillDriverFactoryWebContentsUserDataKey));
43 }
44
45 ContentAutofillDriverFactory::ContentAutofillDriverFactory(
46 content::WebContents* web_contents,
47 AutofillClient* client,
48 const std::string& app_locale,
49 AutofillManager::AutofillDownloadManagerState enable_download_manager)
50 : content::WebContentsObserver(web_contents),
51 client_(client),
52 app_locale_(app_locale),
53 enable_download_manager_(enable_download_manager) {
54 web_contents->ForEachFrame(
55 base::Bind(&ContentAutofillDriverFactory::CreateDriverForFrame,
56 base::Unretained(this)));
57 }
58
59 ContentAutofillDriverFactory::~ContentAutofillDriverFactory() {
60 }
61
62 ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame(
63 content::RenderFrameHost* render_frame_host) {
64 return frame_driver_map_[render_frame_host];
65 }
66
67 bool ContentAutofillDriverFactory::OnMessageReceived(
68 const IPC::Message& message,
69 content::RenderFrameHost* render_frame_host) {
70 return frame_driver_map_[render_frame_host]->HandleMessage(message);
71 }
72
73 void ContentAutofillDriverFactory::RenderFrameCreated(
74 content::RenderFrameHost* render_frame_host) {
75 CreateDriverForFrame(render_frame_host);
76 }
77
78 void ContentAutofillDriverFactory::RenderFrameDeleted(
79 content::RenderFrameHost* render_frame_host) {
80 delete frame_driver_map_[render_frame_host];
81 frame_driver_map_.erase(render_frame_host);
82 }
83
84 void ContentAutofillDriverFactory::DidNavigateAnyFrame(
85 content::RenderFrameHost* render_frame_host,
86 const content::LoadCommittedDetails& details,
87 const content::FrameNavigateParams& params) {
88 frame_driver_map_[render_frame_host]->DidNavigateFrame(details, params);
89 }
90
91 void ContentAutofillDriverFactory::NavigationEntryCommitted(
92 const content::LoadCommittedDetails& load_details) {
93 client_->HideAutofillPopup();
94 }
95
96 void ContentAutofillDriverFactory::WasHidden() {
97 client_->HideAutofillPopup();
98 }
99
100 void ContentAutofillDriverFactory::CreateDriverForFrame(
101 content::RenderFrameHost* render_frame_host) {
102 frame_driver_map_[render_frame_host] = new ContentAutofillDriver(
103 render_frame_host, client_, app_locale_, enable_download_manager_);
104 }
105
106 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698