OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | |
6 #define APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | |
7 | |
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" | |
13 | |
14 #if defined(OS_CHROMEOS) | |
15 #include "ui/display/chromeos/display_configurator.h" | |
16 #endif | |
17 | |
18 namespace aura { | |
19 class TestScreen; | |
20 class Window; | |
21 class WindowTreeHost; | |
22 namespace client { | |
23 class DefaultCaptureClient; | |
24 class FocusClient; | |
25 } | |
26 } | |
27 | |
28 namespace content { | |
29 class BrowserContext; | |
30 } | |
31 | |
32 namespace gfx { | |
33 class Size; | |
34 } | |
35 | |
36 #if defined(OS_CHROMEOS) | |
37 namespace ui { | |
38 class UserActivityPowerManagerNotifier; | |
39 } | |
40 #endif | |
41 | |
42 namespace wm { | |
43 class CompoundEventFilter; | |
44 class CursorManager; | |
45 class FocusRules; | |
46 class InputMethodEventFilter; | |
47 class UserActivityDetector; | |
48 } | |
49 | |
50 namespace apps { | |
51 | |
52 class ShellAppWindow; | |
53 class ShellAppWindowController; | |
54 | |
55 // Handles desktop-related tasks for app_shell. | |
56 class ShellDesktopController : public aura::client::WindowTreeClient, | |
57 public aura::WindowTreeHostObserver | |
58 #if defined(OS_CHROMEOS) | |
59 , | |
60 public ui::DisplayConfigurator::Observer | |
61 #endif | |
62 { | |
63 public: | |
64 ShellDesktopController(); | |
65 virtual ~ShellDesktopController(); | |
66 | |
67 // Returns the single instance of the desktop. (Stateless functions like | |
68 // ShellAppWindowCreateFunction need to be able to access the desktop, so | |
69 // we need a singleton somewhere). | |
70 static ShellDesktopController* instance(); | |
71 | |
72 aura::WindowTreeHost* host() { return host_.get(); } | |
73 | |
74 // Creates the window that hosts the app. | |
75 void CreateRootWindow(); | |
76 | |
77 // Sets the controller to create/close the app windows. Takes the ownership of | |
78 // |app_window_controller|. | |
79 void SetAppWindowController(ShellAppWindowController* app_window_controller); | |
80 | |
81 // Creates a new app window and adds it to the desktop. The desktop maintains | |
82 // ownership of the window. | |
83 ShellAppWindow* CreateAppWindow(content::BrowserContext* context); | |
84 | |
85 // Closes and destroys the app windows. | |
86 void CloseAppWindows(); | |
87 | |
88 // Overridden from aura::client::WindowTreeClient: | |
89 virtual aura::Window* GetDefaultParent(aura::Window* context, | |
90 aura::Window* window, | |
91 const gfx::Rect& bounds) OVERRIDE; | |
92 | |
93 #if defined(OS_CHROMEOS) | |
94 // ui::DisplayConfigurator::Observer overrides. | |
95 virtual void OnDisplayModeChanged(const std::vector< | |
96 ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; | |
97 #endif | |
98 | |
99 // aura::WindowTreeHostObserver overrides: | |
100 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; | |
101 | |
102 protected: | |
103 // Creates and sets the aura clients and window manager stuff. Subclass may | |
104 // initialize different sets of the clients. | |
105 virtual void InitWindowManager(); | |
106 | |
107 // Creates a focus rule that is to be used in the InitWindowManager. | |
108 virtual wm::FocusRules* CreateFocusRules(); | |
109 | |
110 private: | |
111 // Closes and destroys the root window hosting the app. | |
112 void DestroyRootWindow(); | |
113 | |
114 // Returns the dimensions (in pixels) of the primary display, or an empty size | |
115 // if the dimensions can't be determined or no display is connected. | |
116 gfx::Size GetPrimaryDisplaySize(); | |
117 | |
118 #if defined(OS_CHROMEOS) | |
119 scoped_ptr<ui::DisplayConfigurator> display_configurator_; | |
120 #endif | |
121 | |
122 scoped_ptr<aura::TestScreen> test_screen_; | |
123 | |
124 scoped_ptr<aura::WindowTreeHost> host_; | |
125 | |
126 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; | |
127 | |
128 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | |
129 | |
130 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; | |
131 | |
132 scoped_ptr<aura::client::FocusClient> focus_client_; | |
133 | |
134 scoped_ptr<wm::CursorManager> cursor_manager_; | |
135 | |
136 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; | |
137 #if defined(OS_CHROMEOS) | |
138 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; | |
139 #endif | |
140 | |
141 // The desktop supports a single app window. | |
142 scoped_ptr<ShellAppWindowController> app_window_controller_; | |
143 | |
144 DISALLOW_COPY_AND_ASSIGN(ShellDesktopController); | |
145 }; | |
146 | |
147 } // namespace apps | |
148 | |
149 #endif // APPS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_H_ | |
OLD | NEW |