| 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 <string> |
| 8 #include <vector> |
| 9 |
| 7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 8 #include "extensions/browser/app_window/app_window.h" | 11 #include "extensions/browser/app_window/app_window.h" |
| 9 #include "extensions/browser/app_window/native_app_window.h" | 12 #include "extensions/browser/app_window/native_app_window.h" |
| 10 #include "extensions/shell/browser/shell_app_delegate.h" | 13 #include "extensions/shell/browser/shell_app_delegate.h" |
| 11 #include "extensions/shell/browser/shell_app_window.h" | |
| 12 #include "extensions/shell/common/switches.h" | 14 #include "extensions/shell/common/switches.h" |
| 13 #include "ui/aura/client/cursor_client.h" | 15 #include "ui/aura/client/cursor_client.h" |
| 14 #include "ui/aura/client/default_capture_client.h" | 16 #include "ui/aura/client/default_capture_client.h" |
| 15 #include "ui/aura/layout_manager.h" | 17 #include "ui/aura/layout_manager.h" |
| 16 #include "ui/aura/test/test_screen.h" | 18 #include "ui/aura/test/test_screen.h" |
| 17 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 18 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
| 19 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
| 20 #include "ui/base/cursor/cursor.h" | 22 #include "ui/base/cursor/cursor.h" |
| 21 #include "ui/base/cursor/image_cursors.h" | 23 #include "ui/base/cursor/image_cursors.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 #if defined(OS_CHROMEOS) | 178 #if defined(OS_CHROMEOS) |
| 177 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 179 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 178 RemoveObserver(this); | 180 RemoveObserver(this); |
| 179 #endif | 181 #endif |
| 180 } | 182 } |
| 181 | 183 |
| 182 aura::WindowTreeHost* ShellDesktopController::GetHost() { | 184 aura::WindowTreeHost* ShellDesktopController::GetHost() { |
| 183 return host_.get(); | 185 return host_.get(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 ShellAppWindow* ShellDesktopController::CreateShellAppWindow( | |
| 187 content::BrowserContext* context, | |
| 188 const Extension* extension) { | |
| 189 aura::Window* root_window = GetHost()->window(); | |
| 190 | |
| 191 shell_app_window_.reset(new ShellAppWindow); | |
| 192 shell_app_window_->Init(context, extension, root_window->bounds().size()); | |
| 193 | |
| 194 // Attach the web contents view to our window hierarchy. | |
| 195 aura::Window* content = shell_app_window_->GetNativeWindow(); | |
| 196 AddAppWindow(content); | |
| 197 content->Show(); | |
| 198 | |
| 199 return shell_app_window_.get(); | |
| 200 } | |
| 201 | |
| 202 AppWindow* ShellDesktopController::CreateAppWindow( | 188 AppWindow* ShellDesktopController::CreateAppWindow( |
| 203 content::BrowserContext* context, | 189 content::BrowserContext* context, |
| 204 const Extension* extension) { | 190 const Extension* extension) { |
| 205 app_window_ = new AppWindow(context, new ShellAppDelegate, extension); | 191 app_window_ = new AppWindow(context, new ShellAppDelegate, extension); |
| 206 return app_window_; | 192 return app_window_; |
| 207 } | 193 } |
| 208 | 194 |
| 209 void ShellDesktopController::AddAppWindow(aura::Window* window) { | 195 void ShellDesktopController::AddAppWindow(aura::Window* window) { |
| 210 aura::Window* root_window = GetHost()->window(); | 196 aura::Window* root_window = GetHost()->window(); |
| 211 root_window->AddChild(window); | 197 root_window->AddChild(window); |
| 212 } | 198 } |
| 213 | 199 |
| 214 void ShellDesktopController::CloseAppWindows() { | 200 void ShellDesktopController::CloseAppWindows() { |
| 215 shell_app_window_.reset(); | |
| 216 if (app_window_) { | 201 if (app_window_) { |
| 217 app_window_->GetBaseWindow()->Close(); // Close() deletes |app_window_|. | 202 app_window_->GetBaseWindow()->Close(); // Close() deletes |app_window_|. |
| 218 app_window_ = NULL; | 203 app_window_ = NULL; |
| 219 } | 204 } |
| 220 } | 205 } |
| 221 | 206 |
| 222 aura::Window* ShellDesktopController::GetDefaultParent( | 207 aura::Window* ShellDesktopController::GetDefaultParent( |
| 223 aura::Window* context, | 208 aura::Window* context, |
| 224 aura::Window* window, | 209 aura::Window* window, |
| 225 const gfx::Rect& bounds) { | 210 const gfx::Rect& bounds) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 if (displays.empty()) | 340 if (displays.empty()) |
| 356 return gfx::Size(); | 341 return gfx::Size(); |
| 357 const ui::DisplayMode* mode = displays[0].display->current_mode(); | 342 const ui::DisplayMode* mode = displays[0].display->current_mode(); |
| 358 return mode ? mode->size() : gfx::Size(); | 343 return mode ? mode->size() : gfx::Size(); |
| 359 #else | 344 #else |
| 360 return gfx::Size(); | 345 return gfx::Size(); |
| 361 #endif | 346 #endif |
| 362 } | 347 } |
| 363 | 348 |
| 364 } // namespace extensions | 349 } // namespace extensions |
| OLD | NEW |