| 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_ITEM_DELEGATE_H_ | 5 #ifndef ASH_PUBLIC_CPP_SHELF_ITEM_DELEGATE_H_ |
| 6 #define ASH_PUBLIC_CPP_SHELF_ITEM_DELEGATE_H_ | 6 #define ASH_PUBLIC_CPP_SHELF_ITEM_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/public/cpp/app_launch_id.h" | |
| 11 #include "ash/public/cpp/ash_public_export.h" | 10 #include "ash/public/cpp/ash_public_export.h" |
| 12 #include "ash/public/cpp/shelf_types.h" | 11 #include "ash/public/cpp/shelf_types.h" |
| 13 #include "ash/public/interfaces/shelf.mojom.h" | 12 #include "ash/public/interfaces/shelf.mojom.h" |
| 14 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 15 #include "base/macros.h" | 14 #include "base/macros.h" |
| 16 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 17 | 16 |
| 18 class AppWindowLauncherItemController; | 17 class AppWindowLauncherItemController; |
| 19 | 18 |
| 20 namespace ash { | 19 namespace ash { |
| 21 | 20 |
| 22 using MenuItemList = std::vector<mojom::MenuItemPtr>; | 21 using MenuItemList = std::vector<mojom::MenuItemPtr>; |
| 23 | 22 |
| 24 // ShelfItemDelegate tracks some item state and serves as a base class for | 23 // ShelfItemDelegate tracks some item state and serves as a base class for |
| 25 // various subclasses that implement the mojo interface. | 24 // various subclasses that implement the mojo interface. |
| 26 class ASH_PUBLIC_EXPORT ShelfItemDelegate : public mojom::ShelfItemDelegate { | 25 class ASH_PUBLIC_EXPORT ShelfItemDelegate : public mojom::ShelfItemDelegate { |
| 27 public: | 26 public: |
| 28 explicit ShelfItemDelegate(const AppLaunchId& app_launch_id); | 27 explicit ShelfItemDelegate(const ShelfID& shelf_id); |
| 29 ~ShelfItemDelegate() override; | 28 ~ShelfItemDelegate() override; |
| 30 | 29 |
| 31 ShelfID shelf_id() const { return shelf_id_; } | 30 const ShelfID& shelf_id() const { return shelf_id_; } |
| 32 void set_shelf_id(ShelfID id) { shelf_id_ = id; } | 31 void set_shelf_id(const ShelfID& shelf_id) { shelf_id_ = shelf_id; } |
| 33 const AppLaunchId& app_launch_id() const { return app_launch_id_; } | 32 const std::string& app_id() const { return shelf_id_.app_id; } |
| 34 const std::string& app_id() const { return app_launch_id_.app_id(); } | 33 const std::string& launch_id() const { return shelf_id_.launch_id; } |
| 35 const std::string& launch_id() const { return app_launch_id_.launch_id(); } | |
| 36 | 34 |
| 37 bool image_set_by_controller() const { return image_set_by_controller_; } | 35 bool image_set_by_controller() const { return image_set_by_controller_; } |
| 38 void set_image_set_by_controller(bool image_set_by_controller) { | 36 void set_image_set_by_controller(bool image_set_by_controller) { |
| 39 image_set_by_controller_ = image_set_by_controller; | 37 image_set_by_controller_ = image_set_by_controller; |
| 40 } | 38 } |
| 41 | 39 |
| 42 // Returns items for the application menu; used for convenience and testing. | 40 // Returns items for the application menu; used for convenience and testing. |
| 43 virtual MenuItemList GetAppMenuItems(int event_flags); | 41 virtual MenuItemList GetAppMenuItems(int event_flags); |
| 44 | 42 |
| 45 // Returns nullptr if class is not AppWindowLauncherItemController. | 43 // Returns nullptr if class is not AppWindowLauncherItemController. |
| 46 virtual AppWindowLauncherItemController* AsAppWindowLauncherItemController(); | 44 virtual AppWindowLauncherItemController* AsAppWindowLauncherItemController(); |
| 47 | 45 |
| 48 private: | 46 private: |
| 49 // The app launch id; empty if there is no app associated with the item. | 47 // The shelf id; empty if there is no app associated with the item. |
| 50 // Besides the application id, AppLaunchId also contains a launch id, which is | 48 // Besides the application id, ShelfID also contains a launch id, which is an |
| 51 // an id that can be passed to an app when launched in order to support | 49 // id that can be passed to an app when launched in order to support multiple |
| 52 // multiple shelf items per app. This id is used together with the app_id to | 50 // shelf items per app. This id is used together with the app_id to uniquely |
| 53 // uniquely identify each shelf item that has the same app_id. | 51 // identify each shelf item that has the same app_id. |
| 54 const AppLaunchId app_launch_id_; | |
| 55 | |
| 56 // A unique id assigned by the shelf model for the shelf item. | |
| 57 ShelfID shelf_id_; | 52 ShelfID shelf_id_; |
| 58 | 53 |
| 59 // Set to true if the launcher item image has been set by the controller. | 54 // Set to true if the launcher item image has been set by the controller. |
| 60 bool image_set_by_controller_; | 55 bool image_set_by_controller_; |
| 61 | 56 |
| 62 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegate); | 57 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegate); |
| 63 }; | 58 }; |
| 64 | 59 |
| 65 } // namespace ash | 60 } // namespace ash |
| 66 | 61 |
| 67 #endif // ASH_PUBLIC_CPP_SHELF_ITEM_DELEGATE_H_ | 62 #endif // ASH_PUBLIC_CPP_SHELF_ITEM_DELEGATE_H_ |
| OLD | NEW |