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

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

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address gcasto's comments. Created 6 years, 9 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(element); 344 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(element);
345 if (iter == login_to_password_info_.end()) 345 if (iter == login_to_password_info_.end())
346 return false; 346 return false;
347 347
348 int win_key_code = event.windowsKeyCode; 348 int win_key_code = event.windowsKeyCode;
349 iter->second.backspace_pressed_last = 349 iter->second.backspace_pressed_last =
350 (win_key_code == ui::VKEY_BACK || win_key_code == ui::VKEY_DELETE); 350 (win_key_code == ui::VKEY_BACK || win_key_code == ui::VKEY_DELETE);
351 return true; 351 return true;
352 } 352 }
353 353
354 bool PasswordAutofillAgent::DidAcceptAutofillSuggestion( 354 bool PasswordAutofillAgent::AcceptAutofillSuggestionWithPassword(
355 const blink::WebNode& node, 355 const blink::WebNode& node,
356 const blink::WebString& username) { 356 const blink::WebString& username,
357 blink::WebInputElement input; 357 const blink::WebString& password) {
358 PasswordInfo password; 358 blink::WebInputElement username_element;
359 if (!FindLoginInfo(node, &input, &password)) 359 PasswordInfo password_info;
360 if (!FindLoginInfo(node, &username_element, &password_info))
360 return false; 361 return false;
361 362
362 // Set the incoming |username| in the text field and |FillUserNameAndPassword| 363 username_element.setValue(username, true);
363 // will do the rest. 364 SetElementAutofilled(&username_element, true);
Ilya Sherman 2014/03/18 00:14:27 Hmm, this is missing IsElementAutocompletable() ch
Patrick Dubroy 2014/03/28 15:44:22 No, that was an oversight. Fixed.
364 input.setValue(username, true); 365
365 return FillUserNameAndPassword(&input, &password.password_field, 366 password_info.password_field.setValue(password, true);
366 password.fill_data, 367 SetElementAutofilled(&password_info.password_field, true);
367 true /* exact_username_match */, 368
368 true /* set_selection */); 369 return true;
369 } 370 }
370 371
371 bool PasswordAutofillAgent::DidClearAutofillSelection( 372 bool PasswordAutofillAgent::DidClearAutofillSelection(
372 const blink::WebNode& node) { 373 const blink::WebNode& node) {
373 blink::WebInputElement input; 374 blink::WebInputElement input;
374 PasswordInfo password; 375 PasswordInfo password;
375 return FindLoginInfo(node, &input, &password); 376 return FindLoginInfo(node, &input, &password);
376 } 377 }
377 378
378 bool PasswordAutofillAgent::ShowSuggestions( 379 bool PasswordAutofillAgent::ShowSuggestions(
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 906 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
906 if (iter == login_to_password_info_.end()) 907 if (iter == login_to_password_info_.end())
907 return false; 908 return false;
908 909
909 *found_input = input; 910 *found_input = input;
910 *found_password = iter->second; 911 *found_password = iter->second;
911 return true; 912 return true;
912 } 913 }
913 914
914 } // namespace autofill 915 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698