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