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

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: Enumerate all the cases, including the error case 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/full_wallet.h" 39 #include "components/autofill/browser/wallet/full_wallet.h"
41 #include "components/autofill/browser/wallet/wallet_items.h" 40 #include "components/autofill/browser/wallet/wallet_items.h"
42 #include "components/autofill/browser/wallet/wallet_service_url.h" 41 #include "components/autofill/browser/wallet/wallet_service_url.h"
43 #include "components/autofill/common/form_data.h" 42 #include "components/autofill/common/form_data.h"
44 #include "components/user_prefs/pref_registry_syncable.h" 43 #include "components/user_prefs/pref_registry_syncable.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 ALLOW_THIS_IN_INITIALIZER_LIST( 181 ALLOW_THIS_IN_INITIALIZER_LIST(
183 wallet_client_(profile_->GetRequestContext(), this)), 182 wallet_client_(profile_->GetRequestContext(), this)),
184 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), 183 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)),
185 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), 184 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)),
186 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), 185 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)),
187 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)), 186 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)),
188 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), 187 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)),
189 section_showing_popup_(SECTION_BILLING), 188 section_showing_popup_(SECTION_BILLING),
190 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 189 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
191 metric_logger_(metric_logger), 190 metric_logger_(metric_logger),
191 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
192 dialog_type_(dialog_type), 192 dialog_type_(dialog_type),
193 did_submit_(false), 193 did_submit_(false),
194 autocheckout_is_running_(false), 194 autocheckout_is_running_(false),
195 had_autocheckout_error_(false) { 195 had_autocheckout_error_(false) {
196 // TODO(estade): remove duplicates from |form|? 196 // TODO(estade): remove duplicates from |form|?
197 } 197 }
198 198
199 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { 199 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() {
200 if (popup_controller_) 200 if (popup_controller_)
201 popup_controller_->Hide(); 201 popup_controller_->Hide();
202
203 metric_logger_.LogDialogInitialUserState(dialog_type_, initial_user_state_);
202 } 204 }
203 205
204 // static 206 // static
205 void AutofillDialogControllerImpl::RegisterUserPrefs( 207 void AutofillDialogControllerImpl::RegisterUserPrefs(
206 PrefRegistrySyncable* registry) { 208 PrefRegistrySyncable* registry) {
207 registry->RegisterBooleanPref(prefs::kAutofillDialogPayWithoutWallet, 209 registry->RegisterBooleanPref(prefs::kAutofillDialogPayWithoutWallet,
208 kPayWithoutWalletDefault, 210 kPayWithoutWalletDefault,
209 PrefRegistrySyncable::SYNCABLE_PREF); 211 PrefRegistrySyncable::SYNCABLE_PREF);
210 } 212 }
211 213
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 bool items_changed = !wallet_items_ || *wallet_items != *wallet_items_; 1055 bool items_changed = !wallet_items_ || *wallet_items != *wallet_items_;
1054 wallet_items_ = wallet_items.Pass(); 1056 wallet_items_ = wallet_items.Pass();
1055 WalletRequestCompleted(true); 1057 WalletRequestCompleted(true);
1056 1058
1057 if (items_changed) { 1059 if (items_changed) {
1058 GenerateSuggestionsModels(); 1060 GenerateSuggestionsModels();
1059 view_->ModelChanged(); 1061 view_->ModelChanged();
1060 view_->UpdateAccountChooser(); 1062 view_->UpdateAccountChooser();
1061 view_->UpdateNotificationArea(); 1063 view_->UpdateNotificationArea();
1062 } 1064 }
1065
1066 // On the first successful response, compute the initial user state metric.
1067 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN)
1068 initial_user_state_ = GetInitialUserState();
1063 } 1069 }
1064 1070
1065 void AutofillDialogControllerImpl::OnDidSaveAddress( 1071 void AutofillDialogControllerImpl::OnDidSaveAddress(
1066 const std::string& address_id, 1072 const std::string& address_id,
1067 const std::vector<wallet::RequiredAction>& required_actions) { 1073 const std::vector<wallet::RequiredAction>& required_actions) {
1068 NOTIMPLEMENTED() << " address_id=" << address_id 1074 NOTIMPLEMENTED() << " address_id=" << address_id
1069 << ", required_actions=" << !required_actions.empty(); 1075 << ", required_actions=" << !required_actions.empty();
1070 WalletRequestCompleted(true); 1076 WalletRequestCompleted(true);
1071 } 1077 }
1072 1078
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 std::string item_key = model->GetItemKeyForCheckedItem(); 1467 std::string item_key = model->GetItemKeyForCheckedItem();
1462 // If the user is editing or inputting data, ask the view. 1468 // If the user is editing or inputting data, ask the view.
1463 if (item_key.empty() || section_editing_state_[SECTION_SHIPPING]) 1469 if (item_key.empty() || section_editing_state_[SECTION_SHIPPING])
1464 return view_->UseBillingForShipping(); 1470 return view_->UseBillingForShipping();
1465 1471
1466 // Otherwise, the checkbox should be hidden so its state is irrelevant. 1472 // Otherwise, the checkbox should be hidden so its state is irrelevant.
1467 // Always use the shipping suggestion model. 1473 // Always use the shipping suggestion model.
1468 return false; 1474 return false;
1469 } 1475 }
1470 1476
1477 AutofillMetrics::DialogInitialUserStateMetric
1478 AutofillDialogControllerImpl::GetInitialUserState() const {
1479 // Consider a user to be an Autofill user if the user has any credit cards
1480 // or addresses saved. Check that the item count is greater than 1 because
1481 // an "empty" menu still has the "add new" menu item.
1482 const bool has_autofill_profiles =
1483 suggested_cc_.GetItemCount() > 1 ||
1484 suggested_billing_.GetItemCount() > 1;
1485
1486 if (SignedInState() != SIGNED_IN) {
1487 // Not signed in.
1488 return has_autofill_profiles ?
1489 AutofillMetrics::DIALOG_USER_NOT_SIGNED_IN_HAS_AUTOFILL :
1490 AutofillMetrics::DIALOG_USER_NOT_SIGNED_IN_NO_AUTOFILL;
1491 }
1492
1493 // Signed in.
1494 if (wallet_items_->instruments().empty()) {
1495 // No Wallet items.
1496 return has_autofill_profiles ?
1497 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_HAS_AUTOFILL :
1498 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
1499 }
1500
1501 // Has Wallet items.
1502 return has_autofill_profiles ?
1503 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
1504 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
1505 }
1506
1471 } // namespace autofill 1507 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698