| 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 "content/public/browser/context_factory.h" | 5 #include "content/public/browser/context_factory.h" |
| 6 #include "content/shell/browser/shell_browser_context.h" | 6 #include "content/shell/browser/shell_browser_context.h" |
| 7 #include "ui/aura/test/test_screen.h" | 7 #include "ui/aura/test/test_screen.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/gfx/screen.h" | 9 #include "ui/gfx/screen.h" |
| 10 #include "ui/views_content_client/views_content_client.h" | 10 #include "ui/views_content_client/views_content_client.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 const content::MainFunctionParams& content_params, | 40 const content::MainFunctionParams& content_params, |
| 41 ViewsContentClient* views_content_client); | 41 ViewsContentClient* views_content_client); |
| 42 virtual ~ViewsContentClientMainPartsChromeOS() {} | 42 virtual ~ViewsContentClientMainPartsChromeOS() {} |
| 43 | 43 |
| 44 // content::BrowserMainParts: | 44 // content::BrowserMainParts: |
| 45 virtual void PreMainMessageLoopRun() OVERRIDE; | 45 virtual void PreMainMessageLoopRun() OVERRIDE; |
| 46 virtual void PostMainMessageLoopRun() OVERRIDE; | 46 virtual void PostMainMessageLoopRun() OVERRIDE; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // Enable a minimal set of views::corewm to be initialized. | 49 // Enable a minimal set of views::corewm to be initialized. |
| 50 scoped_ptr<gfx::Screen> test_screen_; |
| 50 scoped_ptr< ::wm::WMTestHelper> wm_test_helper_; | 51 scoped_ptr< ::wm::WMTestHelper> wm_test_helper_; |
| 51 scoped_ptr< ::wm::NestedAcceleratorController> nested_accelerator_controller_; | 52 scoped_ptr< ::wm::NestedAcceleratorController> nested_accelerator_controller_; |
| 52 | 53 |
| 53 DISALLOW_COPY_AND_ASSIGN(ViewsContentClientMainPartsChromeOS); | 54 DISALLOW_COPY_AND_ASSIGN(ViewsContentClientMainPartsChromeOS); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 ViewsContentClientMainPartsChromeOS::ViewsContentClientMainPartsChromeOS( | 57 ViewsContentClientMainPartsChromeOS::ViewsContentClientMainPartsChromeOS( |
| 57 const content::MainFunctionParams& content_params, | 58 const content::MainFunctionParams& content_params, |
| 58 ViewsContentClient* views_content_client) | 59 ViewsContentClient* views_content_client) |
| 59 : ViewsContentClientMainPartsAura(content_params, views_content_client) { | 60 : ViewsContentClientMainPartsAura(content_params, views_content_client) { |
| 60 } | 61 } |
| 61 | 62 |
| 62 void ViewsContentClientMainPartsChromeOS::PreMainMessageLoopRun() { | 63 void ViewsContentClientMainPartsChromeOS::PreMainMessageLoopRun() { |
| 63 ViewsContentClientMainPartsAura::PreMainMessageLoopRun(); | 64 ViewsContentClientMainPartsAura::PreMainMessageLoopRun(); |
| 64 | 65 |
| 65 gfx::Size host_size(800, 600); | 66 gfx::Size host_size(800, 600); |
| 66 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | 67 test_screen_.reset(aura::TestScreen::Create(host_size)); |
| 67 aura::TestScreen::Create(host_size)); | 68 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
| 68 // Set up basic pieces of views::corewm. | 69 // Set up basic pieces of views::corewm. |
| 69 wm_test_helper_.reset( | 70 wm_test_helper_.reset( |
| 70 new ::wm::WMTestHelper(host_size, content::GetContextFactory())); | 71 new ::wm::WMTestHelper(host_size, content::GetContextFactory())); |
| 71 // Ensure the X window gets mapped. | 72 // Ensure the X window gets mapped. |
| 72 wm_test_helper_->host()->Show(); | 73 wm_test_helper_->host()->Show(); |
| 73 | 74 |
| 74 // Ensure Aura knows where to open new windows. | 75 // Ensure Aura knows where to open new windows. |
| 75 aura::Window* root_window = wm_test_helper_->host()->window(); | 76 aura::Window* root_window = wm_test_helper_->host()->window(); |
| 76 views_content_client()->task().Run(browser_context(), root_window); | 77 views_content_client()->task().Run(browser_context(), root_window); |
| 77 | 78 |
| 78 nested_accelerator_controller_.reset( | 79 nested_accelerator_controller_.reset( |
| 79 new ::wm::NestedAcceleratorController(new NestedAcceleratorDelegate)); | 80 new ::wm::NestedAcceleratorController(new NestedAcceleratorDelegate)); |
| 80 aura::client::SetDispatcherClient(root_window, | 81 aura::client::SetDispatcherClient(root_window, |
| 81 nested_accelerator_controller_.get()); | 82 nested_accelerator_controller_.get()); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void ViewsContentClientMainPartsChromeOS::PostMainMessageLoopRun() { | 85 void ViewsContentClientMainPartsChromeOS::PostMainMessageLoopRun() { |
| 85 aura::client::SetDispatcherClient(wm_test_helper_->host()->window(), NULL); | 86 aura::client::SetDispatcherClient(wm_test_helper_->host()->window(), NULL); |
| 86 nested_accelerator_controller_.reset(); | 87 nested_accelerator_controller_.reset(); |
| 87 wm_test_helper_.reset(); | 88 wm_test_helper_.reset(); |
| 89 test_screen_.reset(); |
| 88 | 90 |
| 89 ViewsContentClientMainPartsAura::PostMainMessageLoopRun(); | 91 ViewsContentClientMainPartsAura::PostMainMessageLoopRun(); |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace | 94 } // namespace |
| 93 | 95 |
| 94 // static | 96 // static |
| 95 ViewsContentClientMainParts* ViewsContentClientMainParts::Create( | 97 ViewsContentClientMainParts* ViewsContentClientMainParts::Create( |
| 96 const content::MainFunctionParams& content_params, | 98 const content::MainFunctionParams& content_params, |
| 97 ViewsContentClient* views_content_client) { | 99 ViewsContentClient* views_content_client) { |
| 98 return new ViewsContentClientMainPartsChromeOS( | 100 return new ViewsContentClientMainPartsChromeOS( |
| 99 content_params, views_content_client); | 101 content_params, views_content_client); |
| 100 } | 102 } |
| 101 | 103 |
| 102 } // namespace ui | 104 } // namespace ui |
| OLD | NEW |