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_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "apps/app_window_registry.h" | 12 #include "extensions/browser/app_window/app_window_registry.h" |
13 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
14 #include "ui/wm/public/activation_change_observer.h" | 14 #include "ui/wm/public/activation_change_observer.h" |
15 | 15 |
16 namespace apps { | |
17 class AppWindow; | |
18 } | |
19 | |
20 namespace aura { | 16 namespace aura { |
21 | 17 |
22 class Window; | 18 class Window; |
23 | 19 |
24 namespace client { | 20 namespace client { |
25 class ActivationClient; | 21 class ActivationClient; |
26 } | 22 } |
27 } | 23 } |
28 | 24 |
| 25 namespace extensions { |
| 26 class AppWindow; |
| 27 } |
| 28 |
29 class ChromeLauncherController; | 29 class ChromeLauncherController; |
30 class Profile; | 30 class Profile; |
31 class AppWindowLauncherItemController; | 31 class AppWindowLauncherItemController; |
32 | 32 |
33 // AppWindowLauncherController observes the app window registry and the | 33 // AppWindowLauncherController observes the app window registry and the |
34 // aura window manager. It handles adding and removing launcher items from | 34 // aura window manager. It handles adding and removing launcher items from |
35 // ChromeLauncherController. | 35 // ChromeLauncherController. |
36 class AppWindowLauncherController | 36 class AppWindowLauncherController |
37 : public apps::AppWindowRegistry::Observer, | 37 : public extensions::AppWindowRegistry::Observer, |
38 public aura::WindowObserver, | 38 public aura::WindowObserver, |
39 public aura::client::ActivationChangeObserver { | 39 public aura::client::ActivationChangeObserver { |
40 public: | 40 public: |
41 explicit AppWindowLauncherController(ChromeLauncherController* owner); | 41 explicit AppWindowLauncherController(ChromeLauncherController* owner); |
42 virtual ~AppWindowLauncherController(); | 42 virtual ~AppWindowLauncherController(); |
43 | 43 |
44 // Called by ChromeLauncherController when the active user changed and the | 44 // Called by ChromeLauncherController when the active user changed and the |
45 // items need to be updated. | 45 // items need to be updated. |
46 virtual void ActiveUserChanged(const std::string& user_email) {} | 46 virtual void ActiveUserChanged(const std::string& user_email) {} |
47 | 47 |
48 // An additional user identified by |Profile|, got added to the existing | 48 // An additional user identified by |Profile|, got added to the existing |
49 // session. | 49 // session. |
50 virtual void AdditionalUserAddedToSession(Profile* profile); | 50 virtual void AdditionalUserAddedToSession(Profile* profile); |
51 | 51 |
52 // Overridden from AppWindowRegistry::Observer: | 52 // Overridden from AppWindowRegistry::Observer: |
53 virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE; | 53 virtual void OnAppWindowIconChanged( |
54 virtual void OnAppWindowShown(apps::AppWindow* app_window) OVERRIDE; | 54 extensions::AppWindow* app_window) OVERRIDE; |
55 virtual void OnAppWindowHidden(apps::AppWindow* app_window) OVERRIDE; | 55 virtual void OnAppWindowShown(extensions::AppWindow* app_window) OVERRIDE; |
| 56 virtual void OnAppWindowHidden(extensions::AppWindow* app_window) OVERRIDE; |
56 | 57 |
57 // Overriden from aura::WindowObserver: | 58 // Overriden from aura::WindowObserver: |
58 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 59 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
59 | 60 |
60 // Overriden from client::ActivationChangeObserver: | 61 // Overriden from client::ActivationChangeObserver: |
61 virtual void OnWindowActivated(aura::Window* gained_active, | 62 virtual void OnWindowActivated(aura::Window* gained_active, |
62 aura::Window* lost_active) OVERRIDE; | 63 aura::Window* lost_active) OVERRIDE; |
63 | 64 |
64 protected: | 65 protected: |
65 // Registers a app window with the shelf and this object. | 66 // Registers a app window with the shelf and this object. |
66 void RegisterApp(apps::AppWindow* app_window); | 67 void RegisterApp(extensions::AppWindow* app_window); |
67 | 68 |
68 // Unregisters a app window with the shelf and this object. | 69 // Unregisters a app window with the shelf and this object. |
69 void UnregisterApp(aura::Window* window); | 70 void UnregisterApp(aura::Window* window); |
70 | 71 |
71 // Check if a given window is known to the launcher controller. | 72 // Check if a given window is known to the launcher controller. |
72 bool IsRegisteredApp(aura::Window* window); | 73 bool IsRegisteredApp(aura::Window* window); |
73 | 74 |
74 private: | 75 private: |
75 typedef std::map<std::string, AppWindowLauncherItemController*> | 76 typedef std::map<std::string, AppWindowLauncherItemController*> |
76 AppControllerMap; | 77 AppControllerMap; |
77 typedef std::map<aura::Window*, std::string> WindowToAppShelfIdMap; | 78 typedef std::map<aura::Window*, std::string> WindowToAppShelfIdMap; |
78 | 79 |
79 AppWindowLauncherItemController* ControllerForWindow(aura::Window* window); | 80 AppWindowLauncherItemController* ControllerForWindow(aura::Window* window); |
80 | 81 |
81 ChromeLauncherController* owner_; | 82 ChromeLauncherController* owner_; |
82 // A set of unowned AppWindowRegistry pointers for loaded users. | 83 // A set of unowned AppWindowRegistry pointers for loaded users. |
83 // Note that this will only be used with multiple users in the side by side | 84 // Note that this will only be used with multiple users in the side by side |
84 // mode. | 85 // mode. |
85 std::set<apps::AppWindowRegistry*> registry_; | 86 std::set<extensions::AppWindowRegistry*> registry_; |
86 aura::client::ActivationClient* activation_client_; | 87 aura::client::ActivationClient* activation_client_; |
87 | 88 |
88 // Map of app launcher id to controller. | 89 // Map of app launcher id to controller. |
89 AppControllerMap app_controller_map_; | 90 AppControllerMap app_controller_map_; |
90 | 91 |
91 // Allows us to get from an aura::Window to the app shelf id. | 92 // Allows us to get from an aura::Window to the app shelf id. |
92 WindowToAppShelfIdMap window_to_app_shelf_id_map_; | 93 WindowToAppShelfIdMap window_to_app_shelf_id_map_; |
93 | 94 |
94 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherController); | 95 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherController); |
95 }; | 96 }; |
96 | 97 |
97 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_ | 98 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_ |
OLD | NEW |