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

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

Issue 23537014: rAc: Get rid of dialog type in rAc, there is only one type left now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 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/account_chooser_model.h" 5 #include "chrome/browser/ui/autofill/account_chooser_model.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "components/autofill/core/browser/autofill_metrics.h" 14 #include "components/autofill/core/browser/autofill_metrics.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 19
20 namespace autofill { 20 namespace autofill {
21 21
22 const int AccountChooserModel::kActiveWalletItemId = 0; 22 const int AccountChooserModel::kActiveWalletItemId = 0;
23 const int AccountChooserModel::kAutofillItemId = 1; 23 const int AccountChooserModel::kAutofillItemId = 1;
24 24
25 AccountChooserModelDelegate::~AccountChooserModelDelegate() {} 25 AccountChooserModelDelegate::~AccountChooserModelDelegate() {}
26 26
27 AccountChooserModel::AccountChooserModel( 27 AccountChooserModel::AccountChooserModel(
28 AccountChooserModelDelegate* delegate, 28 AccountChooserModelDelegate* delegate,
29 PrefService* prefs, 29 PrefService* prefs,
30 const AutofillMetrics& metric_logger, 30 const AutofillMetrics& metric_logger)
31 DialogType dialog_type)
32 : ui::SimpleMenuModel(this), 31 : ui::SimpleMenuModel(this),
33 delegate_(delegate), 32 delegate_(delegate),
34 checked_item_( 33 checked_item_(
35 prefs->GetBoolean(::prefs::kAutofillDialogPayWithoutWallet) ? 34 prefs->GetBoolean(::prefs::kAutofillDialogPayWithoutWallet) ?
36 kAutofillItemId : kActiveWalletItemId), 35 kAutofillItemId : kActiveWalletItemId),
37 had_wallet_error_(false), 36 had_wallet_error_(false),
38 metric_logger_(metric_logger), 37 metric_logger_(metric_logger) {
39 dialog_type_(dialog_type) {
40 ReconstructMenuItems(); 38 ReconstructMenuItems();
41 } 39 }
42 40
43 AccountChooserModel::~AccountChooserModel() { 41 AccountChooserModel::~AccountChooserModel() {
44 } 42 }
45 43
46 void AccountChooserModel::SelectActiveWalletAccount() { 44 void AccountChooserModel::SelectActiveWalletAccount() {
47 ExecuteCommand(kActiveWalletItemId, 0); 45 ExecuteCommand(kActiveWalletItemId, 0);
48 } 46 }
49 47
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (command_id == kAutofillItemId) { 93 if (command_id == kAutofillItemId) {
96 chooser_event = 94 chooser_event =
97 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_AUTOFILL; 95 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_AUTOFILL;
98 } else if (checked_item_ == kAutofillItemId) { 96 } else if (checked_item_ == kAutofillItemId) {
99 chooser_event = 97 chooser_event =
100 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_WALLET; 98 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_TO_WALLET;
101 } else { 99 } else {
102 chooser_event = 100 chooser_event =
103 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_WALLET_ACCOUNT; 101 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_WALLET_ACCOUNT;
104 } 102 }
105 metric_logger_.LogDialogUiEvent(dialog_type_, chooser_event); 103 metric_logger_.LogDialogUiEvent(chooser_event);
106 104
107 checked_item_ = command_id; 105 checked_item_ = command_id;
108 ReconstructMenuItems(); 106 ReconstructMenuItems();
109 delegate_->AccountChoiceChanged(); 107 delegate_->AccountChoiceChanged();
110 } 108 }
111 109
112 void AccountChooserModel::SetHadWalletError() { 110 void AccountChooserModel::SetHadWalletError() {
113 // Any non-sign-in error disables all Wallet accounts. 111 // Any non-sign-in error disables all Wallet accounts.
114 had_wallet_error_ = true; 112 had_wallet_error_ = true;
115 ClearActiveWalletAccountName(); 113 ClearActiveWalletAccountName();
(...skipping 28 matching lines...) Expand all
144 // A throbber should be shown until the Wallet account name is set. 142 // A throbber should be shown until the Wallet account name is set.
145 AddCheckItem(kActiveWalletItemId, 143 AddCheckItem(kActiveWalletItemId,
146 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_GOOGLE_WALLET)); 144 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_GOOGLE_WALLET));
147 } 145 }
148 146
149 AddCheckItemWithStringId(kAutofillItemId, 147 AddCheckItemWithStringId(kAutofillItemId,
150 IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); 148 IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET);
151 } 149 }
152 150
153 } // namespace autofill 151 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/account_chooser_model.h ('k') | chrome/browser/ui/autofill/account_chooser_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698