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

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

Issue 2859243004: Add metrics for PasswordForm submission types (Closed)
Patch Set: rebase Created 3 years, 7 months 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 <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
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::INPAGE_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();
1046 if (form_util::IsFormVisible(frame, provisionally_saved_form_.form_element(), 1052 if (form_util::IsFormVisible(frame, provisionally_saved_form_.form_element(),
1047 password_form.action, password_form.origin, 1053 password_form.action, password_form.origin,
1048 password_form.form_data) || 1054 password_form.form_data) ||
1049 (provisionally_saved_form_.form_element().IsNull() && 1055 (provisionally_saved_form_.form_element().IsNull() &&
1050 IsUnownedPasswordFormVisible( 1056 IsUnownedPasswordFormVisible(
1051 frame, provisionally_saved_form_.input_element(), 1057 frame, provisionally_saved_form_.input_element(),
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1208 }
1203 1209
1204 void PasswordAutofillAgent::WillCommitProvisionalLoad() { 1210 void PasswordAutofillAgent::WillCommitProvisionalLoad() {
1205 FrameClosing(); 1211 FrameClosing();
1206 } 1212 }
1207 1213
1208 void PasswordAutofillAgent::DidCommitProvisionalLoad( 1214 void PasswordAutofillAgent::DidCommitProvisionalLoad(
1209 bool is_new_navigation, 1215 bool is_new_navigation,
1210 bool is_same_document_navigation) { 1216 bool is_same_document_navigation) {
1211 if (is_same_document_navigation) { 1217 if (is_same_document_navigation) {
1212 OnSameDocumentNavigationCompleted(); 1218 OnSameDocumentNavigationCompleted(true);
1213 } else { 1219 } else {
1214 checked_safe_browsing_reputation_ = false; 1220 checked_safe_browsing_reputation_ = false;
1215 } 1221 }
1216 } 1222 }
1217 1223
1218 void PasswordAutofillAgent::FrameDetached() { 1224 void PasswordAutofillAgent::FrameDetached() {
1219 // If a sub frame has been destroyed while the user was entering information 1225 // 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 1226 // 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. 1227 // for examples of sites that perform login using this technique.
1222 if (render_frame()->GetWebFrame()->Parent() && 1228 if (render_frame()->GetWebFrame()->Parent() &&
1223 provisionally_saved_form_.IsPasswordValid()) { 1229 provisionally_saved_form_.IsPasswordValid()) {
1230 provisionally_saved_form_.SetSubmissionIndicatorEvent(
1231 PasswordForm::SubmissionIndicatorEvent::FRAME_DETACHED);
1224 GetPasswordManagerDriver()->InPageNavigation( 1232 GetPasswordManagerDriver()->InPageNavigation(
1225 provisionally_saved_form_.password_form()); 1233 provisionally_saved_form_.password_form());
1226 } 1234 }
1227 FrameClosing(); 1235 FrameClosing();
1228 } 1236 }
1229 1237
1230 void PasswordAutofillAgent::WillSendSubmitEvent( 1238 void PasswordAutofillAgent::WillSendSubmitEvent(
1231 const blink::WebFormElement& form) { 1239 const blink::WebFormElement& form) {
1232 // Forms submitted via XHR are not seen by WillSubmitForm if the default 1240 // Forms submitted via XHR are not seen by WillSubmitForm if the default
1233 // onsubmit handler is overridden. Such submission first gets detected in 1241 // onsubmit handler is overridden. Such submission first gets detected in
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 } 1281 }
1274 if (provisionally_saved_form_.IsSet() && 1282 if (provisionally_saved_form_.IsSet() &&
1275 submitted_form->action == 1283 submitted_form->action ==
1276 provisionally_saved_form_.password_form().action) { 1284 provisionally_saved_form_.password_form().action) {
1277 if (logger) 1285 if (logger)
1278 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED); 1286 logger->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED);
1279 const auto& saved_form = provisionally_saved_form_.password_form(); 1287 const auto& saved_form = provisionally_saved_form_.password_form();
1280 submitted_form->password_value = saved_form.password_value; 1288 submitted_form->password_value = saved_form.password_value;
1281 submitted_form->new_password_value = saved_form.new_password_value; 1289 submitted_form->new_password_value = saved_form.new_password_value;
1282 submitted_form->username_value = saved_form.username_value; 1290 submitted_form->username_value = saved_form.username_value;
1291 submitted_form->submission_event =
1292 PasswordForm::SubmissionIndicatorEvent::HTML_FORM_SUBMISSION;
1283 } 1293 }
1284 1294
1285 // Some observers depend on sending this information now instead of when 1295 // Some observers depend on sending this information now instead of when
1286 // the frame starts loading. If there are redirects that cause a new 1296 // the frame starts loading. If there are redirects that cause a new
1287 // RenderView to be instantiated (such as redirects to the WebStore) 1297 // RenderView to be instantiated (such as redirects to the WebStore)
1288 // we will never get to finish the load. 1298 // we will never get to finish the load.
1289 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form); 1299 GetPasswordManagerDriver()->PasswordFormSubmitted(*submitted_form);
1290 provisionally_saved_form_.Reset(); 1300 provisionally_saved_form_.Reset();
1291 } else if (logger) { 1301 } else if (logger) {
1292 logger->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD); 1302 logger->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 password_form->new_password_element != 1566 password_form->new_password_element !=
1557 input.NameForAutofill().Utf16()) 1567 input.NameForAutofill().Utf16())
1558 password_form.reset(); 1568 password_form.reset();
1559 } 1569 }
1560 } 1570 }
1561 } 1571 }
1562 1572
1563 if (!password_form) 1573 if (!password_form)
1564 password_form.reset(new PasswordForm()); 1574 password_form.reset(new PasswordForm());
1565 1575
1576 password_form->submission_event =
1577 PasswordForm::SubmissionIndicatorEvent::BY_CONTEXT_MENU_CLICK;
1566 callback.Run(*password_form); 1578 callback.Run(*password_form);
1567 } 1579 }
1568 1580
1569 //////////////////////////////////////////////////////////////////////////////// 1581 ////////////////////////////////////////////////////////////////////////////////
1570 // PasswordAutofillAgent, private: 1582 // PasswordAutofillAgent, private:
1571 1583
1572 bool PasswordAutofillAgent::ShowSuggestionPopup( 1584 bool PasswordAutofillAgent::ShowSuggestionPopup(
1573 const PasswordInfo& password_info, 1585 const PasswordInfo& password_info,
1574 const blink::WebInputElement& user_input, 1586 const blink::WebInputElement& user_input,
1575 bool show_all, 1587 bool show_all,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 PasswordAutofillAgent::GetPasswordManagerDriver() { 1671 PasswordAutofillAgent::GetPasswordManagerDriver() {
1660 if (!password_manager_driver_) { 1672 if (!password_manager_driver_) {
1661 render_frame()->GetRemoteInterfaces()->GetInterface( 1673 render_frame()->GetRemoteInterfaces()->GetInterface(
1662 mojo::MakeRequest(&password_manager_driver_)); 1674 mojo::MakeRequest(&password_manager_driver_));
1663 } 1675 }
1664 1676
1665 return password_manager_driver_; 1677 return password_manager_driver_;
1666 } 1678 }
1667 1679
1668 } // namespace autofill 1680 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698