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

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

Issue 6896036: Autofill passwords after re-opening tab containing a login page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « no previous file | chrome/renderer/autofill/password_autofill_manager_unittest.cc » ('j') | 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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/common/autofill_messages.h" 9 #include "chrome/common/autofill_messages.h"
10 #include "content/renderer/render_view.h" 10 #include "content/renderer/render_view.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (!fe->form_element.autoComplete()) 151 if (!fe->form_element.autoComplete())
152 return; 152 return;
153 153
154 std::map<string16, string16> data_map; 154 std::map<string16, string16> data_map;
155 for (size_t i = 0; i < data.fields.size(); i++) 155 for (size_t i = 0; i < data.fields.size(); i++)
156 data_map[data.fields[i].name] = data.fields[i].value; 156 data_map[data.fields[i].name] = data.fields[i].value;
157 157
158 for (FormInputElementMap::iterator it = fe->input_elements.begin(); 158 for (FormInputElementMap::iterator it = fe->input_elements.begin();
159 it != fe->input_elements.end(); ++it) { 159 it != fe->input_elements.end(); ++it) {
160 WebKit::WebInputElement element = it->second; 160 WebKit::WebInputElement element = it->second;
161 // Don't fill a form that has pre-filled values. 161 // Don't fill a form that has pre-filled values distinct from the ones we
162 if (!element.value().isEmpty()) 162 // want to fill with.
163 if (!element.value().isEmpty() && element.value() != data_map[it->first])
163 return; 164 return;
164 } 165 }
165 166
166 for (FormInputElementMap::iterator it = fe->input_elements.begin(); 167 for (FormInputElementMap::iterator it = fe->input_elements.begin();
167 it != fe->input_elements.end(); ++it) { 168 it != fe->input_elements.end(); ++it) {
168 WebKit::WebInputElement element = it->second; 169 WebKit::WebInputElement element = it->second;
169 DCHECK(element.value().isEmpty());
170 if (!IsElementEditable(element)) 170 if (!IsElementEditable(element))
171 continue; // Don't fill uneditable fields. 171 continue; // Don't fill uneditable fields.
172 172
173 // TODO(tkent): Check maxlength and pattern. 173 // TODO(tkent): Check maxlength and pattern.
174 element.setValue(data_map[it->first]); 174 element.setValue(data_map[it->first]);
175 element.setAutofilled(true); 175 element.setAutofilled(true);
176 element.dispatchFormControlChangeEvent(); 176 element.dispatchFormControlChangeEvent();
177 } 177 }
178 } 178 }
179 179
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); 568 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input);
569 if (iter == login_to_password_info_.end()) 569 if (iter == login_to_password_info_.end())
570 return false; 570 return false;
571 571
572 *found_input = input; 572 *found_input = input;
573 *found_password = iter->second; 573 *found_password = iter->second;
574 return true; 574 return true;
575 } 575 }
576 576
577 } // namespace autofill 577 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/autofill/password_autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698