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

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: Actually fix compile failure. 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(element); 337 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(element);
338 if (iter == login_to_password_info_.end()) 338 if (iter == login_to_password_info_.end())
339 return false; 339 return false;
340 340
341 int win_key_code = event.windowsKeyCode; 341 int win_key_code = event.windowsKeyCode;
342 iter->second.backspace_pressed_last = 342 iter->second.backspace_pressed_last =
343 (win_key_code == ui::VKEY_BACK || win_key_code == ui::VKEY_DELETE); 343 (win_key_code == ui::VKEY_BACK || win_key_code == ui::VKEY_DELETE);
344 return true; 344 return true;
345 } 345 }
346 346
347 bool PasswordAutofillAgent::DidAcceptAutofillSuggestion( 347 bool PasswordAutofillAgent::AcceptSuggestion(
348 const blink::WebNode& node, 348 const blink::WebNode& node,
349 const blink::WebString& username) { 349 const blink::WebString& username,
350 blink::WebInputElement input; 350 const blink::WebString& password) {
351 PasswordInfo password; 351 blink::WebInputElement username_element;
352 if (!FindLoginInfo(node, &input, &password)) 352 PasswordInfo password_info;
353
354 if (!FindLoginInfo(node, &username_element, &password_info) ||
355 !IsElementAutocompletable(username_element) ||
356 !IsElementAutocompletable(password_info.password_field)) {
353 return false; 357 return false;
358 }
354 359
355 // Set the incoming |username| in the text field and |FillUserNameAndPassword| 360 base::string16 current_username = username_element.value();
356 // will do the rest. 361 username_element.setValue(username, true);
357 input.setValue(username, true); 362 username_element.setAutofilled(true);
358 return FillUserNameAndPassword(&input, &password.password_field, 363 username_element.setSelectionRange(current_username.length(),
359 password.fill_data, 364 username.length());
360 true /* exact_username_match */, 365
361 true /* set_selection */); 366 password_info.password_field.setValue(password, true);
367 password_info.password_field.setAutofilled(true);
368
369 return true;
362 } 370 }
363 371
364 bool PasswordAutofillAgent::DidClearAutofillSelection( 372 bool PasswordAutofillAgent::DidClearAutofillSelection(
365 const blink::WebNode& node) { 373 const blink::WebNode& node) {
366 blink::WebInputElement input; 374 blink::WebInputElement input;
367 PasswordInfo password; 375 PasswordInfo password;
368 return FindLoginInfo(node, &input, &password); 376 return FindLoginInfo(node, &input, &password);
369 } 377 }
370 378
371 bool PasswordAutofillAgent::ShowSuggestions( 379 bool PasswordAutofillAgent::ShowSuggestions(
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 898 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
891 if (iter == login_to_password_info_.end()) 899 if (iter == login_to_password_info_.end())
892 return false; 900 return false;
893 901
894 *found_input = input; 902 *found_input = input;
895 *found_password = iter->second; 903 *found_password = iter->second;
896 return true; 904 return true;
897 } 905 }
898 906
899 } // namespace autofill 907 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/password_autofill_agent.h ('k') | components/autofill/core/browser/autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698