| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_COMMON_SHELF_SHELF_APPLICATION_MENU_MODEL_H_ | |
| 6 #define ASH_COMMON_SHELF_SHELF_APPLICATION_MENU_MODEL_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "ash/ash_export.h" | |
| 12 #include "ash/public/cpp/shelf_application_menu_item.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "ui/base/models/simple_menu_model.h" | |
| 15 | |
| 16 namespace ash { | |
| 17 | |
| 18 class ShelfApplicationMenuModelTestAPI; | |
| 19 class ShelfItemDelegate; | |
| 20 | |
| 21 // A menu model listing open applications associated with a shelf item. Layout: | |
| 22 // +---------------------------+ | |
| 23 // | | | |
| 24 // | App Title | | |
| 25 // | | | |
| 26 // | [Icon] Item Title | | |
| 27 // | [Icon] Item Title | | |
| 28 // | | | |
| 29 // +---------------------------+ | |
| 30 class ASH_EXPORT ShelfApplicationMenuModel | |
| 31 : public ui::SimpleMenuModel, | |
| 32 public ui::SimpleMenuModel::Delegate { | |
| 33 public: | |
| 34 // Makes a menu with a |title|, separators, and |items| for |delegate|. | |
| 35 // |delegate| may be null in unit tests that do not execute commands. | |
| 36 ShelfApplicationMenuModel(const base::string16& title, | |
| 37 ShelfAppMenuItemList items, | |
| 38 ShelfItemDelegate* delegate); | |
| 39 ~ShelfApplicationMenuModel() override; | |
| 40 | |
| 41 // ui::SimpleMenuModel::Delegate: | |
| 42 bool IsCommandIdChecked(int command_id) const override; | |
| 43 bool IsCommandIdEnabled(int command_id) const override; | |
| 44 void ExecuteCommand(int command_id, int event_flags) override; | |
| 45 | |
| 46 private: | |
| 47 friend class ShelfApplicationMenuModelTestAPI; | |
| 48 | |
| 49 // Records UMA metrics when a menu item is selected. | |
| 50 void RecordMenuItemSelectedMetrics(int command_id, | |
| 51 int num_menu_items_enabled); | |
| 52 | |
| 53 // The list of menu items as returned from the shelf item's controller. | |
| 54 ShelfAppMenuItemList items_; | |
| 55 | |
| 56 // The shelf item delegate that created the menu and executes its commands. | |
| 57 ShelfItemDelegate* delegate_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(ShelfApplicationMenuModel); | |
| 60 }; | |
| 61 | |
| 62 } // namespace ash | |
| 63 | |
| 64 #endif // ASH_COMMON_SHELF_SHELF_APPLICATION_MENU_MODEL_H_ | |
| OLD | NEW |