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 #include "extensions/shell/browser/shell_desktop_controller.h" | 5 #include "extensions/shell/browser/shell_desktop_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "extensions/browser/app_window/app_window.h" |
| 9 #include "extensions/browser/app_window/native_app_window.h" |
| 10 #include "extensions/shell/browser/shell_app_delegate.h" |
8 #include "extensions/shell/browser/shell_app_window.h" | 11 #include "extensions/shell/browser/shell_app_window.h" |
9 #include "extensions/shell/common/switches.h" | 12 #include "extensions/shell/common/switches.h" |
10 #include "ui/aura/client/cursor_client.h" | 13 #include "ui/aura/client/cursor_client.h" |
11 #include "ui/aura/client/default_capture_client.h" | 14 #include "ui/aura/client/default_capture_client.h" |
12 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
13 #include "ui/aura/test/test_screen.h" | 16 #include "ui/aura/test/test_screen.h" |
14 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
15 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
16 #include "ui/aura/window_tree_host.h" | 19 #include "ui/aura/window_tree_host.h" |
17 #include "ui/base/cursor/cursor.h" | 20 #include "ui/base/cursor/cursor.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE { | 149 virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE { |
147 return true; | 150 return true; |
148 } | 151 } |
149 | 152 |
150 private: | 153 private: |
151 DISALLOW_COPY_AND_ASSIGN(AppsFocusRules); | 154 DISALLOW_COPY_AND_ASSIGN(AppsFocusRules); |
152 }; | 155 }; |
153 | 156 |
154 } // namespace | 157 } // namespace |
155 | 158 |
156 ShellDesktopController::ShellDesktopController() { | 159 ShellDesktopController::ShellDesktopController() |
| 160 : app_window_(NULL) { |
157 #if defined(OS_CHROMEOS) | 161 #if defined(OS_CHROMEOS) |
158 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 162 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
159 AddObserver(this); | 163 AddObserver(this); |
160 display_configurator_.reset(new ui::DisplayConfigurator); | 164 display_configurator_.reset(new ui::DisplayConfigurator); |
161 display_configurator_->Init(false); | 165 display_configurator_->Init(false); |
162 display_configurator_->ForceInitialConfigure(0); | 166 display_configurator_->ForceInitialConfigure(0); |
163 display_configurator_->AddObserver(this); | 167 display_configurator_->AddObserver(this); |
164 #endif | 168 #endif |
165 | 169 |
166 CreateRootWindow(); | 170 CreateRootWindow(); |
167 } | 171 } |
168 | 172 |
169 ShellDesktopController::~ShellDesktopController() { | 173 ShellDesktopController::~ShellDesktopController() { |
170 app_window_.reset(); | 174 CloseAppWindows(); |
171 DestroyRootWindow(); | 175 DestroyRootWindow(); |
172 #if defined(OS_CHROMEOS) | 176 #if defined(OS_CHROMEOS) |
173 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 177 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
174 RemoveObserver(this); | 178 RemoveObserver(this); |
175 #endif | 179 #endif |
176 } | 180 } |
177 | 181 |
178 aura::WindowTreeHost* ShellDesktopController::GetHost() { | 182 aura::WindowTreeHost* ShellDesktopController::GetHost() { |
179 return host_.get(); | 183 return host_.get(); |
180 } | 184 } |
181 | 185 |
182 ShellAppWindow* ShellDesktopController::CreateAppWindow( | 186 ShellAppWindow* ShellDesktopController::CreateShellAppWindow( |
183 content::BrowserContext* context, | 187 content::BrowserContext* context, |
184 const Extension* extension) { | 188 const Extension* extension) { |
185 aura::Window* root_window = GetHost()->window(); | 189 aura::Window* root_window = GetHost()->window(); |
186 | 190 |
187 app_window_.reset(new ShellAppWindow); | 191 shell_app_window_.reset(new ShellAppWindow); |
188 app_window_->Init(context, extension, root_window->bounds().size()); | 192 shell_app_window_->Init(context, extension, root_window->bounds().size()); |
189 | 193 |
190 // Attach the web contents view to our window hierarchy. | 194 // Attach the web contents view to our window hierarchy. |
191 aura::Window* content = app_window_->GetNativeWindow(); | 195 aura::Window* content = shell_app_window_->GetNativeWindow(); |
192 AddAppWindow(content); | 196 AddAppWindow(content); |
193 content->Show(); | 197 content->Show(); |
194 | 198 |
195 return app_window_.get(); | 199 return shell_app_window_.get(); |
| 200 } |
| 201 |
| 202 AppWindow* ShellDesktopController::CreateAppWindow( |
| 203 content::BrowserContext* context, |
| 204 const Extension* extension) { |
| 205 app_window_ = new AppWindow(context, new ShellAppDelegate, extension); |
| 206 return app_window_; |
196 } | 207 } |
197 | 208 |
198 void ShellDesktopController::AddAppWindow(aura::Window* window) { | 209 void ShellDesktopController::AddAppWindow(aura::Window* window) { |
199 aura::Window* root_window = GetHost()->window(); | 210 aura::Window* root_window = GetHost()->window(); |
200 root_window->AddChild(window); | 211 root_window->AddChild(window); |
201 } | 212 } |
202 | 213 |
203 void ShellDesktopController::CloseAppWindows() { | 214 void ShellDesktopController::CloseAppWindows() { |
204 app_window_.reset(); | 215 shell_app_window_.reset(); |
| 216 if (app_window_) { |
| 217 app_window_->GetBaseWindow()->Close(); // Close() deletes |app_window_|. |
| 218 app_window_ = NULL; |
| 219 } |
205 } | 220 } |
206 | 221 |
207 aura::Window* ShellDesktopController::GetDefaultParent( | 222 aura::Window* ShellDesktopController::GetDefaultParent( |
208 aura::Window* context, | 223 aura::Window* context, |
209 aura::Window* window, | 224 aura::Window* window, |
210 const gfx::Rect& bounds) { | 225 const gfx::Rect& bounds) { |
211 return host_->window(); | 226 return host_->window(); |
212 } | 227 } |
213 | 228 |
214 #if defined(OS_CHROMEOS) | 229 #if defined(OS_CHROMEOS) |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 if (displays.empty()) | 355 if (displays.empty()) |
341 return gfx::Size(); | 356 return gfx::Size(); |
342 const ui::DisplayMode* mode = displays[0].display->current_mode(); | 357 const ui::DisplayMode* mode = displays[0].display->current_mode(); |
343 return mode ? mode->size() : gfx::Size(); | 358 return mode ? mode->size() : gfx::Size(); |
344 #else | 359 #else |
345 return gfx::Size(); | 360 return gfx::Size(); |
346 #endif | 361 #endif |
347 } | 362 } |
348 | 363 |
349 } // namespace extensions | 364 } // namespace extensions |
OLD | NEW |