| 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 password_forms)); | 374 password_forms)); |
| 375 } else { | 375 } else { |
| 376 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); | 376 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 | 379 |
| 380 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { | 380 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { |
| 381 bool handled = true; | 381 bool handled = true; |
| 382 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) | 382 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) |
| 383 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) | 383 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) |
| 384 IPC_MESSAGE_HANDLER(AutofillMsg_RemovePasswordSuggestion, |
| 385 OnRemovePasswordSuggestion) |
| 384 IPC_MESSAGE_UNHANDLED(handled = false) | 386 IPC_MESSAGE_UNHANDLED(handled = false) |
| 385 IPC_END_MESSAGE_MAP() | 387 IPC_END_MESSAGE_MAP() |
| 386 return handled; | 388 return handled; |
| 387 } | 389 } |
| 388 | 390 |
| 389 void PasswordAutofillAgent::DidStartLoading() { | 391 void PasswordAutofillAgent::DidStartLoading() { |
| 390 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { | 392 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { |
| 391 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", | 393 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", |
| 392 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); | 394 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); |
| 393 usernames_usage_ = NOTHING_TO_AUTOFILL; | 395 usernames_usage_ = NOTHING_TO_AUTOFILL; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 FormFieldData field; | 551 FormFieldData field; |
| 550 FindFormAndFieldForInputElement( | 552 FindFormAndFieldForInputElement( |
| 551 username_element, &form, &field, REQUIRE_NONE); | 553 username_element, &form, &field, REQUIRE_NONE); |
| 552 Send(new AutofillHostMsg_AddPasswordFormMapping( | 554 Send(new AutofillHostMsg_AddPasswordFormMapping( |
| 553 routing_id(), | 555 routing_id(), |
| 554 field, | 556 field, |
| 555 form_data)); | 557 form_data)); |
| 556 } | 558 } |
| 557 } | 559 } |
| 558 | 560 |
| 561 void PasswordAutofillAgent::OnRemovePasswordSuggestion( |
| 562 const PasswordForm& password_form) { |
| 563 Send(new AutofillHostMsg_RemovePasswordSuggestion(routing_id(), |
| 564 password_form)); |
| 565 } |
| 566 |
| 559 //////////////////////////////////////////////////////////////////////////////// | 567 //////////////////////////////////////////////////////////////////////////////// |
| 560 // PasswordAutofillAgent, private: | 568 // PasswordAutofillAgent, private: |
| 561 | 569 |
| 562 void PasswordAutofillAgent::GetSuggestions( | 570 void PasswordAutofillAgent::GetSuggestions( |
| 563 const PasswordFormFillData& fill_data, | 571 const PasswordFormFillData& fill_data, |
| 564 const base::string16& input, | 572 const base::string16& input, |
| 565 std::vector<base::string16>* suggestions, | 573 std::vector<base::string16>* suggestions, |
| 566 std::vector<base::string16>* realms) { | 574 std::vector<base::string16>* realms) { |
| 567 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { | 575 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { |
| 568 suggestions->push_back(fill_data.basic_data.fields[0].value); | 576 suggestions->push_back(fill_data.basic_data.fields[0].value); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 std::vector<base::string16> suggestions; | 613 std::vector<base::string16> suggestions; |
| 606 std::vector<base::string16> realms; | 614 std::vector<base::string16> realms; |
| 607 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); | 615 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); |
| 608 DCHECK_EQ(suggestions.size(), realms.size()); | 616 DCHECK_EQ(suggestions.size(), realms.size()); |
| 609 | 617 |
| 610 FormData form; | 618 FormData form; |
| 611 FormFieldData field; | 619 FormFieldData field; |
| 612 FindFormAndFieldForInputElement( | 620 FindFormAndFieldForInputElement( |
| 613 user_input, &form, &field, REQUIRE_NONE); | 621 user_input, &form, &field, REQUIRE_NONE); |
| 614 | 622 |
| 623 scoped_ptr<PasswordForm> password_form = |
| 624 CreatePasswordForm(user_input.form()); |
| 625 DCHECK(password_form); |
| 626 |
| 615 blink::WebInputElement selected_element = user_input; | 627 blink::WebInputElement selected_element = user_input; |
| 616 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 628 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
| 617 | 629 |
| 618 float scale = web_view_->pageScaleFactor(); | 630 float scale = web_view_->pageScaleFactor(); |
| 619 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 631 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
| 620 bounding_box.y() * scale, | 632 bounding_box.y() * scale, |
| 621 bounding_box.width() * scale, | 633 bounding_box.width() * scale, |
| 622 bounding_box.height() * scale); | 634 bounding_box.height() * scale); |
| 623 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), | 635 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), |
| 624 field, | 636 field, |
| 637 *password_form, |
| 625 bounding_box_scaled, | 638 bounding_box_scaled, |
| 626 suggestions, | 639 suggestions, |
| 627 realms)); | 640 realms)); |
| 628 return !suggestions.empty(); | 641 return !suggestions.empty(); |
| 629 } | 642 } |
| 630 | 643 |
| 631 void PasswordAutofillAgent::FillFormOnPasswordRecieved( | 644 void PasswordAutofillAgent::FillFormOnPasswordRecieved( |
| 632 const PasswordFormFillData& fill_data, | 645 const PasswordFormFillData& fill_data, |
| 633 blink::WebInputElement username_element, | 646 blink::WebInputElement username_element, |
| 634 blink::WebInputElement password_element) { | 647 blink::WebInputElement password_element) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 } | 837 } |
| 825 | 838 |
| 826 PasswordAutofillAgent::AutofillWebUserGestureHandler:: | 839 PasswordAutofillAgent::AutofillWebUserGestureHandler:: |
| 827 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent) | 840 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent) |
| 828 : agent_(agent) {} | 841 : agent_(agent) {} |
| 829 | 842 |
| 830 PasswordAutofillAgent::AutofillWebUserGestureHandler:: | 843 PasswordAutofillAgent::AutofillWebUserGestureHandler:: |
| 831 ~AutofillWebUserGestureHandler() {} | 844 ~AutofillWebUserGestureHandler() {} |
| 832 | 845 |
| 833 } // namespace autofill | 846 } // namespace autofill |
| OLD | NEW |