Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_models.h

Issue 13331007: Multi-account AccountChooser for interactive autocomplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent fix. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 std::vector<std::pair<std::string, string16> > items_; 87 std::vector<std::pair<std::string, string16> > items_;
88 88
89 SuggestionsMenuModelDelegate* delegate_; 89 SuggestionsMenuModelDelegate* delegate_;
90 90
91 // The command id (and index) of the item which is currently checked. 91 // The command id (and index) of the item which is currently checked.
92 int checked_item_; 92 int checked_item_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(SuggestionsMenuModel); 94 DISALLOW_COPY_AND_ASSIGN(SuggestionsMenuModel);
95 }; 95 };
96 96
97 // A delegate interface to allow the AccountChooserModel to inform its owner
98 // of changes.
99 class AccountChooserModelDelegate {
100 public:
101 virtual ~AccountChooserModelDelegate();
102
103 // Called when the active account has changed.
104 virtual void AccountChoiceChanged() = 0;
105 };
106
107 // A menu model for the account chooser. This allows users to switch between
108 // using Wallet and local Autofill. TODO(estade): this should support multiple
109 // Wallet accounts.
110 class AccountChooserModel : public ui::SimpleMenuModel,
111 public ui::SimpleMenuModel::Delegate {
112 public:
113 AccountChooserModel(AccountChooserModelDelegate* delegate,
114 PrefService* prefs);
115 virtual ~AccountChooserModel();
116
117 // ui::SimpleMenuModel::Delegate implementation.
118 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
119 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
120 virtual bool GetAcceleratorForCommandId(
121 int command_id,
122 ui::Accelerator* accelerator) OVERRIDE;
123 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
124
125 // Should be called when the Wallet server returns an error.
126 void SetHadWalletError();
127
128 // Should be called when the Online Wallet sign-in attempt has failed.
129 void SetHadWalletSigninError();
130
131 bool had_wallet_error() const { return had_wallet_error_; }
132
133 bool WalletIsSelected() const;
134
135 int checked_item() const { return checked_item_; }
136
137 private:
138 void PrefChanged(const std::string& pref);
139
140 // Sets |checked_item_| from the relevant pref.
141 void UpdateCheckmarkFromPref();
142
143 // Command IDs of the items in this menu. For now, we only support a single
144 // account, so there's only one wallet item.
145 static const int kWalletItemId;
146 static const int kAutofillItemId;
147
148 AccountChooserModelDelegate* account_delegate_;
149
150 PrefService* prefs_;
151
152 // The command id of the currently active item.
153 int checked_item_;
154
155 // Whether there has been a Wallet error while the owning dialog has been
156 // open.
157 bool had_wallet_error_;
158
159 PrefChangeRegistrar pref_change_registrar_;
160
161 DISALLOW_COPY_AND_ASSIGN(AccountChooserModel);
162 };
163
164 // A model for possible months in the Gregorian calendar. 97 // A model for possible months in the Gregorian calendar.
165 class MonthComboboxModel : public ui::ComboboxModel { 98 class MonthComboboxModel : public ui::ComboboxModel {
166 public: 99 public:
167 MonthComboboxModel(); 100 MonthComboboxModel();
168 virtual ~MonthComboboxModel(); 101 virtual ~MonthComboboxModel();
169 102
170 static string16 FormatMonth(int index); 103 static string16 FormatMonth(int index);
171 104
172 // ui::Combobox implementation: 105 // ui::Combobox implementation:
173 virtual int GetItemCount() const OVERRIDE; 106 virtual int GetItemCount() const OVERRIDE;
(...skipping 16 matching lines...) Expand all
190 private: 123 private:
191 // The current year (e.g., 2012). 124 // The current year (e.g., 2012).
192 int this_year_; 125 int this_year_;
193 126
194 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel); 127 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel);
195 }; 128 };
196 129
197 } // autofill 130 } // autofill
198 131
199 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ 132 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698