OLD | NEW |
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/password_manager/content/browser/content_password_manager_d
river.h" | 5 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
6 | 6 |
7 #include "components/autofill/content/browser/content_autofill_driver.h" | 7 #include "components/autofill/content/browser/content_autofill_driver.h" |
8 #include "components/autofill/content/common/autofill_messages.h" | |
9 #include "components/autofill/core/common/form_data.h" | 8 #include "components/autofill/core/common/form_data.h" |
10 #include "components/autofill/core/common/password_form.h" | 9 #include "components/autofill/core/common/password_form.h" |
11 #include "components/password_manager/content/browser/bad_message.h" | 10 #include "components/password_manager/content/browser/bad_message.h" |
12 #include "components/password_manager/content/browser/content_password_manager_d
river_factory.h" | 11 #include "components/password_manager/content/browser/content_password_manager_d
river_factory.h" |
13 #include "components/password_manager/core/browser/log_manager.h" | 12 #include "components/password_manager/core/browser/log_manager.h" |
14 #include "components/password_manager/core/browser/password_manager.h" | 13 #include "components/password_manager/core/browser/password_manager.h" |
15 #include "components/password_manager/core/browser/password_manager_client.h" | 14 #include "components/password_manager/core/browser/password_manager_client.h" |
16 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
17 #include "content/public/browser/child_process_security_policy.h" | 16 #include "content/public/browser/child_process_security_policy.h" |
18 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
19 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
20 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
21 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/site_instance.h" | 22 #include "content/public/browser/site_instance.h" |
24 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
25 #include "content/public/common/ssl_status.h" | 24 #include "content/public/common/ssl_status.h" |
26 #include "ipc/ipc_message_macros.h" | |
27 #include "net/cert/cert_status_flags.h" | 25 #include "net/cert/cert_status_flags.h" |
| 26 #include "services/shell/public/cpp/interface_provider.h" |
28 | 27 |
29 namespace password_manager { | 28 namespace password_manager { |
30 | 29 |
31 ContentPasswordManagerDriver::ContentPasswordManagerDriver( | 30 ContentPasswordManagerDriver::ContentPasswordManagerDriver( |
32 content::RenderFrameHost* render_frame_host, | 31 content::RenderFrameHost* render_frame_host, |
33 PasswordManagerClient* client, | 32 PasswordManagerClient* client, |
34 autofill::AutofillClient* autofill_client) | 33 autofill::AutofillClient* autofill_client) |
35 : render_frame_host_(render_frame_host), | 34 : render_frame_host_(render_frame_host), |
36 client_(client), | 35 client_(client), |
37 password_generation_manager_(client, this), | 36 password_generation_manager_(client, this), |
38 password_autofill_manager_(this, autofill_client), | 37 password_autofill_manager_(this, autofill_client), |
39 next_free_key_(0) {} | 38 next_free_key_(0), |
| 39 binding_(this), |
| 40 weak_factory_(this) {} |
40 | 41 |
41 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() { | 42 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() { |
42 } | 43 } |
43 | 44 |
44 // static | 45 // static |
45 ContentPasswordManagerDriver* | 46 ContentPasswordManagerDriver* |
46 ContentPasswordManagerDriver::GetForRenderFrameHost( | 47 ContentPasswordManagerDriver::GetForRenderFrameHost( |
47 content::RenderFrameHost* render_frame_host) { | 48 content::RenderFrameHost* render_frame_host) { |
48 ContentPasswordManagerDriverFactory* factory = | 49 ContentPasswordManagerDriverFactory* factory = |
49 ContentPasswordManagerDriverFactory::FromWebContents( | 50 ContentPasswordManagerDriverFactory::FromWebContents( |
50 content::WebContents::FromRenderFrameHost(render_frame_host)); | 51 content::WebContents::FromRenderFrameHost(render_frame_host)); |
51 return factory ? factory->GetDriverForFrame(render_frame_host) : nullptr; | 52 return factory ? factory->GetDriverForFrame(render_frame_host) : nullptr; |
52 } | 53 } |
53 | 54 |
| 55 void ContentPasswordManagerDriver::BindRequest( |
| 56 autofill::mojom::PasswordManagerDriverRequest request) { |
| 57 binding_.Bind(std::move(request)); |
| 58 } |
| 59 |
54 void ContentPasswordManagerDriver::FillPasswordForm( | 60 void ContentPasswordManagerDriver::FillPasswordForm( |
55 const autofill::PasswordFormFillData& form_data) { | 61 const autofill::PasswordFormFillData& form_data) { |
56 const int key = next_free_key_++; | 62 const int key = next_free_key_++; |
57 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data); | 63 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data); |
58 render_frame_host_->Send(new AutofillMsg_FillPasswordForm( | 64 GetPasswordAutofillAgent()->FillPasswordForm(key, form_data); |
59 render_frame_host_->GetRoutingID(), key, form_data)); | |
60 } | 65 } |
61 | 66 |
62 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( | 67 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( |
63 const autofill::PasswordForm& form) { | 68 const autofill::PasswordForm& form) { |
64 if (!GetPasswordGenerationManager()->IsGenerationEnabled()) | 69 if (!GetPasswordGenerationManager()->IsGenerationEnabled()) |
65 return; | 70 return; |
66 content::RenderFrameHost* host = render_frame_host_; | 71 GetPasswordGenerationAgent()->FormNotBlacklisted(form); |
67 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), form)); | |
68 } | 72 } |
69 | 73 |
70 void ContentPasswordManagerDriver::FormsEligibleForGenerationFound( | 74 void ContentPasswordManagerDriver::FormsEligibleForGenerationFound( |
71 const std::vector<autofill::PasswordFormGenerationData>& forms) { | 75 const std::vector<autofill::PasswordFormGenerationData>& forms) { |
72 content::RenderFrameHost* host = render_frame_host_; | 76 GetPasswordGenerationAgent()->FoundFormsEligibleForGeneration(forms); |
73 host->Send(new AutofillMsg_FoundFormsEligibleForGeneration( | |
74 host->GetRoutingID(), forms)); | |
75 } | 77 } |
76 | 78 |
77 void ContentPasswordManagerDriver::AutofillDataReceived( | 79 void ContentPasswordManagerDriver::AutofillDataReceived( |
78 const std::map<autofill::FormData, | 80 const std::map<autofill::FormData, |
79 autofill::PasswordFormFieldPredictionMap>& predictions) { | 81 autofill::PasswordFormFieldPredictionMap>& predictions) { |
80 content::RenderFrameHost* host = render_frame_host_; | 82 GetPasswordAutofillAgent()->AutofillUsernameAndPasswordDataReceived( |
81 host->Send(new AutofillMsg_AutofillUsernameAndPasswordDataReceived( | 83 predictions); |
82 host->GetRoutingID(), | |
83 predictions)); | |
84 } | 84 } |
85 | 85 |
86 void ContentPasswordManagerDriver::GeneratedPasswordAccepted( | 86 void ContentPasswordManagerDriver::GeneratedPasswordAccepted( |
87 const base::string16& password) { | 87 const base::string16& password) { |
88 content::RenderFrameHost* host = render_frame_host_; | 88 GetPasswordGenerationAgent()->GeneratedPasswordAccepted(password); |
89 host->Send(new AutofillMsg_GeneratedPasswordAccepted(host->GetRoutingID(), | |
90 password)); | |
91 } | 89 } |
92 | 90 |
93 void ContentPasswordManagerDriver::FillSuggestion( | 91 void ContentPasswordManagerDriver::FillSuggestion( |
94 const base::string16& username, | 92 const base::string16& username, |
95 const base::string16& password) { | 93 const base::string16& password) { |
96 GetAutofillAgent()->FillPasswordSuggestion(username, password); | 94 GetAutofillAgent()->FillPasswordSuggestion(username, password); |
97 } | 95 } |
98 | 96 |
99 void ContentPasswordManagerDriver::PreviewSuggestion( | 97 void ContentPasswordManagerDriver::PreviewSuggestion( |
100 const base::string16& username, | 98 const base::string16& username, |
101 const base::string16& password) { | 99 const base::string16& password) { |
102 GetAutofillAgent()->PreviewPasswordSuggestion(username, password); | 100 GetAutofillAgent()->PreviewPasswordSuggestion(username, password); |
103 } | 101 } |
104 | 102 |
105 void ContentPasswordManagerDriver::ShowInitialPasswordAccountSuggestions( | 103 void ContentPasswordManagerDriver::ShowInitialPasswordAccountSuggestions( |
106 const autofill::PasswordFormFillData& form_data) { | 104 const autofill::PasswordFormFillData& form_data) { |
107 const int key = next_free_key_++; | 105 const int key = next_free_key_++; |
108 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data); | 106 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data); |
109 GetAutofillAgent()->ShowInitialPasswordAccountSuggestions(key, form_data); | 107 GetAutofillAgent()->ShowInitialPasswordAccountSuggestions(key, form_data); |
110 } | 108 } |
111 | 109 |
112 void ContentPasswordManagerDriver::ClearPreviewedForm() { | 110 void ContentPasswordManagerDriver::ClearPreviewedForm() { |
113 GetAutofillAgent()->ClearPreviewedForm(); | 111 GetAutofillAgent()->ClearPreviewedForm(); |
114 } | 112 } |
115 | 113 |
116 void ContentPasswordManagerDriver::ForceSavePassword() { | 114 void ContentPasswordManagerDriver::ForceSavePassword() { |
117 content::RenderFrameHost* host = render_frame_host_; | 115 GetPasswordAutofillAgent()->FindFocusedPasswordForm( |
118 host->Send(new AutofillMsg_FindFocusedPasswordForm(host->GetRoutingID())); | 116 base::Bind(&ContentPasswordManagerDriver::OnFocusedPasswordFormFound, |
| 117 weak_factory_.GetWeakPtr())); |
119 } | 118 } |
120 | 119 |
121 void ContentPasswordManagerDriver::GeneratePassword() { | 120 void ContentPasswordManagerDriver::GeneratePassword() { |
122 content::RenderFrameHost* host = render_frame_host_; | 121 GetPasswordGenerationAgent()->UserTriggeredGeneratePassword(); |
123 host->Send( | |
124 new AutofillMsg_UserTriggeredGeneratePassword(host->GetRoutingID())); | |
125 } | 122 } |
126 | 123 |
127 void ContentPasswordManagerDriver::SendLoggingAvailability() { | 124 void ContentPasswordManagerDriver::SendLoggingAvailability() { |
128 render_frame_host_->Send(new AutofillMsg_SetLoggingState( | 125 GetPasswordAutofillAgent()->SetLoggingState( |
129 render_frame_host_->GetRoutingID(), | 126 client_->GetLogManager()->IsLoggingActive()); |
130 client_->GetLogManager()->IsLoggingActive())); | |
131 } | 127 } |
132 | 128 |
133 void ContentPasswordManagerDriver::AllowToRunFormClassifier() { | 129 void ContentPasswordManagerDriver::AllowToRunFormClassifier() { |
134 render_frame_host_->Send(new AutofillMsg_AllowToRunFormClassifier( | 130 GetPasswordGenerationAgent()->AllowToRunFormClassifier(); |
135 render_frame_host_->GetRoutingID())); | |
136 } | 131 } |
137 | 132 |
138 PasswordGenerationManager* | 133 PasswordGenerationManager* |
139 ContentPasswordManagerDriver::GetPasswordGenerationManager() { | 134 ContentPasswordManagerDriver::GetPasswordGenerationManager() { |
140 return &password_generation_manager_; | 135 return &password_generation_manager_; |
141 } | 136 } |
142 | 137 |
143 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { | 138 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { |
144 return client_->GetPasswordManager(); | 139 return client_->GetPasswordManager(); |
145 } | 140 } |
146 | 141 |
147 PasswordAutofillManager* | 142 PasswordAutofillManager* |
148 ContentPasswordManagerDriver::GetPasswordAutofillManager() { | 143 ContentPasswordManagerDriver::GetPasswordAutofillManager() { |
149 return &password_autofill_manager_; | 144 return &password_autofill_manager_; |
150 } | 145 } |
151 | 146 |
152 bool ContentPasswordManagerDriver::HandleMessage(const IPC::Message& message) { | 147 void ContentPasswordManagerDriver::PasswordFormsParsed( |
153 bool handled = true; | |
154 IPC_BEGIN_MESSAGE_MAP(ContentPasswordManagerDriver, message) | |
155 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed, | |
156 OnPasswordFormsParsed) | |
157 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered, | |
158 OnPasswordFormsRendered) | |
159 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted, | |
160 OnPasswordFormSubmitted) | |
161 IPC_MESSAGE_HANDLER(AutofillHostMsg_InPageNavigation, OnInPageNavigation) | |
162 IPC_MESSAGE_HANDLER(AutofillHostMsg_PresaveGeneratedPassword, | |
163 OnPresaveGeneratedPassword) | |
164 IPC_MESSAGE_HANDLER(AutofillHostMsg_SaveGenerationFieldDetectedByClassifier, | |
165 OnSaveGenerationFieldDetectedByClassifier) | |
166 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordNoLongerGenerated, | |
167 OnPasswordNoLongerGenerated) | |
168 IPC_MESSAGE_HANDLER(AutofillHostMsg_FocusedPasswordFormFound, | |
169 OnFocusedPasswordFormFound) | |
170 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, | |
171 &password_autofill_manager_, | |
172 PasswordAutofillManager::OnShowPasswordSuggestions) | |
173 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, | |
174 client_->GetLogManager(), | |
175 LogManager::LogSavePasswordProgress) | |
176 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordAutofillAgentConstructed, | |
177 SendLoggingAvailability) | |
178 IPC_MESSAGE_UNHANDLED(handled = false) | |
179 IPC_END_MESSAGE_MAP() | |
180 return handled; | |
181 } | |
182 | |
183 void ContentPasswordManagerDriver::OnPasswordFormsParsed( | |
184 const std::vector<autofill::PasswordForm>& forms) { | 148 const std::vector<autofill::PasswordForm>& forms) { |
185 for (const auto& form : forms) | 149 for (const auto& form : forms) |
186 if (!CheckChildProcessSecurityPolicy( | 150 if (!CheckChildProcessSecurityPolicy( |
187 form.origin, BadMessageReason::CPMD_BAD_ORIGIN_FORMS_PARSED)) | 151 form.origin, BadMessageReason::CPMD_BAD_ORIGIN_FORMS_PARSED)) |
188 return; | 152 return; |
189 | 153 |
190 OnPasswordFormsParsedNoRenderCheck(forms); | 154 OnPasswordFormsParsedNoRenderCheck(forms); |
191 } | 155 } |
192 | 156 |
193 void ContentPasswordManagerDriver::OnPasswordFormsParsedNoRenderCheck( | 157 void ContentPasswordManagerDriver::OnPasswordFormsParsedNoRenderCheck( |
194 const std::vector<autofill::PasswordForm>& forms) { | 158 const std::vector<autofill::PasswordForm>& forms) { |
195 GetPasswordManager()->OnPasswordFormsParsed(this, forms); | 159 GetPasswordManager()->OnPasswordFormsParsed(this, forms); |
196 GetPasswordGenerationManager()->CheckIfFormClassifierShouldRun(); | 160 GetPasswordGenerationManager()->CheckIfFormClassifierShouldRun(); |
197 } | 161 } |
198 | 162 |
199 void ContentPasswordManagerDriver::OnPasswordFormsRendered( | 163 void ContentPasswordManagerDriver::PasswordFormsRendered( |
200 const std::vector<autofill::PasswordForm>& visible_forms, | 164 const std::vector<autofill::PasswordForm>& visible_forms, |
201 bool did_stop_loading) { | 165 bool did_stop_loading) { |
202 for (const auto& form : visible_forms) | 166 for (const auto& form : visible_forms) |
203 if (!CheckChildProcessSecurityPolicy( | 167 if (!CheckChildProcessSecurityPolicy( |
204 form.origin, BadMessageReason::CPMD_BAD_ORIGIN_FORMS_RENDERED)) | 168 form.origin, BadMessageReason::CPMD_BAD_ORIGIN_FORMS_RENDERED)) |
205 return; | 169 return; |
206 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms, | 170 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms, |
207 did_stop_loading); | 171 did_stop_loading); |
208 } | 172 } |
209 | 173 |
210 void ContentPasswordManagerDriver::OnPasswordFormSubmitted( | 174 void ContentPasswordManagerDriver::PasswordFormSubmitted( |
211 const autofill::PasswordForm& password_form) { | 175 const autofill::PasswordForm& password_form) { |
212 if (!CheckChildProcessSecurityPolicy( | 176 if (!CheckChildProcessSecurityPolicy( |
213 password_form.origin, | 177 password_form.origin, |
214 BadMessageReason::CPMD_BAD_ORIGIN_FORM_SUBMITTED)) | 178 BadMessageReason::CPMD_BAD_ORIGIN_FORM_SUBMITTED)) |
215 return; | 179 return; |
216 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form); | 180 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form); |
217 } | 181 } |
218 | 182 |
219 void ContentPasswordManagerDriver::OnFocusedPasswordFormFound( | 183 void ContentPasswordManagerDriver::OnFocusedPasswordFormFound( |
220 const autofill::PasswordForm& password_form) { | 184 const autofill::PasswordForm& password_form) { |
221 if (!CheckChildProcessSecurityPolicy( | 185 if (!CheckChildProcessSecurityPolicy( |
222 password_form.origin, | 186 password_form.origin, |
223 BadMessageReason::CPMD_BAD_ORIGIN_FOCUSED_PASSWORD_FORM_FOUND)) | 187 BadMessageReason::CPMD_BAD_ORIGIN_FOCUSED_PASSWORD_FORM_FOUND)) |
224 return; | 188 return; |
225 GetPasswordManager()->OnPasswordFormForceSaveRequested(this, password_form); | 189 GetPasswordManager()->OnPasswordFormForceSaveRequested(this, password_form); |
226 } | 190 } |
227 | 191 |
228 void ContentPasswordManagerDriver::DidNavigateFrame( | 192 void ContentPasswordManagerDriver::DidNavigateFrame( |
229 const content::LoadCommittedDetails& details, | 193 const content::LoadCommittedDetails& details, |
230 const content::FrameNavigateParams& params) { | 194 const content::FrameNavigateParams& params) { |
231 // Clear page specific data after main frame navigation. | 195 // Clear page specific data after main frame navigation. |
232 if (!render_frame_host_->GetParent() && !details.is_in_page) { | 196 if (!render_frame_host_->GetParent() && !details.is_in_page) { |
233 GetPasswordManager()->DidNavigateMainFrame(); | 197 GetPasswordManager()->DidNavigateMainFrame(); |
234 GetPasswordAutofillManager()->DidNavigateMainFrame(); | 198 GetPasswordAutofillManager()->DidNavigateMainFrame(); |
235 } | 199 } |
236 } | 200 } |
237 | 201 |
238 void ContentPasswordManagerDriver::OnInPageNavigation( | 202 void ContentPasswordManagerDriver::InPageNavigation( |
239 const autofill::PasswordForm& password_form) { | 203 const autofill::PasswordForm& password_form) { |
240 if (!CheckChildProcessSecurityPolicy( | 204 if (!CheckChildProcessSecurityPolicy( |
241 password_form.origin, | 205 password_form.origin, |
242 BadMessageReason::CPMD_BAD_ORIGIN_IN_PAGE_NAVIGATION)) | 206 BadMessageReason::CPMD_BAD_ORIGIN_IN_PAGE_NAVIGATION)) |
243 return; | 207 return; |
244 GetPasswordManager()->OnInPageNavigation(this, password_form); | 208 GetPasswordManager()->OnInPageNavigation(this, password_form); |
245 } | 209 } |
246 | 210 |
247 void ContentPasswordManagerDriver::OnPresaveGeneratedPassword( | 211 void ContentPasswordManagerDriver::PresaveGeneratedPassword( |
248 const autofill::PasswordForm& password_form) { | 212 const autofill::PasswordForm& password_form) { |
249 if (!CheckChildProcessSecurityPolicy( | 213 if (!CheckChildProcessSecurityPolicy( |
250 password_form.origin, | 214 password_form.origin, |
251 BadMessageReason::CPMD_BAD_ORIGIN_PRESAVE_GENERATED_PASSWORD)) | 215 BadMessageReason::CPMD_BAD_ORIGIN_PRESAVE_GENERATED_PASSWORD)) |
252 return; | 216 return; |
253 GetPasswordManager()->OnPresaveGeneratedPassword(password_form); | 217 GetPasswordManager()->OnPresaveGeneratedPassword(password_form); |
254 } | 218 } |
255 | 219 |
256 void ContentPasswordManagerDriver::OnPasswordNoLongerGenerated( | 220 void ContentPasswordManagerDriver::PasswordNoLongerGenerated( |
257 const autofill::PasswordForm& password_form) { | 221 const autofill::PasswordForm& password_form) { |
258 if (!CheckChildProcessSecurityPolicy( | 222 if (!CheckChildProcessSecurityPolicy( |
259 password_form.origin, | 223 password_form.origin, |
260 BadMessageReason::CPMD_BAD_ORIGIN_PASSWORD_NO_LONGER_GENERATED)) | 224 BadMessageReason::CPMD_BAD_ORIGIN_PASSWORD_NO_LONGER_GENERATED)) |
261 return; | 225 return; |
262 GetPasswordManager()->SetHasGeneratedPasswordForForm(this, password_form, | 226 GetPasswordManager()->SetHasGeneratedPasswordForForm(this, password_form, |
263 false); | 227 false); |
264 } | 228 } |
265 | 229 |
266 void ContentPasswordManagerDriver::OnSaveGenerationFieldDetectedByClassifier( | 230 void ContentPasswordManagerDriver::SaveGenerationFieldDetectedByClassifier( |
267 const autofill::PasswordForm& password_form, | 231 const autofill::PasswordForm& password_form, |
268 const base::string16& generation_field) { | 232 const base::string16& generation_field) { |
269 if (!CheckChildProcessSecurityPolicy( | 233 if (!CheckChildProcessSecurityPolicy( |
270 password_form.origin, | 234 password_form.origin, |
271 BadMessageReason:: | 235 BadMessageReason:: |
272 CPMD_BAD_ORIGIN_SAVE_GENERATION_FIELD_DETECTED_BY_CLASSIFIER)) | 236 CPMD_BAD_ORIGIN_SAVE_GENERATION_FIELD_DETECTED_BY_CLASSIFIER)) |
273 return; | 237 return; |
274 GetPasswordManager()->SaveGenerationFieldDetectedByClassifier( | 238 GetPasswordManager()->SaveGenerationFieldDetectedByClassifier( |
275 password_form, generation_field); | 239 password_form, generation_field); |
276 } | 240 } |
277 | 241 |
| 242 void ContentPasswordManagerDriver::ShowPasswordSuggestions( |
| 243 int key, |
| 244 base::i18n::TextDirection text_direction, |
| 245 const base::string16& typed_username, |
| 246 int options, |
| 247 const gfx::RectF& bounds) { |
| 248 password_autofill_manager_.OnShowPasswordSuggestions( |
| 249 key, text_direction, typed_username, options, bounds); |
| 250 } |
| 251 |
| 252 void ContentPasswordManagerDriver::PasswordAutofillAgentConstructed() { |
| 253 SendLoggingAvailability(); |
| 254 } |
| 255 |
| 256 void ContentPasswordManagerDriver::RecordSavePasswordProgress( |
| 257 const std::string& log) { |
| 258 client_->GetLogManager()->LogSavePasswordProgress(log); |
| 259 } |
| 260 |
278 bool ContentPasswordManagerDriver::CheckChildProcessSecurityPolicy( | 261 bool ContentPasswordManagerDriver::CheckChildProcessSecurityPolicy( |
279 const GURL& url, | 262 const GURL& url, |
280 BadMessageReason reason) { | 263 BadMessageReason reason) { |
281 content::ChildProcessSecurityPolicy* policy = | 264 content::ChildProcessSecurityPolicy* policy = |
282 content::ChildProcessSecurityPolicy::GetInstance(); | 265 content::ChildProcessSecurityPolicy::GetInstance(); |
283 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(), | 266 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(), |
284 url)) { | 267 url)) { |
285 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(), reason); | 268 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(), reason); |
286 return false; | 269 return false; |
287 } | 270 } |
288 | 271 |
289 return true; | 272 return true; |
290 } | 273 } |
291 | 274 |
292 const autofill::mojom::AutofillAgentPtr& | 275 const autofill::mojom::AutofillAgentPtr& |
293 ContentPasswordManagerDriver::GetAutofillAgent() { | 276 ContentPasswordManagerDriver::GetAutofillAgent() { |
294 autofill::ContentAutofillDriver* autofill_driver = | 277 autofill::ContentAutofillDriver* autofill_driver = |
295 autofill::ContentAutofillDriver::GetForRenderFrameHost( | 278 autofill::ContentAutofillDriver::GetForRenderFrameHost( |
296 render_frame_host_); | 279 render_frame_host_); |
297 DCHECK(autofill_driver); | 280 DCHECK(autofill_driver); |
298 return autofill_driver->GetAutofillAgent(); | 281 return autofill_driver->GetAutofillAgent(); |
299 } | 282 } |
300 | 283 |
| 284 const autofill::mojom::PasswordAutofillAgentPtr& |
| 285 ContentPasswordManagerDriver::GetPasswordAutofillAgent() { |
| 286 if (!password_autofill_agent_) { |
| 287 autofill::mojom::PasswordAutofillAgentRequest request = |
| 288 mojo::GetProxy(&password_autofill_agent_); |
| 289 // Some test codes may have no initialized remote interfaces. |
| 290 if (render_frame_host_->GetRemoteInterfaces()) { |
| 291 render_frame_host_->GetRemoteInterfaces()->GetInterface( |
| 292 std::move(request)); |
| 293 } |
| 294 } |
| 295 |
| 296 return password_autofill_agent_; |
| 297 } |
| 298 |
| 299 const autofill::mojom::PasswordGenerationAgentPtr& |
| 300 ContentPasswordManagerDriver::GetPasswordGenerationAgent() { |
| 301 if (!password_gen_agent_) { |
| 302 render_frame_host_->GetRemoteInterfaces()->GetInterface( |
| 303 mojo::GetProxy(&password_gen_agent_)); |
| 304 } |
| 305 |
| 306 return password_gen_agent_; |
| 307 } |
| 308 |
301 } // namespace password_manager | 309 } // namespace password_manager |
OLD | NEW |