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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 // This is a new navigation, so require a new user gesture before filling in | 1005 // This is a new navigation, so require a new user gesture before filling in |
1006 // passwords. | 1006 // passwords. |
1007 gatekeeper_.Reset(); | 1007 gatekeeper_.Reset(); |
1008 } else { | 1008 } else { |
1009 if (logger) | 1009 if (logger) |
1010 logger->LogMessage(Logger::STRING_DECISION_DROP); | 1010 logger->LogMessage(Logger::STRING_DECISION_DROP); |
1011 } | 1011 } |
1012 } | 1012 } |
1013 | 1013 |
1014 void PasswordAutofillAgent::OnFillPasswordForm( | 1014 void PasswordAutofillAgent::OnFillPasswordForm( |
1015 int key, | |
1015 const PasswordFormFillData& form_data) { | 1016 const PasswordFormFillData& form_data) { |
1016 if (usernames_usage_ == NOTHING_TO_AUTOFILL) { | 1017 if (usernames_usage_ == NOTHING_TO_AUTOFILL) { |
1017 if (form_data.other_possible_usernames.size()) | 1018 if (form_data.other_possible_usernames.size()) |
1018 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT; | 1019 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT; |
1019 else if (usernames_usage_ == NOTHING_TO_AUTOFILL) | 1020 else if (usernames_usage_ == NOTHING_TO_AUTOFILL) |
1020 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT; | 1021 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT; |
1021 } | 1022 } |
1022 | 1023 |
1023 FormElementsList forms; | 1024 FormElementsList forms; |
1024 // We own the FormElements* in forms. | 1025 // We own the FormElements* in forms. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 // with identical markup. | 1062 // with identical markup. |
1062 if (login_to_password_info_.find(username_element) != | 1063 if (login_to_password_info_.find(username_element) != |
1063 login_to_password_info_.end()) | 1064 login_to_password_info_.end()) |
1064 continue; | 1065 continue; |
1065 | 1066 |
1066 PasswordInfo password_info; | 1067 PasswordInfo password_info; |
1067 password_info.fill_data = form_data; | 1068 password_info.fill_data = form_data; |
1068 password_info.password_field = password_element; | 1069 password_info.password_field = password_element; |
1069 login_to_password_info_[username_element] = password_info; | 1070 login_to_password_info_[username_element] = password_info; |
1070 password_to_username_[password_element] = username_element; | 1071 password_to_username_[password_element] = username_element; |
1072 login_to_password_info_key_[username_element] = key; | |
1071 | 1073 |
1072 FormData form; | 1074 FormData form; |
1073 FormFieldData field; | 1075 FormFieldData field; |
1074 if (form_contains_username_field) { | 1076 if (form_contains_username_field) { |
1075 FindFormAndFieldForFormControlElement( | 1077 FindFormAndFieldForFormControlElement( |
1076 username_element, &form, &field, REQUIRE_NONE); | 1078 username_element, &form, &field, REQUIRE_NONE); |
Garrett Casto
2014/11/04 07:22:09
This is unneeded, right?
vabr (Chromium)
2014/11/05 11:56:19
Correct, thanks for checking it!
Done.
| |
1077 } | 1079 } |
1078 | |
1079 Send(new AutofillHostMsg_AddPasswordFormMapping( | |
1080 routing_id(), field, form_data)); | |
1081 } | 1080 } |
1082 } | 1081 } |
1083 | 1082 |
1084 void PasswordAutofillAgent::OnSetLoggingState(bool active) { | 1083 void PasswordAutofillAgent::OnSetLoggingState(bool active) { |
1085 logging_state_active_ = active; | 1084 logging_state_active_ = active; |
1086 } | 1085 } |
1087 | 1086 |
1088 //////////////////////////////////////////////////////////////////////////////// | 1087 //////////////////////////////////////////////////////////////////////////////// |
1089 // PasswordAutofillAgent, private: | 1088 // PasswordAutofillAgent, private: |
1090 | 1089 |
(...skipping 14 matching lines...) Expand all Loading... | |
1105 return false; | 1104 return false; |
1106 | 1105 |
1107 FormData form; | 1106 FormData form; |
1108 FormFieldData field; | 1107 FormFieldData field; |
1109 FindFormAndFieldForFormControlElement( | 1108 FindFormAndFieldForFormControlElement( |
1110 user_input, &form, &field, REQUIRE_NONE); | 1109 user_input, &form, &field, REQUIRE_NONE); |
1111 | 1110 |
1112 blink::WebInputElement selected_element = user_input; | 1111 blink::WebInputElement selected_element = user_input; |
1113 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 1112 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
1114 | 1113 |
1114 LoginToPasswordInfoKeyMap::const_iterator key_it = | |
1115 login_to_password_info_key_.find(user_input); | |
1116 DCHECK(key_it != login_to_password_info_key_.end()); | |
1117 | |
1115 float scale = web_view_->pageScaleFactor(); | 1118 float scale = web_view_->pageScaleFactor(); |
1116 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 1119 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
1117 bounding_box.y() * scale, | 1120 bounding_box.y() * scale, |
1118 bounding_box.width() * scale, | 1121 bounding_box.width() * scale, |
1119 bounding_box.height() * scale); | 1122 bounding_box.height() * scale); |
1120 Send(new AutofillHostMsg_ShowPasswordSuggestions( | 1123 Send(new AutofillHostMsg_ShowPasswordSuggestions( |
1121 routing_id(), field, user_input.value(), show_all, bounding_box_scaled)); | 1124 routing_id(), key_it->second, field.text_direction, user_input.value(), |
1125 show_all, bounding_box_scaled)); | |
1122 | 1126 |
1123 bool suggestions_present = false; | 1127 bool suggestions_present = false; |
1124 if (GetSuggestionsStats(fill_data, user_input.value(), show_all, | 1128 if (GetSuggestionsStats(fill_data, user_input.value(), show_all, |
1125 &suggestions_present)) { | 1129 &suggestions_present)) { |
1126 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN; | 1130 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN; |
1127 } | 1131 } |
1128 return suggestions_present; | 1132 return suggestions_present; |
1129 } | 1133 } |
1130 | 1134 |
1131 void PasswordAutofillAgent::PerformInlineAutocomplete( | 1135 void PasswordAutofillAgent::PerformInlineAutocomplete( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 } | 1167 } |
1164 #endif | 1168 #endif |
1165 } | 1169 } |
1166 | 1170 |
1167 void PasswordAutofillAgent::FrameClosing(const blink::WebFrame* frame) { | 1171 void PasswordAutofillAgent::FrameClosing(const blink::WebFrame* frame) { |
1168 for (LoginToPasswordInfoMap::iterator iter = login_to_password_info_.begin(); | 1172 for (LoginToPasswordInfoMap::iterator iter = login_to_password_info_.begin(); |
1169 iter != login_to_password_info_.end();) { | 1173 iter != login_to_password_info_.end();) { |
1170 // There may not be a username field, so get the frame from the password | 1174 // There may not be a username field, so get the frame from the password |
1171 // field. | 1175 // field. |
1172 if (iter->second.password_field.document().frame() == frame) { | 1176 if (iter->second.password_field.document().frame() == frame) { |
1177 login_to_password_info_key_.erase(iter->first); | |
1173 password_to_username_.erase(iter->second.password_field); | 1178 password_to_username_.erase(iter->second.password_field); |
1174 login_to_password_info_.erase(iter++); | 1179 login_to_password_info_.erase(iter++); |
1175 } else { | 1180 } else { |
1176 ++iter; | 1181 ++iter; |
1177 } | 1182 } |
1178 } | 1183 } |
1179 for (FrameToPasswordFormMap::iterator iter = | 1184 for (FrameToPasswordFormMap::iterator iter = |
1180 provisionally_saved_forms_.begin(); | 1185 provisionally_saved_forms_.begin(); |
1181 iter != provisionally_saved_forms_.end();) { | 1186 iter != provisionally_saved_forms_.end();) { |
1182 if (iter->first == frame) | 1187 if (iter->first == frame) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1236 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); | 1241 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); |
1237 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && | 1242 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && |
1238 password_form->password_value.empty() && | 1243 password_form->password_value.empty() && |
1239 password_form->new_password_value.empty())) { | 1244 password_form->new_password_value.empty())) { |
1240 return; | 1245 return; |
1241 } | 1246 } |
1242 provisionally_saved_forms_[frame].reset(password_form.release()); | 1247 provisionally_saved_forms_[frame].reset(password_form.release()); |
1243 } | 1248 } |
1244 | 1249 |
1245 } // namespace autofill | 1250 } // namespace autofill |
OLD | NEW |