| 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/common/autofill_messages.h" | 7 #include "components/autofill/content/common/autofill_messages.h" |
| 8 #include "components/autofill/core/common/form_data.h" | 8 #include "components/autofill/core/common/form_data.h" |
| 9 #include "components/autofill/core/common/password_form.h" | 9 #include "components/autofill/core/common/password_form.h" |
| 10 #include "components/password_manager/content/browser/bad_message.h" | 10 #include "components/password_manager/content/browser/bad_message.h" |
| 11 #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" |
| 12 #include "components/password_manager/core/browser/password_manager.h" |
| 12 #include "components/password_manager/core/browser/password_manager_client.h" | 13 #include "components/password_manager/core/browser/password_manager_client.h" |
| 13 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/child_process_security_policy.h" | 15 #include "content/public/browser/child_process_security_policy.h" |
| 15 #include "content/public/browser/navigation_details.h" | 16 #include "content/public/browser/navigation_details.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/site_instance.h" | 21 #include "content/public/browser/site_instance.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/ssl_status.h" | 23 #include "content/public/common/ssl_status.h" |
| 23 #include "ipc/ipc_message_macros.h" | 24 #include "ipc/ipc_message_macros.h" |
| 24 #include "net/cert/cert_status_flags.h" | 25 #include "net/cert/cert_status_flags.h" |
| 25 | 26 |
| 26 namespace password_manager { | 27 namespace password_manager { |
| 27 | 28 |
| 28 ContentPasswordManagerDriver::ContentPasswordManagerDriver( | 29 ContentPasswordManagerDriver::ContentPasswordManagerDriver( |
| 29 content::RenderFrameHost* render_frame_host, | 30 content::RenderFrameHost* render_frame_host, |
| 30 PasswordManagerClient* client, | 31 PasswordManagerClient* client, |
| 31 autofill::AutofillClient* autofill_client) | 32 autofill::AutofillClient* autofill_client) |
| 32 : render_frame_host_(render_frame_host), | 33 : render_frame_host_(render_frame_host), |
| 33 client_(client), | 34 client_(client), |
| 34 password_generation_manager_(client, this), | 35 password_generation_manager_(client, this), |
| 35 password_autofill_manager_(this, autofill_client), | 36 password_autofill_manager_(this, autofill_client), |
| 36 next_free_key_(0) { | 37 next_free_key_(0) {} |
| 37 } | |
| 38 | 38 |
| 39 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() { | 39 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 // static | 42 // static |
| 43 ContentPasswordManagerDriver* | 43 ContentPasswordManagerDriver* |
| 44 ContentPasswordManagerDriver::GetForRenderFrameHost( | 44 ContentPasswordManagerDriver::GetForRenderFrameHost( |
| 45 content::RenderFrameHost* render_frame_host) { | 45 content::RenderFrameHost* render_frame_host) { |
| 46 ContentPasswordManagerDriverFactory* factory = | 46 ContentPasswordManagerDriverFactory* factory = |
| 47 ContentPasswordManagerDriverFactory::FromWebContents( | 47 ContentPasswordManagerDriverFactory::FromWebContents( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void ContentPasswordManagerDriver::ClearPreviewedForm() { | 107 void ContentPasswordManagerDriver::ClearPreviewedForm() { |
| 108 content::RenderFrameHost* host = render_frame_host_; | 108 content::RenderFrameHost* host = render_frame_host_; |
| 109 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); | 109 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ContentPasswordManagerDriver::ForceSavePassword() { | 112 void ContentPasswordManagerDriver::ForceSavePassword() { |
| 113 content::RenderFrameHost* host = render_frame_host_; | 113 content::RenderFrameHost* host = render_frame_host_; |
| 114 host->Send(new AutofillMsg_FindFocusedPasswordForm(host->GetRoutingID())); | 114 host->Send(new AutofillMsg_FindFocusedPasswordForm(host->GetRoutingID())); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ContentPasswordManagerDriver::NotifyAboutLoggingAvailability( |
| 118 bool is_available) { |
| 119 if (is_available == logging_available_) |
| 120 return; |
| 121 logging_available_ = is_available; |
| 122 SendLoggingAvailability(); |
| 123 } |
| 124 |
| 125 void ContentPasswordManagerDriver::SendLoggingAvailability() { |
| 126 render_frame_host_->Send(new AutofillMsg_SetLoggingState( |
| 127 render_frame_host_->GetRoutingID(), logging_available_)); |
| 128 } |
| 129 |
| 117 PasswordGenerationManager* | 130 PasswordGenerationManager* |
| 118 ContentPasswordManagerDriver::GetPasswordGenerationManager() { | 131 ContentPasswordManagerDriver::GetPasswordGenerationManager() { |
| 119 return &password_generation_manager_; | 132 return &password_generation_manager_; |
| 120 } | 133 } |
| 121 | 134 |
| 122 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { | 135 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { |
| 123 return client_->GetPasswordManager(); | 136 return client_->GetPasswordManager(); |
| 124 } | 137 } |
| 125 | 138 |
| 126 PasswordAutofillManager* | 139 PasswordAutofillManager* |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted, | 151 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted, |
| 139 OnPasswordFormSubmitted) | 152 OnPasswordFormSubmitted) |
| 140 IPC_MESSAGE_HANDLER(AutofillHostMsg_InPageNavigation, OnInPageNavigation) | 153 IPC_MESSAGE_HANDLER(AutofillHostMsg_InPageNavigation, OnInPageNavigation) |
| 141 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordNoLongerGenerated, | 154 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordNoLongerGenerated, |
| 142 OnPasswordNoLongerGenerated) | 155 OnPasswordNoLongerGenerated) |
| 143 IPC_MESSAGE_HANDLER(AutofillHostMsg_FocusedPasswordFormFound, | 156 IPC_MESSAGE_HANDLER(AutofillHostMsg_FocusedPasswordFormFound, |
| 144 OnFocusedPasswordFormFound) | 157 OnFocusedPasswordFormFound) |
| 145 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, | 158 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, |
| 146 &password_autofill_manager_, | 159 &password_autofill_manager_, |
| 147 PasswordAutofillManager::OnShowPasswordSuggestions) | 160 PasswordAutofillManager::OnShowPasswordSuggestions) |
| 148 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, client_, | 161 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, |
| 149 PasswordManagerClient::LogSavePasswordProgress) | 162 client_->GetPasswordManager(), |
| 163 PasswordManager::LogSavePasswordProgress) |
| 164 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordAutofillAgentConstructed, |
| 165 SendLoggingAvailability) |
| 150 IPC_MESSAGE_UNHANDLED(handled = false) | 166 IPC_MESSAGE_UNHANDLED(handled = false) |
| 151 IPC_END_MESSAGE_MAP() | 167 IPC_END_MESSAGE_MAP() |
| 152 return handled; | 168 return handled; |
| 153 } | 169 } |
| 154 | 170 |
| 155 void ContentPasswordManagerDriver::OnPasswordFormsParsed( | 171 void ContentPasswordManagerDriver::OnPasswordFormsParsed( |
| 156 const std::vector<autofill::PasswordForm>& forms) { | 172 const std::vector<autofill::PasswordForm>& forms) { |
| 157 for (const auto& form : forms) | 173 for (const auto& form : forms) |
| 158 if (!CheckChildProcessSecurityPolicy( | 174 if (!CheckChildProcessSecurityPolicy( |
| 159 form.origin, BadMessageReason::CPMD_BAD_ORIGIN_FORMS_PARSED)) | 175 form.origin, BadMessageReason::CPMD_BAD_ORIGIN_FORMS_PARSED)) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(), | 249 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(), |
| 234 url)) { | 250 url)) { |
| 235 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(), reason); | 251 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(), reason); |
| 236 return false; | 252 return false; |
| 237 } | 253 } |
| 238 | 254 |
| 239 return true; | 255 return true; |
| 240 } | 256 } |
| 241 | 257 |
| 242 } // namespace password_manager | 258 } // namespace password_manager |
| OLD | NEW |