Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: components/autofill/content/renderer/password_autofill_agent.cc

Issue 293093002: Don't show "Save password" prompt for a failed login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id())); 237 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id()));
237 } 238 }
238 239
239 PasswordAutofillAgent::~PasswordAutofillAgent() { 240 PasswordAutofillAgent::~PasswordAutofillAgent() {
240 } 241 }
241 242
242 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() 243 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper()
243 : was_user_gesture_seen_(false) { 244 : was_user_gesture_seen_(false) {
244 } 245 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 529
529 if (password_forms.empty() && !only_visible) { 530 if (password_forms.empty() && !only_visible) {
530 // We need to send the PasswordFormsRendered message regardless of whether 531 // We need to send the PasswordFormsRendered message regardless of whether
531 // there are any forms visible, as this is also the code path that triggers 532 // there are any forms visible, as this is also the code path that triggers
532 // showing the infobar. 533 // showing the infobar.
533 return; 534 return;
534 } 535 }
535 536
536 if (only_visible) { 537 if (only_visible) {
537 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), 538 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(),
538 password_forms)); 539 password_forms,
540 did_stop_loading_));
539 } else { 541 } else {
540 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); 542 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms));
541 } 543 }
542 } 544 }
543 545
544 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { 546 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) {
545 bool handled = true; 547 bool handled = true;
546 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) 548 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message)
547 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) 549 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm)
548 IPC_MESSAGE_HANDLER(AutofillMsg_SetLoggingState, OnSetLoggingState) 550 IPC_MESSAGE_HANDLER(AutofillMsg_SetLoggingState, OnSetLoggingState)
549 IPC_MESSAGE_UNHANDLED(handled = false) 551 IPC_MESSAGE_UNHANDLED(handled = false)
550 IPC_END_MESSAGE_MAP() 552 IPC_END_MESSAGE_MAP()
551 return handled; 553 return handled;
552 } 554 }
553 555
554 void PasswordAutofillAgent::DidStartLoading() { 556 void PasswordAutofillAgent::DidStartLoading() {
557 did_stop_loading_ = false;
555 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { 558 if (usernames_usage_ != NOTHING_TO_AUTOFILL) {
556 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", 559 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage",
557 usernames_usage_, 560 usernames_usage_,
558 OTHER_POSSIBLE_USERNAMES_MAX); 561 OTHER_POSSIBLE_USERNAMES_MAX);
559 usernames_usage_ = NOTHING_TO_AUTOFILL; 562 usernames_usage_ = NOTHING_TO_AUTOFILL;
560 } 563 }
561 } 564 }
562 565
563 void PasswordAutofillAgent::DidFinishDocumentLoad(blink::WebLocalFrame* frame) { 566 void PasswordAutofillAgent::DidFinishDocumentLoad(blink::WebLocalFrame* frame) {
564 // The |frame| contents have been parsed, but not yet rendered. Let the 567 // The |frame| contents have been parsed, but not yet rendered. Let the
565 // PasswordManager know that forms are loaded, even though we can't yet tell 568 // PasswordManager know that forms are loaded, even though we can't yet tell
566 // whether they're visible. 569 // whether they're visible.
567 SendPasswordForms(frame, false); 570 SendPasswordForms(frame, false);
568 } 571 }
569 572
570 void PasswordAutofillAgent::DidFinishLoad(blink::WebLocalFrame* frame) { 573 void PasswordAutofillAgent::DidFinishLoad(blink::WebLocalFrame* frame) {
571 // The |frame| contents have been rendered. Let the PasswordManager know 574 // The |frame| contents have been rendered. Let the PasswordManager know
572 // which of the loaded frames are actually visible to the user. This also 575 // which of the loaded frames are actually visible to the user. This also
573 // triggers the "Save password?" infobar if the user just submitted a password 576 // triggers the "Save password?" infobar if the user just submitted a password
574 // form. 577 // form.
575 SendPasswordForms(frame, true); 578 SendPasswordForms(frame, true);
576 } 579 }
577 580
581 void PasswordAutofillAgent::DidStopLoading() {
582 did_stop_loading_ = true;
583 }
584
578 void PasswordAutofillAgent::FrameDetached(blink::WebFrame* frame) { 585 void PasswordAutofillAgent::FrameDetached(blink::WebFrame* frame) {
579 FrameClosing(frame); 586 FrameClosing(frame);
580 } 587 }
581 588
582 void PasswordAutofillAgent::FrameWillClose(blink::WebFrame* frame) { 589 void PasswordAutofillAgent::FrameWillClose(blink::WebFrame* frame) {
583 FrameClosing(frame); 590 FrameClosing(frame);
584 } 591 }
585 592
586 void PasswordAutofillAgent::WillSendSubmitEvent( 593 void PasswordAutofillAgent::WillSendSubmitEvent(
587 blink::WebLocalFrame* frame, 594 blink::WebLocalFrame* frame,
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 username->setSelectionRange(username_selection_start_, 1074 username->setSelectionRange(username_selection_start_,
1068 username->value().length()); 1075 username->value().length());
1069 } 1076 }
1070 if (!password->suggestedValue().isEmpty()) { 1077 if (!password->suggestedValue().isEmpty()) {
1071 password->setSuggestedValue(blink::WebString()); 1078 password->setSuggestedValue(blink::WebString());
1072 password->setAutofilled(was_password_autofilled_); 1079 password->setAutofilled(was_password_autofilled_);
1073 } 1080 }
1074 } 1081 }
1075 1082
1076 } // namespace autofill 1083 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698