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 #ifndef CHROME_BROWSER_UI_AUTOFILL_ACCOUNT_CHOOSER_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_ACCOUNT_CHOOSER_MODEL_H_ |
6 #define CHROME_BROWSER_UI_AUTOFILL_ACCOUNT_CHOOSER_MODEL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_ACCOUNT_CHOOSER_MODEL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Clears the name of the account used to communicate with the Online Wallet. | 71 // Clears the name of the account used to communicate with the Online Wallet. |
72 // Any Wallet error automatically clears the currently active account name. | 72 // Any Wallet error automatically clears the currently active account name. |
73 void ClearActiveWalletAccountName(); | 73 void ClearActiveWalletAccountName(); |
74 | 74 |
75 // Returns the name of the currently active account, or an empty string. | 75 // Returns the name of the currently active account, or an empty string. |
76 const string16& active_wallet_account_name() const { | 76 const string16& active_wallet_account_name() const { |
77 return active_wallet_account_name_; | 77 return active_wallet_account_name_; |
78 } | 78 } |
79 | 79 |
80 // Disables all Wallet accounts and switches to the local Autofill data. | 80 // Disables all Wallet accounts and switches to the local Autofill data. |
81 // Should be called when the Wallet server returns an error with the message | 81 // Should be called when the Wallet server returns an error. |
82 // to be displayed. If |message| is empty the error state will be cleared. | 82 void SetHadWalletError(); |
83 void SetHadWalletError(const base::string16& message); | |
84 | |
85 bool HadWalletError() const; | |
86 | 83 |
87 // Switches the dialog to the local Autofill data. | 84 // Switches the dialog to the local Autofill data. |
88 // Should be called when the Online Wallet sign-in attempt has failed. | 85 // Should be called when the Online Wallet sign-in attempt has failed. |
89 void SetHadWalletSigninError(); | 86 void SetHadWalletSigninError(); |
90 | 87 |
91 // Returns true if the selected account is an Online Wallet account. | 88 // Returns true if the selected account is an Online Wallet account. |
92 bool WalletIsSelected() const; | 89 bool WalletIsSelected() const; |
93 | 90 |
94 // Returns true if the current selection matches the currently active | 91 // Returns true if the current selection matches the currently active |
95 // Wallet account. | 92 // Wallet account. |
96 bool IsActiveWalletAccountSelected() const; | 93 bool IsActiveWalletAccountSelected() const; |
97 | 94 |
98 // Returns the command id of the current selection. | 95 // Returns the command id of the current selection. |
99 int checked_item() const { return checked_item_; } | 96 int checked_item() const { return checked_item_; } |
100 | 97 |
101 base::string16 wallet_error_message() const { return wallet_error_message_; } | |
102 | |
103 protected: | 98 protected: |
104 // Command IDs of the items in this menu; protected for the tests. | 99 // Command IDs of the items in this menu; protected for the tests. |
105 // kActiveWalletItemId is the currently active account. | 100 // kActiveWalletItemId is the currently active account. |
106 // kAutofillItemId is "Pay without the Wallet" (local autofill data). | 101 // kAutofillItemId is "Pay without the Wallet" (local autofill data). |
107 // In the future, kFirstAdditionalItemId will be added as the first id | 102 // In the future, kFirstAdditionalItemId will be added as the first id |
108 // for additional accounts. | 103 // for additional accounts. |
109 static const int kActiveWalletItemId; | 104 static const int kActiveWalletItemId; |
110 static const int kAutofillItemId; | 105 static const int kAutofillItemId; |
111 | 106 |
112 private: | 107 private: |
113 // Reconstructs the set of menu items. | 108 // Reconstructs the set of menu items. |
114 void ReconstructMenuItems(); | 109 void ReconstructMenuItems(); |
115 | 110 |
116 AccountChooserModelDelegate* delegate_; | 111 AccountChooserModelDelegate* delegate_; |
117 | 112 |
118 // The command id of the currently selected item. | 113 // The command id of the currently selected item. |
119 int checked_item_; | 114 int checked_item_; |
120 | 115 |
121 // The message to be displayed if there is a Wallet error. This message is | 116 // Whether there has been a Wallet error. |
122 // only non-empty if a Wallet error has occurred. | 117 bool had_wallet_error_; |
123 base::string16 wallet_error_message_; | |
124 | 118 |
125 // For logging UMA metrics. | 119 // For logging UMA metrics. |
126 const AutofillMetrics& metric_logger_; | 120 const AutofillMetrics& metric_logger_; |
127 const DialogType dialog_type_; | 121 const DialogType dialog_type_; |
128 | 122 |
129 // The name (email) of the account currently used in communications with the | 123 // The name (email) of the account currently used in communications with the |
130 // Online Wallet service. | 124 // Online Wallet service. |
131 string16 active_wallet_account_name_; | 125 string16 active_wallet_account_name_; |
132 | 126 |
133 DISALLOW_COPY_AND_ASSIGN(AccountChooserModel); | 127 DISALLOW_COPY_AND_ASSIGN(AccountChooserModel); |
134 }; | 128 }; |
135 | 129 |
136 } // namespace autofill | 130 } // namespace autofill |
137 | 131 |
138 #endif // CHROME_BROWSER_UI_AUTOFILL_ACCOUNT_CHOOSER_MODEL_H_ | 132 #endif // CHROME_BROWSER_UI_AUTOFILL_ACCOUNT_CHOOSER_MODEL_H_ |
OLD | NEW |