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