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 "ui/base/models/simple_menu_model.h" | 5 #include "ui/base/models/simple_menu_model.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 void SimpleMenuModel::SetMinorText(int index, | 249 void SimpleMenuModel::SetMinorText(int index, |
250 const base::string16& minor_text) { | 250 const base::string16& minor_text) { |
251 items_[ValidateItemIndex(index)].minor_text = minor_text; | 251 items_[ValidateItemIndex(index)].minor_text = minor_text; |
252 } | 252 } |
253 | 253 |
254 void SimpleMenuModel::Clear() { | 254 void SimpleMenuModel::Clear() { |
255 items_.clear(); | 255 items_.clear(); |
256 MenuItemsChanged(); | 256 MenuItemsChanged(); |
257 } | 257 } |
258 | 258 |
259 int SimpleMenuModel::GetIndexOfCommandId(int command_id) { | 259 int SimpleMenuModel::GetIndexOfCommandId(int command_id) const { |
260 for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) { | 260 for (ItemVector::const_iterator i = items_.begin(); i != items_.end(); ++i) { |
261 if (i->command_id == command_id) | 261 if (i->command_id == command_id) |
262 return static_cast<int>(std::distance(items_.begin(), i)); | 262 return static_cast<int>(std::distance(items_.begin(), i)); |
263 } | 263 } |
264 return -1; | 264 return -1; |
265 } | 265 } |
266 | 266 |
267 //////////////////////////////////////////////////////////////////////////////// | 267 //////////////////////////////////////////////////////////////////////////////// |
268 // SimpleMenuModel, MenuModel implementation: | 268 // SimpleMenuModel, MenuModel implementation: |
269 | 269 |
270 bool SimpleMenuModel::HasIcons() const { | 270 bool SimpleMenuModel::HasIcons() const { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 #ifndef NDEBUG | 445 #ifndef NDEBUG |
446 if (item.type == TYPE_SEPARATOR) { | 446 if (item.type == TYPE_SEPARATOR) { |
447 DCHECK_EQ(item.command_id, kSeparatorId); | 447 DCHECK_EQ(item.command_id, kSeparatorId); |
448 } else { | 448 } else { |
449 DCHECK_GE(item.command_id, 0); | 449 DCHECK_GE(item.command_id, 0); |
450 } | 450 } |
451 #endif // NDEBUG | 451 #endif // NDEBUG |
452 } | 452 } |
453 | 453 |
454 } // namespace ui | 454 } // namespace ui |
OLD | NEW |