Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: ui/views/examples/content_client/examples_browser_main_parts.cc

Issue 10081022: Aura/ash split: Remove hacks and get chrome linking without ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move the check to ash/. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/shell/shell.h" 14 #include "content/shell/shell.h"
15 #include "content/shell/shell_browser_context.h" 15 #include "content/shell/shell_browser_context.h"
16 #include "content/shell/shell_devtools_delegate.h" 16 #include "content/shell/shell_devtools_delegate.h"
17 #include "content/shell/shell_switches.h" 17 #include "content/shell/shell_switches.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 #include "net/base/net_module.h" 19 #include "net/base/net_module.h"
20 #include "ui/base/clipboard/clipboard.h" 20 #include "ui/base/clipboard/clipboard.h"
21 #include "ui/views/examples/examples_window.h" 21 #include "ui/views/examples/examples_window.h"
22 #include "ui/views/test/test_views_delegate.h" 22 #include "ui/views/test/test_views_delegate.h"
23 #include "ui/views/focus/accelerator_handler.h" 23 #include "ui/views/focus/accelerator_handler.h"
24 24
25 #if defined(USE_AURA) 25 #if defined(USE_AURA)
26 #include "ui/aura/client/stacking_client.h" 26 #include "ui/aura/desktop/desktop_stacking_client.h"
27 #include "ui/aura/env.h" 27 #include "ui/aura/env.h"
28 #include "ui/aura/root_window.h"
29 #include "ui/aura/window.h"
30 #include "ui/gfx/compositor/compositor.h"
31 #include "ui/gfx/compositor/test/compositor_test_support.h"
32 #include "ui/views/widget/native_widget_aura.h" 28 #include "ui/views/widget/native_widget_aura.h"
33 #endif 29 #endif
34 30
35 namespace views { 31 namespace views {
36 namespace examples { 32 namespace examples {
37 namespace {
38 #if defined(USE_AURA)
39 class RootWindowStackingClient : public aura::client::StackingClient {
40 public:
41 explicit RootWindowStackingClient() {
42 aura::client::SetStackingClient(this);
43 }
44
45 virtual ~RootWindowStackingClient() {
46 aura::client::SetStackingClient(NULL);
47 }
48
49 // Overridden from aura::client::StackingClient:
50 virtual aura::Window* GetDefaultParent(aura::Window* window) OVERRIDE {
51 return window->GetRootWindow();
52 }
53
54 private:
55 DISALLOW_COPY_AND_ASSIGN(RootWindowStackingClient);
56 };
57 #endif
58 }
59 33
60 ExamplesBrowserMainParts::ExamplesBrowserMainParts( 34 ExamplesBrowserMainParts::ExamplesBrowserMainParts(
61 const content::MainFunctionParams& parameters) 35 const content::MainFunctionParams& parameters)
62 : BrowserMainParts(), 36 : BrowserMainParts(),
63 devtools_delegate_(NULL) { 37 devtools_delegate_(NULL) {
64 } 38 }
65 39
66 ExamplesBrowserMainParts::~ExamplesBrowserMainParts() { 40 ExamplesBrowserMainParts::~ExamplesBrowserMainParts() {
67 } 41 }
68 42
69 #if !defined(OS_MACOSX) 43 #if !defined(OS_MACOSX)
70 void ExamplesBrowserMainParts::PreMainMessageLoopStart() { 44 void ExamplesBrowserMainParts::PreMainMessageLoopStart() {
71 } 45 }
72 #endif 46 #endif
73 47
74 int ExamplesBrowserMainParts::PreCreateThreads() { 48 int ExamplesBrowserMainParts::PreCreateThreads() {
75 return 0; 49 return 0;
76 } 50 }
77 51
78 void ExamplesBrowserMainParts::PreMainMessageLoopRun() { 52 void ExamplesBrowserMainParts::PreMainMessageLoopRun() {
79 browser_context_.reset(new content::ShellBrowserContext); 53 browser_context_.reset(new content::ShellBrowserContext);
80 54
81 #if defined(USE_AURA) 55 #if defined(USE_AURA)
82 // TURN ON THE HAX. 56 stacking_client_.reset(new aura::DesktopStackingClient);
83 views::NativeWidgetAura::set_aura_desktop_hax();
84 ui::CompositorTestSupport::Initialize();
85 root_window_stacking_client_.reset(new RootWindowStackingClient);
86 #endif 57 #endif
87 views_delegate_.reset(new views::TestViewsDelegate); 58 views_delegate_.reset(new views::TestViewsDelegate);
88 59
89 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE, 60 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE,
90 browser_context_.get()); 61 browser_context_.get());
91 } 62 }
92 63
93 void ExamplesBrowserMainParts::PostMainMessageLoopRun() { 64 void ExamplesBrowserMainParts::PostMainMessageLoopRun() {
94 if (devtools_delegate_) 65 if (devtools_delegate_)
95 devtools_delegate_->Stop(); 66 devtools_delegate_->Stop();
96 browser_context_.reset(); 67 browser_context_.reset();
97 views_delegate_.reset(); 68 views_delegate_.reset();
98 #if defined(USE_AURA) 69 #if defined(USE_AURA)
99 root_window_stacking_client_.reset(); 70 stacking_client_.reset();
100 aura::Env::DeleteInstance(); 71 aura::Env::DeleteInstance();
101 ui::CompositorTestSupport::Terminate();
102 #endif 72 #endif
103 } 73 }
104 74
105 bool ExamplesBrowserMainParts::MainMessageLoopRun(int* result_code) { 75 bool ExamplesBrowserMainParts::MainMessageLoopRun(int* result_code) {
106 // xxx: Hax here because this kills event handling. 76 // xxx: Hax here because this kills event handling.
107 #if !defined(USE_AURA) 77 #if !defined(USE_AURA)
108 views::AcceleratorHandler accelerator_handler; 78 views::AcceleratorHandler accelerator_handler;
109 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); 79 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler);
110 #else 80 #else
111 MessageLoopForUI::current()->Run(); 81 MessageLoopForUI::current()->Run();
112 #endif 82 #endif
113 return true; 83 return true;
114 } 84 }
115 85
116 ui::Clipboard* ExamplesBrowserMainParts::GetClipboard() { 86 ui::Clipboard* ExamplesBrowserMainParts::GetClipboard() {
117 if (!clipboard_.get()) 87 if (!clipboard_.get())
118 clipboard_.reset(new ui::Clipboard()); 88 clipboard_.reset(new ui::Clipboard());
119 return clipboard_.get(); 89 return clipboard_.get();
120 } 90 }
121 91
122 } // namespace examples 92 } // namespace examples
123 } // namespace views 93 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/content_client/examples_browser_main_parts.h ('k') | ui/views/test/test_views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698