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