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 "ash/launcher/launcher_types.h" | 8 #include "ash/launcher/launcher_types.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // LauncherItemController is used by ChromeLauncherController to track one | 27 // LauncherItemController is used by ChromeLauncherController to track one |
28 // or more windows associated with a launcher item. | 28 // or more windows associated with a launcher item. |
29 class LauncherItemController { | 29 class LauncherItemController { |
30 public: | 30 public: |
31 enum Type { | 31 enum Type { |
32 TYPE_APP, | 32 TYPE_APP, |
33 TYPE_APP_PANEL, | 33 TYPE_APP_PANEL, |
34 TYPE_EXTENSION_PANEL, | 34 TYPE_EXTENSION_PANEL, |
35 TYPE_SHORTCUT, | 35 TYPE_SHORTCUT, |
36 TYPE_TABBED | 36 TYPE_TABBED, |
| 37 TYPE_WINDOWED_APP |
37 }; | 38 }; |
38 | 39 |
39 LauncherItemController(Type type, | 40 LauncherItemController(Type type, |
40 const std::string& app_id, | 41 const std::string& app_id, |
41 ChromeLauncherController* launcher_controller); | 42 ChromeLauncherController* launcher_controller); |
42 virtual ~LauncherItemController(); | 43 virtual ~LauncherItemController(); |
43 | 44 |
44 Type type() const { return type_; } | 45 Type type() const { return type_; } |
45 ash::LauncherID launcher_id() const { return launcher_id_; } | 46 ash::LauncherID launcher_id() const { return launcher_id_; } |
46 void set_launcher_id(ash::LauncherID id) { launcher_id_ = id; } | 47 void set_launcher_id(ash::LauncherID id) { launcher_id_ = id; } |
47 const std::string& app_id() const { return app_id_; } | 48 virtual const std::string& app_id() const; |
48 ChromeLauncherController* launcher_controller() { | 49 ChromeLauncherController* launcher_controller() { |
49 return launcher_controller_; | 50 return launcher_controller_; |
50 } | 51 } |
51 | 52 |
| 53 // Lock this item to the launcher without being pinned (windowed v1 apps). |
| 54 void lock() { locked_++; } |
| 55 void unlock() { |
| 56 DCHECK(locked_); |
| 57 locked_--; |
| 58 } |
| 59 bool locked() { return locked_ > 0; } |
| 60 |
52 // Returns the title for this item. | 61 // Returns the title for this item. |
53 virtual string16 GetTitle() = 0; | 62 virtual string16 GetTitle() = 0; |
54 | 63 |
55 // Returns true if this item controls |window|. | 64 // Returns true if this item controls |window|. |
56 virtual bool HasWindow(aura::Window* window) const = 0; | 65 virtual bool HasWindow(aura::Window* window) const = 0; |
57 | 66 |
58 // Returns true if this item is open. | 67 // Returns true if this item is open. |
59 virtual bool IsOpen() const = 0; | 68 virtual bool IsOpen() const = 0; |
60 | 69 |
61 // Launches a new instance of the app associated with this item. | 70 // Launches a new instance of the app associated with this item. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Returns an empty title if no matching extension can be found. | 103 // Returns an empty title if no matching extension can be found. |
95 string16 GetAppTitle() const; | 104 string16 GetAppTitle() const; |
96 | 105 |
97 private: | 106 private: |
98 const Type type_; | 107 const Type type_; |
99 // App id will be empty if there is no app associated with the window. | 108 // App id will be empty if there is no app associated with the window. |
100 const std::string app_id_; | 109 const std::string app_id_; |
101 ash::LauncherID launcher_id_; | 110 ash::LauncherID launcher_id_; |
102 ChromeLauncherController* launcher_controller_; | 111 ChromeLauncherController* launcher_controller_; |
103 | 112 |
| 113 // The lock counter which tells the launcher if the item can be removed from |
| 114 // the launcher (0) or not (>0). It is being used for windowed V1 |
| 115 // applications. |
| 116 int locked_; |
| 117 |
104 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); | 118 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); |
105 }; | 119 }; |
106 | 120 |
107 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | 121 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
OLD | NEW |