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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 bool PasswordAutofillAgent::OriginCanAccessPasswordManager( | 1025 bool PasswordAutofillAgent::OriginCanAccessPasswordManager( |
1026 const blink::WebSecurityOrigin& origin) { | 1026 const blink::WebSecurityOrigin& origin) { |
1027 return origin.CanAccessPasswordManager(); | 1027 return origin.CanAccessPasswordManager(); |
1028 } | 1028 } |
1029 | 1029 |
1030 void PasswordAutofillAgent::OnDynamicFormsSeen() { | 1030 void PasswordAutofillAgent::OnDynamicFormsSeen() { |
1031 SendPasswordForms(false /* only_visible */); | 1031 SendPasswordForms(false /* only_visible */); |
1032 } | 1032 } |
1033 | 1033 |
1034 void PasswordAutofillAgent::AJAXSucceeded() { | 1034 void PasswordAutofillAgent::AJAXSucceeded() { |
1035 OnSameDocumentNavigationCompleted(); | 1035 OnSameDocumentNavigationCompleted(false); |
1036 } | 1036 } |
1037 | 1037 |
1038 void PasswordAutofillAgent::OnSameDocumentNavigationCompleted() { | 1038 void PasswordAutofillAgent::OnSameDocumentNavigationCompleted( |
| 1039 bool is_inpage_navigation) { |
1039 if (!provisionally_saved_form_.IsPasswordValid()) | 1040 if (!provisionally_saved_form_.IsPasswordValid()) |
1040 return; | 1041 return; |
1041 | 1042 |
| 1043 provisionally_saved_form_.SetSubmissionIndicatorEvent( |
| 1044 is_inpage_navigation |
| 1045 ? PasswordForm::SubmissionIndicatorEvent::SAME_DOCUMENT_NAVIGATION |
| 1046 : PasswordForm::SubmissionIndicatorEvent::XHR_SUCCEEDED); |
| 1047 |
1042 // Prompt to save only if the form is now gone, either invisible or | 1048 // Prompt to save only if the form is now gone, either invisible or |
1043 // removed from the DOM. | 1049 // removed from the DOM. |
1044 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 1050 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
1045 const auto& password_form = provisionally_saved_form_.password_form(); | 1051 const auto& password_form = provisionally_saved_form_.password_form(); |
| 1052 // TODO(crbug.com/720347): This method could be called often and checking form |
| 1053 // visibility could be expesive. Add performance metrics for this. |
1046 if (form_util::IsFormVisible(frame, provisionally_saved_form_.form_element(), | 1054 if (form_util::IsFormVisible(frame, provisionally_saved_form_.form_element(), |
1047 password_form.action, password_form.origin, | 1055 password_form.action, password_form.origin, |
1048 password_form.form_data) || | 1056 password_form.form_data) || |
1049 (provisionally_saved_form_.form_element().IsNull() && | 1057 (provisionally_saved_form_.form_element().IsNull() && |
1050 IsUnownedPasswordFormVisible( | 1058 IsUnownedPasswordFormVisible( |
1051 frame, provisionally_saved_form_.input_element(), | 1059 frame, provisionally_saved_form_.input_element(), |
1052 password_form.action, password_form.origin, password_form.form_data, | 1060 password_form.action, password_form.origin, password_form.form_data, |
1053 form_predictions_))) { | 1061 form_predictions_))) { |
1054 return; | 1062 return; |
1055 } | 1063 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 } | 1210 } |
1203 | 1211 |
1204 void PasswordAutofillAgent::WillCommitProvisionalLoad() { | 1212 void PasswordAutofillAgent::WillCommitProvisionalLoad() { |
1205 FrameClosing(); | 1213 FrameClosing(); |
1206 } | 1214 } |
1207 | 1215 |
1208 void PasswordAutofillAgent::DidCommitProvisionalLoad( | 1216 void PasswordAutofillAgent::DidCommitProvisionalLoad( |
1209 bool is_new_navigation, | 1217 bool is_new_navigation, |
1210 bool is_same_document_navigation) { | 1218 bool is_same_document_navigation) { |
1211 if (is_same_document_navigation) { | 1219 if (is_same_document_navigation) { |
1212 OnSameDocumentNavigationCompleted(); | 1220 OnSameDocumentNavigationCompleted(true); |
1213 } else { | 1221 } else { |
1214 checked_safe_browsing_reputation_ = false; | 1222 checked_safe_browsing_reputation_ = false; |
1215 } | 1223 } |
1216 } | 1224 } |
1217 | 1225 |
1218 void PasswordAutofillAgent::FrameDetached() { | 1226 void PasswordAutofillAgent::FrameDetached() { |
1219 // If a sub frame has been destroyed while the user was entering information | 1227 // If a sub frame has been destroyed while the user was entering information |
1220 // into a password form, try to save the data. See https://crbug.com/450806 | 1228 // into a password form, try to save the data. See https://crbug.com/450806 |
1221 // for examples of sites that perform login using this technique. | 1229 // for examples of sites that perform login using this technique. |
1222 if (render_frame()->GetWebFrame()->Parent() && | 1230 if (render_frame()->GetWebFrame()->Parent() && |
1223 provisionally_saved_form_.IsPasswordValid()) { | 1231 provisionally_saved_form_.IsPasswordValid()) { |
| 1232 provisionally_saved_form_.SetSubmissionIndicatorEvent( |
| 1233 PasswordForm::SubmissionIndicatorEvent::FRAME_DETACHED); |
1224 GetPasswordManagerDriver()->InPageNavigation( | 1234 GetPasswordManagerDriver()->InPageNavigation( |
1225 provisionally_saved_form_.password_form()); | 1235 provisionally_saved_form_.password_form()); |
1226 } | 1236 } |
1227 FrameClosing(); | 1237 FrameClosing(); |
1228 } | 1238 } |
1229 | 1239 |
1230 void PasswordAutofillAgent::WillSendSubmitEvent( | 1240 void PasswordAutofillAgent::WillSendSubmitEvent( |
1231 const blink::WebFormElement& form) { | 1241 const blink::WebFormElement& form) { |
1232 // Forms submitted via XHR are not seen by WillSubmitForm if the default | 1242 // Forms submitted via XHR are not seen by WillSubmitForm if the default |
1233 // onsubmit handler is overridden. Such submission first gets detected in | 1243 // onsubmit handler is overridden. Such submission first gets detected in |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 } | 1283 } |
1274 if (provisionally_saved_form_.IsSet() && | 1284 if (provisionally_saved_form_.IsSet() && |
1275 submitted_form->action == | 1285 submitted_form->action == |
1276 provisionally_saved_form_.password_form().action) { | 1286 provisionally_saved_form_.password_form().action) { |
1277 if (logger) | 1287 if (logger) |
1278 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED); | 1288 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED); |
1279 const auto& saved_form = provisionally_saved_form_.password_form(); | 1289 const auto& saved_form = provisionally_saved_form_.password_form(); |
1280 submitted_form->password_value = saved_form.password_value; | 1290 submitted_form->password_value = saved_form.password_value; |
1281 submitted_form->new_password_value = saved_form.new_password_value; | 1291 submitted_form->new_password_value = saved_form.new_password_value; |
1282 submitted_form->username_value = saved_form.username_value; | 1292 submitted_form->username_value = saved_form.username_value; |
| 1293 submitted_form->submission_event = |
| 1294 PasswordForm::SubmissionIndicatorEvent::HTML_FORM_SUBMISSION; |
1283 } | 1295 } |
1284 | 1296 |
1285 // Some observers depend on sending this information now instead of when | 1297 // Some observers depend on sending this information now instead of when |
1286 // the frame starts loading. If there are redirects that cause a new | 1298 // the frame starts loading. If there are redirects that cause a new |
1287 // RenderView to be instantiated (such as redirects to the WebStore) | 1299 // RenderView to be instantiated (such as redirects to the WebStore) |
1288 // we will never get to finish the load. | 1300 // we will never get to finish the load. |
1289 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form); | 1301 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form); |
1290 provisionally_saved_form_.Reset(); | 1302 provisionally_saved_form_.Reset(); |
1291 } else if (logger) { | 1303 } else if (logger) { |
1292 logger->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD); | 1304 logger->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 password_form->new_password_element != | 1568 password_form->new_password_element != |
1557 input.NameForAutofill().Utf16()) | 1569 input.NameForAutofill().Utf16()) |
1558 password_form.reset(); | 1570 password_form.reset(); |
1559 } | 1571 } |
1560 } | 1572 } |
1561 } | 1573 } |
1562 | 1574 |
1563 if (!password_form) | 1575 if (!password_form) |
1564 password_form.reset(new PasswordForm()); | 1576 password_form.reset(new PasswordForm()); |
1565 | 1577 |
| 1578 password_form->submission_event = |
| 1579 PasswordForm::SubmissionIndicatorEvent::MANUAL_SAVE; |
1566 callback.Run(*password_form); | 1580 callback.Run(*password_form); |
1567 } | 1581 } |
1568 | 1582 |
1569 //////////////////////////////////////////////////////////////////////////////// | 1583 //////////////////////////////////////////////////////////////////////////////// |
1570 // PasswordAutofillAgent, private: | 1584 // PasswordAutofillAgent, private: |
1571 | 1585 |
1572 bool PasswordAutofillAgent::ShowSuggestionPopup( | 1586 bool PasswordAutofillAgent::ShowSuggestionPopup( |
1573 const PasswordInfo& password_info, | 1587 const PasswordInfo& password_info, |
1574 const blink::WebInputElement& user_input, | 1588 const blink::WebInputElement& user_input, |
1575 bool show_all, | 1589 bool show_all, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 PasswordAutofillAgent::GetPasswordManagerDriver() { | 1673 PasswordAutofillAgent::GetPasswordManagerDriver() { |
1660 if (!password_manager_driver_) { | 1674 if (!password_manager_driver_) { |
1661 render_frame()->GetRemoteInterfaces()->GetInterface( | 1675 render_frame()->GetRemoteInterfaces()->GetInterface( |
1662 mojo::MakeRequest(&password_manager_driver_)); | 1676 mojo::MakeRequest(&password_manager_driver_)); |
1663 } | 1677 } |
1664 | 1678 |
1665 return password_manager_driver_; | 1679 return password_manager_driver_; |
1666 } | 1680 } |
1667 | 1681 |
1668 } // namespace autofill | 1682 } // namespace autofill |
OLD | NEW |