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_models.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return items_[index].first; | 69 return items_[index].first; |
70 } | 70 } |
71 | 71 |
72 std::string SuggestionsMenuModel::GetItemKeyForCheckedItem() const { | 72 std::string SuggestionsMenuModel::GetItemKeyForCheckedItem() const { |
73 if (items_.empty()) | 73 if (items_.empty()) |
74 return std::string(); | 74 return std::string(); |
75 | 75 |
76 return items_[checked_item_].first; | 76 return items_[checked_item_].first; |
77 } | 77 } |
78 | 78 |
| 79 void SuggestionsMenuModel::SetCheckedItem(const std::string& item_key) { |
| 80 for (size_t i = 0; i < items_.size(); ++i) { |
| 81 if (items_[i].first == item_key) { |
| 82 checked_item_ = i; |
| 83 return; |
| 84 } |
| 85 } |
| 86 |
| 87 NOTREACHED(); |
| 88 } |
| 89 |
79 bool SuggestionsMenuModel::IsCommandIdChecked( | 90 bool SuggestionsMenuModel::IsCommandIdChecked( |
80 int command_id) const { | 91 int command_id) const { |
81 return checked_item_ == command_id; | 92 return checked_item_ == command_id; |
82 } | 93 } |
83 | 94 |
84 bool SuggestionsMenuModel::IsCommandIdEnabled( | 95 bool SuggestionsMenuModel::IsCommandIdEnabled( |
85 int command_id) const { | 96 int command_id) const { |
86 return true; | 97 return true; |
87 } | 98 } |
88 | 99 |
89 bool SuggestionsMenuModel::GetAcceleratorForCommandId( | 100 bool SuggestionsMenuModel::GetAcceleratorForCommandId( |
90 int command_id, | 101 int command_id, |
91 ui::Accelerator* accelerator) { | 102 ui::Accelerator* accelerator) { |
92 return false; | 103 return false; |
93 } | 104 } |
94 | 105 |
95 void SuggestionsMenuModel::ExecuteCommand(int command_id, int event_flags) { | 106 void SuggestionsMenuModel::ExecuteCommand(int command_id, int event_flags) { |
96 checked_item_ = command_id; | 107 delegate_->SuggestionItemSelected(this, GetItemKeyAt(command_id)); |
97 delegate_->SuggestionItemSelected(*this); | |
98 } | 108 } |
99 | 109 |
100 // AccountChooserModel --------------------------------------------------------- | 110 // AccountChooserModel --------------------------------------------------------- |
101 | 111 |
102 const int AccountChooserModel::kWalletItemId = 0; | 112 const int AccountChooserModel::kWalletItemId = 0; |
103 const int AccountChooserModel::kAutofillItemId = 1; | 113 const int AccountChooserModel::kAutofillItemId = 1; |
104 | 114 |
105 AccountChooserModelDelegate::~AccountChooserModelDelegate() {} | 115 AccountChooserModelDelegate::~AccountChooserModelDelegate() {} |
106 | 116 |
107 AccountChooserModel::AccountChooserModel( | 117 AccountChooserModel::AccountChooserModel( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 228 } |
219 | 229 |
220 string16 YearComboboxModel::GetItemAt(int index) { | 230 string16 YearComboboxModel::GetItemAt(int index) { |
221 if (index == 0) | 231 if (index == 0) |
222 return string16(); | 232 return string16(); |
223 | 233 |
224 return base::IntToString16(this_year_ + index - 1); | 234 return base::IntToString16(this_year_ + index - 1); |
225 } | 235 } |
226 | 236 |
227 } // autofill | 237 } // autofill |
OLD | NEW |