Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_dialog_models.h |
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_models.h b/chrome/browser/ui/autofill/autofill_dialog_models.h |
| index 40841f9a0bca8a351f1138975f94e50c3b5c9fec..e71b17fc6d7cb1c6a5720f9716c89daac40c91cd 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_models.h |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_models.h |
| @@ -122,16 +122,58 @@ class AccountChooserModel : public ui::SimpleMenuModel, |
| ui::Accelerator* accelerator) OVERRIDE; |
| virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| + // Forces the currently selected account to be the Wallet as part of |
| + // interactive sign-in flows (e.g. when the user clicks the "Sign in" link) |
| + // 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.
|
| + // This will calls AccountChoiceChanged on the delegate. |
| + void ForceWalletAccountSelected(); |
| + |
| + // Returns true if there are any available accounts or if the currently |
| + // signed-in account is known. |
| + bool HasAccountsToChoose() const; |
| + |
| + // Should be called if the set of available accounts is changed. |
| + // The set doesn't have to include the currently signed-in account. |
| + // The menu model will be reconstructed due to this call. |
| + // It is the responsibility of the caller to update the view accordingly. |
| + void SetAvailableAccounts(const std::vector<std::string>& accounts); |
| + |
| + // Should be called if the signed-in account in the content area is known. |
| + // The menu model will be reconstructed due to this call. |
| + // It is the responsibility of the caller to update the view accordingly. |
| + void SetCurrentlySignedInAccount(const std::string& account); |
| + |
| + // Should be called if the sign-in status of the content area is unknown. |
| + // Any Wallet error automatically resets the currently signed-in account. |
| + // The menu model will be reconstructed due to this call. |
| + // It is the responsibility of the caller to update the view accordingly. |
| + void ResetCurrentlySignedInAccount(); |
| + |
| + // Returns the last known signed-in account, or an empty string. |
| + // Returned account may be different from the currently selected account |
| + // if the currently selected account is the autofill data. |
| + std::string GetCurrentlySignedInAccount() const; |
| + |
| // Should be called when the Wallet server returns an error. |
| + // This disables all Wallet accounts and switches to the autofill data. |
| + // The AccountChoiceChanged() will be called on the delegate. |
| void SetHadWalletError(); |
| // Should be called when the Online Wallet sign-in attempt has failed. |
| + // This swithes the dialog to the autofill data. |
| + // The AccountChoiceChanged() will be called on the delegate. |
| void SetHadWalletSigninError(); |
| bool had_wallet_error() const { return had_wallet_error_; } |
| + // Returns true if the selected account is an Online Wallet account. |
| bool WalletIsSelected() const; |
| + // Returns true if the currently selected account matches the currently |
| + // signed-in account. |
| + bool IsCurrentlySignedInAccountSelected() const; |
| + |
| + // Returns the command id of the currently selected account. |
| int checked_item() const { return checked_item_; } |
| private: |
| @@ -140,10 +182,13 @@ class AccountChooserModel : public ui::SimpleMenuModel, |
| // Sets |checked_item_| from the relevant pref. |
| void UpdateCheckmarkFromPref(); |
| - // Command IDs of the items in this menu. For now, we only support a single |
| - // account, so there's only one wallet item. |
| - static const int kWalletItemId; |
| - static const int kAutofillItemId; |
| + // Reconstructs the set of menu items. |
| + void ReconstructMenuItems(); |
| + |
| + // Command IDs of the items in this menu. |
| + static const int kContentAreaWalletItemId; // The content area sign-in. |
| + static const int kAutofillItemId; // Local data. |
| + static const int kFirstAccountItemId; // First command id for other accounts. |
| AccountChooserModelDelegate* account_delegate_; |
| @@ -158,6 +203,15 @@ class AccountChooserModel : public ui::SimpleMenuModel, |
| PrefChangeRegistrar pref_change_registrar_; |
| + // The user account name (email) that is currently signed into the content. |
| + // May be different from the currently selected account (e.g. autofill data). |
| + // Set whenever the sign-in helper fetches the user info. |
| + std::string current_username_; |
| + |
| + // The set of accounts the user could choose from (excluding autofill data). |
| + // Doesn't have to include the account currently signed into the content. |
| + std::vector<std::string> available_accounts_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(AccountChooserModel); |
| }; |