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/common/autofill_messages.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" |
25 #include "ipc/ipc_message_macros.h" | 26 #include "ipc/ipc_message_macros.h" |
| 27 #include "mojo/common/common_type_converters.h" |
26 #include "net/cert/cert_status_flags.h" | 28 #include "net/cert/cert_status_flags.h" |
27 | 29 |
28 namespace password_manager { | 30 namespace password_manager { |
29 | 31 |
30 ContentPasswordManagerDriver::ContentPasswordManagerDriver( | 32 ContentPasswordManagerDriver::ContentPasswordManagerDriver( |
31 content::RenderFrameHost* render_frame_host, | 33 content::RenderFrameHost* render_frame_host, |
32 PasswordManagerClient* client, | 34 PasswordManagerClient* client, |
33 autofill::AutofillClient* autofill_client) | 35 autofill::AutofillClient* autofill_client) |
34 : render_frame_host_(render_frame_host), | 36 : render_frame_host_(render_frame_host), |
35 client_(client), | 37 client_(client), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void ContentPasswordManagerDriver::GeneratedPasswordAccepted( | 87 void ContentPasswordManagerDriver::GeneratedPasswordAccepted( |
86 const base::string16& password) { | 88 const base::string16& password) { |
87 content::RenderFrameHost* host = render_frame_host_; | 89 content::RenderFrameHost* host = render_frame_host_; |
88 host->Send(new AutofillMsg_GeneratedPasswordAccepted(host->GetRoutingID(), | 90 host->Send(new AutofillMsg_GeneratedPasswordAccepted(host->GetRoutingID(), |
89 password)); | 91 password)); |
90 } | 92 } |
91 | 93 |
92 void ContentPasswordManagerDriver::FillSuggestion( | 94 void ContentPasswordManagerDriver::FillSuggestion( |
93 const base::string16& username, | 95 const base::string16& username, |
94 const base::string16& password) { | 96 const base::string16& password) { |
95 content::RenderFrameHost* host = render_frame_host_; | 97 GetAutofillAgent()->FillPasswordSuggestion(mojo::String::From(username), |
96 host->Send(new AutofillMsg_FillPasswordSuggestion(host->GetRoutingID(), | 98 mojo::String::From(password)); |
97 username, password)); | |
98 } | 99 } |
99 | 100 |
100 void ContentPasswordManagerDriver::PreviewSuggestion( | 101 void ContentPasswordManagerDriver::PreviewSuggestion( |
101 const base::string16& username, | 102 const base::string16& username, |
102 const base::string16& password) { | 103 const base::string16& password) { |
103 content::RenderFrameHost* host = render_frame_host_; | 104 GetAutofillAgent()->PreviewPasswordSuggestion(mojo::String::From(username), |
104 host->Send(new AutofillMsg_PreviewPasswordSuggestion(host->GetRoutingID(), | 105 mojo::String::From(password)); |
105 username, password)); | |
106 } | 106 } |
107 | 107 |
108 void ContentPasswordManagerDriver::ShowInitialPasswordAccountSuggestions( | 108 void ContentPasswordManagerDriver::ShowInitialPasswordAccountSuggestions( |
109 const autofill::PasswordFormFillData& form_data) { | 109 const autofill::PasswordFormFillData& form_data) { |
110 const int key = next_free_key_++; | 110 const int key = next_free_key_++; |
111 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data); | 111 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data); |
112 render_frame_host_->Send( | 112 GetAutofillAgent()->ShowInitialPasswordAccountSuggestions(key, form_data); |
113 new AutofillMsg_ShowInitialPasswordAccountSuggestions( | |
114 render_frame_host_->GetRoutingID(), key, form_data)); | |
115 } | 113 } |
116 | 114 |
117 void ContentPasswordManagerDriver::ClearPreviewedForm() { | 115 void ContentPasswordManagerDriver::ClearPreviewedForm() { |
118 content::RenderFrameHost* host = render_frame_host_; | 116 GetAutofillAgent()->ClearPreviewedForm(); |
119 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); | |
120 } | 117 } |
121 | 118 |
122 void ContentPasswordManagerDriver::ForceSavePassword() { | 119 void ContentPasswordManagerDriver::ForceSavePassword() { |
123 content::RenderFrameHost* host = render_frame_host_; | 120 content::RenderFrameHost* host = render_frame_host_; |
124 host->Send(new AutofillMsg_FindFocusedPasswordForm(host->GetRoutingID())); | 121 host->Send(new AutofillMsg_FindFocusedPasswordForm(host->GetRoutingID())); |
125 } | 122 } |
126 | 123 |
127 void ContentPasswordManagerDriver::GeneratePassword() { | 124 void ContentPasswordManagerDriver::GeneratePassword() { |
128 content::RenderFrameHost* host = render_frame_host_; | 125 content::RenderFrameHost* host = render_frame_host_; |
129 host->Send( | 126 host->Send( |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 content::ChildProcessSecurityPolicy::GetInstance(); | 285 content::ChildProcessSecurityPolicy::GetInstance(); |
289 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(), | 286 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(), |
290 url)) { | 287 url)) { |
291 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(), reason); | 288 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(), reason); |
292 return false; | 289 return false; |
293 } | 290 } |
294 | 291 |
295 return true; | 292 return true; |
296 } | 293 } |
297 | 294 |
| 295 const autofill::mojom::AutofillAgentPtr& |
| 296 ContentPasswordManagerDriver::GetAutofillAgent() { |
| 297 autofill::ContentAutofillDriver* autofill_driver = |
| 298 autofill::ContentAutofillDriver::GetForRenderFrameHost( |
| 299 render_frame_host_); |
| 300 DCHECK(autofill_driver); |
| 301 return autofill_driver->GetAutofillAgent(); |
| 302 } |
| 303 |
298 } // namespace password_manager | 304 } // namespace password_manager |
OLD | NEW |