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

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 7740070: Add metrics to measure time elapsed between form load and form submission with or without Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Once more, with feeling Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/autofill/autofill_manager.h" 5 #include "chrome/browser/autofill/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/common/notification_service.h" 45 #include "content/common/notification_service.h"
46 #include "content/common/notification_source.h" 46 #include "content/common/notification_source.h"
47 #include "googleurl/src/gurl.h" 47 #include "googleurl/src/gurl.h"
48 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
49 #include "ipc/ipc_message_macros.h" 49 #include "ipc/ipc_message_macros.h"
50 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
51 #include "webkit/glue/form_data.h" 51 #include "webkit/glue/form_data.h"
52 #include "webkit/glue/form_data_predictions.h" 52 #include "webkit/glue/form_data_predictions.h"
53 #include "webkit/glue/form_field.h" 53 #include "webkit/glue/form_field.h"
54 54
55 using base::TimeTicks;
55 using switches::kEnableAutofillFeedback; 56 using switches::kEnableAutofillFeedback;
56 using webkit_glue::FormData; 57 using webkit_glue::FormData;
57 using webkit_glue::FormDataPredictions; 58 using webkit_glue::FormDataPredictions;
58 using webkit_glue::FormField; 59 using webkit_glue::FormField;
59 60
60 namespace { 61 namespace {
61 62
62 // We only send a fraction of the forms to upload server. 63 // We only send a fraction of the forms to upload server.
63 // The rate for positive/negative matches potentially could be different. 64 // The rate for positive/negative matches potentially could be different.
64 const double kAutofillPositiveUploadRateDefaultValue = 0.20; 65 const double kAutofillPositiveUploadRateDefaultValue = 0.20;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, 297 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData,
297 OnDidFillAutofillFormData) 298 OnDidFillAutofillFormData)
298 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, 299 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions,
299 OnDidShowAutofillSuggestions) 300 OnDidShowAutofillSuggestions)
300 IPC_MESSAGE_UNHANDLED(handled = false) 301 IPC_MESSAGE_UNHANDLED(handled = false)
301 IPC_END_MESSAGE_MAP() 302 IPC_END_MESSAGE_MAP()
302 303
303 return handled; 304 return handled;
304 } 305 }
305 306
306 void AutofillManager::OnFormSubmitted(const FormData& form) { 307 void AutofillManager::OnFormSubmitted(const FormData& form,
308 const TimeTicks& timestamp) {
307 // Let AutoComplete know as well. 309 // Let AutoComplete know as well.
308 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); 310 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form);
309 311
310 if (!IsAutofillEnabled()) 312 if (!IsAutofillEnabled())
311 return; 313 return;
312 314
313 if (tab_contents()->browser_context()->IsOffTheRecord()) 315 if (tab_contents()->browser_context()->IsOffTheRecord())
314 return; 316 return;
315 317
316 // Don't save data that was submitted through JavaScript. 318 // Don't save data that was submitted through JavaScript.
(...skipping 12 matching lines...) Expand all
329 FormStructure* cached_submitted_form; 331 FormStructure* cached_submitted_form;
330 if (!FindCachedForm(form, &cached_submitted_form)) 332 if (!FindCachedForm(form, &cached_submitted_form))
331 return; 333 return;
332 submitted_form.UpdateFromCache(*cached_submitted_form); 334 submitted_form.UpdateFromCache(*cached_submitted_form);
333 335
334 // Only upload server statistics and UMA metrics if at least some local data 336 // Only upload server statistics and UMA metrics if at least some local data
335 // is available to use as a baseline. 337 // is available to use as a baseline.
336 if (!personal_data_->profiles().empty() || 338 if (!personal_data_->profiles().empty() ||
337 !personal_data_->credit_cards().empty()) { 339 !personal_data_->credit_cards().empty()) {
338 DeterminePossibleFieldTypesForUpload(&submitted_form); 340 DeterminePossibleFieldTypesForUpload(&submitted_form);
339 submitted_form.LogQualityMetrics(*metric_logger_); 341 submitted_form.LogQualityMetrics(*metric_logger_,
342 forms_loaded_timestamp_,
343 initial_interaction_timestamp_,
344 timestamp);
340 345
341 if (submitted_form.ShouldBeCrowdsourced()) 346 if (submitted_form.ShouldBeCrowdsourced())
342 UploadFormData(submitted_form); 347 UploadFormData(submitted_form);
343 } 348 }
344 349
345 if (!submitted_form.IsAutofillable(true)) 350 if (!submitted_form.IsAutofillable(true))
346 return; 351 return;
347 352
348 ImportFormData(submitted_form); 353 ImportFormData(submitted_form);
349 } 354 }
350 355
351 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms) { 356 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,
357 const TimeTicks& timestamp) {
352 bool enabled = IsAutofillEnabled(); 358 bool enabled = IsAutofillEnabled();
353 if (!has_logged_autofill_enabled_) { 359 if (!has_logged_autofill_enabled_) {
354 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled); 360 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled);
355 has_logged_autofill_enabled_ = true; 361 has_logged_autofill_enabled_ = true;
356 } 362 }
357 363
358 if (!enabled) 364 if (!enabled)
359 return; 365 return;
360 366
367 forms_loaded_timestamp_ = timestamp;
361 ParseForms(forms); 368 ParseForms(forms);
362 } 369 }
363 370
364 void AutofillManager::OnTextFieldDidChange(const FormData& form, 371 void AutofillManager::OnTextFieldDidChange(const FormData& form,
365 const FormField& field) { 372 const FormField& field,
373 const TimeTicks& timestamp) {
366 FormStructure* form_structure = NULL; 374 FormStructure* form_structure = NULL;
367 AutofillField* autofill_field = NULL; 375 AutofillField* autofill_field = NULL;
368 if (!FindCachedFormAndField(form, field, &form_structure, &autofill_field)) 376 if (!FindCachedFormAndField(form, field, &form_structure, &autofill_field))
369 return; 377 return;
370 378
371 if (!user_did_type_) { 379 if (!user_did_type_) {
372 user_did_type_ = true; 380 user_did_type_ = true;
373 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE); 381 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
374 } 382 }
375 383
376 if (autofill_field->is_autofilled) { 384 if (autofill_field->is_autofilled) {
377 autofill_field->is_autofilled = false; 385 autofill_field->is_autofilled = false;
378 metric_logger_->LogUserHappinessMetric( 386 metric_logger_->LogUserHappinessMetric(
379 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD); 387 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
380 388
381 if (!user_did_edit_autofilled_field_) { 389 if (!user_did_edit_autofilled_field_) {
382 user_did_edit_autofilled_field_ = true; 390 user_did_edit_autofilled_field_ = true;
383 metric_logger_->LogUserHappinessMetric( 391 metric_logger_->LogUserHappinessMetric(
384 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE); 392 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE);
385 } 393 }
386 } 394 }
395
396 UpdateInitialInteractionTimestamp(timestamp);
387 } 397 }
388 398
389 void AutofillManager::OnQueryFormFieldAutofill( 399 void AutofillManager::OnQueryFormFieldAutofill(
390 int query_id, 400 int query_id,
391 const webkit_glue::FormData& form, 401 const webkit_glue::FormData& form,
392 const webkit_glue::FormField& field) { 402 const webkit_glue::FormField& field) {
393 std::vector<string16> values; 403 std::vector<string16> values;
394 std::vector<string16> labels; 404 std::vector<string16> labels;
395 std::vector<string16> icons; 405 std::vector<string16> icons;
396 std::vector<int> unique_ids; 406 std::vector<int> unique_ids;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 636 }
627 637
628 void AutofillManager::OnDidPreviewAutofillFormData() { 638 void AutofillManager::OnDidPreviewAutofillFormData() {
629 NotificationService::current()->Notify( 639 NotificationService::current()->Notify(
630 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, 640 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
631 Source<RenderViewHost>(tab_contents()->render_view_host()), 641 Source<RenderViewHost>(tab_contents()->render_view_host()),
632 NotificationService::NoDetails()); 642 NotificationService::NoDetails());
633 } 643 }
634 644
635 645
636 void AutofillManager::OnDidFillAutofillFormData() { 646 void AutofillManager::OnDidFillAutofillFormData(const TimeTicks& timestamp) {
637 NotificationService::current()->Notify( 647 NotificationService::current()->Notify(
638 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, 648 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
639 Source<RenderViewHost>(tab_contents()->render_view_host()), 649 Source<RenderViewHost>(tab_contents()->render_view_host()),
640 NotificationService::NoDetails()); 650 NotificationService::NoDetails());
641 651
642 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL); 652 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
643 if (!user_did_autofill_) { 653 if (!user_did_autofill_) {
644 user_did_autofill_ = true; 654 user_did_autofill_ = true;
645 metric_logger_->LogUserHappinessMetric( 655 metric_logger_->LogUserHappinessMetric(
646 AutofillMetrics::USER_DID_AUTOFILL_ONCE); 656 AutofillMetrics::USER_DID_AUTOFILL_ONCE);
647 } 657 }
658
659 UpdateInitialInteractionTimestamp(timestamp);
648 } 660 }
649 661
650 void AutofillManager::OnDidShowAutofillSuggestions(bool is_new_popup) { 662 void AutofillManager::OnDidShowAutofillSuggestions(bool is_new_popup) {
651 NotificationService::current()->Notify( 663 NotificationService::current()->Notify(
652 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS, 664 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
653 Source<RenderViewHost>(tab_contents()->render_view_host()), 665 Source<RenderViewHost>(tab_contents()->render_view_host()),
654 NotificationService::NoDetails()); 666 NotificationService::NoDetails());
655 667
656 if (is_new_popup) { 668 if (is_new_popup) {
657 metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN); 669 metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 780 }
769 781
770 void AutofillManager::Reset() { 782 void AutofillManager::Reset() {
771 form_structures_.reset(); 783 form_structures_.reset();
772 has_logged_autofill_enabled_ = false; 784 has_logged_autofill_enabled_ = false;
773 has_logged_address_suggestions_count_ = false; 785 has_logged_address_suggestions_count_ = false;
774 did_show_suggestions_ = false; 786 did_show_suggestions_ = false;
775 user_did_type_ = false; 787 user_did_type_ = false;
776 user_did_autofill_ = false; 788 user_did_autofill_ = false;
777 user_did_edit_autofilled_field_ = false; 789 user_did_edit_autofilled_field_ = false;
790 forms_loaded_timestamp_ = TimeTicks();
791 initial_interaction_timestamp_ = TimeTicks();
778 } 792 }
779 793
780 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, 794 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents,
781 PersonalDataManager* personal_data) 795 PersonalDataManager* personal_data)
782 : TabContentsObserver(tab_contents->tab_contents()), 796 : TabContentsObserver(tab_contents->tab_contents()),
783 tab_contents_wrapper_(tab_contents), 797 tab_contents_wrapper_(tab_contents),
784 personal_data_(personal_data), 798 personal_data_(personal_data),
785 download_manager_(NULL), 799 download_manager_(NULL),
786 disable_download_manager_requests_(true), 800 disable_download_manager_requests_(true),
787 metric_logger_(new AutofillMetrics), 801 metric_logger_(new AutofillMetrics),
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 void AutofillManager::UnpackGUIDs(int id, 1158 void AutofillManager::UnpackGUIDs(int id,
1145 GUIDPair* cc_guid, 1159 GUIDPair* cc_guid,
1146 GUIDPair* profile_guid) { 1160 GUIDPair* profile_guid) {
1147 int cc_id = id >> std::numeric_limits<unsigned short>::digits & 1161 int cc_id = id >> std::numeric_limits<unsigned short>::digits &
1148 std::numeric_limits<unsigned short>::max(); 1162 std::numeric_limits<unsigned short>::max();
1149 int profile_id = id & std::numeric_limits<unsigned short>::max(); 1163 int profile_id = id & std::numeric_limits<unsigned short>::max();
1150 1164
1151 *cc_guid = IDToGUID(cc_id); 1165 *cc_guid = IDToGUID(cc_id);
1152 *profile_guid = IDToGUID(profile_id); 1166 *profile_guid = IDToGUID(profile_id);
1153 } 1167 }
1168
1169 void AutofillManager::UpdateInitialInteractionTimestamp(
1170 const TimeTicks& interaction_timestamp) {
1171 if (initial_interaction_timestamp_.is_null() ||
1172 interaction_timestamp < initial_interaction_timestamp_) {
1173 initial_interaction_timestamp_ = interaction_timestamp;
1174 }
1175 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698