OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
15 | 15 |
16 namespace apps { | |
17 class AppWindow; | |
18 } | |
19 | |
20 namespace aura { | 16 namespace aura { |
21 class Window; | 17 class Window; |
22 } | 18 } |
23 | 19 |
| 20 namespace extensions { |
| 21 class AppWindow; |
| 22 } |
| 23 |
24 namespace gfx { | 24 namespace gfx { |
25 class Image; | 25 class Image; |
26 } | 26 } |
27 | 27 |
28 class ChromeLauncherController; | 28 class ChromeLauncherController; |
29 | 29 |
30 // This is a LauncherItemController for app windows. There is one instance per | 30 // This is a LauncherItemController for app windows. There is one instance per |
31 // app, per launcher id. For apps with multiple windows, each item controller | 31 // app, per launcher id. For apps with multiple windows, each item controller |
32 // keeps track of all windows associated with the app and their activation | 32 // keeps track of all windows associated with the app and their activation |
33 // order. Instances are owned by ash::ShelfItemDelegateManager. | 33 // order. Instances are owned by ash::ShelfItemDelegateManager. |
34 // | 34 // |
35 // Tests are in chrome_launcher_controller_browsertest.cc | 35 // Tests are in chrome_launcher_controller_browsertest.cc |
36 class AppWindowLauncherItemController : public LauncherItemController, | 36 class AppWindowLauncherItemController : public LauncherItemController, |
37 public aura::WindowObserver { | 37 public aura::WindowObserver { |
38 public: | 38 public: |
39 AppWindowLauncherItemController(Type type, | 39 AppWindowLauncherItemController(Type type, |
40 const std::string& app_shelf_id, | 40 const std::string& app_shelf_id, |
41 const std::string& app_id, | 41 const std::string& app_id, |
42 ChromeLauncherController* controller); | 42 ChromeLauncherController* controller); |
43 | 43 |
44 virtual ~AppWindowLauncherItemController(); | 44 virtual ~AppWindowLauncherItemController(); |
45 | 45 |
46 void AddAppWindow(apps::AppWindow* app_window, ash::ShelfItemStatus status); | 46 void AddAppWindow(extensions::AppWindow* app_window, |
| 47 ash::ShelfItemStatus status); |
47 | 48 |
48 void RemoveAppWindowForWindow(aura::Window* window); | 49 void RemoveAppWindowForWindow(aura::Window* window); |
49 | 50 |
50 void SetActiveWindow(aura::Window* window); | 51 void SetActiveWindow(aura::Window* window); |
51 | 52 |
52 const std::string& app_shelf_id() const { return app_shelf_id_; } | 53 const std::string& app_shelf_id() const { return app_shelf_id_; } |
53 | 54 |
54 // LauncherItemController overrides: | 55 // LauncherItemController overrides: |
55 virtual bool IsOpen() const OVERRIDE; | 56 virtual bool IsOpen() const OVERRIDE; |
56 virtual bool IsVisible() const OVERRIDE; | 57 virtual bool IsVisible() const OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
75 size_t app_window_count() const { return app_windows_.size(); } | 76 size_t app_window_count() const { return app_windows_.size(); } |
76 | 77 |
77 // Activates the window at position |index|. | 78 // Activates the window at position |index|. |
78 void ActivateIndexedApp(size_t index); | 79 void ActivateIndexedApp(size_t index); |
79 | 80 |
80 // Install the app. Only valid for ephemeral apps, which can be promoted to | 81 // Install the app. Only valid for ephemeral apps, which can be promoted to |
81 // regular installed apps. | 82 // regular installed apps. |
82 void InstallApp(); | 83 void InstallApp(); |
83 | 84 |
84 private: | 85 private: |
85 typedef std::list<apps::AppWindow*> AppWindowList; | 86 typedef std::list<extensions::AppWindow*> AppWindowList; |
86 | 87 |
87 void ShowAndActivateOrMinimize(apps::AppWindow* app_window); | 88 void ShowAndActivateOrMinimize(extensions::AppWindow* app_window); |
88 | 89 |
89 // Activate the given |window_to_show|, or - if already selected - advance to | 90 // Activate the given |window_to_show|, or - if already selected - advance to |
90 // the next window of similar type. | 91 // the next window of similar type. |
91 void ActivateOrAdvanceToNextAppWindow(apps::AppWindow* window_to_show); | 92 void ActivateOrAdvanceToNextAppWindow(extensions::AppWindow* window_to_show); |
92 | 93 |
93 // List of associated app windows | 94 // List of associated app windows |
94 AppWindowList app_windows_; | 95 AppWindowList app_windows_; |
95 | 96 |
96 // Pointer to the most recently active app window | 97 // Pointer to the most recently active app window |
97 apps::AppWindow* last_active_app_window_; | 98 extensions::AppWindow* last_active_app_window_; |
98 | 99 |
99 // The launcher id associated with this set of windows. There is one | 100 // The launcher id associated with this set of windows. There is one |
100 // AppLauncherItemController for each |app_shelf_id_|. | 101 // AppLauncherItemController for each |app_shelf_id_|. |
101 const std::string app_shelf_id_; | 102 const std::string app_shelf_id_; |
102 | 103 |
103 // Scoped list of observed windows (for removal on destruction) | 104 // Scoped list of observed windows (for removal on destruction) |
104 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; | 105 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; |
105 | 106 |
106 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); | 107 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); |
107 }; | 108 }; |
108 | 109 |
109 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ | 110 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ |
OLD | NEW |