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