OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/common/shelf/shelf_item_delegate.h" | |
11 #include "ash/common/shelf/shelf_item_types.h" | 10 #include "ash/common/shelf/shelf_item_types.h" |
| 11 #include "ash/public/interfaces/shelf.mojom.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
15 | 15 |
16 class AppWindowLauncherItemController; | 16 class AppWindowLauncherItemController; |
17 class ChromeLauncherController; | 17 class ChromeLauncherController; |
18 | 18 |
19 // LauncherItemController is used by ChromeLauncherController to track one | 19 // LauncherItemController is used by ChromeLauncherController to track one |
20 // or more windows associated with a shelf item. | 20 // or more windows associated with a shelf item. |
21 // TODO (khmel): Consider using ash::AppLauncherId instead of pair | 21 // TODO (khmel): Consider using ash::AppLauncherId instead of pair |
22 // |app_id| and |launch_id|. | 22 // |app_id| and |launch_id|. |
23 class LauncherItemController : public ash::ShelfItemDelegate { | 23 class LauncherItemController : public ash::mojom::ShelfItemDelegate { |
24 public: | 24 public: |
25 LauncherItemController(const std::string& app_id, | 25 LauncherItemController(const std::string& app_id, |
26 const std::string& launch_id, | 26 const std::string& launch_id, |
27 ChromeLauncherController* launcher_controller); | 27 ChromeLauncherController* launcher_controller); |
28 ~LauncherItemController() override; | 28 ~LauncherItemController() override; |
29 | 29 |
30 ash::ShelfID shelf_id() const { return shelf_id_; } | 30 ash::ShelfID shelf_id() const { return shelf_id_; } |
31 void set_shelf_id(ash::ShelfID id) { shelf_id_ = id; } | 31 void set_shelf_id(ash::ShelfID id) { shelf_id_ = id; } |
32 const std::string& app_id() const { return app_id_; } | 32 const std::string& app_id() const { return app_id_; } |
33 const std::string& launch_id() const { return launch_id_; } | 33 const std::string& launch_id() const { return launch_id_; } |
34 ChromeLauncherController* launcher_controller() const { | 34 ChromeLauncherController* launcher_controller() const { |
35 return launcher_controller_; | 35 return launcher_controller_; |
36 } | 36 } |
37 | 37 |
38 // Lock this item to the launcher without being pinned (windowed v1 apps). | 38 // Lock this item to the launcher without being pinned (windowed v1 apps). |
39 void lock() { locked_++; } | 39 void lock() { locked_++; } |
40 void unlock() { | 40 void unlock() { |
41 DCHECK(locked_); | 41 DCHECK(locked_); |
42 locked_--; | 42 locked_--; |
43 } | 43 } |
44 bool locked() const { return locked_ > 0; } | 44 bool locked() const { return locked_ > 0; } |
45 | 45 |
46 bool image_set_by_controller() const { return image_set_by_controller_; } | 46 bool image_set_by_controller() const { return image_set_by_controller_; } |
47 void set_image_set_by_controller(bool image_set_by_controller) { | 47 void set_image_set_by_controller(bool image_set_by_controller) { |
48 image_set_by_controller_ = image_set_by_controller; | 48 image_set_by_controller_ = image_set_by_controller; |
49 } | 49 } |
50 | 50 |
| 51 // Returns items for the application menu; used for convenience and testing. |
| 52 virtual std::vector<ash::mojom::MenuItemPtr> GetAppMenuItems(int event_flags); |
| 53 |
51 // Returns nullptr if class is not AppWindowLauncherItemController. | 54 // Returns nullptr if class is not AppWindowLauncherItemController. |
52 virtual AppWindowLauncherItemController* AsAppWindowLauncherItemController(); | 55 virtual AppWindowLauncherItemController* AsAppWindowLauncherItemController(); |
53 | 56 |
54 private: | 57 private: |
55 // The application id; empty if there is no app associated with the item. | 58 // The application id; empty if there is no app associated with the item. |
56 const std::string app_id_; | 59 const std::string app_id_; |
57 | 60 |
58 // An id that can be passed to an app when launched in order to support | 61 // An id that can be passed to an app when launched in order to support |
59 // multiple shelf items per app. This id is used together with the app_id to | 62 // multiple shelf items per app. This id is used together with the app_id to |
60 // uniquely identify each shelf item that has the same app_id. | 63 // uniquely identify each shelf item that has the same app_id. |
61 const std::string launch_id_; | 64 const std::string launch_id_; |
62 | 65 |
63 // A unique id assigned by the shelf model for the shelf item. | 66 // A unique id assigned by the shelf model for the shelf item. |
64 ash::ShelfID shelf_id_; | 67 ash::ShelfID shelf_id_; |
65 | 68 |
66 ChromeLauncherController* launcher_controller_; | 69 ChromeLauncherController* launcher_controller_; |
67 | 70 |
68 // The lock counter which tells the launcher if the item can be removed from | 71 // The lock counter which tells the launcher if the item can be removed from |
69 // the launcher (0) or not (>0). It is being used for windowed V1 | 72 // the launcher (0) or not (>0). It is being used for windowed V1 |
70 // applications. | 73 // applications. |
71 int locked_; | 74 int locked_; |
72 | 75 |
73 // Set to true if the launcher item image has been set by the controller. | 76 // Set to true if the launcher item image has been set by the controller. |
74 bool image_set_by_controller_; | 77 bool image_set_by_controller_; |
75 | 78 |
76 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); | 79 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); |
77 }; | 80 }; |
78 | 81 |
79 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | 82 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
OLD | NEW |