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.h" | 9 #include "base/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/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/shell_browser_context.h" | 15 #include "content/shell/shell_browser_context.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "ui/views/examples/examples_window_with_content.h" | 17 #include "ui/views/examples/examples_window_with_content.h" |
18 #include "ui/views/focus/accelerator_handler.h" | 18 #include "ui/views/focus/accelerator_handler.h" |
19 #include "ui/views/test/desktop_test_views_delegate.h" | 19 #include "ui/views/test/desktop_test_views_delegate.h" |
20 | 20 |
21 #if defined(USE_AURA) | 21 #if defined(USE_AURA) |
22 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
24 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 24 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
25 #include "ui/views/widget/desktop_aura/desktop_stacking_client.h" | |
26 #include "ui/views/widget/native_widget_aura.h" | 25 #include "ui/views/widget/native_widget_aura.h" |
27 #endif | 26 #endif |
28 | 27 |
29 namespace views { | 28 namespace views { |
30 namespace examples { | 29 namespace examples { |
31 | 30 |
32 ExamplesBrowserMainParts::ExamplesBrowserMainParts( | 31 ExamplesBrowserMainParts::ExamplesBrowserMainParts( |
33 const content::MainFunctionParams& parameters) { | 32 const content::MainFunctionParams& parameters) { |
34 } | 33 } |
35 | 34 |
36 ExamplesBrowserMainParts::~ExamplesBrowserMainParts() { | 35 ExamplesBrowserMainParts::~ExamplesBrowserMainParts() { |
37 } | 36 } |
38 | 37 |
39 void ExamplesBrowserMainParts::PreMainMessageLoopRun() { | 38 void ExamplesBrowserMainParts::PreMainMessageLoopRun() { |
40 browser_context_.reset(new content::ShellBrowserContext(false)); | 39 browser_context_.reset(new content::ShellBrowserContext(false)); |
41 | 40 |
42 #if !defined(OS_CHROMEOS) && defined(USE_AURA) | 41 #if !defined(OS_CHROMEOS) && defined(USE_AURA) |
43 stacking_client_.reset(new DesktopStackingClient); | |
44 aura::client::SetStackingClient(stacking_client_.get()); | |
45 gfx::Screen::SetScreenInstance( | 42 gfx::Screen::SetScreenInstance( |
46 gfx::SCREEN_TYPE_NATIVE, CreateDesktopScreen()); | 43 gfx::SCREEN_TYPE_NATIVE, CreateDesktopScreen()); |
47 #endif | 44 #endif |
48 views_delegate_.reset(new DesktopTestViewsDelegate); | 45 views_delegate_.reset(new DesktopTestViewsDelegate); |
49 | 46 |
50 ShowExamplesWindowWithContent(QUIT_ON_CLOSE, browser_context_.get()); | 47 ShowExamplesWindowWithContent(QUIT_ON_CLOSE, browser_context_.get()); |
51 } | 48 } |
52 | 49 |
53 void ExamplesBrowserMainParts::PostMainMessageLoopRun() { | 50 void ExamplesBrowserMainParts::PostMainMessageLoopRun() { |
54 browser_context_.reset(); | 51 browser_context_.reset(); |
55 views_delegate_.reset(); | 52 views_delegate_.reset(); |
56 #if defined(USE_AURA) | 53 #if defined(USE_AURA) |
57 stacking_client_.reset(); | |
58 aura::Env::DeleteInstance(); | 54 aura::Env::DeleteInstance(); |
59 #endif | 55 #endif |
60 } | 56 } |
61 | 57 |
62 bool ExamplesBrowserMainParts::MainMessageLoopRun(int* result_code) { | 58 bool ExamplesBrowserMainParts::MainMessageLoopRun(int* result_code) { |
63 // xxx: Hax here because this kills event handling. | 59 // xxx: Hax here because this kills event handling. |
64 #if !defined(USE_AURA) | 60 #if !defined(USE_AURA) |
65 AcceleratorHandler accelerator_handler; | 61 AcceleratorHandler accelerator_handler; |
66 base::RunLoop run_loop(&accelerator_handler); | 62 base::RunLoop run_loop(&accelerator_handler); |
67 #else | 63 #else |
68 base::RunLoop run_loop; | 64 base::RunLoop run_loop; |
69 #endif | 65 #endif |
70 run_loop.Run(); | 66 run_loop.Run(); |
71 return true; | 67 return true; |
72 } | 68 } |
73 | 69 |
74 } // namespace examples | 70 } // namespace examples |
75 } // namespace views | 71 } // namespace views |
OLD | NEW |