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