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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 // |suggestedValue| set, and |suggestedValue| will be registered for copying to | 443 // |suggestedValue| set, and |suggestedValue| will be registered for copying to |
444 // the real value through |registration_callback|. Returns true when the | 444 // the real value through |registration_callback|. Returns true when the |
445 // username gets selected from |other_possible_usernames|, else returns false. | 445 // username gets selected from |other_possible_usernames|, else returns false. |
446 bool FillFormOnPasswordReceived( | 446 bool FillFormOnPasswordReceived( |
447 const PasswordFormFillData& fill_data, | 447 const PasswordFormFillData& fill_data, |
448 blink::WebInputElement username_element, | 448 blink::WebInputElement username_element, |
449 blink::WebInputElement password_element, | 449 blink::WebInputElement password_element, |
450 std::map<const blink::WebInputElement, blink::WebString>& | 450 std::map<const blink::WebInputElement, blink::WebString>& |
451 nonscript_modified_values, | 451 nonscript_modified_values, |
452 base::Callback<void(blink::WebInputElement*)> registration_callback) { | 452 base::Callback<void(blink::WebInputElement*)> registration_callback) { |
453 // Do not fill if the password field is in an iframe. | 453 // Do not fill if the password field is in a chain of iframes not having |
454 DCHECK(password_element.document().frame()); | 454 // identical origin. |
455 if (password_element.document().frame()->parent()) | 455 blink::WebFrame* cur_frame = password_element.document().frame(); |
456 blink::WebString bottom_frame_origin = | |
457 cur_frame->securityOrigin().toString(); | |
458 | |
459 DCHECK(cur_frame); | |
460 | |
461 while (cur_frame->parent() && | |
Garrett Casto
2015/05/26 20:31:38
I think that it's slightly simpler to construct th
| |
462 bottom_frame_origin.equals(cur_frame->securityOrigin().toString())) { | |
463 cur_frame = cur_frame->parent(); | |
464 } | |
465 if (!bottom_frame_origin.equals(cur_frame->securityOrigin().toString())) { | |
Garrett Casto
2015/05/26 20:31:38
Nit: We don't put one braces on one line if statem
| |
456 return false; | 466 return false; |
467 } | |
457 | 468 |
458 // If we can't modify the password, don't try to set the username | 469 // If we can't modify the password, don't try to set the username |
459 if (!IsElementAutocompletable(password_element)) | 470 if (!IsElementAutocompletable(password_element)) |
460 return false; | 471 return false; |
461 | 472 |
462 bool form_contains_username_field = FillDataContainsUsername(fill_data); | 473 bool form_contains_username_field = FillDataContainsUsername(fill_data); |
463 // If the form contains an autocompletable username field, try to set the | 474 // If the form contains an autocompletable username field, try to set the |
464 // username to the preferred name, but only if: | 475 // username to the preferred name, but only if: |
465 // (a) The fill-on-account-select flag is not set, and | 476 // (a) The fill-on-account-select flag is not set, and |
466 // (b) The username element isn't prefilled | 477 // (b) The username element isn't prefilled |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { | 1441 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { |
1431 agent_->DidStopLoading(); | 1442 agent_->DidStopLoading(); |
1432 } | 1443 } |
1433 | 1444 |
1434 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1445 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: |
1435 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { | 1446 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { |
1436 agent_->LegacyDidStartProvisionalLoad(navigated_frame); | 1447 agent_->LegacyDidStartProvisionalLoad(navigated_frame); |
1437 } | 1448 } |
1438 | 1449 |
1439 } // namespace autofill | 1450 } // namespace autofill |
OLD | NEW |