| OLD | NEW |
| 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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) | 31 DialogType dialog_type) |
| 32 : ui::SimpleMenuModel(this), | 32 : ui::SimpleMenuModel(this), |
| 33 delegate_(delegate), | 33 delegate_(delegate), |
| 34 checked_item_( | 34 checked_item_( |
| 35 prefs->GetBoolean(::prefs::kAutofillDialogPayWithoutWallet) ? | 35 prefs->GetBoolean(::prefs::kAutofillDialogPayWithoutWallet) ? |
| 36 kAutofillItemId : kActiveWalletItemId), | 36 kAutofillItemId : kActiveWalletItemId), |
| 37 wallet_error_(false), |
| 37 metric_logger_(metric_logger), | 38 metric_logger_(metric_logger), |
| 38 dialog_type_(dialog_type) { | 39 dialog_type_(dialog_type) { |
| 39 ReconstructMenuItems(); | 40 ReconstructMenuItems(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 AccountChooserModel::~AccountChooserModel() { | 43 AccountChooserModel::~AccountChooserModel() { |
| 43 } | 44 } |
| 44 | 45 |
| 45 void AccountChooserModel::SelectActiveWalletAccount() { | 46 void AccountChooserModel::SelectActiveWalletAccount() { |
| 46 ExecuteCommand(kActiveWalletItemId, 0); | 47 ExecuteCommand(kActiveWalletItemId, 0); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 chooser_event = | 102 chooser_event = |
| 102 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_WALLET_ACCOUNT; | 103 AutofillMetrics::DIALOG_UI_ACCOUNT_CHOOSER_SWITCHED_WALLET_ACCOUNT; |
| 103 } | 104 } |
| 104 metric_logger_.LogDialogUiEvent(dialog_type_, chooser_event); | 105 metric_logger_.LogDialogUiEvent(dialog_type_, chooser_event); |
| 105 | 106 |
| 106 checked_item_ = command_id; | 107 checked_item_ = command_id; |
| 107 ReconstructMenuItems(); | 108 ReconstructMenuItems(); |
| 108 delegate_->AccountChoiceChanged(); | 109 delegate_->AccountChoiceChanged(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void AccountChooserModel::SetHadWalletError(const base::string16& message) { | 112 void AccountChooserModel::SetHadWalletError() { |
| 112 // Any non-sign-in error disables all Wallet accounts. | 113 // Any non-sign-in error disables all Wallet accounts. |
| 113 wallet_error_message_ = message; | 114 wallet_error_ = true; |
| 114 ClearActiveWalletAccountName(); | 115 ClearActiveWalletAccountName(); |
| 115 ExecuteCommand(kAutofillItemId, 0); | 116 ExecuteCommand(kAutofillItemId, 0); |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool AccountChooserModel::HadWalletError() const { | 119 bool AccountChooserModel::HadWalletError() const { |
| 119 return !wallet_error_message_.empty(); | 120 return wallet_error_; |
| 120 } | 121 } |
| 121 | 122 |
| 122 void AccountChooserModel::SetHadWalletSigninError() { | 123 void AccountChooserModel::SetHadWalletSigninError() { |
| 123 ClearActiveWalletAccountName(); | 124 ClearActiveWalletAccountName(); |
| 124 ExecuteCommand(kAutofillItemId, 0); | 125 ExecuteCommand(kAutofillItemId, 0); |
| 125 } | 126 } |
| 126 | 127 |
| 127 bool AccountChooserModel::WalletIsSelected() const { | 128 bool AccountChooserModel::WalletIsSelected() const { |
| 128 return checked_item_ != kAutofillItemId; | 129 return checked_item_ != kAutofillItemId; |
| 129 } | 130 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 147 // A throbber should be shown until the Wallet account name is set. | 148 // A throbber should be shown until the Wallet account name is set. |
| 148 AddCheckItem(kActiveWalletItemId, | 149 AddCheckItem(kActiveWalletItemId, |
| 149 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_GOOGLE_WALLET)); | 150 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_GOOGLE_WALLET)); |
| 150 } | 151 } |
| 151 | 152 |
| 152 AddCheckItemWithStringId(kAutofillItemId, | 153 AddCheckItemWithStringId(kAutofillItemId, |
| 153 IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); | 154 IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); |
| 154 } | 155 } |
| 155 | 156 |
| 156 } // namespace autofill | 157 } // namespace autofill |
| OLD | NEW |