OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | 5 #ifndef APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ |
6 #define APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | 6 #define APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/aura/client/window_tree_client.h" |
11 #include "ui/aura/window_tree_host_observer.h" | 12 #include "ui/aura/window_tree_host_observer.h" |
12 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
13 | 14 |
14 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
15 #include "ui/display/chromeos/display_configurator.h" | 16 #include "ui/display/chromeos/display_configurator.h" |
16 #endif | 17 #endif |
17 | 18 |
18 namespace aura { | 19 namespace aura { |
19 class TestScreen; | 20 class TestScreen; |
| 21 class Window; |
20 class WindowTreeHost; | 22 class WindowTreeHost; |
| 23 namespace client { |
| 24 class DefaultCaptureClient; |
| 25 class FocusClient; |
| 26 } |
21 } | 27 } |
22 | 28 |
23 namespace content { | 29 namespace content { |
24 class BrowserContext; | 30 class BrowserContext; |
25 } | 31 } |
26 | 32 |
27 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
28 namespace ui { | 34 namespace ui { |
29 class UserActivityPowerManagerNotifier; | 35 class UserActivityPowerManagerNotifier; |
30 } | 36 } |
31 #endif | 37 #endif |
32 | 38 |
33 namespace wm { | 39 namespace wm { |
34 class CursorManager; | 40 class CursorManager; |
| 41 class CompoundEventFilter; |
| 42 class InputMethodEventFilter; |
35 class UserActivityDetector; | 43 class UserActivityDetector; |
36 class WMTestHelper; | |
37 } | 44 } |
38 | 45 |
39 namespace apps { | 46 namespace apps { |
40 | 47 |
41 class ShellAppWindow; | 48 class ShellAppWindow; |
42 | 49 |
43 // Handles desktop-related tasks for app_shell. | 50 // Handles desktop-related tasks for app_shell. |
44 class ShellDesktopController | 51 class ShellDesktopController : aura::client::WindowTreeClient |
45 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
46 : public ui::DisplayConfigurator::Observer | 53 , |
| 54 public ui::DisplayConfigurator::Observer |
47 #endif | 55 #endif |
48 { | 56 { |
49 public: | 57 public: |
50 ShellDesktopController(); | 58 ShellDesktopController(); |
51 virtual ~ShellDesktopController(); | 59 virtual ~ShellDesktopController(); |
52 | 60 |
53 // Returns the single instance of the desktop. (Stateless functions like | 61 // Returns the single instance of the desktop. (Stateless functions like |
54 // ShellAppWindowCreateFunction need to be able to access the desktop, so | 62 // ShellAppWindowCreateFunction need to be able to access the desktop, so |
55 // we need a singleton somewhere). | 63 // we need a singleton somewhere). |
56 static ShellDesktopController* instance(); | 64 static ShellDesktopController* instance(); |
57 | 65 |
| 66 // Creates the window that hosts the app. |
| 67 void CreateRootWindow(); |
| 68 |
58 // Creates a new app window and adds it to the desktop. The desktop maintains | 69 // Creates a new app window and adds it to the desktop. The desktop maintains |
59 // ownership of the window. | 70 // ownership of the window. |
60 ShellAppWindow* CreateAppWindow(content::BrowserContext* context); | 71 ShellAppWindow* CreateAppWindow(content::BrowserContext* context); |
61 | 72 |
62 // Closes and destroys the app window. | 73 // Closes and destroys the app window. |
63 void CloseAppWindow(); | 74 void CloseAppWindow(); |
64 | 75 |
65 // Returns the host for the Aura window tree. | 76 // Overridden from aura::client::WindowTreeClient: |
66 aura::WindowTreeHost* GetWindowTreeHost(); | 77 virtual aura::Window* GetDefaultParent(aura::Window* context, |
| 78 aura::Window* window, |
| 79 const gfx::Rect& bounds) OVERRIDE; |
67 | 80 |
68 #if defined(OS_CHROMEOS) | 81 #if defined(OS_CHROMEOS) |
69 // ui::DisplayConfigurator::Observer overrides. | 82 // ui::DisplayConfigurator::Observer overrides. |
70 virtual void OnDisplayModeChanged(const std::vector< | 83 virtual void OnDisplayModeChanged(const std::vector< |
71 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; | 84 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; |
72 #endif | 85 #endif |
73 | 86 |
| 87 aura::WindowTreeHost* host() { |
| 88 return host_.get(); |
| 89 }; |
| 90 |
| 91 protected: |
| 92 // Creates and sets the aura clients and window manager stuffs. Subclass may |
| 93 // initialize different sets of the clients. |
| 94 virtual void InitWindowManager(); |
| 95 |
74 private: | 96 private: |
75 // Creates the window that hosts the app. | |
76 void CreateRootWindow(); | |
77 | |
78 // Closes and destroys the root window hosting the app. | 97 // Closes and destroys the root window hosting the app. |
79 void DestroyRootWindow(); | 98 void DestroyRootWindow(); |
80 | 99 |
81 // Returns the dimensions (in pixels) of the primary display, or an empty size | 100 // Returns the dimensions (in pixels) of the primary display, or an empty size |
82 // if the dimensions can't be determined or no display is connected. | 101 // if the dimensions can't be determined or no display is connected. |
83 gfx::Size GetPrimaryDisplaySize(); | 102 gfx::Size GetPrimaryDisplaySize(); |
84 | 103 |
85 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
86 scoped_ptr<ui::DisplayConfigurator> display_configurator_; | 105 scoped_ptr<ui::DisplayConfigurator> display_configurator_; |
87 #endif | 106 #endif |
88 | 107 |
89 // Enable a minimal set of views::corewm to be initialized. | 108 scoped_ptr<aura::TestScreen> test_screen_; |
90 scoped_ptr<wm::WMTestHelper> wm_test_helper_; | |
91 | 109 |
92 scoped_ptr<aura::TestScreen> test_screen_; | 110 scoped_ptr<aura::WindowTreeHost> host_; |
| 111 |
| 112 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; |
| 113 |
| 114 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 115 |
| 116 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; |
| 117 |
| 118 scoped_ptr<aura::client::FocusClient> focus_client_; |
93 | 119 |
94 scoped_ptr<wm::CursorManager> cursor_manager_; | 120 scoped_ptr<wm::CursorManager> cursor_manager_; |
95 | 121 |
96 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; | 122 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; |
97 #if defined(OS_CHROMEOS) | 123 #if defined(OS_CHROMEOS) |
98 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; | 124 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; |
99 #endif | 125 #endif |
100 | 126 |
101 // The desktop supports a single app window. | 127 // The desktop supports a single app window. |
102 scoped_ptr<ShellAppWindow> app_window_; | 128 scoped_ptr<ShellAppWindow> app_window_; |
103 | 129 |
104 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController); | 130 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController); |
105 }; | 131 }; |
106 | 132 |
107 } // namespace apps | 133 } // namespace apps |
108 | 134 |
109 #endif // APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | 135 #endif // APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ |
OLD | NEW |