| 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" |
| 11 #include "ui/base/ime/input_method_initializer.h" | 11 #include "ui/base/ime/input_method_initializer.h" |
| 12 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
| 13 #include "ui/views/test/test_views_delegate.h" | 13 #include "ui/views/test/test_views_delegate.h" |
| 14 #include "ui/views/views_delegate.h" | 14 #include "ui/views/views_delegate.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 #include "ui/wm/test/wm_test_helper.h" | 16 #include "ui/wm/test/wm_test_helper.h" |
| 17 | 17 |
| 18 #if defined(OS_CHROMEOS) && defined(USE_X11) | 18 #if defined(OS_CHROMEOS) |
| 19 #include "ui/display/chromeos/display_mode.h" | 19 #include "ui/display/chromeos/display_mode.h" |
| 20 #include "ui/display/chromeos/display_snapshot.h" | 20 #include "ui/display/chromeos/display_snapshot.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace apps { | 23 namespace apps { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const SkColor kBackgroundColor = SK_ColorBLACK; | 26 const SkColor kBackgroundColor = SK_ColorBLACK; |
| 27 | 27 |
| 28 // A ViewsDelegate to attach new unparented windows to app_shell's root window. | 28 // A ViewsDelegate to attach new unparented windows to app_shell's root window. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 | 42 |
| 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) && defined(USE_X11) | 52 #if defined(OS_CHROMEOS) |
| 53 output_configurator_.reset(new ui::OutputConfigurator); | 53 output_configurator_.reset(new ui::OutputConfigurator); |
| 54 output_configurator_->Init(false); | 54 output_configurator_->Init(false); |
| 55 output_configurator_->ForceInitialConfigure(0); | 55 output_configurator_->ForceInitialConfigure(0); |
| 56 output_configurator_->AddObserver(this); | 56 output_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) && defined(USE_X11) | 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::OutputConfigurator::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()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 99 // Ensure the X window gets mapped. | 99 // Ensure the X window gets mapped. |
| 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) && defined(USE_X11) | 109 #if defined(OS_CHROMEOS) |
| 110 const std::vector<ui::OutputConfigurator::DisplayState>& states = | 110 const std::vector<ui::OutputConfigurator::DisplayState>& states = |
| 111 output_configurator_->cached_outputs(); | 111 output_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 |