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