OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/examples/content_client/examples_browser_main_parts.h" | 5 #include "ui/views/examples/content_client/examples_browser_main_parts.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
15 #include "content/shell/browser/shell_browser_context.h" | 15 #include "content/shell/browser/shell_browser_context.h" |
| 16 #include "ui/aura/env.h" |
16 #include "ui/base/ime/input_method_initializer.h" | 17 #include "ui/base/ime/input_method_initializer.h" |
| 18 #include "ui/gfx/screen.h" |
| 19 #include "ui/views/corewm/wm_state.h" |
17 #include "ui/views/examples/examples_window_with_content.h" | 20 #include "ui/views/examples/examples_window_with_content.h" |
18 #include "ui/views/test/desktop_test_views_delegate.h" | 21 #include "ui/views/test/desktop_test_views_delegate.h" |
19 #include "url/gurl.h" | |
20 | |
21 #if defined(USE_AURA) | |
22 #include "ui/aura/env.h" | |
23 #include "ui/gfx/screen.h" | |
24 #include "ui/views/corewm/wm_state.h" | |
25 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 22 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
26 #include "ui/views/widget/native_widget_aura.h" | 23 #include "ui/views/widget/native_widget_aura.h" |
27 #endif | 24 #include "url/gurl.h" |
28 | 25 |
29 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
30 #include "ui/aura/test/test_screen.h" | 27 #include "ui/aura/test/test_screen.h" |
31 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
32 #include "ui/aura/window_event_dispatcher.h" | 29 #include "ui/aura/window_event_dispatcher.h" |
33 #include "ui/wm/test/wm_test_helper.h" | 30 #include "ui/wm/test/wm_test_helper.h" |
34 #endif | 31 #endif |
35 | 32 |
36 namespace views { | 33 namespace views { |
37 namespace examples { | 34 namespace examples { |
38 | 35 |
39 ExamplesBrowserMainParts::ExamplesBrowserMainParts( | 36 ExamplesBrowserMainParts::ExamplesBrowserMainParts( |
40 const content::MainFunctionParams& parameters) { | 37 const content::MainFunctionParams& parameters) { |
41 } | 38 } |
42 | 39 |
43 ExamplesBrowserMainParts::~ExamplesBrowserMainParts() { | 40 ExamplesBrowserMainParts::~ExamplesBrowserMainParts() { |
44 } | 41 } |
45 | 42 |
46 void ExamplesBrowserMainParts::ToolkitInitialized() { | 43 void ExamplesBrowserMainParts::ToolkitInitialized() { |
47 #if defined(USE_AURA) | |
48 wm_state_.reset(new views::corewm::WMState); | 44 wm_state_.reset(new views::corewm::WMState); |
49 #endif | |
50 } | 45 } |
51 | 46 |
52 void ExamplesBrowserMainParts::PreMainMessageLoopRun() { | 47 void ExamplesBrowserMainParts::PreMainMessageLoopRun() { |
53 ui::InitializeInputMethodForTesting(); | 48 ui::InitializeInputMethodForTesting(); |
54 browser_context_.reset(new content::ShellBrowserContext(false, NULL)); | 49 browser_context_.reset(new content::ShellBrowserContext(false, NULL)); |
55 | 50 |
56 gfx::NativeView window_context = NULL; | 51 gfx::NativeView window_context = NULL; |
57 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
58 gfx::Screen::SetScreenInstance( | 53 gfx::Screen::SetScreenInstance( |
59 gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); | 54 gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create()); |
60 // Set up basic pieces of views::corewm. | 55 // Set up basic pieces of views::corewm. |
61 wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600))); | 56 wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600))); |
62 // Ensure the X window gets mapped. | 57 // Ensure the X window gets mapped. |
63 wm_test_helper_->host()->Show(); | 58 wm_test_helper_->host()->Show(); |
64 // Ensure Aura knows where to open new windows. | 59 // Ensure Aura knows where to open new windows. |
65 window_context = wm_test_helper_->host()->window(); | 60 window_context = wm_test_helper_->host()->window(); |
66 #elif defined(USE_AURA) | 61 #else |
67 aura::Env::CreateInstance(); | 62 aura::Env::CreateInstance(); |
68 gfx::Screen::SetScreenInstance( | 63 gfx::Screen::SetScreenInstance( |
69 gfx::SCREEN_TYPE_NATIVE, CreateDesktopScreen()); | 64 gfx::SCREEN_TYPE_NATIVE, CreateDesktopScreen()); |
70 #endif | 65 #endif |
71 views_delegate_.reset(new DesktopTestViewsDelegate); | 66 views_delegate_.reset(new DesktopTestViewsDelegate); |
72 | 67 |
73 ShowExamplesWindowWithContent( | 68 ShowExamplesWindowWithContent( |
74 QUIT_ON_CLOSE, browser_context_.get(), window_context); | 69 QUIT_ON_CLOSE, browser_context_.get(), window_context); |
75 } | 70 } |
76 | 71 |
77 void ExamplesBrowserMainParts::PostMainMessageLoopRun() { | 72 void ExamplesBrowserMainParts::PostMainMessageLoopRun() { |
78 browser_context_.reset(); | 73 browser_context_.reset(); |
79 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
80 wm_test_helper_.reset(); | 75 wm_test_helper_.reset(); |
81 #endif | 76 #endif |
82 views_delegate_.reset(); | 77 views_delegate_.reset(); |
83 #if defined(USE_AURA) | |
84 aura::Env::DeleteInstance(); | 78 aura::Env::DeleteInstance(); |
85 #endif | |
86 } | 79 } |
87 | 80 |
88 bool ExamplesBrowserMainParts::MainMessageLoopRun(int* result_code) { | 81 bool ExamplesBrowserMainParts::MainMessageLoopRun(int* result_code) { |
89 base::RunLoop run_loop; | 82 base::RunLoop run_loop; |
90 run_loop.Run(); | 83 run_loop.Run(); |
91 return true; | 84 return true; |
92 } | 85 } |
93 | 86 |
94 } // namespace examples | 87 } // namespace examples |
95 } // namespace views | 88 } // namespace views |
OLD | NEW |