OLD | NEW |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 std::string GetItemKeyAt(int index) const; | 65 std::string GetItemKeyAt(int index) const; |
66 | 66 |
67 // Returns the ID key for the item at |checked_item_|, or an empty string if | 67 // Returns the ID key for the item at |checked_item_|, or an empty string if |
68 // there are no items. | 68 // there are no items. |
69 std::string GetItemKeyForCheckedItem() const; | 69 std::string GetItemKeyForCheckedItem() const; |
70 | 70 |
71 // Sets which item is checked. | 71 // Sets which item is checked. |
72 void SetCheckedItem(const std::string& item_key); | 72 void SetCheckedItem(const std::string& item_key); |
73 void SetCheckedIndex(size_t index); | 73 void SetCheckedIndex(size_t index); |
74 | 74 |
| 75 // Sets the item to be checked to the |n|th item that has key |item_key|. |
| 76 // If there are fewer than |n| items that share |item_key|, the last one |
| 77 // becomes checked. If there is no item with |item_key|, nothing happens. |
| 78 // |n| is 1-indexed. |
| 79 void SetCheckedItemNthWithKey(const std::string& item_key, size_t n); |
| 80 |
| 81 int checked_item() const { return checked_item_; } |
| 82 |
75 // Enable/disable an item by key. | 83 // Enable/disable an item by key. |
76 void SetEnabled(const std::string& item_key, bool enabled); | 84 void SetEnabled(const std::string& item_key, bool enabled); |
77 | 85 |
78 int checked_item() { return checked_item_; } | |
79 | |
80 // ui::SimpleMenuModel::Delegate implementation. | 86 // ui::SimpleMenuModel::Delegate implementation. |
81 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 87 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
82 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 88 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
83 virtual bool GetAcceleratorForCommandId( | 89 virtual bool GetAcceleratorForCommandId( |
84 int command_id, | 90 int command_id, |
85 ui::Accelerator* accelerator) OVERRIDE; | 91 ui::Accelerator* accelerator) OVERRIDE; |
86 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 92 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
87 | 93 |
88 private: | 94 private: |
89 // Represents an item in this model. | 95 // Represents an item in this model. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 private: | 142 private: |
137 // The current year (e.g., 2012). | 143 // The current year (e.g., 2012). |
138 int this_year_; | 144 int this_year_; |
139 | 145 |
140 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel); | 146 DISALLOW_COPY_AND_ASSIGN(YearComboboxModel); |
141 }; | 147 }; |
142 | 148 |
143 } // autofill | 149 } // autofill |
144 | 150 |
145 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ | 151 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_ |
OLD | NEW |