| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   81     checked_item_ = kWalletAccountsStartId; |   81     checked_item_ = kWalletAccountsStartId; | 
|   82  |   82  | 
|   83   ReconstructMenuItems(); |   83   ReconstructMenuItems(); | 
|   84   delegate_->UpdateAccountChooserView(); |   84   delegate_->UpdateAccountChooserView(); | 
|   85 } |   85 } | 
|   86  |   86  | 
|   87 base::string16 AccountChooserModel::GetActiveWalletAccountName() const { |   87 base::string16 AccountChooserModel::GetActiveWalletAccountName() const { | 
|   88   if (wallet_accounts_.empty()) |   88   if (wallet_accounts_.empty()) | 
|   89     return base::string16(); |   89     return base::string16(); | 
|   90  |   90  | 
|   91   return UTF8ToUTF16(wallet_accounts_[GetActiveWalletAccountIndex()]); |   91   return base::UTF8ToUTF16(wallet_accounts_[GetActiveWalletAccountIndex()]); | 
|   92 } |   92 } | 
|   93  |   93  | 
|   94 size_t AccountChooserModel::GetActiveWalletAccountIndex() const { |   94 size_t AccountChooserModel::GetActiveWalletAccountIndex() const { | 
|   95   if (!WalletIsSelected()) |   95   if (!WalletIsSelected()) | 
|   96     return 0; |   96     return 0; | 
|   97  |   97  | 
|   98   return checked_item_ - kWalletAccountsStartId; |   98   return checked_item_ - kWalletAccountsStartId; | 
|   99 } |   99 } | 
|  100  |  100  | 
|  101 bool AccountChooserModel::IsCommandIdChecked(int command_id) const { |  101 bool AccountChooserModel::IsCommandIdChecked(int command_id) const { | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  166 bool AccountChooserModel::WalletIsSelected() const { |  166 bool AccountChooserModel::WalletIsSelected() const { | 
|  167   return checked_item_ != kAutofillItemId; |  167   return checked_item_ != kAutofillItemId; | 
|  168 } |  168 } | 
|  169  |  169  | 
|  170 void AccountChooserModel::ReconstructMenuItems() { |  170 void AccountChooserModel::ReconstructMenuItems() { | 
|  171   Clear(); |  171   Clear(); | 
|  172  |  172  | 
|  173   if (!wallet_accounts_.empty()) { |  173   if (!wallet_accounts_.empty()) { | 
|  174     for (size_t i = 0; i < wallet_accounts_.size(); ++i) { |  174     for (size_t i = 0; i < wallet_accounts_.size(); ++i) { | 
|  175       int item_id = kWalletAccountsStartId + i; |  175       int item_id = kWalletAccountsStartId + i; | 
|  176       AddCheckItem(item_id, UTF8ToUTF16(wallet_accounts_[i])); |  176       AddCheckItem(item_id, base::UTF8ToUTF16(wallet_accounts_[i])); | 
|  177     } |  177     } | 
|  178   } else if (checked_item_ == kWalletAccountsStartId) { |  178   } else if (checked_item_ == kWalletAccountsStartId) { | 
|  179     // A selected active Wallet account without account names means |  179     // A selected active Wallet account without account names means | 
|  180     // that the sign-in attempt is in progress. |  180     // that the sign-in attempt is in progress. | 
|  181     AddCheckItem(kWalletAccountsStartId, |  181     AddCheckItem(kWalletAccountsStartId, | 
|  182                  l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_GOOGLE_WALLET)); |  182                  l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_GOOGLE_WALLET)); | 
|  183   } |  183   } | 
|  184  |  184  | 
|  185   AddCheckItemWithStringId(kWalletAddAccountId, |  185   AddCheckItemWithStringId(kWalletAddAccountId, | 
|  186                            IDS_AUTOFILL_DIALOG_ADD_ACCOUNT); |  186                            IDS_AUTOFILL_DIALOG_ADD_ACCOUNT); | 
|  187   AddCheckItemWithStringId(kAutofillItemId, |  187   AddCheckItemWithStringId(kAutofillItemId, | 
|  188                            IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); |  188                            IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); | 
|  189 } |  189 } | 
|  190  |  190  | 
|  191 }  // namespace autofill |  191 }  // namespace autofill | 
| OLD | NEW |