OLD | NEW |
---|---|
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 Loading... | |
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::AcceptAutofillSuggestion( |
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 if (IsElementAutocompletable(username_element) && |
363 // will do the rest. | 364 IsElementAutocompletable(password_info.password_field)) { |
Ilya Sherman
2014/03/28 21:33:34
nit: I would invert this condition and include an
Patrick Dubroy
2014/04/01 16:08:48
Done.
| |
364 input.setValue(username, true); | 365 base::string16 current_username = username_element.value(); |
365 return FillUserNameAndPassword(&input, &password.password_field, | 366 username_element.setValue(username, true); |
366 password.fill_data, | 367 SetElementAutofilled(&username_element, true); |
367 true /* exact_username_match */, | 368 username_element.setSelectionRange(current_username.length(), |
368 true /* set_selection */); | 369 username.length()); |
370 | |
371 password_info.password_field.setValue(password, true); | |
372 SetElementAutofilled(&password_info.password_field, true); | |
373 } | |
374 | |
375 return true; | |
369 } | 376 } |
Ilya Sherman
2014/03/28 21:33:34
Could you please add test coverage for this method
Patrick Dubroy
2014/04/01 16:08:48
Done. In doing so, I did noticed some weird behavi
Garrett Casto
2014/04/01 17:32:21
I think that this was an oversight, but note that
| |
370 | 377 |
371 bool PasswordAutofillAgent::DidClearAutofillSelection( | 378 bool PasswordAutofillAgent::DidClearAutofillSelection( |
372 const blink::WebNode& node) { | 379 const blink::WebNode& node) { |
373 blink::WebInputElement input; | 380 blink::WebInputElement input; |
374 PasswordInfo password; | 381 PasswordInfo password; |
375 return FindLoginInfo(node, &input, &password); | 382 return FindLoginInfo(node, &input, &password); |
376 } | 383 } |
377 | 384 |
378 bool PasswordAutofillAgent::ShowSuggestions( | 385 bool PasswordAutofillAgent::ShowSuggestions( |
379 const blink::WebInputElement& element) { | 386 const blink::WebInputElement& element) { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 912 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
906 if (iter == login_to_password_info_.end()) | 913 if (iter == login_to_password_info_.end()) |
907 return false; | 914 return false; |
908 | 915 |
909 *found_input = input; | 916 *found_input = input; |
910 *found_password = iter->second; | 917 *found_password = iter->second; |
911 return true; | 918 return true; |
912 } | 919 } |
913 | 920 |
914 } // namespace autofill | 921 } // namespace autofill |
OLD | NEW |