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