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 EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "extensions/shell/browser/desktop_controller.h"
14 #include "ui/aura/client/window_tree_client.h"
15 #include "ui/aura/window_tree_host_observer.h"
17 #if defined(OS_CHROMEOS)
18 #include "chromeos/dbus/power_manager_client.h"
19 #include "ui/display/chromeos/display_configurator.h"
26 class DefaultCaptureClient
;
40 class UserActivityDetector
;
41 #if defined(OS_CHROMEOS)
42 class UserActivityPowerManagerNotifier
;
47 class CompoundEventFilter
;
49 class InputMethodEventFilter
;
52 namespace extensions
{
53 class AppWindowClient
;
57 // Handles desktop-related tasks for app_shell.
58 class ShellDesktopControllerAura
59 : public DesktopController
,
60 public aura::client::WindowTreeClient
,
61 #if defined(OS_CHROMEOS)
62 public chromeos::PowerManagerClient::Observer
,
63 public ui::DisplayConfigurator::Observer
,
65 public aura::WindowTreeHostObserver
{
67 ShellDesktopControllerAura();
68 ~ShellDesktopControllerAura() override
;
71 gfx::Size
GetWindowSize() override
;
72 AppWindow
* CreateAppWindow(content::BrowserContext
* context
,
73 const Extension
* extension
) override
;
74 void AddAppWindow(gfx::NativeWindow window
) override
;
75 void RemoveAppWindow(AppWindow
* window
) override
;
76 void CloseAppWindows() override
;
78 // aura::client::WindowTreeClient overrides:
79 aura::Window
* GetDefaultParent(aura::Window
* context
,
81 const gfx::Rect
& bounds
) override
;
83 #if defined(OS_CHROMEOS)
84 // chromeos::PowerManagerClient::Observer overrides:
85 void PowerButtonEventReceived(bool down
,
86 const base::TimeTicks
& timestamp
) override
;
88 // ui::DisplayConfigurator::Observer overrides.
89 void OnDisplayModeChanged(
90 const ui::DisplayConfigurator::DisplayStateList
& displays
) override
;
93 // aura::WindowTreeHostObserver overrides:
94 void OnHostCloseRequested(const aura::WindowTreeHost
* host
) override
;
97 // Creates and sets the aura clients and window manager stuff. Subclass may
98 // initialize different sets of the clients.
99 virtual void InitWindowManager();
102 // Creates the window that hosts the app.
103 void CreateRootWindow();
105 // Closes and destroys the root window hosting the app.
106 void DestroyRootWindow();
108 // Returns the dimensions (in pixels) of the primary display, or an empty size
109 // if the dimensions can't be determined or no display is connected.
110 gfx::Size
GetPrimaryDisplaySize();
112 #if defined(OS_CHROMEOS)
113 scoped_ptr
<ui::DisplayConfigurator
> display_configurator_
;
116 scoped_ptr
<ShellScreen
> screen_
;
118 scoped_ptr
<aura::WindowTreeHost
> host_
;
120 scoped_ptr
<wm::CompoundEventFilter
> root_window_event_filter_
;
122 scoped_ptr
<aura::client::DefaultCaptureClient
> capture_client_
;
124 scoped_ptr
<wm::InputMethodEventFilter
> input_method_filter_
;
126 scoped_ptr
<aura::client::FocusClient
> focus_client_
;
128 scoped_ptr
<wm::CursorManager
> cursor_manager_
;
130 scoped_ptr
<ui::UserActivityDetector
> user_activity_detector_
;
131 #if defined(OS_CHROMEOS)
132 scoped_ptr
<ui::UserActivityPowerManagerNotifier
> user_activity_notifier_
;
135 scoped_ptr
<AppWindowClient
> app_window_client_
;
137 // NativeAppWindow::Close() deletes the AppWindow.
138 std::vector
<AppWindow
*> app_windows_
;
140 DISALLOW_COPY_AND_ASSIGN(ShellDesktopControllerAura
);
143 } // namespace extensions
145 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_