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 scoped_ptr<PasswordForm> password_form = CreatePasswordForm(current_form_); |
| 644 DCHECK(password_form); |
| 645 login_to_password_info_.clear(); |
| 646 |
| 647 Send(new AutofillHostMsg_RemoveSavedPasswordAndUpdateManagers( |
| 648 routing_id(), *password_form)); |
| 649 } |
641 | 650 |
642 //////////////////////////////////////////////////////////////////////////////// | 651 //////////////////////////////////////////////////////////////////////////////// |
643 // PasswordAutofillAgent, private: | 652 // PasswordAutofillAgent, private: |
644 | 653 |
645 void PasswordAutofillAgent::GetSuggestions( | 654 void PasswordAutofillAgent::GetSuggestions( |
646 const PasswordFormFillData& fill_data, | 655 const PasswordFormFillData& fill_data, |
647 const base::string16& input, | 656 const base::string16& input, |
648 std::vector<base::string16>* suggestions, | 657 std::vector<base::string16>* suggestions, |
649 std::vector<base::string16>* realms) { | 658 std::vector<base::string16>* realms) { |
650 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { | 659 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; | 697 std::vector<base::string16> suggestions; |
689 std::vector<base::string16> realms; | 698 std::vector<base::string16> realms; |
690 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); | 699 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); |
691 DCHECK_EQ(suggestions.size(), realms.size()); | 700 DCHECK_EQ(suggestions.size(), realms.size()); |
692 | 701 |
693 FormData form; | 702 FormData form; |
694 FormFieldData field; | 703 FormFieldData field; |
695 FindFormAndFieldForFormControlElement( | 704 FindFormAndFieldForFormControlElement( |
696 user_input, &form, &field, REQUIRE_NONE); | 705 user_input, &form, &field, REQUIRE_NONE); |
697 | 706 |
| 707 current_form_ = user_input.form(); |
| 708 |
698 blink::WebInputElement selected_element = user_input; | 709 blink::WebInputElement selected_element = user_input; |
699 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 710 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
700 | 711 |
701 float scale = web_view_->pageScaleFactor(); | 712 float scale = web_view_->pageScaleFactor(); |
702 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 713 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
703 bounding_box.y() * scale, | 714 bounding_box.y() * scale, |
704 bounding_box.width() * scale, | 715 bounding_box.width() * scale, |
705 bounding_box.height() * scale); | 716 bounding_box.height() * scale); |
706 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), | 717 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), |
707 field, | 718 field, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 906 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
896 if (iter == login_to_password_info_.end()) | 907 if (iter == login_to_password_info_.end()) |
897 return false; | 908 return false; |
898 | 909 |
899 *found_input = input; | 910 *found_input = input; |
900 *found_password = iter->second; | 911 *found_password = iter->second; |
901 return true; | 912 return true; |
902 } | 913 } |
903 | 914 |
904 } // namespace autofill | 915 } // namespace autofill |
OLD | NEW |