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

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

Issue 686653003: Don't use FormFieldData only as a key in a map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 1 month 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
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 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 // This is a new navigation, so require a new user gesture before filling in 995 // This is a new navigation, so require a new user gesture before filling in
996 // passwords. 996 // passwords.
997 gatekeeper_.Reset(); 997 gatekeeper_.Reset();
998 } else { 998 } else {
999 if (logger) 999 if (logger)
1000 logger->LogMessage(Logger::STRING_DECISION_DROP); 1000 logger->LogMessage(Logger::STRING_DECISION_DROP);
1001 } 1001 }
1002 } 1002 }
1003 1003
1004 void PasswordAutofillAgent::OnFillPasswordForm( 1004 void PasswordAutofillAgent::OnFillPasswordForm(
1005 int key,
1005 const PasswordFormFillData& form_data) { 1006 const PasswordFormFillData& form_data) {
1006 if (usernames_usage_ == NOTHING_TO_AUTOFILL) { 1007 if (usernames_usage_ == NOTHING_TO_AUTOFILL) {
1007 if (form_data.other_possible_usernames.size()) 1008 if (form_data.other_possible_usernames.size())
1008 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT; 1009 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT;
1009 else if (usernames_usage_ == NOTHING_TO_AUTOFILL) 1010 else if (usernames_usage_ == NOTHING_TO_AUTOFILL)
1010 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT; 1011 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT;
1011 } 1012 }
1012 1013
1013 FormElementsList forms; 1014 FormElementsList forms;
1014 // We own the FormElements* in forms. 1015 // We own the FormElements* in forms.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 // with identical markup. 1052 // with identical markup.
1052 if (login_to_password_info_.find(username_element) != 1053 if (login_to_password_info_.find(username_element) !=
1053 login_to_password_info_.end()) 1054 login_to_password_info_.end())
1054 continue; 1055 continue;
1055 1056
1056 PasswordInfo password_info; 1057 PasswordInfo password_info;
1057 password_info.fill_data = form_data; 1058 password_info.fill_data = form_data;
1058 password_info.password_field = password_element; 1059 password_info.password_field = password_element;
1059 login_to_password_info_[username_element] = password_info; 1060 login_to_password_info_[username_element] = password_info;
1060 password_to_username_[password_element] = username_element; 1061 password_to_username_[password_element] = username_element;
1061 1062 login_to_password_info_key_[username_element] = key;
1062 FormData form;
1063 FormFieldData field;
1064 if (form_contains_username_field) {
1065 FindFormAndFieldForFormControlElement(
1066 username_element, &form, &field, REQUIRE_NONE);
1067 }
1068
1069 Send(new AutofillHostMsg_AddPasswordFormMapping(
1070 routing_id(), field, form_data));
1071 } 1063 }
1072 } 1064 }
1073 1065
1074 void PasswordAutofillAgent::OnSetLoggingState(bool active) { 1066 void PasswordAutofillAgent::OnSetLoggingState(bool active) {
1075 logging_state_active_ = active; 1067 logging_state_active_ = active;
1076 } 1068 }
1077 1069
1078 //////////////////////////////////////////////////////////////////////////////// 1070 ////////////////////////////////////////////////////////////////////////////////
1079 // PasswordAutofillAgent, private: 1071 // PasswordAutofillAgent, private:
1080 1072
(...skipping 14 matching lines...) Expand all
1095 return false; 1087 return false;
1096 1088
1097 FormData form; 1089 FormData form;
1098 FormFieldData field; 1090 FormFieldData field;
1099 FindFormAndFieldForFormControlElement( 1091 FindFormAndFieldForFormControlElement(
1100 user_input, &form, &field, REQUIRE_NONE); 1092 user_input, &form, &field, REQUIRE_NONE);
1101 1093
1102 blink::WebInputElement selected_element = user_input; 1094 blink::WebInputElement selected_element = user_input;
1103 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); 1095 gfx::Rect bounding_box(selected_element.boundsInViewportSpace());
1104 1096
1097 LoginToPasswordInfoKeyMap::const_iterator key_it =
1098 login_to_password_info_key_.find(user_input);
1099 DCHECK(key_it != login_to_password_info_key_.end());
1100
1105 float scale = web_view_->pageScaleFactor(); 1101 float scale = web_view_->pageScaleFactor();
1106 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, 1102 gfx::RectF bounding_box_scaled(bounding_box.x() * scale,
1107 bounding_box.y() * scale, 1103 bounding_box.y() * scale,
1108 bounding_box.width() * scale, 1104 bounding_box.width() * scale,
1109 bounding_box.height() * scale); 1105 bounding_box.height() * scale);
1110 Send(new AutofillHostMsg_ShowPasswordSuggestions( 1106 Send(new AutofillHostMsg_ShowPasswordSuggestions(
1111 routing_id(), field, user_input.value(), show_all, bounding_box_scaled)); 1107 routing_id(), key_it->second, field.text_direction, user_input.value(),
1108 show_all, bounding_box_scaled));
1112 1109
1113 bool suggestions_present = false; 1110 bool suggestions_present = false;
1114 if (GetSuggestionsStats(fill_data, user_input.value(), show_all, 1111 if (GetSuggestionsStats(fill_data, user_input.value(), show_all,
1115 &suggestions_present)) { 1112 &suggestions_present)) {
1116 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN; 1113 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN;
1117 } 1114 }
1118 return suggestions_present; 1115 return suggestions_present;
1119 } 1116 }
1120 1117
1121 void PasswordAutofillAgent::PerformInlineAutocomplete( 1118 void PasswordAutofillAgent::PerformInlineAutocomplete(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 } 1150 }
1154 #endif 1151 #endif
1155 } 1152 }
1156 1153
1157 void PasswordAutofillAgent::FrameClosing(const blink::WebFrame* frame) { 1154 void PasswordAutofillAgent::FrameClosing(const blink::WebFrame* frame) {
1158 for (LoginToPasswordInfoMap::iterator iter = login_to_password_info_.begin(); 1155 for (LoginToPasswordInfoMap::iterator iter = login_to_password_info_.begin();
1159 iter != login_to_password_info_.end();) { 1156 iter != login_to_password_info_.end();) {
1160 // There may not be a username field, so get the frame from the password 1157 // There may not be a username field, so get the frame from the password
1161 // field. 1158 // field.
1162 if (iter->second.password_field.document().frame() == frame) { 1159 if (iter->second.password_field.document().frame() == frame) {
1160 login_to_password_info_key_.erase(iter->first);
1163 password_to_username_.erase(iter->second.password_field); 1161 password_to_username_.erase(iter->second.password_field);
1164 login_to_password_info_.erase(iter++); 1162 login_to_password_info_.erase(iter++);
1165 } else { 1163 } else {
1166 ++iter; 1164 ++iter;
1167 } 1165 }
1168 } 1166 }
1169 for (FrameToPasswordFormMap::iterator iter = 1167 for (FrameToPasswordFormMap::iterator iter =
1170 provisionally_saved_forms_.begin(); 1168 provisionally_saved_forms_.begin();
1171 iter != provisionally_saved_forms_.end();) { 1169 iter != provisionally_saved_forms_.end();) {
1172 if (iter->first == frame) 1170 if (iter->first == frame)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); 1224 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form));
1227 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && 1225 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD &&
1228 password_form->password_value.empty() && 1226 password_form->password_value.empty() &&
1229 password_form->new_password_value.empty())) { 1227 password_form->new_password_value.empty())) {
1230 return; 1228 return;
1231 } 1229 }
1232 provisionally_saved_forms_[frame].reset(password_form.release()); 1230 provisionally_saved_forms_[frame].reset(password_form.release());
1233 } 1231 }
1234 1232
1235 } // namespace autofill 1233 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698