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" | 10 #include "ash/common/shelf/shelf_item_delegate.h" |
11 #include "ash/common/shelf/shelf_item_types.h" | 11 #include "ash/common/shelf/shelf_item_types.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 "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
16 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
17 | 17 |
18 class ChromeLauncherController; | 18 class ChromeLauncherController; |
19 class ChromeLauncherAppMenuItem; | 19 class ChromeLauncherAppMenuItem; |
20 | 20 |
21 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems; | 21 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems; |
22 | 22 |
23 // LauncherItemController is used by ChromeLauncherController to track one | 23 // LauncherItemController is used by ChromeLauncherController to track one |
24 // or more windows associated with a shelf item. | 24 // or more windows associated with a shelf item. |
25 class LauncherItemController : public ash::ShelfItemDelegate { | 25 class LauncherItemController : public ash::ShelfItemDelegate { |
26 public: | 26 public: |
27 enum Type { | 27 LauncherItemController(const std::string& app_id, |
28 TYPE_APP, | |
29 TYPE_APP_PANEL, | |
30 TYPE_SHORTCUT, | |
31 }; | |
32 | |
33 LauncherItemController(Type type, | |
34 const std::string& app_id, | |
35 const std::string& launch_id, | 28 const std::string& launch_id, |
36 ChromeLauncherController* launcher_controller); | 29 ChromeLauncherController* launcher_controller); |
37 ~LauncherItemController() override; | 30 ~LauncherItemController() override; |
38 | 31 |
39 Type type() const { return type_; } | |
40 ash::ShelfID shelf_id() const { return shelf_id_; } | 32 ash::ShelfID shelf_id() const { return shelf_id_; } |
41 void set_shelf_id(ash::ShelfID id) { shelf_id_ = id; } | 33 void set_shelf_id(ash::ShelfID id) { shelf_id_ = id; } |
42 const std::string& app_id() const { return app_id_; } | 34 const std::string& app_id() const { return app_id_; } |
43 const std::string& launch_id() const { return launch_id_; } | 35 const std::string& launch_id() const { return launch_id_; } |
44 ChromeLauncherController* launcher_controller() const { | 36 ChromeLauncherController* launcher_controller() const { |
45 return launcher_controller_; | 37 return launcher_controller_; |
46 } | 38 } |
47 | 39 |
48 // Lock this item to the launcher without being pinned (windowed v1 apps). | 40 // Lock this item to the launcher without being pinned (windowed v1 apps). |
49 void lock() { locked_++; } | 41 void lock() { locked_++; } |
(...skipping 15 matching lines...) Expand all Loading... |
65 virtual void Launch(ash::LaunchSource source, int event_flags) = 0; | 57 virtual void Launch(ash::LaunchSource source, int event_flags) = 0; |
66 | 58 |
67 // Shows and activates the most-recently-active window associated with the | 59 // Shows and activates the most-recently-active window associated with the |
68 // item, or launches the item if it is not currently open. | 60 // item, or launches the item if it is not currently open. |
69 // Returns the action performed by activating the item. | 61 // Returns the action performed by activating the item. |
70 virtual PerformedAction Activate(ash::LaunchSource source) = 0; | 62 virtual PerformedAction Activate(ash::LaunchSource source) = 0; |
71 | 63 |
72 // Called to retrieve the list of running applications. | 64 // Called to retrieve the list of running applications. |
73 virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) = 0; | 65 virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) = 0; |
74 | 66 |
75 // Helper function to get the ash::ShelfItemType for the item type. | |
76 ash::ShelfItemType GetShelfItemType() const; | |
77 | |
78 private: | 67 private: |
79 const Type type_; | |
80 | |
81 // The application id; empty if there is no app associated with the item. | 68 // The application id; empty if there is no app associated with the item. |
82 const std::string app_id_; | 69 const std::string app_id_; |
83 | 70 |
84 // An id that can be passed to an app when launched in order to support | 71 // An id that can be passed to an app when launched in order to support |
85 // multiple shelf items per app. This id is used together with the app_id to | 72 // multiple shelf items per app. This id is used together with the app_id to |
86 // uniquely identify each shelf item that has the same app_id. | 73 // uniquely identify each shelf item that has the same app_id. |
87 const std::string launch_id_; | 74 const std::string launch_id_; |
88 | 75 |
89 // A unique id assigned by the shelf model for the shelf item. | 76 // A unique id assigned by the shelf model for the shelf item. |
90 ash::ShelfID shelf_id_; | 77 ash::ShelfID shelf_id_; |
91 | 78 |
92 ChromeLauncherController* launcher_controller_; | 79 ChromeLauncherController* launcher_controller_; |
93 | 80 |
94 // The lock counter which tells the launcher if the item can be removed from | 81 // The lock counter which tells the launcher if the item can be removed from |
95 // the launcher (0) or not (>0). It is being used for windowed V1 | 82 // the launcher (0) or not (>0). It is being used for windowed V1 |
96 // applications. | 83 // applications. |
97 int locked_; | 84 int locked_; |
98 | 85 |
99 // Set to true if the launcher item image has been set by the controller. | 86 // Set to true if the launcher item image has been set by the controller. |
100 bool image_set_by_controller_; | 87 bool image_set_by_controller_; |
101 | 88 |
102 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); | 89 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); |
103 }; | 90 }; |
104 | 91 |
105 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | 92 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
OLD | NEW |