Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / app_window_launcher_controller.h
bloba4993dc21c39a0336ce085be09aedf77b78c1faf
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_
8 #include <list>
9 #include <map>
10 #include <string>
12 #include "extensions/browser/app_window/app_window_registry.h"
13 #include "ui/aura/window_observer.h"
14 #include "ui/wm/public/activation_change_observer.h"
16 namespace aura {
18 class Window;
20 namespace client {
21 class ActivationClient;
25 namespace extensions {
26 class AppWindow;
29 class ChromeLauncherController;
30 class Profile;
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 extensions::AppWindowRegistry::Observer,
38 public aura::WindowObserver,
39 public aura::client::ActivationChangeObserver {
40 public:
41 explicit AppWindowLauncherController(ChromeLauncherController* owner);
42 ~AppWindowLauncherController() override;
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
49 // session.
50 virtual void AdditionalUserAddedToSession(Profile* profile);
52 // Overridden from AppWindowRegistry::Observer:
53 void OnAppWindowIconChanged(extensions::AppWindow* app_window) override;
54 void OnAppWindowShown(extensions::AppWindow* app_window,
55 bool was_hidden) override;
56 void OnAppWindowHidden(extensions::AppWindow* app_window) override;
58 // Overriden from aura::WindowObserver:
59 void OnWindowDestroying(aura::Window* window) override;
61 // Overriden from client::ActivationChangeObserver:
62 void OnWindowActivated(
63 aura::client::ActivationChangeObserver::ActivationReason reason,
64 aura::Window* gained_active,
65 aura::Window* lost_active) override;
67 protected:
68 // Registers a app window with the shelf and this object.
69 void RegisterApp(extensions::AppWindow* app_window);
71 // Unregisters a app window with the shelf and this object.
72 void UnregisterApp(aura::Window* window);
74 // Check if a given window is known to the launcher controller.
75 bool IsRegisteredApp(aura::Window* window);
77 private:
78 typedef std::map<std::string, AppWindowLauncherItemController*>
79 AppControllerMap;
80 typedef std::map<aura::Window*, std::string> WindowToAppShelfIdMap;
82 AppWindowLauncherItemController* ControllerForWindow(aura::Window* window);
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<extensions::AppWindowRegistry*> registry_;
89 aura::client::ActivationClient* activation_client_;
91 // Map of app launcher id to controller.
92 AppControllerMap app_controller_map_;
94 // Allows us to get from an aura::Window to the app shelf id.
95 WindowToAppShelfIdMap window_to_app_shelf_id_map_;
97 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherController);
100 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_CONTROLLER_H_