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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 12588002: [Autofill] Add user type metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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 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 "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/ui/base_window.h" 24 #include "chrome/browser/ui/base_window.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_finder.h" 26 #include "chrome/browser/ui/browser_finder.h"
27 #include "chrome/browser/ui/browser_window.h" 27 #include "chrome/browser/ui/browser_window.h"
28 #include "chrome/browser/ui/extensions/native_app_window.h" 28 #include "chrome/browser/ui/extensions/native_app_window.h"
29 #include "chrome/browser/ui/extensions/shell_window.h" 29 #include "chrome/browser/ui/extensions/shell_window.h"
30 #include "chrome/common/chrome_version_info.h" 30 #include "chrome/common/chrome_version_info.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "components/autofill/browser/autofill_country.h" 32 #include "components/autofill/browser/autofill_country.h"
33 #include "components/autofill/browser/autofill_manager.h" 33 #include "components/autofill/browser/autofill_manager.h"
34 #include "components/autofill/browser/autofill_metrics.h"
35 #include "components/autofill/browser/autofill_type.h" 34 #include "components/autofill/browser/autofill_type.h"
36 #include "components/autofill/browser/personal_data_manager.h" 35 #include "components/autofill/browser/personal_data_manager.h"
37 #include "components/autofill/browser/risk/fingerprint.h" 36 #include "components/autofill/browser/risk/fingerprint.h"
38 #include "components/autofill/browser/risk/proto/fingerprint.pb.h" 37 #include "components/autofill/browser/risk/proto/fingerprint.pb.h"
39 #include "components/autofill/browser/validation.h" 38 #include "components/autofill/browser/validation.h"
40 #include "components/autofill/browser/wallet/cart.h" 39 #include "components/autofill/browser/wallet/cart.h"
41 #include "components/autofill/browser/wallet/full_wallet.h" 40 #include "components/autofill/browser/wallet/full_wallet.h"
42 #include "components/autofill/browser/wallet/instrument.h" 41 #include "components/autofill/browser/wallet/instrument.h"
43 #include "components/autofill/browser/wallet/wallet_address.h" 42 #include "components/autofill/browser/wallet/wallet_address.h"
44 #include "components/autofill/browser/wallet/wallet_items.h" 43 #include "components/autofill/browser/wallet/wallet_items.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 ALLOW_THIS_IN_INITIALIZER_LIST( 235 ALLOW_THIS_IN_INITIALIZER_LIST(
237 wallet_client_(profile_->GetRequestContext(), this)), 236 wallet_client_(profile_->GetRequestContext(), this)),
238 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), 237 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)),
239 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), 238 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)),
240 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), 239 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)),
241 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)), 240 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)),
242 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), 241 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)),
243 section_showing_popup_(SECTION_BILLING), 242 section_showing_popup_(SECTION_BILLING),
244 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 243 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
245 metric_logger_(metric_logger), 244 metric_logger_(metric_logger),
245 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
246 dialog_type_(dialog_type), 246 dialog_type_(dialog_type),
247 did_submit_(false), 247 did_submit_(false),
248 autocheckout_is_running_(false), 248 autocheckout_is_running_(false),
249 had_autocheckout_error_(false) { 249 had_autocheckout_error_(false) {
250 // TODO(estade): remove duplicates from |form|? 250 // TODO(estade): remove duplicates from |form|?
251 } 251 }
252 252
253 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { 253 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() {
254 if (popup_controller_) 254 if (popup_controller_)
255 popup_controller_->Hide(); 255 popup_controller_->Hide();
256
257 metric_logger_.LogDialogInitialUserState(dialog_type_, initial_user_state_);
256 } 258 }
257 259
258 // static 260 // static
259 void AutofillDialogControllerImpl::RegisterUserPrefs( 261 void AutofillDialogControllerImpl::RegisterUserPrefs(
260 PrefRegistrySyncable* registry) { 262 PrefRegistrySyncable* registry) {
261 registry->RegisterBooleanPref(prefs::kAutofillDialogPayWithoutWallet, 263 registry->RegisterBooleanPref(prefs::kAutofillDialogPayWithoutWallet,
262 kPayWithoutWalletDefault, 264 kPayWithoutWalletDefault,
263 PrefRegistrySyncable::SYNCABLE_PREF); 265 PrefRegistrySyncable::SYNCABLE_PREF);
264 } 266 }
265 267
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 } 1107 }
1106 1108
1107 void AutofillDialogControllerImpl::OnDidGetWalletItems( 1109 void AutofillDialogControllerImpl::OnDidGetWalletItems(
1108 scoped_ptr<wallet::WalletItems> wallet_items) { 1110 scoped_ptr<wallet::WalletItems> wallet_items) {
1109 // TODO(dbeam): verify all items support kCartCurrency? 1111 // TODO(dbeam): verify all items support kCartCurrency?
1110 wallet_items_ = wallet_items.Pass(); 1112 wallet_items_ = wallet_items.Pass();
1111 GenerateSuggestionsModels(); 1113 GenerateSuggestionsModels();
1112 view_->ModelChanged(); 1114 view_->ModelChanged();
1113 view_->UpdateAccountChooser(); 1115 view_->UpdateAccountChooser();
1114 view_->UpdateNotificationArea(); 1116 view_->UpdateNotificationArea();
1117
1118 // On the first successful response, compute the initial user state metric.
1119 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN)
1120 initial_user_state_ = GetInitialUserState();
1115 } 1121 }
1116 1122
1117 void AutofillDialogControllerImpl::OnDidSaveAddress( 1123 void AutofillDialogControllerImpl::OnDidSaveAddress(
1118 const std::string& address_id, 1124 const std::string& address_id,
1119 const std::vector<wallet::RequiredAction>& required_actions) { 1125 const std::vector<wallet::RequiredAction>& required_actions) {
1120 // TODO(dbeam): handle required actions. 1126 // TODO(dbeam): handle required actions.
1121 active_address_id_ = address_id; 1127 active_address_id_ = address_id;
1122 GetFullWallet(); 1128 GetFullWallet();
1123 } 1129 }
1124 1130
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 } 1654 }
1649 callback_.Run(&form_structure_); 1655 callback_.Run(&form_structure_);
1650 callback_ = base::Callback<void(const FormStructure*)>(); 1656 callback_ = base::Callback<void(const FormStructure*)>();
1651 1657
1652 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { 1658 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) {
1653 // This may delete us. 1659 // This may delete us.
1654 Hide(); 1660 Hide();
1655 } 1661 }
1656 } 1662 }
1657 1663
1664 AutofillMetrics::DialogInitialUserStateMetric
1665 AutofillDialogControllerImpl::GetInitialUserState() const {
1666 // Consider a user to be an Autofill user if the user has any credit cards
1667 // or addresses saved. Check that the item count is greater than 1 because
1668 // an "empty" menu still has the "add new" menu item.
1669 const bool has_autofill_profiles =
1670 suggested_cc_.GetItemCount() > 1 ||
1671 suggested_billing_.GetItemCount() > 1;
1672
1673 if (SignedInState() != SIGNED_IN) {
1674 // Not signed in.
1675 return has_autofill_profiles ?
1676 AutofillMetrics::DIALOG_USER_NOT_SIGNED_IN_HAS_AUTOFILL :
1677 AutofillMetrics::DIALOG_USER_NOT_SIGNED_IN_NO_AUTOFILL;
1678 }
1679
1680 // Signed in.
1681 if (wallet_items_->instruments().empty()) {
1682 // No Wallet items.
1683 return has_autofill_profiles ?
1684 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_HAS_AUTOFILL :
1685 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
1686 }
1687
1688 // Has Wallet items.
1689 return has_autofill_profiles ?
1690 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
1691 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
1692 }
1693
1658 } // namespace autofill 1694 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698