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/content_password_manager_d
river_factory.h" | 11 #include "components/password_manager/content/browser/content_password_manager_d
river_factory.h" |
11 #include "components/password_manager/core/browser/password_manager_client.h" | 12 #include "components/password_manager/core/browser/password_manager_client.h" |
12 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/child_process_security_policy.h" |
13 #include "content/public/browser/navigation_details.h" | 15 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
15 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/site_instance.h" | 20 #include "content/public/browser/site_instance.h" |
18 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
19 #include "content/public/common/ssl_status.h" | 22 #include "content/public/common/ssl_status.h" |
20 #include "ipc/ipc_message_macros.h" | 23 #include "ipc/ipc_message_macros.h" |
21 #include "net/cert/cert_status_flags.h" | 24 #include "net/cert/cert_status_flags.h" |
22 | 25 |
23 namespace password_manager { | 26 namespace password_manager { |
24 | 27 |
25 ContentPasswordManagerDriver::ContentPasswordManagerDriver( | 28 ContentPasswordManagerDriver::ContentPasswordManagerDriver( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 PasswordAutofillManager::OnShowPasswordSuggestions) | 147 PasswordAutofillManager::OnShowPasswordSuggestions) |
145 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, client_, | 148 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, client_, |
146 PasswordManagerClient::LogSavePasswordProgress) | 149 PasswordManagerClient::LogSavePasswordProgress) |
147 IPC_MESSAGE_UNHANDLED(handled = false) | 150 IPC_MESSAGE_UNHANDLED(handled = false) |
148 IPC_END_MESSAGE_MAP() | 151 IPC_END_MESSAGE_MAP() |
149 return handled; | 152 return handled; |
150 } | 153 } |
151 | 154 |
152 void ContentPasswordManagerDriver::OnPasswordFormsParsed( | 155 void ContentPasswordManagerDriver::OnPasswordFormsParsed( |
153 const std::vector<autofill::PasswordForm>& forms) { | 156 const std::vector<autofill::PasswordForm>& forms) { |
| 157 for (const auto& form : forms) |
| 158 if (!CheckChildProcessSecurityPolicy( |
| 159 form.origin, |
| 160 bad_message::BadMessageReason::CPMD_BAD_ORIGIN_FORMS_PARSED)) |
| 161 return; |
154 GetPasswordManager()->OnPasswordFormsParsed(this, forms); | 162 GetPasswordManager()->OnPasswordFormsParsed(this, forms); |
155 } | 163 } |
156 | 164 |
157 void ContentPasswordManagerDriver::OnPasswordFormsRendered( | 165 void ContentPasswordManagerDriver::OnPasswordFormsRendered( |
158 const std::vector<autofill::PasswordForm>& visible_forms, | 166 const std::vector<autofill::PasswordForm>& visible_forms, |
159 bool did_stop_loading) { | 167 bool did_stop_loading) { |
| 168 for (const auto& form : visible_forms) |
| 169 if (!CheckChildProcessSecurityPolicy( |
| 170 form.origin, |
| 171 bad_message::BadMessageReason::CPMD_BAD_ORIGIN_FORMS_RENDERED)) |
| 172 return; |
160 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms, | 173 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms, |
161 did_stop_loading); | 174 did_stop_loading); |
162 } | 175 } |
163 | 176 |
164 void ContentPasswordManagerDriver::OnPasswordFormSubmitted( | 177 void ContentPasswordManagerDriver::OnPasswordFormSubmitted( |
165 const autofill::PasswordForm& password_form) { | 178 const autofill::PasswordForm& password_form) { |
| 179 if (!CheckChildProcessSecurityPolicy( |
| 180 password_form.origin, |
| 181 bad_message::BadMessageReason::CPMD_BAD_ORIGIN_FORM_SUBMITTED)) |
| 182 return; |
166 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form); | 183 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form); |
167 } | 184 } |
168 | 185 |
169 void ContentPasswordManagerDriver::OnFocusedPasswordFormFound( | 186 void ContentPasswordManagerDriver::OnFocusedPasswordFormFound( |
170 const autofill::PasswordForm& password_form) { | 187 const autofill::PasswordForm& password_form) { |
| 188 if (!CheckChildProcessSecurityPolicy( |
| 189 password_form.origin, |
| 190 bad_message::BadMessageReason:: |
| 191 CPMD_BAD_ORIGIN_FOCUSED_PASSWORD_FORM_FOUND)) |
| 192 return; |
171 GetPasswordManager()->OnPasswordFormForceSaveRequested(this, password_form); | 193 GetPasswordManager()->OnPasswordFormForceSaveRequested(this, password_form); |
172 } | 194 } |
173 | 195 |
174 void ContentPasswordManagerDriver::DidNavigateFrame( | 196 void ContentPasswordManagerDriver::DidNavigateFrame( |
175 const content::LoadCommittedDetails& details, | 197 const content::LoadCommittedDetails& details, |
176 const content::FrameNavigateParams& params) { | 198 const content::FrameNavigateParams& params) { |
177 // Clear page specific data after main frame navigation. | 199 // Clear page specific data after main frame navigation. |
178 if (!render_frame_host_->GetParent() && !details.is_in_page) { | 200 if (!render_frame_host_->GetParent() && !details.is_in_page) { |
179 GetPasswordManager()->DidNavigateMainFrame(); | 201 GetPasswordManager()->DidNavigateMainFrame(); |
180 GetPasswordAutofillManager()->DidNavigateMainFrame(); | 202 GetPasswordAutofillManager()->DidNavigateMainFrame(); |
181 } | 203 } |
182 } | 204 } |
183 | 205 |
184 void ContentPasswordManagerDriver::OnInPageNavigation( | 206 void ContentPasswordManagerDriver::OnInPageNavigation( |
185 const autofill::PasswordForm& password_form) { | 207 const autofill::PasswordForm& password_form) { |
| 208 if (!CheckChildProcessSecurityPolicy( |
| 209 password_form.origin, |
| 210 bad_message::BadMessageReason::CPMD_BAD_ORIGIN_IN_PAGE_NAVIGATION)) |
| 211 return; |
186 GetPasswordManager()->OnInPageNavigation(this, password_form); | 212 GetPasswordManager()->OnInPageNavigation(this, password_form); |
187 } | 213 } |
188 | 214 |
189 void ContentPasswordManagerDriver::OnPasswordNoLongerGenerated( | 215 void ContentPasswordManagerDriver::OnPasswordNoLongerGenerated( |
190 const autofill::PasswordForm& password_form) { | 216 const autofill::PasswordForm& password_form) { |
| 217 if (!CheckChildProcessSecurityPolicy( |
| 218 password_form.origin, |
| 219 bad_message::BadMessageReason:: |
| 220 CPMD_BAD_ORIGIN_PASSWORD_NO_LONGER_GENERATED)) |
| 221 return; |
191 GetPasswordManager()->SetHasGeneratedPasswordForForm(this, password_form, | 222 GetPasswordManager()->SetHasGeneratedPasswordForForm(this, password_form, |
192 false); | 223 false); |
193 } | 224 } |
194 | 225 |
| 226 bool ContentPasswordManagerDriver::CheckChildProcessSecurityPolicy( |
| 227 const GURL& url, |
| 228 bad_message::BadMessageReason reason) { |
| 229 content::ChildProcessSecurityPolicy* policy = |
| 230 content::ChildProcessSecurityPolicy::GetInstance(); |
| 231 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(), |
| 232 url)) { |
| 233 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(), reason); |
| 234 return false; |
| 235 } |
| 236 |
| 237 return true; |
| 238 } |
| 239 |
195 } // namespace password_manager | 240 } // namespace password_manager |
OLD | NEW |