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

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
« no previous file with comments | « chrome/test/data/password/password_form.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 496 }
497 } 497 }
498 return NULL; 498 return NULL;
499 } 499 }
500 500
501 void PasswordAutofillAgent::DidStartProvisionalLoad(blink::WebFrame* frame) { 501 void PasswordAutofillAgent::DidStartProvisionalLoad(blink::WebFrame* frame) {
502 if (!frame->parent()) { 502 if (!frame->parent()) {
503 // If the navigation is not triggered by a user gesture, e.g. by some ajax 503 // If the navigation is not triggered by a user gesture, e.g. by some ajax
504 // callback, then inherit the submitted password form from the previous 504 // callback, then inherit the submitted password form from the previous
505 // state. This fixes the no password save issue for ajax login, tracked in 505 // state. This fixes the no password save issue for ajax login, tracked in
506 // [http://crbug/43219]. Note that there are still some sites that this 506 // [http://crbug/43219]. Note that this still fails for sites that use
507 // fails for because they use some element other than a submit button to 507 // synchonous XHR as isProcessingUserGesture() will return true.
508 // trigger submission (which means WillSendSubmitEvent will not be called).
509 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame); 508 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame);
510 if (!blink::WebUserGestureIndicator::isProcessingUserGesture() && 509 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) {
511 provisionally_saved_forms_[form_frame].get()) { 510 // If onsubmit has been called, try and save that form.
512 Send(new AutofillHostMsg_PasswordFormSubmitted( 511 if (provisionally_saved_forms_[form_frame].get()) {
513 routing_id(), 512 Send(new AutofillHostMsg_PasswordFormSubmitted(
514 *provisionally_saved_forms_[form_frame])); 513 routing_id(),
515 provisionally_saved_forms_.erase(form_frame); 514 *provisionally_saved_forms_[form_frame]));
515 provisionally_saved_forms_.erase(form_frame);
516 } else {
517 // Loop through the forms on the page looking for one that has been
518 // filled out. If one exists, try and save the credentials.
519 blink::WebVector<blink::WebFormElement> forms;
520 frame->document().forms(forms);
521
522 for (size_t i = 0; i < forms.size(); ++i) {
523 blink::WebFormElement fe = forms[i];
524 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(fe));
525 if (password_form.get() &&
526 !password_form->username_value.empty() &&
527 !password_form->password_value.empty()) {
528 Send(new AutofillHostMsg_PasswordFormSubmitted(
529 routing_id(), *password_form));
530 }
531 }
532 }
516 } 533 }
517 // Clear the whole map during main frame navigation. 534 // Clear the whole map during main frame navigation.
518 provisionally_saved_forms_.clear(); 535 provisionally_saved_forms_.clear();
519 536
520 // We are navigating, se we need to wait for a new user gesture before 537 // We are navigating, se we need to wait for a new user gesture before
521 // filling in passwords. 538 // filling in passwords.
522 user_gesture_occurred_ = false; 539 user_gesture_occurred_ = false;
523 gesture_handler_->clearElements(); 540 gesture_handler_->clearElements();
524 } 541 }
525 } 542 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 } 870 }
854 871
855 PasswordAutofillAgent::AutofillWebUserGestureHandler:: 872 PasswordAutofillAgent::AutofillWebUserGestureHandler::
856 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent) 873 AutofillWebUserGestureHandler(PasswordAutofillAgent* agent)
857 : agent_(agent) {} 874 : agent_(agent) {}
858 875
859 PasswordAutofillAgent::AutofillWebUserGestureHandler:: 876 PasswordAutofillAgent::AutofillWebUserGestureHandler::
860 ~AutofillWebUserGestureHandler() {} 877 ~AutofillWebUserGestureHandler() {}
861 878
862 } // namespace autofill 879 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/data/password/password_form.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698