Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 virtual ~AccountChooserModel(); | 115 virtual ~AccountChooserModel(); |
| 116 | 116 |
| 117 // ui::SimpleMenuModel::Delegate implementation. | 117 // ui::SimpleMenuModel::Delegate implementation. |
| 118 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 118 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 119 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 119 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 120 virtual bool GetAcceleratorForCommandId( | 120 virtual bool GetAcceleratorForCommandId( |
| 121 int command_id, | 121 int command_id, |
| 122 ui::Accelerator* accelerator) OVERRIDE; | 122 ui::Accelerator* accelerator) OVERRIDE; |
| 123 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 123 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 124 | 124 |
| 125 // Forces the currently selected account to be the Wallet as part of | |
| 126 // interactive sign-in flows (e.g. when the user clicks the "Sign in" link) | |
| 127 // which should be considered as the selected account change. | |
|
Evan Stade
2013/03/29 23:08:45
this comment is hard to understand.
aruslan
2013/03/30 00:07:47
Done.
| |
| 128 // This will calls AccountChoiceChanged on the delegate. | |
| 129 void ForceWalletAccountSelected(); | |
| 130 | |
| 131 // Returns true if there are any available accounts or if the currently | |
| 132 // signed-in account is known. | |
| 133 bool HasAccountsToChoose() const; | |
| 134 | |
| 135 // Should be called if the set of available accounts is changed. | |
| 136 // The set doesn't have to include the currently signed-in account. | |
| 137 // The menu model will be reconstructed due to this call. | |
| 138 // It is the responsibility of the caller to update the view accordingly. | |
| 139 void SetAvailableAccounts(const std::vector<std::string>& accounts); | |
| 140 | |
| 141 // Should be called if the signed-in account in the content area is known. | |
| 142 // The menu model will be reconstructed due to this call. | |
| 143 // It is the responsibility of the caller to update the view accordingly. | |
| 144 void SetCurrentlySignedInAccount(const std::string& account); | |
| 145 | |
| 146 // Should be called if the sign-in status of the content area is unknown. | |
| 147 // Any Wallet error automatically resets the currently signed-in account. | |
| 148 // The menu model will be reconstructed due to this call. | |
| 149 // It is the responsibility of the caller to update the view accordingly. | |
| 150 void ResetCurrentlySignedInAccount(); | |
| 151 | |
| 152 // Returns the last known signed-in account, or an empty string. | |
| 153 // Returned account may be different from the currently selected account | |
| 154 // if the currently selected account is the autofill data. | |
| 155 std::string GetCurrentlySignedInAccount() const; | |
| 156 | |
| 125 // Should be called when the Wallet server returns an error. | 157 // Should be called when the Wallet server returns an error. |
| 158 // This disables all Wallet accounts and switches to the autofill data. | |
| 159 // The AccountChoiceChanged() will be called on the delegate. | |
| 126 void SetHadWalletError(); | 160 void SetHadWalletError(); |
| 127 | 161 |
| 128 // Should be called when the Online Wallet sign-in attempt has failed. | 162 // Should be called when the Online Wallet sign-in attempt has failed. |
| 163 // This swithes the dialog to the autofill data. | |
| 164 // The AccountChoiceChanged() will be called on the delegate. | |
| 129 void SetHadWalletSigninError(); | 165 void SetHadWalletSigninError(); |
| 130 | 166 |
| 131 bool had_wallet_error() const { return had_wallet_error_; } | 167 bool had_wallet_error() const { return had_wallet_error_; } |
| 132 | 168 |
| 169 // Returns true if the selected account is an Online Wallet account. | |
| 133 bool WalletIsSelected() const; | 170 bool WalletIsSelected() const; |
| 134 | 171 |
| 172 // Returns true if the currently selected account matches the currently | |
| 173 // signed-in account. | |
| 174 bool IsCurrentlySignedInAccountSelected() const; | |
| 175 | |
| 176 // Returns the command id of the currently selected account. | |
| 135 int checked_item() const { return checked_item_; } | 177 int checked_item() const { return checked_item_; } |
| 136 | 178 |
| 137 private: | 179 private: |
| 138 void PrefChanged(const std::string& pref); | 180 void PrefChanged(const std::string& pref); |
| 139 | 181 |
| 140 // Sets |checked_item_| from the relevant pref. | 182 // Sets |checked_item_| from the relevant pref. |
| 141 void UpdateCheckmarkFromPref(); | 183 void UpdateCheckmarkFromPref(); |
| 142 | 184 |
| 143 // Command IDs of the items in this menu. For now, we only support a single | 185 // Reconstructs the set of menu items. |
| 144 // account, so there's only one wallet item. | 186 void ReconstructMenuItems(); |
| 145 static const int kWalletItemId; | 187 |
| 146 static const int kAutofillItemId; | 188 // Command IDs of the items in this menu. |
| 189 static const int kContentAreaWalletItemId; // The content area sign-in. | |
| 190 static const int kAutofillItemId; // Local data. | |
| 191 static const int kFirstAccountItemId; // First command id for other accounts. | |
| 147 | 192 |
| 148 AccountChooserModelDelegate* account_delegate_; | 193 AccountChooserModelDelegate* account_delegate_; |
| 149 | 194 |
| 150 PrefService* prefs_; | 195 PrefService* prefs_; |
| 151 | 196 |
| 152 // The command id of the currently active item. | 197 // The command id of the currently active item. |
| 153 int checked_item_; | 198 int checked_item_; |
| 154 | 199 |
| 155 // Whether there has been a Wallet error while the owning dialog has been | 200 // Whether there has been a Wallet error while the owning dialog has been |
| 156 // open. | 201 // open. |
| 157 bool had_wallet_error_; | 202 bool had_wallet_error_; |
| 158 | 203 |
| 159 PrefChangeRegistrar pref_change_registrar_; | 204 PrefChangeRegistrar pref_change_registrar_; |
| 160 | 205 |
| 206 // The user account name (email) that is currently signed into the content. | |
| 207 // May be different from the currently selected account (e.g. autofill data). | |
| 208 // Set whenever the sign-in helper fetches the user info. | |
| 209 std::string current_username_; | |
| 210 | |
| 211 // The set of accounts the user could choose from (excluding autofill data). | |
| 212 // Doesn't have to include the account currently signed into the content. | |
| 213 std::vector<std::string> available_accounts_; | |
| 214 | |
| 161 DISALLOW_COPY_AND_ASSIGN(AccountChooserModel); | 215 DISALLOW_COPY_AND_ASSIGN(AccountChooserModel); |
| 162 }; | 216 }; |
| 163 | 217 |
| 164 // A model for possible months in the Gregorian calendar. | 218 // A model for possible months in the Gregorian calendar. |
| 165 class MonthComboboxModel : public ui::ComboboxModel { | 219 class MonthComboboxModel : public ui::ComboboxModel { |
| 166 public: | 220 public: |
| 167 MonthComboboxModel(); | 221 MonthComboboxModel(); |
| 168 virtual ~MonthComboboxModel(); | 222 virtual ~MonthComboboxModel(); |
| 169 | 223 |
| 170 static string16 FormatMonth(int index); | 224 static string16 FormatMonth(int index); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 190 private: | 244 private: |
| 191 // The current year (e.g., 2012). | 245 // The current year (e.g., 2012). |
| 192 int this_year_; | 246 int this_year_; |
| 193 | 247 |
| 194 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel); | 248 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel); |
| 195 }; | 249 }; |
| 196 | 250 |
| 197 } // autofill | 251 } // autofill |
| 198 | 252 |
| 199 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ | 253 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ |
| OLD | NEW |