OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 void SimpleMenuModel::Delegate::CommandIdHighlighted(int command_id) { | 46 void SimpleMenuModel::Delegate::CommandIdHighlighted(int command_id) { |
47 } | 47 } |
48 | 48 |
49 void SimpleMenuModel::Delegate::MenuWillShow() { | 49 void SimpleMenuModel::Delegate::MenuWillShow() { |
50 } | 50 } |
51 | 51 |
52 void SimpleMenuModel::Delegate::MenuClosed() { | 52 void SimpleMenuModel::Delegate::MenuClosed() { |
53 } | 53 } |
54 | 54 |
| 55 void SimpleMenuModel::Delegate::ExecuteCommandWithFlags( |
| 56 int command_id, int flags) { |
| 57 ExecuteCommand(command_id); |
| 58 } |
| 59 |
55 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
56 // SimpleMenuModel, public: | 61 // SimpleMenuModel, public: |
57 | 62 |
58 SimpleMenuModel::SimpleMenuModel(Delegate* delegate) | 63 SimpleMenuModel::SimpleMenuModel(Delegate* delegate) |
59 : delegate_(delegate), | 64 : delegate_(delegate), |
60 menu_model_delegate_(NULL), | 65 menu_model_delegate_(NULL), |
61 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 66 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
62 } | 67 } |
63 | 68 |
64 SimpleMenuModel::~SimpleMenuModel() { | 69 SimpleMenuModel::~SimpleMenuModel() { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 void SimpleMenuModel::HighlightChangedTo(int index) { | 288 void SimpleMenuModel::HighlightChangedTo(int index) { |
284 if (delegate_) | 289 if (delegate_) |
285 delegate_->CommandIdHighlighted(GetCommandIdAt(index)); | 290 delegate_->CommandIdHighlighted(GetCommandIdAt(index)); |
286 } | 291 } |
287 | 292 |
288 void SimpleMenuModel::ActivatedAt(int index) { | 293 void SimpleMenuModel::ActivatedAt(int index) { |
289 if (delegate_) | 294 if (delegate_) |
290 delegate_->ExecuteCommand(GetCommandIdAt(index)); | 295 delegate_->ExecuteCommand(GetCommandIdAt(index)); |
291 } | 296 } |
292 | 297 |
| 298 void SimpleMenuModel::ActivatedAtWithFlags(int index, int flags) { |
| 299 if (delegate_) |
| 300 delegate_->ExecuteCommandWithFlags(GetCommandIdAt(index), flags); |
| 301 } |
| 302 |
293 MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const { | 303 MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const { |
294 return items_.at(FlipIndex(index)).submenu; | 304 return items_.at(FlipIndex(index)).submenu; |
295 } | 305 } |
296 | 306 |
297 void SimpleMenuModel::MenuWillShow() { | 307 void SimpleMenuModel::MenuWillShow() { |
298 if (delegate_) | 308 if (delegate_) |
299 delegate_->MenuWillShow(); | 309 delegate_->MenuWillShow(); |
300 } | 310 } |
301 | 311 |
302 void SimpleMenuModel::MenuClosed() { | 312 void SimpleMenuModel::MenuClosed() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 #ifndef NDEBUG | 349 #ifndef NDEBUG |
340 if (item.type == TYPE_SEPARATOR) { | 350 if (item.type == TYPE_SEPARATOR) { |
341 DCHECK_EQ(item.command_id, kSeparatorId); | 351 DCHECK_EQ(item.command_id, kSeparatorId); |
342 } else { | 352 } else { |
343 DCHECK_GE(item.command_id, 0); | 353 DCHECK_GE(item.command_id, 0); |
344 } | 354 } |
345 #endif // NDEBUG | 355 #endif // NDEBUG |
346 } | 356 } |
347 | 357 |
348 } // namespace ui | 358 } // namespace ui |
OLD | NEW |