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