| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ASH_PUBLIC_CPP_SHELF_APPLICATION_MENU_ITEM_H_ | 5 #ifndef ASH_PUBLIC_CPP_SHELF_APPLICATION_MENU_ITEM_H_ |
| 6 #define ASH_PUBLIC_CPP_SHELF_APPLICATION_MENU_ITEM_H_ | 6 #define ASH_PUBLIC_CPP_SHELF_APPLICATION_MENU_ITEM_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/public/cpp/ash_public_export.h" | 11 #include "ash/public/cpp/ash_public_export.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 | 17 |
| 18 // The title, icon, and execute function for shelf application menu items. | 18 // The command id, title, and icon for shelf application menu items. |
| 19 class ASH_PUBLIC_EXPORT ShelfApplicationMenuItem { | 19 class ASH_PUBLIC_EXPORT ShelfApplicationMenuItem { |
| 20 public: | 20 public: |
| 21 // Creates an item with a |title| and optional |icon| (pass nullptr for none). | 21 // Creates an item with a client-specific |command_id|, a |title|, and an |
| 22 explicit ShelfApplicationMenuItem(const base::string16 title, | 22 // optional |icon| (pass nullptr for no icon). |
| 23 const gfx::Image* icon = nullptr); | 23 ShelfApplicationMenuItem(uint32_t command_id, |
| 24 virtual ~ShelfApplicationMenuItem(); | 24 const base::string16& title, |
| 25 const gfx::Image* icon = nullptr); |
| 26 ~ShelfApplicationMenuItem(); |
| 25 | 27 |
| 26 // The title and icon for this menu item. | 28 // The title and icon for this menu item. |
| 29 uint32_t command_id() const { return command_id_; } |
| 27 const base::string16& title() const { return title_; } | 30 const base::string16& title() const { return title_; } |
| 28 const gfx::Image& icon() const { return icon_; } | 31 const gfx::Image& icon() const { return icon_; } |
| 29 | 32 |
| 30 // Executes the menu item; |event_flags| can be used to check additional | |
| 31 // keyboard modifiers from the event that issued this command. | |
| 32 virtual void Execute(int event_flags); | |
| 33 | |
| 34 private: | 33 private: |
| 34 const uint32_t command_id_; |
| 35 const base::string16 title_; | 35 const base::string16 title_; |
| 36 const gfx::Image icon_; | 36 const gfx::Image icon_; |
| 37 | 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(ShelfApplicationMenuItem); | 38 DISALLOW_COPY_AND_ASSIGN(ShelfApplicationMenuItem); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 using ShelfAppMenuItemList = | 41 using ShelfAppMenuItemList = |
| 42 std::vector<std::unique_ptr<ShelfApplicationMenuItem>>; | 42 std::vector<std::unique_ptr<ShelfApplicationMenuItem>>; |
| 43 | 43 |
| 44 } // namespace ash | 44 } // namespace ash |
| 45 | 45 |
| 46 #endif // ASH_PUBLIC_CPP_SHELF_APPLICATION_MENU_ITEM_H_ | 46 #endif // ASH_PUBLIC_CPP_SHELF_APPLICATION_MENU_ITEM_H_ |
| OLD | NEW |