Chromium Code Reviews| 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 | |
| 564 FormElementsList forms; | |
| 565 // We own the FormElements* in forms. | |
|
vabr (Chromium)
2014/02/05 20:34:20
nit: Add the vertical bars around forms: |forms|,
vabr (Chromium)
2014/02/05 20:34:20
Actually, could you please remove the comment? It
riadh.chtara
2014/02/11 21:03:46
Done.
riadh.chtara
2014/02/11 21:03:46
Done.
riadh.chtara
2014/02/11 21:03:46
Done.
| |
| 566 blink::WebInputElement username_element; | |
| 567 FindFormElements(render_view()->GetWebView(), password_form.form_data, &forms) ; | |
|
vabr (Chromium)
2014/02/05 20:34:20
This line, and a couple of lines below, seem to be
riadh.chtara
2014/02/11 21:03:46
Done.
| |
| 568 FormElementsList::iterator iter; | |
| 569 for (iter = forms.begin(); iter != forms.end(); ++iter) { | |
| 570 scoped_ptr<FormElements> form_elements(*iter); | |
|
vabr (Chromium)
2014/02/05 20:34:20
Please don't do this. If you leave the for cycle e
| |
| 571 | |
| 572 // First, get pointers to username element. | |
| 573 username_element = | |
| 574 form_elements->input_elements[password_form.form_data.fields[0].name]; | |
| 575 if (login_to_password_info_.find(username_element) != | |
|
vabr (Chromium)
2014/02/05 20:34:20
Please prefer ContainsKey from base/stl_util.h to
vabr (Chromium)
2014/02/05 20:34:20
nit: Instead of doing
for (...) {
if (condition
riadh.chtara
2014/02/11 21:03:46
Done.
riadh.chtara
2014/02/11 21:03:46
Done.
| |
| 576 login_to_password_info_.end()) { | |
| 577 login_to_password_info_.erase(username_element); | |
| 578 Send(new AutofillHostMsg_RemovePasswordSuggestion(routing_id(), | |
| 579 password_form)); | |
|
vabr (Chromium)
2014/02/05 20:34:20
Please indent correctly.
riadh.chtara
2014/02/11 21:03:46
Done.
| |
| 580 std::vector<PasswordForm> password_forms; | |
| 581 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(username_element .form())); | |
|
vabr (Chromium)
2014/02/05 20:34:20
Also, note that now you have a name collision: the
riadh.chtara
2014/02/11 21:03:46
Done.
| |
| 582 if (password_form.get()) { | |
| 583 password_forms.push_back(*password_form); | |
| 584 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_form s)); | |
|
vabr (Chromium)
2014/02/05 20:34:20
I'm not sure I follow you here: Why are you sendin
riadh.chtara
2014/02/11 21:03:46
|AutofillHostMsg_PasswordFormsParsed| is sent so t
| |
| 585 } | |
| 586 break; | |
| 587 } | |
| 588 } | |
| 589 } | |
| 590 | |
| 559 //////////////////////////////////////////////////////////////////////////////// | 591 //////////////////////////////////////////////////////////////////////////////// |
| 560 // PasswordAutofillAgent, private: | 592 // PasswordAutofillAgent, private: |
| 561 | 593 |
| 562 void PasswordAutofillAgent::GetSuggestions( | 594 void PasswordAutofillAgent::GetSuggestions( |
| 563 const PasswordFormFillData& fill_data, | 595 const PasswordFormFillData& fill_data, |
| 564 const base::string16& input, | 596 const base::string16& input, |
| 565 std::vector<base::string16>* suggestions, | 597 std::vector<base::string16>* suggestions, |
| 566 std::vector<base::string16>* realms) { | 598 std::vector<base::string16>* realms) { |
| 567 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { | 599 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { |
| 568 suggestions->push_back(fill_data.basic_data.fields[0].value); | 600 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; | 637 std::vector<base::string16> suggestions; |
| 606 std::vector<base::string16> realms; | 638 std::vector<base::string16> realms; |
| 607 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); | 639 GetSuggestions(fill_data, user_input.value(), &suggestions, &realms); |
| 608 DCHECK_EQ(suggestions.size(), realms.size()); | 640 DCHECK_EQ(suggestions.size(), realms.size()); |
| 609 | 641 |
| 610 FormData form; | 642 FormData form; |
| 611 FormFieldData field; | 643 FormFieldData field; |
| 612 FindFormAndFieldForInputElement( | 644 FindFormAndFieldForInputElement( |
| 613 user_input, &form, &field, REQUIRE_NONE); | 645 user_input, &form, &field, REQUIRE_NONE); |
| 614 | 646 |
| 647 scoped_ptr<PasswordForm> password_form = | |
| 648 CreatePasswordForm(user_input.form()); | |
| 649 DCHECK(password_form); | |
| 650 | |
| 615 blink::WebInputElement selected_element = user_input; | 651 blink::WebInputElement selected_element = user_input; |
| 616 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 652 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
| 617 | 653 |
| 618 float scale = web_view_->pageScaleFactor(); | 654 float scale = web_view_->pageScaleFactor(); |
| 619 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 655 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
| 620 bounding_box.y() * scale, | 656 bounding_box.y() * scale, |
| 621 bounding_box.width() * scale, | 657 bounding_box.width() * scale, |
| 622 bounding_box.height() * scale); | 658 bounding_box.height() * scale); |
| 623 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), | 659 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), |
| 624 field, | 660 field, |
| 661 *password_form, | |
| 625 bounding_box_scaled, | 662 bounding_box_scaled, |
| 626 suggestions, | 663 suggestions, |
| 627 realms)); | 664 realms)); |
| 628 return !suggestions.empty(); | 665 return !suggestions.empty(); |
| 629 } | 666 } |
| 630 | 667 |
| 631 void PasswordAutofillAgent::FillFormOnPasswordRecieved( | 668 void PasswordAutofillAgent::FillFormOnPasswordRecieved( |
| 632 const PasswordFormFillData& fill_data, | 669 const PasswordFormFillData& fill_data, |
| 633 blink::WebInputElement username_element, | 670 blink::WebInputElement username_element, |
| 634 blink::WebInputElement password_element) { | 671 blink::WebInputElement password_element) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 } | 861 } |
| 825 | 862 |
| 826 PasswordAutofillAgent::AutofillWebUserGestureHandler:: | 863 PasswordAutofillAgent::AutofillWebUserGestureHandler:: |
| 827 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent) | 864 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent) |
| 828 : agent_(agent) {} | 865 : agent_(agent) {} |
| 829 | 866 |
| 830 PasswordAutofillAgent::AutofillWebUserGestureHandler:: | 867 PasswordAutofillAgent::AutofillWebUserGestureHandler:: |
| 831 ~AutofillWebUserGestureHandler() {} | 868 ~AutofillWebUserGestureHandler() {} |
| 832 | 869 |
| 833 } // namespace autofill | 870 } // namespace autofill |
| OLD | NEW |