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 break; | |
Dan Beam
2013/04/16 03:01:14
return;
Evan Stade
2013/04/16 19:06:20
sure, why not
| |
84 } | |
85 } | |
Dan Beam
2013/04/16 03:01:14
NOTREACHED(); IMO (unless this is valid for some r
Evan Stade
2013/04/16 19:06:20
Done.
| |
86 } | |
87 | |
79 bool SuggestionsMenuModel::IsCommandIdChecked( | 88 bool SuggestionsMenuModel::IsCommandIdChecked( |
80 int command_id) const { | 89 int command_id) const { |
81 return checked_item_ == command_id; | 90 return checked_item_ == command_id; |
82 } | 91 } |
83 | 92 |
84 bool SuggestionsMenuModel::IsCommandIdEnabled( | 93 bool SuggestionsMenuModel::IsCommandIdEnabled( |
85 int command_id) const { | 94 int command_id) const { |
86 return true; | 95 return true; |
87 } | 96 } |
88 | 97 |
89 bool SuggestionsMenuModel::GetAcceleratorForCommandId( | 98 bool SuggestionsMenuModel::GetAcceleratorForCommandId( |
90 int command_id, | 99 int command_id, |
91 ui::Accelerator* accelerator) { | 100 ui::Accelerator* accelerator) { |
92 return false; | 101 return false; |
93 } | 102 } |
94 | 103 |
95 void SuggestionsMenuModel::ExecuteCommand(int command_id, int event_flags) { | 104 void SuggestionsMenuModel::ExecuteCommand(int command_id, int event_flags) { |
96 checked_item_ = command_id; | 105 delegate_->SuggestionItemSelected(this, GetItemKeyAt(command_id)); |
97 delegate_->SuggestionItemSelected(*this); | |
98 } | 106 } |
99 | 107 |
100 // AccountChooserModel --------------------------------------------------------- | 108 // AccountChooserModel --------------------------------------------------------- |
101 | 109 |
102 const int AccountChooserModel::kWalletItemId = 0; | 110 const int AccountChooserModel::kWalletItemId = 0; |
103 const int AccountChooserModel::kAutofillItemId = 1; | 111 const int AccountChooserModel::kAutofillItemId = 1; |
104 | 112 |
105 AccountChooserModelDelegate::~AccountChooserModelDelegate() {} | 113 AccountChooserModelDelegate::~AccountChooserModelDelegate() {} |
106 | 114 |
107 AccountChooserModel::AccountChooserModel( | 115 AccountChooserModel::AccountChooserModel( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 } | 226 } |
219 | 227 |
220 string16 YearComboboxModel::GetItemAt(int index) { | 228 string16 YearComboboxModel::GetItemAt(int index) { |
221 if (index == 0) | 229 if (index == 0) |
222 return string16(); | 230 return string16(); |
223 | 231 |
224 return base::IntToString16(this_year_ + index - 1); | 232 return base::IntToString16(this_year_ + index - 1); |
225 } | 233 } |
226 | 234 |
227 } // autofill | 235 } // autofill |
OLD | NEW |