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

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

Issue 11743036: requestAutocomplete: change comboboxes to dropdown menus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: isherman review Created 7 years, 11 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_COMBOBOXES_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMBOBOXES_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 "ui/base/models/combobox_model.h" 14 #include "ui/base/models/combobox_model.h"
15 #include "ui/base/models/simple_menu_model.h"
15 16
16 namespace autofill { 17 namespace autofill {
17 18
18 // A model for the comboboxes that allow the user to select from different sets 19 class SuggestionsMenuModel;
19 // of known data. 20
20 class SuggestionsComboboxModel : public ui::ComboboxModel { 21 class SuggestionsMenuModelDelegate {
21 public: 22 public:
22 SuggestionsComboboxModel(); 23 virtual ~SuggestionsMenuModelDelegate();
23 virtual ~SuggestionsComboboxModel(); 24
25 // Called when a menu item has been activated.
26 virtual void SuggestionItemSelected(const SuggestionsMenuModel& model) = 0;
27 };
28
29 // A model for the dropdowns that allow the user to select from different
30 // sets of known data. It wraps a SimpleMenuModel, providing a mapping between
31 // index and item GUID.
32 class SuggestionsMenuModel : public ui::SimpleMenuModel,
33 public ui::SimpleMenuModel::Delegate {
34 public:
35 explicit SuggestionsMenuModel(SuggestionsMenuModelDelegate* delegate);
36 virtual ~SuggestionsMenuModel();
24 37
25 // Adds an item and its identifying key to the model. 38 // Adds an item and its identifying key to the model.
26 void AddItem(const std::string& key, const string16& display_label); 39 void AddKeyedItem(const std::string& key, const string16& display_label);
27 40
28 // Returns the ID key for the item at |index|. 41 // Returns the ID key for the item at |index|.
29 std::string GetItemKeyAt(int index) const; 42 std::string GetItemKeyAt(int index) const;
30 43
31 // ui::Combobox implementation: 44 int checked_item() { return checked_item_; }
32 virtual int GetItemCount() const OVERRIDE; 45
33 virtual string16 GetItemAt(int index) OVERRIDE; 46 // ui::SimpleMenuModel::Delegate implementation.
47 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
48 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
49 virtual bool GetAcceleratorForCommandId(
50 int command_id,
51 ui::Accelerator* accelerator) OVERRIDE;
52 virtual void ExecuteCommand(int command_id) OVERRIDE;
34 53
35 private: 54 private:
36 // The items this model represents, in presentation order. The first 55 // The items this model represents, in presentation order. The first
37 // string is the "key" which identifies the item. The second is the 56 // string is the "key" which identifies the item. The second is the
38 // display string for the item. 57 // display string for the item.
39 std::vector<std::pair<std::string, string16> > items_; 58 std::vector<std::pair<std::string, string16> > items_;
40 59
41 DISALLOW_COPY_AND_ASSIGN(SuggestionsComboboxModel); 60 SuggestionsMenuModelDelegate* delegate_;
61
62 // The command id (and index) of the item which is currently checked.
63 int checked_item_;
64
65 DISALLOW_COPY_AND_ASSIGN(SuggestionsMenuModel);
42 }; 66 };
43 67
44 // A model for possible months in the Gregorian calendar. 68 // A model for possible months in the Gregorian calendar.
45 class MonthComboboxModel : public ui::ComboboxModel { 69 class MonthComboboxModel : public ui::ComboboxModel {
46 public: 70 public:
47 MonthComboboxModel(); 71 MonthComboboxModel();
48 virtual ~MonthComboboxModel(); 72 virtual ~MonthComboboxModel();
49 73
50 // ui::Combobox implementation: 74 // ui::Combobox implementation:
51 virtual int GetItemCount() const OVERRIDE; 75 virtual int GetItemCount() const OVERRIDE;
(...skipping 15 matching lines...) Expand all
67 91
68 private: 92 private:
69 // The current year (e.g., 2012). 93 // The current year (e.g., 2012).
70 int this_year_; 94 int this_year_;
71 95
72 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel); 96 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel);
73 }; 97 };
74 98
75 } // autofill 99 } // autofill
76 100
77 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMBOBOXES_H_ 101 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller.cc ('k') | chrome/browser/ui/autofill/autofill_dialog_models.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698