| 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 "apps/shell/browser/shell_desktop_controller.h" | 5 #include "apps/shell/browser/shell_desktop_controller.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkColor.h" | 7 #include "third_party/skia/include/core/SkColor.h" |
| 8 #include "ui/aura/env.h" | 8 #include "ui/aura/env.h" |
| 9 #include "ui/aura/test/test_screen.h" | 9 #include "ui/aura/test/test_screen.h" |
| 10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 private: | 43 private: |
| 44 aura::Window* root_window_; // Not owned. | 44 aura::Window* root_window_; // Not owned. |
| 45 | 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate); | 46 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 ShellDesktopController::ShellDesktopController() { | 51 ShellDesktopController::ShellDesktopController() { |
| 52 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
| 53 output_configurator_.reset(new ui::OutputConfigurator); | 53 display_configurator_.reset(new ui::DisplayConfigurator); |
| 54 output_configurator_->Init(false); | 54 display_configurator_->Init(false); |
| 55 output_configurator_->ForceInitialConfigure(0); | 55 display_configurator_->ForceInitialConfigure(0); |
| 56 output_configurator_->AddObserver(this); | 56 display_configurator_->AddObserver(this); |
| 57 #endif | 57 #endif |
| 58 CreateRootWindow(); | 58 CreateRootWindow(); |
| 59 | 59 |
| 60 DCHECK(!views::ViewsDelegate::views_delegate); | 60 DCHECK(!views::ViewsDelegate::views_delegate); |
| 61 views::ViewsDelegate::views_delegate = | 61 views::ViewsDelegate::views_delegate = |
| 62 new ShellViewsDelegate(wm_test_helper_->host()->window()); | 62 new ShellViewsDelegate(wm_test_helper_->host()->window()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 ShellDesktopController::~ShellDesktopController() { | 65 ShellDesktopController::~ShellDesktopController() { |
| 66 delete views::ViewsDelegate::views_delegate; | 66 delete views::ViewsDelegate::views_delegate; |
| 67 views::ViewsDelegate::views_delegate = NULL; | 67 views::ViewsDelegate::views_delegate = NULL; |
| 68 DestroyRootWindow(); | 68 DestroyRootWindow(); |
| 69 aura::Env::DeleteInstance(); | 69 aura::Env::DeleteInstance(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 aura::WindowTreeHost* ShellDesktopController::GetWindowTreeHost() { | 72 aura::WindowTreeHost* ShellDesktopController::GetWindowTreeHost() { |
| 73 return wm_test_helper_->host(); | 73 return wm_test_helper_->host(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
| 77 void ShellDesktopController::OnDisplayModeChanged( | 77 void ShellDesktopController::OnDisplayModeChanged( |
| 78 const std::vector<ui::OutputConfigurator::DisplayState>& outputs) { | 78 const std::vector<ui::DisplayConfigurator::DisplayState>& outputs) { |
| 79 gfx::Size size = GetPrimaryDisplaySize(); | 79 gfx::Size size = GetPrimaryDisplaySize(); |
| 80 if (!size.IsEmpty()) | 80 if (!size.IsEmpty()) |
| 81 wm_test_helper_->host()->UpdateRootWindowSize(size); | 81 wm_test_helper_->host()->UpdateRootWindowSize(size); |
| 82 } | 82 } |
| 83 #endif | 83 #endif |
| 84 | 84 |
| 85 void ShellDesktopController::CreateRootWindow() { | 85 void ShellDesktopController::CreateRootWindow() { |
| 86 test_screen_.reset(aura::TestScreen::Create()); | 86 test_screen_.reset(aura::TestScreen::Create()); |
| 87 // TODO(jamescook): Replace this with a real Screen implementation. | 87 // TODO(jamescook): Replace this with a real Screen implementation. |
| 88 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 88 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 100 wm_test_helper_->host()->Show(); | 100 wm_test_helper_->host()->Show(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void ShellDesktopController::DestroyRootWindow() { | 103 void ShellDesktopController::DestroyRootWindow() { |
| 104 wm_test_helper_.reset(); | 104 wm_test_helper_.reset(); |
| 105 ui::ShutdownInputMethodForTesting(); | 105 ui::ShutdownInputMethodForTesting(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 gfx::Size ShellDesktopController::GetPrimaryDisplaySize() { | 108 gfx::Size ShellDesktopController::GetPrimaryDisplaySize() { |
| 109 #if defined(OS_CHROMEOS) | 109 #if defined(OS_CHROMEOS) |
| 110 const std::vector<ui::OutputConfigurator::DisplayState>& states = | 110 const std::vector<ui::DisplayConfigurator::DisplayState>& states = |
| 111 output_configurator_->cached_outputs(); | 111 display_configurator_->cached_outputs(); |
| 112 if (states.empty()) | 112 if (states.empty()) |
| 113 return gfx::Size(); | 113 return gfx::Size(); |
| 114 const ui::DisplayMode* mode = states[0].display->current_mode(); | 114 const ui::DisplayMode* mode = states[0].display->current_mode(); |
| 115 return mode ? mode->size() : gfx::Size(); | 115 return mode ? mode->size() : gfx::Size(); |
| 116 #else | 116 #else |
| 117 return gfx::Size(); | 117 return gfx::Size(); |
| 118 #endif | 118 #endif |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace apps | 121 } // namespace apps |
| OLD | NEW |