| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/content/renderer/password_autofill_agent.h" | 5 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 (!FillDataContainsUsername(data) || | 181 (!FillDataContainsUsername(data) || |
| 182 FindFormInputElement(form_element, data.username_field, result)); | 182 FindFormInputElement(form_element, data.username_field, result)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Helper to locate form elements identified by |data|. | 185 // Helper to locate form elements identified by |data|. |
| 186 void FindFormElements(content::RenderFrame* render_frame, | 186 void FindFormElements(content::RenderFrame* render_frame, |
| 187 const PasswordFormFillData& data, | 187 const PasswordFormFillData& data, |
| 188 FormElementsList* results) { | 188 FormElementsList* results) { |
| 189 DCHECK(results); | 189 DCHECK(results); |
| 190 | 190 |
| 191 GURL::Replacements rep; | |
| 192 rep.ClearQuery(); | |
| 193 rep.ClearRef(); | |
| 194 | |
| 195 blink::WebDocument doc = render_frame->GetWebFrame()->document(); | 191 blink::WebDocument doc = render_frame->GetWebFrame()->document(); |
| 196 if (!doc.isHTMLDocument()) | 192 if (!doc.isHTMLDocument()) |
| 197 return; | 193 return; |
| 198 | 194 |
| 199 GURL full_origin(doc.url()); | 195 if (data.origin != GetCanonicalOriginForDocument(doc)) |
| 200 if (data.origin != full_origin.ReplaceComponents(rep)) | |
| 201 return; | 196 return; |
| 202 | 197 |
| 203 blink::WebVector<blink::WebFormElement> forms; | 198 blink::WebVector<blink::WebFormElement> forms; |
| 204 doc.forms(forms); | 199 doc.forms(forms); |
| 205 | 200 |
| 206 for (size_t i = 0; i < forms.size(); ++i) { | 201 for (size_t i = 0; i < forms.size(); ++i) { |
| 207 blink::WebFormElement fe = forms[i]; | 202 blink::WebFormElement fe = forms[i]; |
| 208 | 203 |
| 209 GURL full_action(doc.completeURL(fe.action())); | |
| 210 if (full_action.is_empty()) { | |
| 211 // The default action URL is the form's origin. | |
| 212 full_action = full_origin; | |
| 213 } | |
| 214 | |
| 215 // Action URL must match. | 204 // Action URL must match. |
| 216 if (data.action != full_action.ReplaceComponents(rep)) | 205 if (data.action != GetCanonicalActionForForm(fe)) |
| 217 continue; | 206 continue; |
| 218 | 207 |
| 219 scoped_ptr<FormElements> curr_elements(new FormElements); | 208 scoped_ptr<FormElements> curr_elements(new FormElements); |
| 220 if (!FindFormInputElements(&fe, data, curr_elements.get())) | 209 if (!FindFormInputElements(&fe, data, curr_elements.get())) |
| 221 continue; | 210 continue; |
| 222 | 211 |
| 223 // We found the right element. | 212 // We found the right element. |
| 224 // Note: this assignment adds a reference to |fe|. | 213 // Note: this assignment adds a reference to |fe|. |
| 225 curr_elements->form_element = fe; | 214 curr_elements->form_element = fe; |
| 226 results->push_back(curr_elements.release()); | 215 results->push_back(curr_elements.release()); |
| (...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { | 1422 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { |
| 1434 agent_->DidStopLoading(); | 1423 agent_->DidStopLoading(); |
| 1435 } | 1424 } |
| 1436 | 1425 |
| 1437 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1426 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: |
| 1438 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { | 1427 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { |
| 1439 agent_->LegacyDidStartProvisionalLoad(navigated_frame); | 1428 agent_->LegacyDidStartProvisionalLoad(navigated_frame); |
| 1440 } | 1429 } |
| 1441 | 1430 |
| 1442 } // namespace autofill | 1431 } // namespace autofill |
| OLD | NEW |