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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 password_forms)); | 435 password_forms)); |
436 } else { | 436 } else { |
437 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); | 437 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); |
438 } | 438 } |
439 } | 439 } |
440 | 440 |
441 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { | 441 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { |
442 bool handled = true; | 442 bool handled = true; |
443 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) | 443 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) |
444 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) | 444 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) |
445 IPC_MESSAGE_HANDLER(AutofillMsg_RemovePasswordSuggestion, | |
446 OnRemovePasswordSuggestion) | |
445 IPC_MESSAGE_UNHANDLED(handled = false) | 447 IPC_MESSAGE_UNHANDLED(handled = false) |
446 IPC_END_MESSAGE_MAP() | 448 IPC_END_MESSAGE_MAP() |
447 return handled; | 449 return handled; |
448 } | 450 } |
449 | 451 |
450 void PasswordAutofillAgent::DidStartLoading() { | 452 void PasswordAutofillAgent::DidStartLoading() { |
451 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { | 453 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { |
452 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", | 454 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", |
453 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); | 455 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); |
454 usernames_usage_ = NOTHING_TO_AUTOFILL; | 456 usernames_usage_ = NOTHING_TO_AUTOFILL; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 FormData form; | 633 FormData form; |
632 FormFieldData field; | 634 FormFieldData field; |
633 FindFormAndFieldForFormControlElement( | 635 FindFormAndFieldForFormControlElement( |
634 username_element, &form, &field, REQUIRE_NONE); | 636 username_element, &form, &field, REQUIRE_NONE); |
635 Send(new AutofillHostMsg_AddPasswordFormMapping( | 637 Send(new AutofillHostMsg_AddPasswordFormMapping( |
636 routing_id(), | 638 routing_id(), |
637 field, | 639 field, |
638 form_data)); | 640 form_data)); |
639 } | 641 } |
640 } | 642 } |
643 void PasswordAutofillAgent::OnRemovePasswordSuggestion( | |
644 const base::string16& username_to_remove) { | |
645 scoped_ptr<PasswordForm> password_form = | |
646 CreatePasswordForm(current_form_); | |
647 DCHECK(password_form); | |
vabr (Chromium)
2014/04/04 10:51:40
Please check with a debug build of Chrome, that us
rchtara
2014/04/04 16:07:20
I just checked it and it's working
:)
| |
648 password_form->username_value = username_to_remove; | |
649 | |
650 std::vector<PasswordForm> updated_password_forms; | |
651 | |
652 LoginToPasswordInfoMap::iterator iter; | |
653 for (iter = login_to_password_info_.begin(); | |
654 iter != login_to_password_info_.end();) { | |
655 scoped_ptr<PasswordForm> new_password_form( | |
656 CreatePasswordForm(iter->second.password_field.form())); | |
657 if (new_password_form.get()) { | |
658 login_to_password_info_.erase(iter++); | |
659 updated_password_forms.push_back(*new_password_form); | |
660 } else { | |
661 ++iter; | |
662 } | |
663 } | |
664 | |
665 Send(new AutofillHostMsg_RemovePasswordSuggestion( | |
666 routing_id(), *password_form, updated_password_forms)); | |
667 } | |
641 | 668 |
642 //////////////////////////////////////////////////////////////////////////////// | 669 //////////////////////////////////////////////////////////////////////////////// |
643 // PasswordAutofillAgent, private: | 670 // PasswordAutofillAgent, private: |
644 | 671 |
645 void PasswordAutofillAgent::GetSuggestions( | 672 void PasswordAutofillAgent::GetSuggestions( |
646 const PasswordFormFillData& fill_data, | 673 const PasswordFormFillData& fill_data, |
647 const base::string16& input, | 674 const base::string16& input, |
648 std::vector<base::string16>* suggestions, | 675 std::vector<base::string16>* suggestions, |
649 std::vector<base::string16>* realms) { | 676 std::vector<base::string16>* realms) { |
650 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { | 677 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 std::vector<base::string16> suggestions; | 715 std::vector<base::string16> suggestions; |
689 std::vector<base::string16> realms; | 716 std::vector<base::string16> realms; |
690 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); | 717 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); |
691 DCHECK_EQ(suggestions.size(), realms.size()); | 718 DCHECK_EQ(suggestions.size(), realms.size()); |
692 | 719 |
693 FormData form; | 720 FormData form; |
694 FormFieldData field; | 721 FormFieldData field; |
695 FindFormAndFieldForFormControlElement( | 722 FindFormAndFieldForFormControlElement( |
696 user_input, &form, &field, REQUIRE_NONE); | 723 user_input, &form, &field, REQUIRE_NONE); |
697 | 724 |
725 current_form_ = user_input.form(); | |
726 | |
698 blink::WebInputElement selected_element = user_input; | 727 blink::WebInputElement selected_element = user_input; |
699 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 728 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
700 | 729 |
701 float scale = web_view_->pageScaleFactor(); | 730 float scale = web_view_->pageScaleFactor(); |
702 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 731 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
703 bounding_box.y() * scale, | 732 bounding_box.y() * scale, |
704 bounding_box.width() * scale, | 733 bounding_box.width() * scale, |
705 bounding_box.height() * scale); | 734 bounding_box.height() * scale); |
706 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), | 735 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), |
707 field, | 736 field, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 924 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
896 if (iter == login_to_password_info_.end()) | 925 if (iter == login_to_password_info_.end()) |
897 return false; | 926 return false; |
898 | 927 |
899 *found_input = input; | 928 *found_input = input; |
900 *found_password = iter->second; | 929 *found_password = iter->second; |
901 return true; | 930 return true; |
902 } | 931 } |
903 | 932 |
904 } // namespace autofill | 933 } // namespace autofill |
OLD | NEW |