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 #include "chrome/browser/ui/autofill/autofill_dialog_comboboxes.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 | 11 |
12 namespace autofill { | 12 namespace autofill { |
13 | 13 |
14 // SuggestionsComboboxModel ---------------------------------------------------- | 14 SuggestionsMenuModelDelegate::~SuggestionsMenuModelDelegate() {} |
15 | 15 |
16 SuggestionsComboboxModel::SuggestionsComboboxModel() {} | 16 // SuggestionsMenuModel ---------------------------------------------------- |
17 | 17 |
18 SuggestionsComboboxModel::~SuggestionsComboboxModel() {} | 18 SuggestionsMenuModel::SuggestionsMenuModel( |
| 19 SuggestionsMenuModelDelegate* delegate) |
| 20 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
| 21 delegate_(delegate), |
| 22 checked_item_(0) {} |
19 | 23 |
20 void SuggestionsComboboxModel::AddItem( | 24 SuggestionsMenuModel::~SuggestionsMenuModel() {} |
| 25 |
| 26 void SuggestionsMenuModel::AddKeyedItem( |
21 const std::string& key, const string16& item) { | 27 const std::string& key, const string16& item) { |
22 items_.push_back(std::make_pair(key, item)); | 28 items_.push_back(std::make_pair(key, item)); |
| 29 AddCheckItem(items_.size() - 1, item); |
23 } | 30 } |
24 | 31 |
25 std::string SuggestionsComboboxModel::GetItemKeyAt(int index) const { | 32 std::string SuggestionsMenuModel::GetItemKeyAt(int index) const { |
26 return items_[index].first; | 33 return items_[index].first; |
27 } | 34 } |
28 | 35 |
29 int SuggestionsComboboxModel::GetItemCount() const { | 36 bool SuggestionsMenuModel::IsCommandIdChecked( |
30 return items_.size(); | 37 int command_id) const { |
| 38 return checked_item_ == command_id; |
31 } | 39 } |
32 | 40 |
33 string16 SuggestionsComboboxModel::GetItemAt(int index) { | 41 bool SuggestionsMenuModel::IsCommandIdEnabled( |
34 return items_[index].second; | 42 int command_id) const { |
| 43 return true; |
| 44 } |
| 45 |
| 46 bool SuggestionsMenuModel::GetAcceleratorForCommandId( |
| 47 int command_id, |
| 48 ui::Accelerator* accelerator) { |
| 49 return false; |
| 50 } |
| 51 |
| 52 void SuggestionsMenuModel::ExecuteCommand(int command_id) { |
| 53 checked_item_ = command_id; |
| 54 delegate_->SuggestionItemSelected(*this, items_[command_id].first); |
35 } | 55 } |
36 | 56 |
37 // MonthComboboxModel ---------------------------------------------------------- | 57 // MonthComboboxModel ---------------------------------------------------------- |
38 | 58 |
39 MonthComboboxModel::MonthComboboxModel() {} | 59 MonthComboboxModel::MonthComboboxModel() {} |
40 | 60 |
41 MonthComboboxModel::~MonthComboboxModel() {} | 61 MonthComboboxModel::~MonthComboboxModel() {} |
42 | 62 |
43 int MonthComboboxModel::GetItemCount() const { | 63 int MonthComboboxModel::GetItemCount() const { |
44 return 12; | 64 return 12; |
(...skipping 16 matching lines...) Expand all Loading... |
61 | 81 |
62 int YearComboboxModel::GetItemCount() const { | 82 int YearComboboxModel::GetItemCount() const { |
63 return 10; | 83 return 10; |
64 } | 84 } |
65 | 85 |
66 string16 YearComboboxModel::GetItemAt(int index) { | 86 string16 YearComboboxModel::GetItemAt(int index) { |
67 return base::IntToString16(this_year_ + index); | 87 return base::IntToString16(this_year_ + index); |
68 } | 88 } |
69 | 89 |
70 } // autofill | 90 } // autofill |
OLD | NEW |