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