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