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

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

Issue 137893009: [Password Autofill] Catch XHR submitted forms where onsubmit() wasn't called. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 478 }
479 } 479 }
480 return NULL; 480 return NULL;
481 } 481 }
482 482
483 void PasswordAutofillAgent::DidStartProvisionalLoad(blink::WebFrame* frame) { 483 void PasswordAutofillAgent::DidStartProvisionalLoad(blink::WebFrame* frame) {
484 if (!frame->parent()) { 484 if (!frame->parent()) {
485 // If the navigation is not triggered by a user gesture, e.g. by some ajax 485 // If the navigation is not triggered by a user gesture, e.g. by some ajax
486 // callback, then inherit the submitted password form from the previous 486 // callback, then inherit the submitted password form from the previous
487 // state. This fixes the no password save issue for ajax login, tracked in 487 // state. This fixes the no password save issue for ajax login, tracked in
488 // [http://crbug/43219]. Note that there are still some sites that this 488 // [http://crbug/43219]. Note that this still fails for sites that use
489 // fails for because they use some element other than a submit button to 489 // synchonous XHR as isProcessingUserGesture() will return true.
490 // trigger submission (which means WillSendSubmitEvent will not be called).
491 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame); 490 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame);
492 if (!blink::WebUserGestureIndicator::isProcessingUserGesture() && 491 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) {
493 provisionally_saved_forms_[form_frame].get()) { 492 // If onsubmit has been called, try and save that form.
494 Send(new AutofillHostMsg_PasswordFormSubmitted( 493 if (provisionally_saved_forms_[form_frame].get()) {
495 routing_id(), 494 Send(new AutofillHostMsg_PasswordFormSubmitted(
496 *provisionally_saved_forms_[form_frame])); 495 routing_id(),
497 provisionally_saved_forms_.erase(form_frame); 496 *provisionally_saved_forms_[form_frame]));
497 provisionally_saved_forms_.erase(form_frame);
498 } else {
499 // Loop through the forms on the page looking for one that has been
500 // filled out. If one exists, try and save the credentials.
501 blink::WebVector<blink::WebFormElement> forms;
502 frame->document().forms(forms);
503
504 for (size_t i = 0; i < forms.size(); ++i) {
vabr (Chromium) 2014/01/16 09:22:10 If your performance concerns were about this for c
Garrett Casto 2014/01/16 22:23:59 Yeah. From a performance standpoint the most optim
vabr (Chromium) 2014/01/17 09:28:01 Sure, let's wait if we need to optimise this at al
505 blink::WebFormElement fe = forms[i];
506 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(fe));
507 if (password_form.get() &&
508 !password_form->username_value.empty() &&
509 !password_form->password_value.empty()) {
510 Send(new AutofillHostMsg_PasswordFormSubmitted(
511 routing_id(), *password_form));
512 }
513 }
514 }
498 } 515 }
499 // Clear the whole map during main frame navigation. 516 // Clear the whole map during main frame navigation.
500 provisionally_saved_forms_.clear(); 517 provisionally_saved_forms_.clear();
501 518
502 // We are navigating, se we need to wait for a new user gesture before 519 // We are navigating, se we need to wait for a new user gesture before
503 // filling in passwords. 520 // filling in passwords.
504 user_gesture_occurred_ = false; 521 user_gesture_occurred_ = false;
505 gesture_handler_->clearElements(); 522 gesture_handler_->clearElements();
506 } 523 }
507 } 524 }
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 } 857 }
841 858
842 PasswordAutofillAgent::AutofillWebUserGestureHandler:: 859 PasswordAutofillAgent::AutofillWebUserGestureHandler::
843 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent) 860 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent)
844 : agent_(agent) {} 861 : agent_(agent) {}
845 862
846 PasswordAutofillAgent::AutofillWebUserGestureHandler:: 863 PasswordAutofillAgent::AutofillWebUserGestureHandler::
847 ~AutofillWebUserGestureHandler() {} 864 ~AutofillWebUserGestureHandler() {}
848 865
849 } // namespace autofill 866 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698