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

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: Rebase after https://chromiumcodereview.appspot.com/13870019 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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "components/autofill/browser/autofill_manager_delegate.h"
15 #include "ui/base/models/combobox_model.h" 14 #include "ui/base/models/combobox_model.h"
16 #include "ui/base/models/simple_menu_model.h" 15 #include "ui/base/models/simple_menu_model.h"
17 16
18 class AutofillMetrics;
19 class PrefService;
20
21 namespace autofill { 17 namespace autofill {
22 18
23 class SuggestionsMenuModel; 19 class SuggestionsMenuModel;
24 20
25 class SuggestionsMenuModelDelegate { 21 class SuggestionsMenuModelDelegate {
26 public: 22 public:
27 virtual ~SuggestionsMenuModelDelegate(); 23 virtual ~SuggestionsMenuModelDelegate();
28 24
29 // Called when a menu item has been activated. 25 // Called when a menu item has been activated.
30 virtual void SuggestionItemSelected(const SuggestionsMenuModel& model) = 0; 26 virtual void SuggestionItemSelected(const SuggestionsMenuModel& model) = 0;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::vector<std::pair<std::string, string16> > items_; 84 std::vector<std::pair<std::string, string16> > items_;
89 85
90 SuggestionsMenuModelDelegate* delegate_; 86 SuggestionsMenuModelDelegate* delegate_;
91 87
92 // The command id (and index) of the item which is currently checked. 88 // The command id (and index) of the item which is currently checked.
93 int checked_item_; 89 int checked_item_;
94 90
95 DISALLOW_COPY_AND_ASSIGN(SuggestionsMenuModel); 91 DISALLOW_COPY_AND_ASSIGN(SuggestionsMenuModel);
96 }; 92 };
97 93
98 // A delegate interface to allow the AccountChooserModel to inform its owner
99 // of changes.
100 class AccountChooserModelDelegate {
101 public:
102 virtual ~AccountChooserModelDelegate();
103
104 // Called when the active account has changed.
105 virtual void AccountChoiceChanged() = 0;
106 };
107
108 // A menu model for the account chooser. This allows users to switch between
109 // using Wallet and local Autofill. TODO(estade): this should support multiple
110 // Wallet accounts.
111 class AccountChooserModel : public ui::SimpleMenuModel,
112 public ui::SimpleMenuModel::Delegate {
113 public:
114 AccountChooserModel(AccountChooserModelDelegate* delegate,
115 PrefService* prefs,
116 const AutofillMetrics& metric_logger,
117 DialogType dialog_type);
118 virtual ~AccountChooserModel();
119
120 // ui::SimpleMenuModel::Delegate implementation.
121 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
122 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
123 virtual bool GetAcceleratorForCommandId(
124 int command_id,
125 ui::Accelerator* accelerator) OVERRIDE;
126 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
127
128 // Should be called when the Wallet server returns an error.
129 void SetHadWalletError();
130
131 // Should be called when the Online Wallet sign-in attempt has failed.
132 void SetHadWalletSigninError();
133
134 bool had_wallet_error() const { return had_wallet_error_; }
135
136 bool WalletIsSelected() const;
137
138 int checked_item() const { return checked_item_; }
139
140 // Command IDs of the items in this menu. For now, we only support a single
141 // account, so there's only one wallet item.
142 static const int kWalletItemId;
143 static const int kAutofillItemId;
144
145 private:
146 AccountChooserModelDelegate* account_delegate_;
147
148 // The command id of the currently active item.
149 int checked_item_;
150
151 // Whether there has been a Wallet error while the owning dialog has been
152 // open.
153 bool had_wallet_error_;
154
155 // For logging UMA metrics.
156 const AutofillMetrics& metric_logger_;
157 const DialogType dialog_type_;
158
159 DISALLOW_COPY_AND_ASSIGN(AccountChooserModel);
160 };
161
162 // A model for possible months in the Gregorian calendar. 94 // A model for possible months in the Gregorian calendar.
163 class MonthComboboxModel : public ui::ComboboxModel { 95 class MonthComboboxModel : public ui::ComboboxModel {
164 public: 96 public:
165 MonthComboboxModel(); 97 MonthComboboxModel();
166 virtual ~MonthComboboxModel(); 98 virtual ~MonthComboboxModel();
167 99
168 static string16 FormatMonth(int index); 100 static string16 FormatMonth(int index);
169 101
170 // ui::Combobox implementation: 102 // ui::Combobox implementation:
171 virtual int GetItemCount() const OVERRIDE; 103 virtual int GetItemCount() const OVERRIDE;
(...skipping 16 matching lines...) Expand all
188 private: 120 private:
189 // The current year (e.g., 2012). 121 // The current year (e.g., 2012).
190 int this_year_; 122 int this_year_;
191 123
192 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel); 124 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel);
193 }; 125 };
194 126
195 } // autofill 127 } // autofill
196 128
197 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ 129 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698