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

Side by Side Diff: chrome/renderer/autofill/password_autofill_manager.cc

Issue 9625026: Save password without an associated username. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 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
« no previous file with comments | « chrome/browser/password_manager/password_form_manager.cc ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/renderer/autofill/password_autofill_manager.h" 5 #include "chrome/renderer/autofill/password_autofill_manager.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.h" 9 #include "base/message_loop.h"
10 #include "chrome/common/autofill_messages.h" 10 #include "chrome/common/autofill_messages.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 static bool FindFormInputElements(WebKit::WebFormElement* fe, 48 static bool FindFormInputElements(WebKit::WebFormElement* fe,
49 const webkit::forms::FormData& data, 49 const webkit::forms::FormData& data,
50 FormElements* result) { 50 FormElements* result) {
51 // Loop through the list of elements we need to find on the form in order to 51 // Loop through the list of elements we need to find on the form in order to
52 // autofill it. If we don't find any one of them, abort processing this 52 // autofill it. If we don't find any one of them, abort processing this
53 // form; it can't be the right one. 53 // form; it can't be the right one.
54 for (size_t j = 0; j < data.fields.size(); j++) { 54 for (size_t j = 0; j < data.fields.size(); j++) {
55 WebKit::WebVector<WebKit::WebNode> temp_elements; 55 WebKit::WebVector<WebKit::WebNode> temp_elements;
56 fe->getNamedElements(data.fields[j].name, temp_elements); 56 fe->getNamedElements(data.fields[j].name, temp_elements);
57 57
58 // It's true if the form hasn't the user_name elemtnt for the password.
59 // In this case, we just skip and continue to autofill,
60 // because we'd like to autofill the password if user_name doesn't exist.
61 if (temp_elements.size() == 0) {
62 continue;
63 }
Ilya Sherman 2012/03/08 23:48:49 This doesn't seem like the right change. We shoul
Yumikiyo Osanai 2012/03/20 15:53:37 Done.
64
58 // Match the first input element, if any. 65 // Match the first input element, if any.
59 // |getNamedElements| may return non-input elements where the names match, 66 // |getNamedElements| may return non-input elements where the names match,
60 // so the results are filtered for input elements. 67 // so the results are filtered for input elements.
61 // If more than one match is made, then we have ambiguity (due to misuse 68 // If more than one match is made, then we have ambiguity (due to misuse
62 // of "name" attribute) so is it considered not found. 69 // of "name" attribute) so is it considered not found.
63 bool found_input = false; 70 bool found_input = false;
64 for (size_t i = 0; i < temp_elements.size(); ++i) { 71 for (size_t i = 0; i < temp_elements.size(); ++i) {
65 if (temp_elements[i].to<WebKit::WebElement>().hasTagName("input")) { 72 if (temp_elements[i].to<WebKit::WebElement>().hasTagName("input")) {
66 // Check for a non-unique match. 73 // Check for a non-unique match.
67 if (found_input) { 74 if (found_input) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 442
436 // We might have already filled this form if there are two <form> elements 443 // We might have already filled this form if there are two <form> elements
437 // with identical markup. 444 // with identical markup.
438 if (login_to_password_info_.find(username_element) != 445 if (login_to_password_info_.find(username_element) !=
439 login_to_password_info_.end()) 446 login_to_password_info_.end())
440 continue; 447 continue;
441 448
442 PasswordInfo password_info; 449 PasswordInfo password_info;
443 password_info.fill_data = form_data; 450 password_info.fill_data = form_data;
444 password_info.password_field = password_element; 451 password_info.password_field = password_element;
445 login_to_password_info_[username_element] = password_info; 452 login_to_password_info_[password_element] = password_info;
446 } 453 }
447 } 454 }
448 455
449 //////////////////////////////////////////////////////////////////////////////// 456 ////////////////////////////////////////////////////////////////////////////////
450 // PasswordAutofillManager, private: 457 // PasswordAutofillManager, private:
451 458
452 void PasswordAutofillManager::GetSuggestions( 459 void PasswordAutofillManager::GetSuggestions(
453 const webkit::forms::PasswordFormFillData& fill_data, 460 const webkit::forms::PasswordFormFillData& fill_data,
454 const string16& input, 461 const string16& input,
455 std::vector<string16>* suggestions) { 462 std::vector<string16>* suggestions) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 593 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
587 if (iter == login_to_password_info_.end()) 594 if (iter == login_to_password_info_.end())
588 return false; 595 return false;
589 596
590 *found_input = input; 597 *found_input = input;
591 *found_password = iter->second; 598 *found_password = iter->second;
592 return true; 599 return true;
593 } 600 }
594 601
595 } // namespace autofill 602 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_form_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698