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

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

Issue 241193002: Password autofill: Check for user gesture switches to new Blink backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OVERRIDE removed test enabled Created 6 years, 8 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 388
389 bool PasswordAutofillAgent::OriginCanAccessPasswordManager( 389 bool PasswordAutofillAgent::OriginCanAccessPasswordManager(
390 const blink::WebSecurityOrigin& origin) { 390 const blink::WebSecurityOrigin& origin) {
391 return origin.canAccessPasswordManager(); 391 return origin.canAccessPasswordManager();
392 } 392 }
393 393
394 void PasswordAutofillAgent::OnDynamicFormsSeen(blink::WebFrame* frame) { 394 void PasswordAutofillAgent::OnDynamicFormsSeen(blink::WebFrame* frame) {
395 SendPasswordForms(frame, false /* only_visible */); 395 SendPasswordForms(frame, false /* only_visible */);
396 } 396 }
397 397
398 void PasswordAutofillAgent::FirstUserGestureObserved() {
399 gatekeeper_.OnUserGesture();
400 }
401
398 void PasswordAutofillAgent::SendPasswordForms(blink::WebFrame* frame, 402 void PasswordAutofillAgent::SendPasswordForms(blink::WebFrame* frame,
399 bool only_visible) { 403 bool only_visible) {
400 // Make sure that this security origin is allowed to use password manager. 404 // Make sure that this security origin is allowed to use password manager.
401 blink::WebSecurityOrigin origin = frame->document().securityOrigin(); 405 blink::WebSecurityOrigin origin = frame->document().securityOrigin();
402 if (!OriginCanAccessPasswordManager(origin)) 406 if (!OriginCanAccessPasswordManager(origin))
403 return; 407 return;
404 408
405 // Checks whether the webpage is a redirect page or an empty page. 409 // Checks whether the webpage is a redirect page or an empty page.
406 if (IsWebpageEmpty(frame)) 410 if (IsWebpageEmpty(frame))
407 return; 411 return;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // the frame starts loading. If there are redirects that cause a new 514 // the frame starts loading. If there are redirects that cause a new
511 // RenderView to be instantiated (such as redirects to the WebStore) 515 // RenderView to be instantiated (such as redirects to the WebStore)
512 // we will never get to finish the load. 516 // we will never get to finish the load.
513 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(), 517 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
514 *submitted_form)); 518 *submitted_form));
515 // Remove reference since we have already submitted this form. 519 // Remove reference since we have already submitted this form.
516 provisionally_saved_forms_.erase(frame); 520 provisionally_saved_forms_.erase(frame);
517 } 521 }
518 } 522 }
519 523
520 void PasswordAutofillAgent::WillProcessUserGesture() {
521 gatekeeper_.OnUserGesture();
522 }
523
524 blink::WebFrame* PasswordAutofillAgent::CurrentOrChildFrameWithSavedForms( 524 blink::WebFrame* PasswordAutofillAgent::CurrentOrChildFrameWithSavedForms(
525 const blink::WebFrame* current_frame) { 525 const blink::WebFrame* current_frame) {
526 for (FrameToPasswordFormMap::const_iterator it = 526 for (FrameToPasswordFormMap::const_iterator it =
527 provisionally_saved_forms_.begin(); 527 provisionally_saved_forms_.begin();
528 it != provisionally_saved_forms_.end(); 528 it != provisionally_saved_forms_.end();
529 ++it) { 529 ++it) {
530 blink::WebFrame* form_frame = it->first; 530 blink::WebFrame* form_frame = it->first;
531 // The check that the returned frame is related to |current_frame| is mainly 531 // The check that the returned frame is related to |current_frame| is mainly
532 // for double-checking. There should not be any unrelated frames in 532 // for double-checking. There should not be any unrelated frames in
533 // |provisionally_saved_forms_|, because the map is cleared after 533 // |provisionally_saved_forms_|, because the map is cleared after
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 if (set_selection) { 811 if (set_selection) {
812 username_element->setSelectionRange(current_username.length(), 812 username_element->setSelectionRange(current_username.length(),
813 username.length()); 813 username.length());
814 } 814 }
815 } else if (current_username != username) { 815 } else if (current_username != username) {
816 // If the username can't be filled and it doesn't match a saved password 816 // If the username can't be filled and it doesn't match a saved password
817 // as is, don't autofill a password. 817 // as is, don't autofill a password.
818 return false; 818 return false;
819 } 819 }
820 820
821 // TODO(vabr): The "gatekeeper" feature is currently disabled on mobile.
822 // http://crbug.com/345510#c13
823 #if !defined(OS_ANDROID) || !defined(OS_IOS)
824 // Wait to fill in the password until a user gesture occurs. This is to make 821 // Wait to fill in the password until a user gesture occurs. This is to make
825 // sure that we do not fill in the DOM with a password until we believe the 822 // sure that we do not fill in the DOM with a password until we believe the
826 // user is intentionally interacting with the page. 823 // user is intentionally interacting with the page.
827 password_element->setSuggestedValue(password); 824 password_element->setSuggestedValue(password);
828 gatekeeper_.RegisterElement(password_element); 825 gatekeeper_.RegisterElement(password_element);
829 #else
830 password_element->setValue(password);
831 #endif
832 826
833 password_element->setAutofilled(true); 827 password_element->setAutofilled(true);
834 return true; 828 return true;
835 } 829 }
836 830
837 void PasswordAutofillAgent::PerformInlineAutocomplete( 831 void PasswordAutofillAgent::PerformInlineAutocomplete(
838 const blink::WebInputElement& username_input, 832 const blink::WebInputElement& username_input,
839 const blink::WebInputElement& password_input, 833 const blink::WebInputElement& password_input,
840 const PasswordFormFillData& fill_data) { 834 const PasswordFormFillData& fill_data) {
841 DCHECK(!fill_data.wait_for_username); 835 DCHECK(!fill_data.wait_for_username);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 890 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
897 if (iter == login_to_password_info_.end()) 891 if (iter == login_to_password_info_.end())
898 return false; 892 return false;
899 893
900 *found_input = input; 894 *found_input = input;
901 *found_password = iter->second; 895 *found_password = iter->second;
902 return true; 896 return true;
903 } 897 }
904 898
905 } // namespace autofill 899 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698