| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // PasswordAutofillAgent, public: | 225 // PasswordAutofillAgent, public: |
| 226 | 226 |
| 227 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view) | 227 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view) |
| 228 : content::RenderViewObserver(render_view), | 228 : content::RenderViewObserver(render_view), |
| 229 usernames_usage_(NOTHING_TO_AUTOFILL), | 229 usernames_usage_(NOTHING_TO_AUTOFILL), |
| 230 web_view_(render_view->GetWebView()), | 230 web_view_(render_view->GetWebView()), |
| 231 logging_state_active_(false), | 231 logging_state_active_(false), |
| 232 was_username_autofilled_(false), | 232 was_username_autofilled_(false), |
| 233 was_password_autofilled_(false), | 233 was_password_autofilled_(false), |
| 234 username_selection_start_(0), | 234 username_selection_start_(0), |
| 235 did_stop_loading_(false), |
| 235 weak_ptr_factory_(this) { | 236 weak_ptr_factory_(this) { |
| 236 } | 237 } |
| 237 | 238 |
| 238 PasswordAutofillAgent::~PasswordAutofillAgent() { | 239 PasswordAutofillAgent::~PasswordAutofillAgent() { |
| 239 } | 240 } |
| 240 | 241 |
| 241 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() | 242 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() |
| 242 : was_user_gesture_seen_(false) { | 243 : was_user_gesture_seen_(false) { |
| 243 } | 244 } |
| 244 | 245 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 532 |
| 532 if (password_forms.empty() && !only_visible) { | 533 if (password_forms.empty() && !only_visible) { |
| 533 // We need to send the PasswordFormsRendered message regardless of whether | 534 // We need to send the PasswordFormsRendered message regardless of whether |
| 534 // there are any forms visible, as this is also the code path that triggers | 535 // there are any forms visible, as this is also the code path that triggers |
| 535 // showing the infobar. | 536 // showing the infobar. |
| 536 return; | 537 return; |
| 537 } | 538 } |
| 538 | 539 |
| 539 if (only_visible) { | 540 if (only_visible) { |
| 540 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), | 541 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), |
| 541 password_forms)); | 542 password_forms, |
| 543 did_stop_loading_)); |
| 542 } else { | 544 } else { |
| 543 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); | 545 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); |
| 544 } | 546 } |
| 545 } | 547 } |
| 546 | 548 |
| 547 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { | 549 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { |
| 548 bool handled = true; | 550 bool handled = true; |
| 549 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) | 551 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) |
| 550 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) | 552 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) |
| 551 IPC_MESSAGE_HANDLER(AutofillMsg_ChangeLoggingState, OnChangeLoggingState) | 553 IPC_MESSAGE_HANDLER(AutofillMsg_ChangeLoggingState, OnChangeLoggingState) |
| 552 IPC_MESSAGE_UNHANDLED(handled = false) | 554 IPC_MESSAGE_UNHANDLED(handled = false) |
| 553 IPC_END_MESSAGE_MAP() | 555 IPC_END_MESSAGE_MAP() |
| 554 return handled; | 556 return handled; |
| 555 } | 557 } |
| 556 | 558 |
| 557 void PasswordAutofillAgent::DidStartLoading() { | 559 void PasswordAutofillAgent::DidStartLoading() { |
| 560 did_stop_loading_ = false; |
| 558 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { | 561 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { |
| 559 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", | 562 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", |
| 560 usernames_usage_, | 563 usernames_usage_, |
| 561 OTHER_POSSIBLE_USERNAMES_MAX); | 564 OTHER_POSSIBLE_USERNAMES_MAX); |
| 562 usernames_usage_ = NOTHING_TO_AUTOFILL; | 565 usernames_usage_ = NOTHING_TO_AUTOFILL; |
| 563 } | 566 } |
| 564 } | 567 } |
| 565 | 568 |
| 566 void PasswordAutofillAgent::DidFinishDocumentLoad(blink::WebLocalFrame* frame) { | 569 void PasswordAutofillAgent::DidFinishDocumentLoad(blink::WebLocalFrame* frame) { |
| 567 // The |frame| contents have been parsed, but not yet rendered. Let the | 570 // The |frame| contents have been parsed, but not yet rendered. Let the |
| 568 // PasswordManager know that forms are loaded, even though we can't yet tell | 571 // PasswordManager know that forms are loaded, even though we can't yet tell |
| 569 // whether they're visible. | 572 // whether they're visible. |
| 570 SendPasswordForms(frame, false); | 573 SendPasswordForms(frame, false); |
| 571 } | 574 } |
| 572 | 575 |
| 573 void PasswordAutofillAgent::DidFinishLoad(blink::WebLocalFrame* frame) { | 576 void PasswordAutofillAgent::DidFinishLoad(blink::WebLocalFrame* frame) { |
| 574 // The |frame| contents have been rendered. Let the PasswordManager know | 577 // The |frame| contents have been rendered. Let the PasswordManager know |
| 575 // which of the loaded frames are actually visible to the user. This also | 578 // which of the loaded frames are actually visible to the user. This also |
| 576 // triggers the "Save password?" infobar if the user just submitted a password | 579 // triggers the "Save password?" infobar if the user just submitted a password |
| 577 // form. | 580 // form. |
| 578 SendPasswordForms(frame, true); | 581 SendPasswordForms(frame, true); |
| 579 } | 582 } |
| 580 | 583 |
| 584 void PasswordAutofillAgent::DidStopLoading() { |
| 585 did_stop_loading_ = true; |
| 586 } |
| 587 |
| 581 void PasswordAutofillAgent::FrameDetached(blink::WebFrame* frame) { | 588 void PasswordAutofillAgent::FrameDetached(blink::WebFrame* frame) { |
| 582 FrameClosing(frame); | 589 FrameClosing(frame); |
| 583 } | 590 } |
| 584 | 591 |
| 585 void PasswordAutofillAgent::FrameWillClose(blink::WebFrame* frame) { | 592 void PasswordAutofillAgent::FrameWillClose(blink::WebFrame* frame) { |
| 586 FrameClosing(frame); | 593 FrameClosing(frame); |
| 587 } | 594 } |
| 588 | 595 |
| 589 void PasswordAutofillAgent::WillSendSubmitEvent( | 596 void PasswordAutofillAgent::WillSendSubmitEvent( |
| 590 blink::WebLocalFrame* frame, | 597 blink::WebLocalFrame* frame, |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 username->setSelectionRange(username_selection_start_, | 1077 username->setSelectionRange(username_selection_start_, |
| 1071 username->value().length()); | 1078 username->value().length()); |
| 1072 } | 1079 } |
| 1073 if (!password->suggestedValue().isEmpty()) { | 1080 if (!password->suggestedValue().isEmpty()) { |
| 1074 password->setSuggestedValue(blink::WebString()); | 1081 password->setSuggestedValue(blink::WebString()); |
| 1075 password->setAutofilled(was_password_autofilled_); | 1082 password->setAutofilled(was_password_autofilled_); |
| 1076 } | 1083 } |
| 1077 } | 1084 } |
| 1078 | 1085 |
| 1079 } // namespace autofill | 1086 } // namespace autofill |
| OLD | NEW |