| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "ash/public/cpp/app_launch_id.h" | |
| 11 #include "ash/public/cpp/shelf_types.h" | |
| 12 #include "ash/public/interfaces/shelf.mojom.h" | |
| 13 #include "base/compiler_specific.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "ui/events/event.h" | |
| 16 | |
| 17 class AppWindowLauncherItemController; | |
| 18 class ChromeLauncherController; | |
| 19 | |
| 20 using MenuItemList = std::vector<ash::mojom::MenuItemPtr>; | |
| 21 | |
| 22 // LauncherItemController is used by ChromeLauncherController to track one | |
| 23 // or more windows associated with a shelf item. | |
| 24 class LauncherItemController : public ash::mojom::ShelfItemDelegate { | |
| 25 public: | |
| 26 LauncherItemController(const ash::AppLaunchId& app_launch_id, | |
| 27 ChromeLauncherController* launcher_controller); | |
| 28 ~LauncherItemController() override; | |
| 29 | |
| 30 ash::ShelfID shelf_id() const { return shelf_id_; } | |
| 31 void set_shelf_id(ash::ShelfID id) { shelf_id_ = id; } | |
| 32 const ash::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& launch_id() const { return app_launch_id_.launch_id(); } | |
| 35 ChromeLauncherController* launcher_controller() const { | |
| 36 return launcher_controller_; | |
| 37 } | |
| 38 | |
| 39 bool image_set_by_controller() const { return image_set_by_controller_; } | |
| 40 void set_image_set_by_controller(bool image_set_by_controller) { | |
| 41 image_set_by_controller_ = image_set_by_controller; | |
| 42 } | |
| 43 | |
| 44 // Returns items for the application menu; used for convenience and testing. | |
| 45 virtual MenuItemList GetAppMenuItems(int event_flags); | |
| 46 | |
| 47 // Returns nullptr if class is not AppWindowLauncherItemController. | |
| 48 virtual AppWindowLauncherItemController* AsAppWindowLauncherItemController(); | |
| 49 | |
| 50 private: | |
| 51 // 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 | |
| 53 // 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 | |
| 55 // uniquely identify each shelf item that has the same app_id. | |
| 56 const ash::AppLaunchId app_launch_id_; | |
| 57 | |
| 58 // A unique id assigned by the shelf model for the shelf item. | |
| 59 ash::ShelfID shelf_id_; | |
| 60 | |
| 61 ChromeLauncherController* launcher_controller_; | |
| 62 | |
| 63 // Set to true if the launcher item image has been set by the controller. | |
| 64 bool image_set_by_controller_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); | |
| 67 }; | |
| 68 | |
| 69 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | |
| OLD | NEW |