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::ExecuteCommandWithDisposition( | |
56 int command_id, int disposition) { | |
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::ActivatedAtWithDisposition(int index, int disposition) { | |
299 if (delegate_) | |
brettw
2011/05/03 19:43:53
BTW if you have >1 line in a conditional, we alway
| |
300 delegate_->ExecuteCommandWithDisposition(GetCommandIdAt(index), | |
301 disposition); | |
302 } | |
303 | |
293 MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const { | 304 MenuModel* SimpleMenuModel::GetSubmenuModelAt(int index) const { |
294 return items_.at(FlipIndex(index)).submenu; | 305 return items_.at(FlipIndex(index)).submenu; |
295 } | 306 } |
296 | 307 |
297 void SimpleMenuModel::MenuWillShow() { | 308 void SimpleMenuModel::MenuWillShow() { |
298 if (delegate_) | 309 if (delegate_) |
299 delegate_->MenuWillShow(); | 310 delegate_->MenuWillShow(); |
300 } | 311 } |
301 | 312 |
302 void SimpleMenuModel::MenuClosed() { | 313 void SimpleMenuModel::MenuClosed() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 #ifndef NDEBUG | 350 #ifndef NDEBUG |
340 if (item.type == TYPE_SEPARATOR) { | 351 if (item.type == TYPE_SEPARATOR) { |
341 DCHECK_EQ(item.command_id, kSeparatorId); | 352 DCHECK_EQ(item.command_id, kSeparatorId); |
342 } else { | 353 } else { |
343 DCHECK_GE(item.command_id, 0); | 354 DCHECK_GE(item.command_id, 0); |
344 } | 355 } |
345 #endif // NDEBUG | 356 #endif // NDEBUG |
346 } | 357 } |
347 | 358 |
348 } // namespace ui | 359 } // namespace ui |
OLD | NEW |