| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // to true returns a dummy name instead. | 117 // to true returns a dummy name instead. |
| 118 base::string16 FieldName(const FormFieldData& field, | 118 base::string16 FieldName(const FormFieldData& field, |
| 119 bool ambiguous_or_empty_names) { | 119 bool ambiguous_or_empty_names) { |
| 120 return ambiguous_or_empty_names | 120 return ambiguous_or_empty_names |
| 121 ? IsPasswordField(field) ? base::ASCIIToUTF16(kDummyPasswordField) | 121 ? IsPasswordField(field) ? base::ASCIIToUTF16(kDummyPasswordField) |
| 122 : base::ASCIIToUTF16(kDummyUsernameField) | 122 : base::ASCIIToUTF16(kDummyUsernameField) |
| 123 : field.name; | 123 : field.name; |
| 124 } | 124 } |
| 125 | 125 |
| 126 bool IsUnownedPasswordFormVisible(blink::WebFrame* frame, | 126 bool IsUnownedPasswordFormVisible(blink::WebFrame* frame, |
| 127 const blink::WebInputElement& input_element, |
| 127 const GURL& action, | 128 const GURL& action, |
| 128 const GURL& origin, | 129 const GURL& origin, |
| 129 const FormData& form_data, | 130 const FormData& form_data, |
| 130 const FormsPredictionsMap& form_predictions) { | 131 const FormsPredictionsMap& form_predictions) { |
| 132 if (!input_element.isNull() && form_util::IsWebNodeVisible(input_element)) |
| 133 return true; |
| 134 |
| 131 std::unique_ptr<PasswordForm> unowned_password_form( | 135 std::unique_ptr<PasswordForm> unowned_password_form( |
| 132 CreatePasswordFormFromUnownedInputElements(*frame, nullptr, | 136 CreatePasswordFormFromUnownedInputElements(*frame, nullptr, |
| 133 &form_predictions)); | 137 &form_predictions)); |
| 134 if (!unowned_password_form) | 138 if (!unowned_password_form) |
| 135 return false; | 139 return false; |
| 136 std::vector<blink::WebFormControlElement> control_elements = | 140 std::vector<blink::WebFormControlElement> control_elements = |
| 137 form_util::GetUnownedAutofillableFormFieldElements( | 141 form_util::GetUnownedAutofillableFormFieldElements( |
| 138 frame->document().all(), nullptr); | 142 frame->document().all(), nullptr); |
| 139 if (!form_util::IsSomeControlElementVisible(control_elements)) | 143 if (!form_util::IsSomeControlElementVisible(control_elements)) |
| 140 return false; | 144 return false; |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 // To honor the user having explicitly cleared the password, even an empty | 707 // To honor the user having explicitly cleared the password, even an empty |
| 704 // password will be saved here. | 708 // password will be saved here. |
| 705 std::unique_ptr<PasswordForm> password_form; | 709 std::unique_ptr<PasswordForm> password_form; |
| 706 if (element.form().isNull()) { | 710 if (element.form().isNull()) { |
| 707 password_form = CreatePasswordFormFromUnownedInputElements( | 711 password_form = CreatePasswordFormFromUnownedInputElements( |
| 708 *element_frame, &field_value_and_properties_map_, &form_predictions_); | 712 *element_frame, &field_value_and_properties_map_, &form_predictions_); |
| 709 } else { | 713 } else { |
| 710 password_form = CreatePasswordFormFromWebForm( | 714 password_form = CreatePasswordFormFromWebForm( |
| 711 element.form(), &field_value_and_properties_map_, &form_predictions_); | 715 element.form(), &field_value_and_properties_map_, &form_predictions_); |
| 712 } | 716 } |
| 713 ProvisionallySavePassword(std::move(password_form), RESTRICTION_NONE); | 717 ProvisionallySavePassword(std::move(password_form), element.form(), element, |
| 718 RESTRICTION_NONE); |
| 714 | 719 |
| 715 if (element.isPasswordField()) { | 720 if (element.isPasswordField()) { |
| 716 PasswordToLoginMap::iterator iter = password_to_username_.find(element); | 721 PasswordToLoginMap::iterator iter = password_to_username_.find(element); |
| 717 if (iter != password_to_username_.end()) { | 722 if (iter != password_to_username_.end()) { |
| 718 web_input_to_password_info_[iter->second].password_was_edited_last = true; | 723 web_input_to_password_info_[iter->second].password_was_edited_last = true; |
| 719 // Note that the suggested value of |mutable_element| was reset when its | 724 // Note that the suggested value of |mutable_element| was reset when its |
| 720 // value changed. | 725 // value changed. |
| 721 mutable_element.setAutofilled(false); | 726 mutable_element.setAutofilled(false); |
| 722 } | 727 } |
| 723 } | 728 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 | 990 |
| 986 void PasswordAutofillAgent::OnDynamicFormsSeen() { | 991 void PasswordAutofillAgent::OnDynamicFormsSeen() { |
| 987 SendPasswordForms(false /* only_visible */); | 992 SendPasswordForms(false /* only_visible */); |
| 988 } | 993 } |
| 989 | 994 |
| 990 void PasswordAutofillAgent::AJAXSucceeded() { | 995 void PasswordAutofillAgent::AJAXSucceeded() { |
| 991 OnSamePageNavigationCompleted(); | 996 OnSamePageNavigationCompleted(); |
| 992 } | 997 } |
| 993 | 998 |
| 994 void PasswordAutofillAgent::OnSamePageNavigationCompleted() { | 999 void PasswordAutofillAgent::OnSamePageNavigationCompleted() { |
| 995 if (!ProvisionallySavedPasswordIsValid()) | 1000 if (!provisionally_saved_form_.IsPasswordValid()) |
| 996 return; | 1001 return; |
| 997 | 1002 |
| 998 // Prompt to save only if the form is now gone, either invisible or | 1003 // Prompt to save only if the form is now gone, either invisible or |
| 999 // removed from the DOM. | 1004 // removed from the DOM. |
| 1000 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 1005 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
| 1001 if (form_util::IsFormVisible(frame, provisionally_saved_form_->action, | 1006 const auto& password_form = provisionally_saved_form_.password_form(); |
| 1002 provisionally_saved_form_->origin, | 1007 if (form_util::IsFormVisible(frame, provisionally_saved_form_.form_element(), |
| 1003 provisionally_saved_form_->form_data) || | 1008 password_form.action, password_form.origin, |
| 1004 IsUnownedPasswordFormVisible(frame, provisionally_saved_form_->action, | 1009 password_form.form_data) || |
| 1005 provisionally_saved_form_->origin, | 1010 (provisionally_saved_form_.form_element().isNull() && |
| 1006 provisionally_saved_form_->form_data, | 1011 IsUnownedPasswordFormVisible( |
| 1007 form_predictions_)) { | 1012 frame, provisionally_saved_form_.input_element(), |
| 1013 password_form.action, password_form.origin, password_form.form_data, |
| 1014 form_predictions_))) { |
| 1008 return; | 1015 return; |
| 1009 } | 1016 } |
| 1010 | 1017 |
| 1011 GetPasswordManagerDriver()->InPageNavigation(*provisionally_saved_form_); | 1018 GetPasswordManagerDriver()->InPageNavigation(password_form); |
| 1012 provisionally_saved_form_.reset(); | 1019 provisionally_saved_form_.Reset(); |
| 1013 } | 1020 } |
| 1014 | 1021 |
| 1015 void PasswordAutofillAgent::FirstUserGestureObserved() { | 1022 void PasswordAutofillAgent::FirstUserGestureObserved() { |
| 1016 gatekeeper_.OnUserGesture(); | 1023 gatekeeper_.OnUserGesture(); |
| 1017 } | 1024 } |
| 1018 | 1025 |
| 1019 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { | 1026 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { |
| 1020 std::unique_ptr<RendererSavePasswordProgressLogger> logger; | 1027 std::unique_ptr<RendererSavePasswordProgressLogger> logger; |
| 1021 if (logging_state_active_) { | 1028 if (logging_state_active_) { |
| 1022 logger.reset(new RendererSavePasswordProgressLogger( | 1029 logger.reset(new RendererSavePasswordProgressLogger( |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 if (is_same_page_navigation) { | 1158 if (is_same_page_navigation) { |
| 1152 OnSamePageNavigationCompleted(); | 1159 OnSamePageNavigationCompleted(); |
| 1153 } | 1160 } |
| 1154 } | 1161 } |
| 1155 | 1162 |
| 1156 void PasswordAutofillAgent::FrameDetached() { | 1163 void PasswordAutofillAgent::FrameDetached() { |
| 1157 // If a sub frame has been destroyed while the user was entering information | 1164 // If a sub frame has been destroyed while the user was entering information |
| 1158 // into a password form, try to save the data. See https://crbug.com/450806 | 1165 // into a password form, try to save the data. See https://crbug.com/450806 |
| 1159 // for examples of sites that perform login using this technique. | 1166 // for examples of sites that perform login using this technique. |
| 1160 if (render_frame()->GetWebFrame()->parent() && | 1167 if (render_frame()->GetWebFrame()->parent() && |
| 1161 ProvisionallySavedPasswordIsValid()) { | 1168 provisionally_saved_form_.IsPasswordValid()) { |
| 1162 GetPasswordManagerDriver()->InPageNavigation(*provisionally_saved_form_); | 1169 GetPasswordManagerDriver()->InPageNavigation( |
| 1170 provisionally_saved_form_.password_form()); |
| 1163 } | 1171 } |
| 1164 FrameClosing(); | 1172 FrameClosing(); |
| 1165 } | 1173 } |
| 1166 | 1174 |
| 1167 void PasswordAutofillAgent::WillSendSubmitEvent( | 1175 void PasswordAutofillAgent::WillSendSubmitEvent( |
| 1168 const blink::WebFormElement& form) { | 1176 const blink::WebFormElement& form) { |
| 1169 // Forms submitted via XHR are not seen by WillSubmitForm if the default | 1177 // Forms submitted via XHR are not seen by WillSubmitForm if the default |
| 1170 // onsubmit handler is overridden. Such submission first gets detected in | 1178 // onsubmit handler is overridden. Such submission first gets detected in |
| 1171 // DidStartProvisionalLoad, which no longer knows about the particular form, | 1179 // DidStartProvisionalLoad, which no longer knows about the particular form, |
| 1172 // and uses the candidate stored in |provisionally_saved_form_|. | 1180 // and uses the candidate stored in |provisionally_saved_form_|. |
| 1173 // | 1181 // |
| 1174 // User-typed password will get stored to |provisionally_saved_form_| in | 1182 // User-typed password will get stored to |provisionally_saved_form_| in |
| 1175 // TextDidChangeInTextField. Autofilled or JavaScript-copied passwords need to | 1183 // TextDidChangeInTextField. Autofilled or JavaScript-copied passwords need to |
| 1176 // be saved here. | 1184 // be saved here. |
| 1177 // | 1185 // |
| 1178 // Only non-empty passwords are saved here. Empty passwords were likely | 1186 // Only non-empty passwords are saved here. Empty passwords were likely |
| 1179 // cleared by some scripts (http://crbug.com/28910, http://crbug.com/391693). | 1187 // cleared by some scripts (http://crbug.com/28910, http://crbug.com/391693). |
| 1180 // Had the user cleared the password, |provisionally_saved_form_| would | 1188 // Had the user cleared the password, |provisionally_saved_form_| would |
| 1181 // already have been updated in TextDidChangeInTextField. | 1189 // already have been updated in TextDidChangeInTextField. |
| 1182 std::unique_ptr<PasswordForm> password_form = CreatePasswordFormFromWebForm( | 1190 std::unique_ptr<PasswordForm> password_form = CreatePasswordFormFromWebForm( |
| 1183 form, &field_value_and_properties_map_, &form_predictions_); | 1191 form, &field_value_and_properties_map_, &form_predictions_); |
| 1184 ProvisionallySavePassword(std::move(password_form), | 1192 ProvisionallySavePassword(std::move(password_form), form, |
| 1193 blink::WebInputElement(), |
| 1185 RESTRICTION_NON_EMPTY_PASSWORD); | 1194 RESTRICTION_NON_EMPTY_PASSWORD); |
| 1186 } | 1195 } |
| 1187 | 1196 |
| 1188 void PasswordAutofillAgent::WillSubmitForm(const blink::WebFormElement& form) { | 1197 void PasswordAutofillAgent::WillSubmitForm(const blink::WebFormElement& form) { |
| 1189 std::unique_ptr<RendererSavePasswordProgressLogger> logger; | 1198 std::unique_ptr<RendererSavePasswordProgressLogger> logger; |
| 1190 if (logging_state_active_) { | 1199 if (logging_state_active_) { |
| 1191 logger.reset(new RendererSavePasswordProgressLogger( | 1200 logger.reset(new RendererSavePasswordProgressLogger( |
| 1192 GetPasswordManagerDriver().get())); | 1201 GetPasswordManagerDriver().get())); |
| 1193 logger->LogMessage(Logger::STRING_WILL_SUBMIT_FORM_METHOD); | 1202 logger->LogMessage(Logger::STRING_WILL_SUBMIT_FORM_METHOD); |
| 1194 LogHTMLForm(logger.get(), Logger::STRING_HTML_FORM_FOR_SUBMIT, form); | 1203 LogHTMLForm(logger.get(), Logger::STRING_HTML_FORM_FOR_SUBMIT, form); |
| 1195 } | 1204 } |
| 1196 | 1205 |
| 1197 std::unique_ptr<PasswordForm> submitted_form = CreatePasswordFormFromWebForm( | 1206 std::unique_ptr<PasswordForm> submitted_form = CreatePasswordFormFromWebForm( |
| 1198 form, &field_value_and_properties_map_, &form_predictions_); | 1207 form, &field_value_and_properties_map_, &form_predictions_); |
| 1199 | 1208 |
| 1200 // If there is a provisionally saved password, copy over the previous | 1209 // If there is a provisionally saved password, copy over the previous |
| 1201 // password value so we get the user's typed password, not the value that | 1210 // password value so we get the user's typed password, not the value that |
| 1202 // may have been transformed for submit. | 1211 // may have been transformed for submit. |
| 1203 // TODO(gcasto): Do we need to have this action equality check? Is it trying | 1212 // TODO(gcasto): Do we need to have this action equality check? Is it trying |
| 1204 // to prevent accidentally copying over passwords from a different form? | 1213 // to prevent accidentally copying over passwords from a different form? |
| 1205 if (submitted_form) { | 1214 if (submitted_form) { |
| 1206 if (logger) { | 1215 if (logger) { |
| 1207 logger->LogPasswordForm(Logger::STRING_CREATED_PASSWORD_FORM, | 1216 logger->LogPasswordForm(Logger::STRING_CREATED_PASSWORD_FORM, |
| 1208 *submitted_form); | 1217 *submitted_form); |
| 1209 } | 1218 } |
| 1210 if (provisionally_saved_form_ && | 1219 if (provisionally_saved_form_.IsSet() && |
| 1211 submitted_form->action == provisionally_saved_form_->action) { | 1220 submitted_form->action == |
| 1221 provisionally_saved_form_.password_form().action) { |
| 1212 if (logger) | 1222 if (logger) |
| 1213 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED); | 1223 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED); |
| 1214 submitted_form->password_value = | 1224 const auto& saved_form = provisionally_saved_form_.password_form(); |
| 1215 provisionally_saved_form_->password_value; | 1225 submitted_form->password_value = saved_form.password_value; |
| 1216 submitted_form->new_password_value = | 1226 submitted_form->new_password_value = saved_form.new_password_value; |
| 1217 provisionally_saved_form_->new_password_value; | 1227 submitted_form->username_value = saved_form.username_value; |
| 1218 submitted_form->username_value = | |
| 1219 provisionally_saved_form_->username_value; | |
| 1220 } | 1228 } |
| 1221 | 1229 |
| 1222 // Some observers depend on sending this information now instead of when | 1230 // Some observers depend on sending this information now instead of when |
| 1223 // the frame starts loading. If there are redirects that cause a new | 1231 // the frame starts loading. If there are redirects that cause a new |
| 1224 // RenderView to be instantiated (such as redirects to the WebStore) | 1232 // RenderView to be instantiated (such as redirects to the WebStore) |
| 1225 // we will never get to finish the load. | 1233 // we will never get to finish the load. |
| 1226 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form); | 1234 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form); |
| 1227 provisionally_saved_form_.reset(); | 1235 provisionally_saved_form_.Reset(); |
| 1228 } else if (logger) { | 1236 } else if (logger) { |
| 1229 logger->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD); | 1237 logger->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD); |
| 1230 } | 1238 } |
| 1231 } | 1239 } |
| 1232 | 1240 |
| 1233 void PasswordAutofillAgent::OnDestruct() { | 1241 void PasswordAutofillAgent::OnDestruct() { |
| 1234 binding_.Close(); | 1242 binding_.Close(); |
| 1235 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 1243 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 1236 } | 1244 } |
| 1237 | 1245 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1256 // history navigation). We don't want to trigger saving in these cases. | 1264 // history navigation). We don't want to trigger saving in these cases. |
| 1257 content::DocumentState* document_state = | 1265 content::DocumentState* document_state = |
| 1258 content::DocumentState::FromDataSource(data_source); | 1266 content::DocumentState::FromDataSource(data_source); |
| 1259 content::NavigationState* navigation_state = | 1267 content::NavigationState* navigation_state = |
| 1260 document_state->navigation_state(); | 1268 document_state->navigation_state(); |
| 1261 ui::PageTransition type = navigation_state->GetTransitionType(); | 1269 ui::PageTransition type = navigation_state->GetTransitionType(); |
| 1262 if (ui::PageTransitionIsWebTriggerable(type) && | 1270 if (ui::PageTransitionIsWebTriggerable(type) && |
| 1263 ui::PageTransitionIsNewNavigation(type) && | 1271 ui::PageTransitionIsNewNavigation(type) && |
| 1264 !blink::WebUserGestureIndicator::isProcessingUserGesture()) { | 1272 !blink::WebUserGestureIndicator::isProcessingUserGesture()) { |
| 1265 // If onsubmit has been called, try and save that form. | 1273 // If onsubmit has been called, try and save that form. |
| 1266 if (provisionally_saved_form_) { | 1274 if (provisionally_saved_form_.IsSet()) { |
| 1267 if (logger) { | 1275 if (logger) { |
| 1268 logger->LogPasswordForm( | 1276 logger->LogPasswordForm( |
| 1269 Logger::STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME, | 1277 Logger::STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME, |
| 1270 *provisionally_saved_form_); | 1278 provisionally_saved_form_.password_form()); |
| 1271 } | 1279 } |
| 1272 GetPasswordManagerDriver()->PasswordFormSubmitted( | 1280 GetPasswordManagerDriver()->PasswordFormSubmitted( |
| 1273 *provisionally_saved_form_); | 1281 provisionally_saved_form_.password_form()); |
| 1274 provisionally_saved_form_.reset(); | 1282 provisionally_saved_form_.Reset(); |
| 1275 } else { | 1283 } else { |
| 1276 std::vector<std::unique_ptr<PasswordForm>> possible_submitted_forms; | 1284 std::vector<std::unique_ptr<PasswordForm>> possible_submitted_forms; |
| 1277 // Loop through the forms on the page looking for one that has been | 1285 // Loop through the forms on the page looking for one that has been |
| 1278 // filled out. If one exists, try and save the credentials. | 1286 // filled out. If one exists, try and save the credentials. |
| 1279 blink::WebVector<blink::WebFormElement> forms; | 1287 blink::WebVector<blink::WebFormElement> forms; |
| 1280 render_frame()->GetWebFrame()->document().forms(forms); | 1288 render_frame()->GetWebFrame()->document().forms(forms); |
| 1281 | 1289 |
| 1282 bool password_forms_found = false; | 1290 bool password_forms_found = false; |
| 1283 for (size_t i = 0; i < forms.size(); ++i) { | 1291 for (size_t i = 0; i < forms.size(); ++i) { |
| 1284 blink::WebFormElement form_element = forms[i]; | 1292 blink::WebFormElement form_element = forms[i]; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 render_frame()->GetRenderView()->ElementBoundsInWindow(user_input)); | 1553 render_frame()->GetRenderView()->ElementBoundsInWindow(user_input)); |
| 1546 username_query_prefix_ = username_string; | 1554 username_query_prefix_ = username_string; |
| 1547 return CanShowSuggestion(password_info.fill_data, username_string, show_all); | 1555 return CanShowSuggestion(password_info.fill_data, username_string, show_all); |
| 1548 } | 1556 } |
| 1549 | 1557 |
| 1550 void PasswordAutofillAgent::FrameClosing() { | 1558 void PasswordAutofillAgent::FrameClosing() { |
| 1551 for (auto const& iter : web_input_to_password_info_) { | 1559 for (auto const& iter : web_input_to_password_info_) { |
| 1552 password_to_username_.erase(iter.second.password_field); | 1560 password_to_username_.erase(iter.second.password_field); |
| 1553 } | 1561 } |
| 1554 web_input_to_password_info_.clear(); | 1562 web_input_to_password_info_.clear(); |
| 1555 provisionally_saved_form_.reset(); | 1563 provisionally_saved_form_.Reset(); |
| 1556 field_value_and_properties_map_.clear(); | 1564 field_value_and_properties_map_.clear(); |
| 1557 } | 1565 } |
| 1558 | 1566 |
| 1559 void PasswordAutofillAgent::ClearPreview( | 1567 void PasswordAutofillAgent::ClearPreview( |
| 1560 blink::WebInputElement* username, | 1568 blink::WebInputElement* username, |
| 1561 blink::WebInputElement* password) { | 1569 blink::WebInputElement* password) { |
| 1562 if (!username->isNull() && !username->suggestedValue().isEmpty()) { | 1570 if (!username->isNull() && !username->suggestedValue().isEmpty()) { |
| 1563 username->setSuggestedValue(blink::WebString()); | 1571 username->setSuggestedValue(blink::WebString()); |
| 1564 username->setAutofilled(was_username_autofilled_); | 1572 username->setAutofilled(was_username_autofilled_); |
| 1565 username->setSelectionRange(username_query_prefix_.length(), | 1573 username->setSelectionRange(username_query_prefix_.length(), |
| 1566 username->value().length()); | 1574 username->value().length()); |
| 1567 } | 1575 } |
| 1568 if (!password->suggestedValue().isEmpty()) { | 1576 if (!password->suggestedValue().isEmpty()) { |
| 1569 password->setSuggestedValue(blink::WebString()); | 1577 password->setSuggestedValue(blink::WebString()); |
| 1570 password->setAutofilled(was_password_autofilled_); | 1578 password->setAutofilled(was_password_autofilled_); |
| 1571 } | 1579 } |
| 1572 } | 1580 } |
| 1573 | 1581 |
| 1574 void PasswordAutofillAgent::ProvisionallySavePassword( | 1582 void PasswordAutofillAgent::ProvisionallySavePassword( |
| 1575 std::unique_ptr<PasswordForm> password_form, | 1583 std::unique_ptr<PasswordForm> password_form, |
| 1584 const blink::WebFormElement& form, |
| 1585 const blink::WebInputElement& input, |
| 1576 ProvisionallySaveRestriction restriction) { | 1586 ProvisionallySaveRestriction restriction) { |
| 1577 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && | 1587 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && |
| 1578 password_form->password_value.empty() && | 1588 password_form->password_value.empty() && |
| 1579 password_form->new_password_value.empty())) { | 1589 password_form->new_password_value.empty())) { |
| 1580 return; | 1590 return; |
| 1581 } | 1591 } |
| 1582 provisionally_saved_form_ = std::move(password_form); | 1592 DCHECK(password_form && (!form.isNull() || !input.isNull())); |
| 1583 } | 1593 provisionally_saved_form_.Set(std::move(password_form), form, input); |
| 1584 | |
| 1585 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { | |
| 1586 return provisionally_saved_form_ && | |
| 1587 !provisionally_saved_form_->username_value.empty() && | |
| 1588 !(provisionally_saved_form_->password_value.empty() && | |
| 1589 provisionally_saved_form_->new_password_value.empty()); | |
| 1590 } | 1594 } |
| 1591 | 1595 |
| 1592 const mojom::AutofillDriverPtr& PasswordAutofillAgent::GetAutofillDriver() { | 1596 const mojom::AutofillDriverPtr& PasswordAutofillAgent::GetAutofillDriver() { |
| 1593 DCHECK(autofill_agent_); | 1597 DCHECK(autofill_agent_); |
| 1594 return autofill_agent_->GetAutofillDriver(); | 1598 return autofill_agent_->GetAutofillDriver(); |
| 1595 } | 1599 } |
| 1596 | 1600 |
| 1597 const mojom::PasswordManagerDriverPtr& | 1601 const mojom::PasswordManagerDriverPtr& |
| 1598 PasswordAutofillAgent::GetPasswordManagerDriver() { | 1602 PasswordAutofillAgent::GetPasswordManagerDriver() { |
| 1599 if (!password_manager_driver_) { | 1603 if (!password_manager_driver_) { |
| 1600 render_frame()->GetRemoteInterfaces()->GetInterface( | 1604 render_frame()->GetRemoteInterfaces()->GetInterface( |
| 1601 mojo::MakeRequest(&password_manager_driver_)); | 1605 mojo::MakeRequest(&password_manager_driver_)); |
| 1602 } | 1606 } |
| 1603 | 1607 |
| 1604 return password_manager_driver_; | 1608 return password_manager_driver_; |
| 1605 } | 1609 } |
| 1606 | 1610 |
| 1607 } // namespace autofill | 1611 } // namespace autofill |
| OLD | NEW |