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_H_
6 #define EXTENSIONS_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 "extensions/shell/browser/desktop_controller.h"
12 #include "ui/aura/client/window_tree_client.h"
13 #include "ui/aura/window_tree_host_observer.h"
15 #if defined(OS_CHROMEOS)
16 #include "chromeos/dbus/power_manager_client.h"
17 #include "ui/display/chromeos/display_configurator.h"
25 class DefaultCaptureClient
;
38 #if defined(OS_CHROMEOS)
40 class UserActivityPowerManagerNotifier
;
45 class CompoundEventFilter
;
47 class InputMethodEventFilter
;
48 class UserActivityDetector
;
51 namespace extensions
{
55 class ShellAppWindowController
;
57 // Handles desktop-related tasks for app_shell.
58 class ShellDesktopController
: public DesktopController
,
59 public aura::client::WindowTreeClient
,
60 #if defined(OS_CHROMEOS)
61 public chromeos::PowerManagerClient::Observer
,
62 public ui::DisplayConfigurator::Observer
,
64 public aura::WindowTreeHostObserver
{
66 ShellDesktopController();
67 virtual ~ShellDesktopController();
70 virtual aura::WindowTreeHost
* GetHost() OVERRIDE
;
71 virtual ShellAppWindow
* CreateAppWindow(content::BrowserContext
* context
,
72 const Extension
* extension
) OVERRIDE
;
73 virtual void CloseAppWindows() OVERRIDE
;
75 // aura::client::WindowTreeClient overrides:
76 virtual aura::Window
* GetDefaultParent(aura::Window
* context
,
78 const gfx::Rect
& bounds
) OVERRIDE
;
80 #if defined(OS_CHROMEOS)
81 // chromeos::PowerManagerClient::Observer overrides:
82 virtual void PowerButtonEventReceived(bool down
,
83 const base::TimeTicks
& timestamp
)
86 // ui::DisplayConfigurator::Observer overrides.
87 virtual void OnDisplayModeChanged(const std::vector
<
88 ui::DisplayConfigurator::DisplayState
>& displays
) OVERRIDE
;
91 // aura::WindowTreeHostObserver overrides:
92 virtual void OnHostCloseRequested(const aura::WindowTreeHost
* host
) OVERRIDE
;
95 // Creates and sets the aura clients and window manager stuff. Subclass may
96 // initialize different sets of the clients.
97 virtual void InitWindowManager();
100 // Creates the window that hosts the app.
101 void CreateRootWindow();
103 // Closes and destroys the root window hosting the app.
104 void DestroyRootWindow();
106 // Returns the dimensions (in pixels) of the primary display, or an empty size
107 // if the dimensions can't be determined or no display is connected.
108 gfx::Size
GetPrimaryDisplaySize();
110 #if defined(OS_CHROMEOS)
111 scoped_ptr
<ui::DisplayConfigurator
> display_configurator_
;
114 scoped_ptr
<aura::TestScreen
> test_screen_
;
116 scoped_ptr
<aura::WindowTreeHost
> host_
;
118 scoped_ptr
<wm::CompoundEventFilter
> root_window_event_filter_
;
120 scoped_ptr
<aura::client::DefaultCaptureClient
> capture_client_
;
122 scoped_ptr
<wm::InputMethodEventFilter
> input_method_filter_
;
124 scoped_ptr
<aura::client::FocusClient
> focus_client_
;
126 scoped_ptr
<wm::CursorManager
> cursor_manager_
;
128 scoped_ptr
<wm::UserActivityDetector
> user_activity_detector_
;
129 #if defined(OS_CHROMEOS)
130 scoped_ptr
<ui::UserActivityPowerManagerNotifier
> user_activity_notifier_
;
133 // The desktop supports a single app window.
134 scoped_ptr
<ShellAppWindow
> app_window_
;
136 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController
);
139 } // namespace extensions
141 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_