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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_
12 #include "apps/app_window_registry.h"
13 #include "ui/aura/window_observer.h"
14 #include "ui/wm/public/activation_change_observer.h"
25 class ActivationClient
;
29 class ChromeLauncherController
;
31 class AppWindowLauncherItemController
;
33 // AppWindowLauncherController observes the app window registry and the
34 // aura window manager. It handles adding and removing launcher items from
35 // ChromeLauncherController.
36 class AppWindowLauncherController
37 : public apps::AppWindowRegistry::Observer
,
38 public aura::WindowObserver
,
39 public aura::client::ActivationChangeObserver
{
41 explicit AppWindowLauncherController(ChromeLauncherController
* owner
);
42 virtual ~AppWindowLauncherController();
44 // Called by ChromeLauncherController when the active user changed and the
45 // items need to be updated.
46 virtual void ActiveUserChanged(const std::string
& user_email
) {}
48 // An additional user identified by |Profile|, got added to the existing
50 virtual void AdditionalUserAddedToSession(Profile
* profile
);
52 // Overridden from AppWindowRegistry::Observer:
53 virtual void OnAppWindowAdded(apps::AppWindow
* app_window
) OVERRIDE
;
54 virtual void OnAppWindowIconChanged(apps::AppWindow
* app_window
) OVERRIDE
;
55 virtual void OnAppWindowRemoved(apps::AppWindow
* app_window
) OVERRIDE
;
56 #if defined(OS_CHROMEOS)
57 virtual void OnAppWindowShown(apps::AppWindow
* app_window
) OVERRIDE
;
58 virtual void OnAppWindowHidden(apps::AppWindow
* app_window
) OVERRIDE
;
61 // Overriden from aura::WindowObserver:
62 virtual void OnWindowDestroying(aura::Window
* window
) OVERRIDE
;
64 // Overriden from client::ActivationChangeObserver:
65 virtual void OnWindowActivated(aura::Window
* gained_active
,
66 aura::Window
* lost_active
) OVERRIDE
;
69 // Registers a app window with the shelf and this object.
70 void RegisterApp(apps::AppWindow
* app_window
);
72 // Unregisters a app window with the shelf and this object.
73 void UnregisterApp(aura::Window
* window
);
75 // Check if a given window is known to the launcher controller.
76 bool IsRegisteredApp(aura::Window
* window
);
79 typedef std::map
<std::string
, AppWindowLauncherItemController
*>
81 typedef std::map
<aura::Window
*, std::string
> WindowToAppShelfIdMap
;
83 AppWindowLauncherItemController
* ControllerForWindow(aura::Window
* window
);
85 ChromeLauncherController
* owner_
;
86 // 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
89 std::set
<apps::AppWindowRegistry
*> registry_
;
90 aura::client::ActivationClient
* activation_client_
;
92 // Map of app launcher id to controller.
93 AppControllerMap app_controller_map_
;
95 // Allows us to get from an aura::Window to the app shelf id.
96 WindowToAppShelfIdMap window_to_app_shelf_id_map_
;
98 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherController
);
101 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_