Chromium Code Reviews| 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( |
|
engedy
2017/05/09 22:02:58
nit: Now this sounds like: OnBanana(bool is_banana
dvadym
2017/05/10 12:10:12
Absolutely agree. But I'd prefer to use this CL ju
engedy
2017/05/10 13:07:42
Acknowledged.
| |
| 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_.SetSubmissionEvent( | |
| 1044 is_inpage_navigation ? PasswordForm::SubmissionEvent::INPAGE_NAVIGATION | |
| 1045 : PasswordForm::SubmissionEvent::XHR_SUCCEEDED); | |
| 1046 | |
| 1042 // Prompt to save only if the form is now gone, either invisible or | 1047 // Prompt to save only if the form is now gone, either invisible or |
| 1043 // removed from the DOM. | 1048 // removed from the DOM. |
| 1044 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 1049 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
| 1045 const auto& password_form = provisionally_saved_form_.password_form(); | 1050 const auto& password_form = provisionally_saved_form_.password_form(); |
| 1046 if (form_util::IsFormVisible(frame, provisionally_saved_form_.form_element(), | 1051 if (form_util::IsFormVisible(frame, provisionally_saved_form_.form_element(), |
|
engedy
2017/05/09 22:02:59
It seems to me that this is called on *every* succ
dvadym
2017/05/10 12:10:12
Yeah, for me it also looks strange. It was impleme
engedy
2017/05/10 13:07:42
Can we file a tracking bug for these metrics and m
dvadym
2017/05/10 14:09:25
Done.
| |
| 1047 password_form.action, password_form.origin, | 1052 password_form.action, password_form.origin, |
| 1048 password_form.form_data) || | 1053 password_form.form_data) || |
| 1049 (provisionally_saved_form_.form_element().IsNull() && | 1054 (provisionally_saved_form_.form_element().IsNull() && |
| 1050 IsUnownedPasswordFormVisible( | 1055 IsUnownedPasswordFormVisible( |
| 1051 frame, provisionally_saved_form_.input_element(), | 1056 frame, provisionally_saved_form_.input_element(), |
| 1052 password_form.action, password_form.origin, password_form.form_data, | 1057 password_form.action, password_form.origin, password_form.form_data, |
| 1053 form_predictions_))) { | 1058 form_predictions_))) { |
| 1054 return; | 1059 return; |
| 1055 } | 1060 } |
| 1056 | 1061 |
| 1057 GetPasswordManagerDriver()->InPageNavigation(password_form); | 1062 GetPasswordManagerDriver()->InPageNavigation(password_form); |
|
engedy
2017/05/09 22:02:59
nit: Then this could be updated to PasswordFormSuc
dvadym
2017/05/10 12:10:11
Absolutely agree. But I'd prefere to use this CL j
engedy
2017/05/10 13:07:42
Acknowledged.
| |
| 1058 provisionally_saved_form_.Reset(); | 1063 provisionally_saved_form_.Reset(); |
| 1059 } | 1064 } |
| 1060 | 1065 |
| 1061 void PasswordAutofillAgent::UserGestureObserved() { | 1066 void PasswordAutofillAgent::UserGestureObserved() { |
| 1062 gatekeeper_.OnUserGesture(); | 1067 gatekeeper_.OnUserGesture(); |
| 1063 } | 1068 } |
| 1064 | 1069 |
| 1065 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { | 1070 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { |
| 1066 std::unique_ptr<RendererSavePasswordProgressLogger> logger; | 1071 std::unique_ptr<RendererSavePasswordProgressLogger> logger; |
| 1067 if (logging_state_active_) { | 1072 if (logging_state_active_) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1202 } | 1207 } |
| 1203 | 1208 |
| 1204 void PasswordAutofillAgent::WillCommitProvisionalLoad() { | 1209 void PasswordAutofillAgent::WillCommitProvisionalLoad() { |
| 1205 FrameClosing(); | 1210 FrameClosing(); |
| 1206 } | 1211 } |
| 1207 | 1212 |
| 1208 void PasswordAutofillAgent::DidCommitProvisionalLoad( | 1213 void PasswordAutofillAgent::DidCommitProvisionalLoad( |
| 1209 bool is_new_navigation, | 1214 bool is_new_navigation, |
| 1210 bool is_same_document_navigation) { | 1215 bool is_same_document_navigation) { |
| 1211 if (is_same_document_navigation) { | 1216 if (is_same_document_navigation) { |
| 1212 OnSameDocumentNavigationCompleted(); | 1217 OnSameDocumentNavigationCompleted(true); |
| 1213 } else { | 1218 } else { |
| 1214 checked_safe_browsing_reputation_ = false; | 1219 checked_safe_browsing_reputation_ = false; |
| 1215 } | 1220 } |
| 1216 } | 1221 } |
| 1217 | 1222 |
| 1218 void PasswordAutofillAgent::FrameDetached() { | 1223 void PasswordAutofillAgent::FrameDetached() { |
| 1219 // If a sub frame has been destroyed while the user was entering information | 1224 // 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 | 1225 // 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. | 1226 // for examples of sites that perform login using this technique. |
| 1222 if (render_frame()->GetWebFrame()->Parent() && | 1227 if (render_frame()->GetWebFrame()->Parent() && |
| 1223 provisionally_saved_form_.IsPasswordValid()) { | 1228 provisionally_saved_form_.IsPasswordValid()) { |
| 1229 provisionally_saved_form_.SetSubmissionEvent( | |
| 1230 PasswordForm::SubmissionEvent::FRAME_DETACHED); | |
| 1224 GetPasswordManagerDriver()->InPageNavigation( | 1231 GetPasswordManagerDriver()->InPageNavigation( |
| 1225 provisionally_saved_form_.password_form()); | 1232 provisionally_saved_form_.password_form()); |
| 1226 } | 1233 } |
| 1227 FrameClosing(); | 1234 FrameClosing(); |
| 1228 } | 1235 } |
| 1229 | 1236 |
| 1230 void PasswordAutofillAgent::WillSendSubmitEvent( | 1237 void PasswordAutofillAgent::WillSendSubmitEvent( |
| 1231 const blink::WebFormElement& form) { | 1238 const blink::WebFormElement& form) { |
| 1232 // Forms submitted via XHR are not seen by WillSubmitForm if the default | 1239 // Forms submitted via XHR are not seen by WillSubmitForm if the default |
| 1233 // onsubmit handler is overridden. Such submission first gets detected in | 1240 // onsubmit handler is overridden. Such submission first gets detected in |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1273 } | 1280 } |
| 1274 if (provisionally_saved_form_.IsSet() && | 1281 if (provisionally_saved_form_.IsSet() && |
| 1275 submitted_form->action == | 1282 submitted_form->action == |
| 1276 provisionally_saved_form_.password_form().action) { | 1283 provisionally_saved_form_.password_form().action) { |
| 1277 if (logger) | 1284 if (logger) |
| 1278 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED); | 1285 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED); |
| 1279 const auto& saved_form = provisionally_saved_form_.password_form(); | 1286 const auto& saved_form = provisionally_saved_form_.password_form(); |
| 1280 submitted_form->password_value = saved_form.password_value; | 1287 submitted_form->password_value = saved_form.password_value; |
| 1281 submitted_form->new_password_value = saved_form.new_password_value; | 1288 submitted_form->new_password_value = saved_form.new_password_value; |
| 1282 submitted_form->username_value = saved_form.username_value; | 1289 submitted_form->username_value = saved_form.username_value; |
| 1290 submitted_form->submission_event = | |
| 1291 PasswordForm::SubmissionEvent::HTML_FORM_SUBMISSION; | |
| 1283 } | 1292 } |
| 1284 | 1293 |
| 1285 // Some observers depend on sending this information now instead of when | 1294 // Some observers depend on sending this information now instead of when |
| 1286 // the frame starts loading. If there are redirects that cause a new | 1295 // the frame starts loading. If there are redirects that cause a new |
| 1287 // RenderView to be instantiated (such as redirects to the WebStore) | 1296 // RenderView to be instantiated (such as redirects to the WebStore) |
| 1288 // we will never get to finish the load. | 1297 // we will never get to finish the load. |
| 1289 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form); | 1298 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form); |
| 1290 provisionally_saved_form_.Reset(); | 1299 provisionally_saved_form_.Reset(); |
| 1291 } else if (logger) { | 1300 } else if (logger) { |
| 1292 logger->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD); | 1301 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 != | 1565 password_form->new_password_element != |
| 1557 input.NameForAutofill().Utf16()) | 1566 input.NameForAutofill().Utf16()) |
| 1558 password_form.reset(); | 1567 password_form.reset(); |
| 1559 } | 1568 } |
| 1560 } | 1569 } |
| 1561 } | 1570 } |
| 1562 | 1571 |
| 1563 if (!password_form) | 1572 if (!password_form) |
| 1564 password_form.reset(new PasswordForm()); | 1573 password_form.reset(new PasswordForm()); |
| 1565 | 1574 |
| 1575 password_form->submission_event = | |
| 1576 PasswordForm::SubmissionEvent::BY_CONTEXT_MENU_CLICK; | |
| 1566 callback.Run(*password_form); | 1577 callback.Run(*password_form); |
| 1567 } | 1578 } |
| 1568 | 1579 |
| 1569 //////////////////////////////////////////////////////////////////////////////// | 1580 //////////////////////////////////////////////////////////////////////////////// |
| 1570 // PasswordAutofillAgent, private: | 1581 // PasswordAutofillAgent, private: |
| 1571 | 1582 |
| 1572 bool PasswordAutofillAgent::ShowSuggestionPopup( | 1583 bool PasswordAutofillAgent::ShowSuggestionPopup( |
| 1573 const PasswordInfo& password_info, | 1584 const PasswordInfo& password_info, |
| 1574 const blink::WebInputElement& user_input, | 1585 const blink::WebInputElement& user_input, |
| 1575 bool show_all, | 1586 bool show_all, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1659 PasswordAutofillAgent::GetPasswordManagerDriver() { | 1670 PasswordAutofillAgent::GetPasswordManagerDriver() { |
| 1660 if (!password_manager_driver_) { | 1671 if (!password_manager_driver_) { |
| 1661 render_frame()->GetRemoteInterfaces()->GetInterface( | 1672 render_frame()->GetRemoteInterfaces()->GetInterface( |
| 1662 mojo::MakeRequest(&password_manager_driver_)); | 1673 mojo::MakeRequest(&password_manager_driver_)); |
| 1663 } | 1674 } |
| 1664 | 1675 |
| 1665 return password_manager_driver_; | 1676 return password_manager_driver_; |
| 1666 } | 1677 } |
| 1667 | 1678 |
| 1668 } // namespace autofill | 1679 } // namespace autofill |
| OLD | NEW |