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

Side by Side Diff: components/autofill/content/browser/content_autofill_driver_factory.cc

Issue 2745803003: autofill-try
Patch Set: autofill-try Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/browser/content_autofill_driver_factory.h" 5 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "components/autofill/content/browser/content_autofill_driver.h" 12 #include "components/autofill/content/browser/content_autofill_driver.h"
13 #include "components/autofill/core/browser/autofill_manager.h" 13 #include "components/autofill/core/browser/autofill_manager.h"
14 #include "content/public/browser/navigation_handle.h" 14 #include "content/public/browser/navigation_handle.h"
15 #include "content/public/browser/render_frame_host.h" 15 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 17
18 namespace autofill { 18 namespace autofill {
19 19
20 namespace { 20 namespace {
21 21
22 std::unique_ptr<AutofillDriver> CreateDriver( 22 std::unique_ptr<AutofillDriver> CreateDriver(
23 content::RenderFrameHost* render_frame_host, 23 content::RenderFrameHost* render_frame_host,
24 AutofillClient* client, 24 AutofillClient* client,
25 const std::string& app_locale, 25 const std::string& app_locale,
26 AutofillManager::AutofillDownloadManagerState enable_download_manager) { 26 AutofillManager::AutofillDownloadManagerState enable_download_manager,
27 AutofillProvider* provider) {
27 return base::MakeUnique<ContentAutofillDriver>( 28 return base::MakeUnique<ContentAutofillDriver>(
28 render_frame_host, client, app_locale, enable_download_manager); 29 render_frame_host, client, app_locale, enable_download_manager, provider);
29 } 30 }
30 31
31 } // namespace 32 } // namespace
32 33
33 const char ContentAutofillDriverFactory:: 34 const char ContentAutofillDriverFactory::
34 kContentAutofillDriverFactoryWebContentsUserDataKey[] = 35 kContentAutofillDriverFactoryWebContentsUserDataKey[] =
35 "web_contents_autofill_driver_factory"; 36 "web_contents_autofill_driver_factory";
36 37
37 ContentAutofillDriverFactory::~ContentAutofillDriverFactory() {} 38 ContentAutofillDriverFactory::~ContentAutofillDriverFactory() {}
38 39
39 // static 40 // static
40 void ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( 41 void ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
41 content::WebContents* contents, 42 content::WebContents* contents,
42 AutofillClient* client, 43 AutofillClient* client,
43 const std::string& app_locale, 44 const std::string& app_locale,
44 AutofillManager::AutofillDownloadManagerState enable_download_manager) { 45 AutofillManager::AutofillDownloadManagerState enable_download_manager) {
46 CreateForWebContentsAndDelegate(contents, client, app_locale,
47 enable_download_manager, nullptr);
48 }
49
50 void ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
51 content::WebContents* contents,
52 AutofillClient* client,
53 const std::string& app_locale,
54 AutofillManager::AutofillDownloadManagerState enable_download_manager,
55 AutofillProvider* provider) {
45 if (FromWebContents(contents)) 56 if (FromWebContents(contents))
46 return; 57 return;
47 58
48 auto new_factory = base::WrapUnique(new ContentAutofillDriverFactory( 59 auto new_factory = base::WrapUnique(new ContentAutofillDriverFactory(
49 contents, client, app_locale, enable_download_manager)); 60 contents, client, app_locale, enable_download_manager, provider));
50 const std::vector<content::RenderFrameHost*> frames = 61 const std::vector<content::RenderFrameHost*> frames =
51 contents->GetAllFrames(); 62 contents->GetAllFrames();
52 for (content::RenderFrameHost* frame : frames) { 63 for (content::RenderFrameHost* frame : frames) {
53 if (frame->IsRenderFrameLive()) 64 if (frame->IsRenderFrameLive())
54 new_factory->RenderFrameCreated(frame); 65 new_factory->RenderFrameCreated(frame);
55 } 66 }
56 67
57 contents->SetUserData(kContentAutofillDriverFactoryWebContentsUserDataKey, 68 contents->SetUserData(kContentAutofillDriverFactoryWebContentsUserDataKey,
58 std::move(new_factory)); 69 std::move(new_factory));
59 } 70 }
(...skipping 27 matching lines...) Expand all
87 98
88 ContentAutofillDriver* driver = factory->DriverForFrame(render_frame_host); 99 ContentAutofillDriver* driver = factory->DriverForFrame(render_frame_host);
89 if (driver) 100 if (driver)
90 driver->BindRequest(std::move(request)); 101 driver->BindRequest(std::move(request));
91 } 102 }
92 103
93 ContentAutofillDriverFactory::ContentAutofillDriverFactory( 104 ContentAutofillDriverFactory::ContentAutofillDriverFactory(
94 content::WebContents* web_contents, 105 content::WebContents* web_contents,
95 AutofillClient* client, 106 AutofillClient* client,
96 const std::string& app_locale, 107 const std::string& app_locale,
97 AutofillManager::AutofillDownloadManagerState enable_download_manager) 108 AutofillManager::AutofillDownloadManagerState enable_download_manager,
109 AutofillProvider* provider)
98 : AutofillDriverFactory(client), 110 : AutofillDriverFactory(client),
99 content::WebContentsObserver(web_contents), 111 content::WebContentsObserver(web_contents),
100 app_locale_(app_locale), 112 app_locale_(app_locale),
101 enable_download_manager_(enable_download_manager) {} 113 enable_download_manager_(enable_download_manager),
114 provider_(provider) {}
102 115
103 ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame( 116 ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame(
104 content::RenderFrameHost* render_frame_host) { 117 content::RenderFrameHost* render_frame_host) {
105 // This cast is safe because AutofillDriverFactory::AddForKey is protected 118 // This cast is safe because AutofillDriverFactory::AddForKey is protected
106 // and always called with ContentAutofillDriver instances within 119 // and always called with ContentAutofillDriver instances within
107 // ContentAutofillDriverFactory. 120 // ContentAutofillDriverFactory.
108 return static_cast<ContentAutofillDriver*>(DriverForKey(render_frame_host)); 121 return static_cast<ContentAutofillDriver*>(DriverForKey(render_frame_host));
109 } 122 }
110 123
111 void ContentAutofillDriverFactory::RenderFrameCreated( 124 void ContentAutofillDriverFactory::RenderFrameCreated(
112 content::RenderFrameHost* render_frame_host) { 125 content::RenderFrameHost* render_frame_host) {
113 AddForKey(render_frame_host, 126 AddForKey(render_frame_host,
114 base::Bind(CreateDriver, render_frame_host, client(), app_locale_, 127 base::Bind(CreateDriver, render_frame_host, client(), app_locale_,
115 enable_download_manager_)); 128 enable_download_manager_, provider_));
116 } 129 }
117 130
118 void ContentAutofillDriverFactory::RenderFrameDeleted( 131 void ContentAutofillDriverFactory::RenderFrameDeleted(
119 content::RenderFrameHost* render_frame_host) { 132 content::RenderFrameHost* render_frame_host) {
120 DeleteForKey(render_frame_host); 133 DeleteForKey(render_frame_host);
121 } 134 }
122 135
123 void ContentAutofillDriverFactory::DidFinishNavigation( 136 void ContentAutofillDriverFactory::DidFinishNavigation(
124 content::NavigationHandle* navigation_handle) { 137 content::NavigationHandle* navigation_handle) {
125 if (!navigation_handle->HasCommitted()) 138 if (!navigation_handle->HasCommitted())
126 return; 139 return;
127 140
128 NavigationFinished(); 141 NavigationFinished();
129 DriverForFrame(navigation_handle->GetRenderFrameHost()) 142 DriverForFrame(navigation_handle->GetRenderFrameHost())
130 ->DidNavigateFrame(navigation_handle); 143 ->DidNavigateFrame(navigation_handle);
131 } 144 }
132 145
133 void ContentAutofillDriverFactory::WasHidden() { 146 void ContentAutofillDriverFactory::WasHidden() {
134 TabHidden(); 147 TabHidden();
135 } 148 }
136 149
137 } // namespace autofill 150 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698