Chromium Code Reviews| Index: extensions/shell/browser/shell_desktop_controller.cc |
| diff --git a/extensions/shell/browser/shell_desktop_controller.cc b/extensions/shell/browser/shell_desktop_controller.cc |
| index 6ab9bac6fbd616379c6786efd72ccfe62f5e99a4..f61bbc6e46393f6ba382d39b32ad406985da8f11 100644 |
| --- a/extensions/shell/browser/shell_desktop_controller.cc |
| +++ b/extensions/shell/browser/shell_desktop_controller.cc |
| @@ -5,7 +5,7 @@ |
| #include "extensions/shell/browser/shell_desktop_controller.h" |
| #include "base/command_line.h" |
| -#include "extensions/shell/browser/shell_app_window_controller.h" |
| +#include "extensions/shell/browser/shell_app_window.h" |
| #include "extensions/shell/common/switches.h" |
| #include "ui/aura/client/cursor_client.h" |
| #include "ui/aura/client/default_capture_client.h" |
| @@ -151,13 +151,9 @@ class AppsFocusRules : public wm::BaseFocusRules { |
| DISALLOW_COPY_AND_ASSIGN(AppsFocusRules); |
| }; |
| -ShellDesktopController* g_instance = NULL; |
| - |
| } // namespace |
| ShellDesktopController::ShellDesktopController() { |
| - CHECK(!g_instance) << "ShellDesktopController already exists"; |
| - |
| #if defined(OS_CHROMEOS) |
| chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| AddObserver(this); |
| @@ -168,13 +164,9 @@ ShellDesktopController::ShellDesktopController() { |
| #endif |
| CreateRootWindow(); |
| - |
| - g_instance = this; |
| } |
| ShellDesktopController::~ShellDesktopController() { |
| - app_window_controller_.reset(); |
| - g_instance = NULL; |
| DestroyRootWindow(); |
|
James Cook
2014/08/25 16:56:14
I think you should either app_window_.reset() befo
oshima
2014/08/25 17:29:32
Done.
|
| #if defined(OS_CHROMEOS) |
| chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| @@ -182,30 +174,28 @@ ShellDesktopController::~ShellDesktopController() { |
| #endif |
| } |
| -// static |
| -ShellDesktopController* ShellDesktopController::instance() { |
| - return g_instance; |
| -} |
| - |
| -void ShellDesktopController::SetAppWindowController( |
| - ShellAppWindowController* app_window_controller) { |
| - app_window_controller_.reset(app_window_controller); |
| +aura::WindowTreeHost* ShellDesktopController::GetHost() { |
| + return host_.get(); |
| } |
| ShellAppWindow* ShellDesktopController::CreateAppWindow( |
| content::BrowserContext* context, |
| const Extension* extension) { |
| - return app_window_controller_->CreateAppWindow(context, extension); |
| -} |
| + aura::Window* root_window = GetHost()->window(); |
| -void ShellDesktopController::CloseAppWindows() { |
| - if (app_window_controller_) |
| - app_window_controller_->CloseAppWindows(); |
| + app_window_.reset(new ShellAppWindow); |
| + app_window_->Init(context, extension, root_window->bounds().size()); |
| + |
| + // Attach the web contents view to our window hierarchy. |
| + aura::Window* content = app_window_->GetNativeWindow(); |
| + root_window->AddChild(content); |
| + content->Show(); |
| + |
| + return app_window_.get(); |
| } |
| -void ShellDesktopController::SetDisplayWorkAreaInsets( |
| - const gfx::Insets& insets) { |
| - test_screen_->SetWorkAreaInsets(insets); |
| +void ShellDesktopController::CloseAppWindows() { |
| + app_window_.reset(); |
| } |
| aura::Window* ShellDesktopController::GetDefaultParent( |
| @@ -243,7 +233,7 @@ void ShellDesktopController::OnHostCloseRequested( |
| void ShellDesktopController::InitWindowManager() { |
| wm::FocusController* focus_controller = |
| - new wm::FocusController(CreateFocusRules()); |
| + new wm::FocusController(new AppsFocusRules()); |
| aura::client::SetFocusClient(host_->window(), focus_controller); |
| host_->window()->AddPreTargetHandler(focus_controller); |
| aura::client::SetActivationClient(host_->window(), focus_controller); |
| @@ -277,10 +267,6 @@ void ShellDesktopController::InitWindowManager() { |
| #endif |
| } |
| -wm::FocusRules* ShellDesktopController::CreateFocusRules() { |
| - return new AppsFocusRules(); |
| -} |
| - |
| void ShellDesktopController::CreateRootWindow() { |
| // Set up basic pieces of ui::wm. |
| gfx::Size size; |