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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 password_forms)); | 442 password_forms)); |
443 } else { | 443 } else { |
444 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); | 444 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { | 448 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { |
449 bool handled = true; | 449 bool handled = true; |
450 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) | 450 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) |
451 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) | 451 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) |
452 IPC_MESSAGE_HANDLER(AutofillMsg_RemovePasswordSuggestion, | |
453 OnRemovePasswordSuggestion) | |
452 IPC_MESSAGE_UNHANDLED(handled = false) | 454 IPC_MESSAGE_UNHANDLED(handled = false) |
453 IPC_END_MESSAGE_MAP() | 455 IPC_END_MESSAGE_MAP() |
454 return handled; | 456 return handled; |
455 } | 457 } |
456 | 458 |
457 void PasswordAutofillAgent::DidStartLoading() { | 459 void PasswordAutofillAgent::DidStartLoading() { |
458 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { | 460 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { |
459 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", | 461 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", |
460 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); | 462 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); |
461 usernames_usage_ = NOTHING_TO_AUTOFILL; | 463 usernames_usage_ = NOTHING_TO_AUTOFILL; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 FormData form; | 640 FormData form; |
639 FormFieldData field; | 641 FormFieldData field; |
640 FindFormAndFieldForInputElement( | 642 FindFormAndFieldForInputElement( |
641 username_element, &form, &field, REQUIRE_NONE); | 643 username_element, &form, &field, REQUIRE_NONE); |
642 Send(new AutofillHostMsg_AddPasswordFormMapping( | 644 Send(new AutofillHostMsg_AddPasswordFormMapping( |
643 routing_id(), | 645 routing_id(), |
644 field, | 646 field, |
645 form_data)); | 647 form_data)); |
646 } | 648 } |
647 } | 649 } |
650 void PasswordAutofillAgent::OnRemovePasswordSuggestion( | |
651 const PasswordForm& password_form) { | |
652 | |
653 std::vector<PasswordForm> updated_password_forms; | |
654 | |
655 LoginToPasswordInfoMap::iterator iter; | |
656 for (iter = login_to_password_info_.begin(); | |
657 iter != login_to_password_info_.end();) { | |
658 scoped_ptr<PasswordForm> new_password_form( | |
659 CreatePasswordForm(iter->second.password_field.form())); | |
660 if (new_password_form.get()) { | |
vabr (Chromium)
2014/04/01 16:56:08
Should we also test if new_password_form is simila
rchtara
2014/04/03 08:44:50
I'm sure but i think it better to leave that to th
| |
661 login_to_password_info_.erase(iter++); | |
662 updated_password_forms.push_back(*new_password_form); | |
663 } else { | |
664 ++iter; | |
665 } | |
666 } | |
667 | |
668 Send(new AutofillHostMsg_RemovePasswordSuggestion( | |
669 routing_id(), password_form, updated_password_forms)); | |
670 } | |
648 | 671 |
649 //////////////////////////////////////////////////////////////////////////////// | 672 //////////////////////////////////////////////////////////////////////////////// |
650 // PasswordAutofillAgent, private: | 673 // PasswordAutofillAgent, private: |
651 | 674 |
652 void PasswordAutofillAgent::GetSuggestions( | 675 void PasswordAutofillAgent::GetSuggestions( |
653 const PasswordFormFillData& fill_data, | 676 const PasswordFormFillData& fill_data, |
654 const base::string16& input, | 677 const base::string16& input, |
655 std::vector<base::string16>* suggestions, | 678 std::vector<base::string16>* suggestions, |
656 std::vector<base::string16>* realms) { | 679 std::vector<base::string16>* realms) { |
657 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { | 680 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 std::vector<base::string16> suggestions; | 718 std::vector<base::string16> suggestions; |
696 std::vector<base::string16> realms; | 719 std::vector<base::string16> realms; |
697 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); | 720 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); |
698 DCHECK_EQ(suggestions.size(), realms.size()); | 721 DCHECK_EQ(suggestions.size(), realms.size()); |
699 | 722 |
700 FormData form; | 723 FormData form; |
701 FormFieldData field; | 724 FormFieldData field; |
702 FindFormAndFieldForInputElement( | 725 FindFormAndFieldForInputElement( |
703 user_input, &form, &field, REQUIRE_NONE); | 726 user_input, &form, &field, REQUIRE_NONE); |
704 | 727 |
728 scoped_ptr<PasswordForm> password_form = | |
729 CreatePasswordForm(user_input.form()); | |
vabr (Chromium)
2014/04/01 17:14:35
To record, what we just spoke about: instead of cr
rchtara
2014/04/03 08:44:50
Done.
| |
730 DCHECK(password_form); | |
731 | |
705 blink::WebInputElement selected_element = user_input; | 732 blink::WebInputElement selected_element = user_input; |
706 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 733 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
707 | 734 |
708 float scale = web_view_->pageScaleFactor(); | 735 float scale = web_view_->pageScaleFactor(); |
709 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 736 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
710 bounding_box.y() * scale, | 737 bounding_box.y() * scale, |
711 bounding_box.width() * scale, | 738 bounding_box.width() * scale, |
712 bounding_box.height() * scale); | 739 bounding_box.height() * scale); |
713 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), | 740 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), |
714 field, | 741 field, |
742 *password_form, | |
715 bounding_box_scaled, | 743 bounding_box_scaled, |
716 suggestions, | 744 suggestions, |
717 realms)); | 745 realms)); |
718 return !suggestions.empty(); | 746 return !suggestions.empty(); |
719 } | 747 } |
720 | 748 |
721 void PasswordAutofillAgent::FillFormOnPasswordRecieved( | 749 void PasswordAutofillAgent::FillFormOnPasswordRecieved( |
722 const PasswordFormFillData& fill_data, | 750 const PasswordFormFillData& fill_data, |
723 blink::WebInputElement username_element, | 751 blink::WebInputElement username_element, |
724 blink::WebInputElement password_element) { | 752 blink::WebInputElement password_element) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 933 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
906 if (iter == login_to_password_info_.end()) | 934 if (iter == login_to_password_info_.end()) |
907 return false; | 935 return false; |
908 | 936 |
909 *found_input = input; | 937 *found_input = input; |
910 *found_password = iter->second; | 938 *found_password = iter->second; |
911 return true; | 939 return true; |
912 } | 940 } |
913 | 941 |
914 } // namespace autofill | 942 } // namespace autofill |
OLD | NEW |