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 APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_
6 #define APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/aura/client/window_tree_client.h"
12 #include "ui/aura/window_tree_host_observer.h"
14 #if defined(OS_CHROMEOS)
15 #include "ui/display/chromeos/display_configurator.h"
23 class DefaultCaptureClient;
36 #if defined(OS_CHROMEOS)
38 class UserActivityPowerManagerNotifier;
43 class CompoundEventFilter;
45 class InputMethodEventFilter;
46 class UserActivityDetector;
52 class ShellAppWindowController;
54 // Handles desktop-related tasks for app_shell.
55 class ShellDesktopController : public aura::client::WindowTreeClient,
56 public aura::WindowTreeHostObserver
57 #if defined(OS_CHROMEOS)
59 public ui::DisplayConfigurator::Observer
63 ShellDesktopController();
64 virtual ~ShellDesktopController();
66 // Returns the single instance of the desktop. (Stateless functions like
67 // ShellAppWindowCreateFunction need to be able to access the desktop, so
68 // we need a singleton somewhere).
69 static ShellDesktopController* instance();
71 aura::WindowTreeHost* host() { return host_.get(); }
73 // Creates the window that hosts the app.
74 void CreateRootWindow();
76 // Sets the controller to create/close the app windows. Takes the ownership of
77 // |app_window_controller|.
78 void SetAppWindowController(ShellAppWindowController* app_window_controller);
80 // Creates a new app window and adds it to the desktop. The desktop maintains
81 // ownership of the window.
82 ShellAppWindow* CreateAppWindow(content::BrowserContext* context);
84 // Closes and destroys the app windows.
85 void CloseAppWindows();
87 // Overridden from aura::client::WindowTreeClient:
88 virtual aura::Window* GetDefaultParent(aura::Window* context,
90 const gfx::Rect& bounds) OVERRIDE;
92 #if defined(OS_CHROMEOS)
93 // ui::DisplayConfigurator::Observer overrides.
94 virtual void OnDisplayModeChanged(const std::vector<
95 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE;
98 // aura::WindowTreeHostObserver overrides:
99 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE;
102 // Creates and sets the aura clients and window manager stuff. Subclass may
103 // initialize different sets of the clients.
104 virtual void InitWindowManager();
107 // Closes and destroys the root window hosting the app.
108 void DestroyRootWindow();
110 // Returns the dimensions (in pixels) of the primary display, or an empty size
111 // if the dimensions can't be determined or no display is connected.
112 gfx::Size GetPrimaryDisplaySize();
114 #if defined(OS_CHROMEOS)
115 scoped_ptr<ui::DisplayConfigurator> display_configurator_;
118 scoped_ptr<aura::TestScreen> test_screen_;
120 scoped_ptr<aura::WindowTreeHost> host_;
122 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_;
124 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
126 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_;
128 scoped_ptr<aura::client::FocusClient> focus_client_;
130 scoped_ptr<wm::CursorManager> cursor_manager_;
132 scoped_ptr<wm::UserActivityDetector> user_activity_detector_;
133 #if defined(OS_CHROMEOS)
134 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
137 // The desktop supports a single app window.
138 scoped_ptr<ShellAppWindowController> app_window_controller_;
140 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController);
145 #endif // APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_