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_RemoveSavedPassword, OnRemoveSavedPassword) |
445 IPC_MESSAGE_UNHANDLED(handled = false) | 446 IPC_MESSAGE_UNHANDLED(handled = false) |
446 IPC_END_MESSAGE_MAP() | 447 IPC_END_MESSAGE_MAP() |
447 return handled; | 448 return handled; |
448 } | 449 } |
449 | 450 |
450 void PasswordAutofillAgent::DidStartLoading() { | 451 void PasswordAutofillAgent::DidStartLoading() { |
451 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { | 452 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { |
452 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", | 453 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", |
453 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); | 454 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); |
454 usernames_usage_ = NOTHING_TO_AUTOFILL; | 455 usernames_usage_ = NOTHING_TO_AUTOFILL; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 FormData form; | 632 FormData form; |
632 FormFieldData field; | 633 FormFieldData field; |
633 FindFormAndFieldForFormControlElement( | 634 FindFormAndFieldForFormControlElement( |
634 username_element, &form, &field, REQUIRE_NONE); | 635 username_element, &form, &field, REQUIRE_NONE); |
635 Send(new AutofillHostMsg_AddPasswordFormMapping( | 636 Send(new AutofillHostMsg_AddPasswordFormMapping( |
636 routing_id(), | 637 routing_id(), |
637 field, | 638 field, |
638 form_data)); | 639 form_data)); |
639 } | 640 } |
640 } | 641 } |
| 642 void PasswordAutofillAgent::OnRemoveSavedPassword( |
| 643 const base::string16& username_to_remove) { |
| 644 scoped_ptr<PasswordForm> password_form = CreatePasswordForm(current_form_); |
| 645 DCHECK(password_form); |
| 646 password_form->username_value = username_to_remove; |
| 647 login_to_password_info_.clear(); |
| 648 |
| 649 Send(new AutofillHostMsg_RemoveSavedPasswordAndUpdateManagers( |
| 650 routing_id(), *password_form)); |
| 651 } |
641 | 652 |
642 //////////////////////////////////////////////////////////////////////////////// | 653 //////////////////////////////////////////////////////////////////////////////// |
643 // PasswordAutofillAgent, private: | 654 // PasswordAutofillAgent, private: |
644 | 655 |
645 void PasswordAutofillAgent::GetSuggestions( | 656 void PasswordAutofillAgent::GetSuggestions( |
646 const PasswordFormFillData& fill_data, | 657 const PasswordFormFillData& fill_data, |
647 const base::string16& input, | 658 const base::string16& input, |
648 std::vector<base::string16>* suggestions, | 659 std::vector<base::string16>* suggestions, |
649 std::vector<base::string16>* realms) { | 660 std::vector<base::string16>* realms) { |
650 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { | 661 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; | 699 std::vector<base::string16> suggestions; |
689 std::vector<base::string16> realms; | 700 std::vector<base::string16> realms; |
690 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); | 701 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); |
691 DCHECK_EQ(suggestions.size(), realms.size()); | 702 DCHECK_EQ(suggestions.size(), realms.size()); |
692 | 703 |
693 FormData form; | 704 FormData form; |
694 FormFieldData field; | 705 FormFieldData field; |
695 FindFormAndFieldForFormControlElement( | 706 FindFormAndFieldForFormControlElement( |
696 user_input, &form, &field, REQUIRE_NONE); | 707 user_input, &form, &field, REQUIRE_NONE); |
697 | 708 |
| 709 current_form_ = user_input.form(); |
| 710 |
698 blink::WebInputElement selected_element = user_input; | 711 blink::WebInputElement selected_element = user_input; |
699 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 712 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
700 | 713 |
701 float scale = web_view_->pageScaleFactor(); | 714 float scale = web_view_->pageScaleFactor(); |
702 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 715 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
703 bounding_box.y() * scale, | 716 bounding_box.y() * scale, |
704 bounding_box.width() * scale, | 717 bounding_box.width() * scale, |
705 bounding_box.height() * scale); | 718 bounding_box.height() * scale); |
706 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), | 719 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), |
707 field, | 720 field, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 908 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
896 if (iter == login_to_password_info_.end()) | 909 if (iter == login_to_password_info_.end()) |
897 return false; | 910 return false; |
898 | 911 |
899 *found_input = input; | 912 *found_input = input; |
900 *found_password = iter->second; | 913 *found_password = iter->second; |
901 return true; | 914 return true; |
902 } | 915 } |
903 | 916 |
904 } // namespace autofill | 917 } // namespace autofill |
OLD | NEW |