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

Side by Side Diff: mojo/examples/aura_demo/aura_demo.cc

Issue 162213002: Change mojo demo apps to use Application. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add shell() to ServiceFactory::Owner Created 6 years, 10 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
« no previous file with comments | « no previous file | mojo/examples/compositor_app/compositor_app.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "mojo/examples/aura_demo/demo_screen.h" 11 #include "mojo/examples/aura_demo/demo_screen.h"
12 #include "mojo/examples/aura_demo/root_window_host_mojo.h" 12 #include "mojo/examples/aura_demo/root_window_host_mojo.h"
13 #include "mojo/public/bindings/allocation_scope.h" 13 #include "mojo/public/bindings/allocation_scope.h"
14 #include "mojo/public/bindings/remote_ptr.h"
15 #include "mojo/public/gles2/gles2_cpp.h" 14 #include "mojo/public/gles2/gles2_cpp.h"
15 #include "mojo/public/shell/application.h"
16 #include "mojo/public/system/core.h" 16 #include "mojo/public/system/core.h"
17 #include "mojo/public/system/macros.h" 17 #include "mojo/public/system/macros.h"
18 #include "mojom/native_viewport.h" 18 #include "mojom/native_viewport.h"
19 #include "mojom/shell.h" 19 #include "mojom/shell.h"
20 #include "ui/aura/client/default_capture_client.h" 20 #include "ui/aura/client/default_capture_client.h"
21 #include "ui/aura/client/window_tree_client.h" 21 #include "ui/aura/client/window_tree_client.h"
22 #include "ui/aura/env.h" 22 #include "ui/aura/env.h"
23 #include "ui/aura/root_window.h" 23 #include "ui/aura/root_window.h"
24 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
25 #include "ui/aura/window_delegate.h" 25 #include "ui/aura/window_delegate.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 private: 110 private:
111 aura::Window* window_; 111 aura::Window* window_;
112 112
113 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; 113 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); 115 DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient);
116 }; 116 };
117 117
118 class AuraDemo : public ShellClient { 118 class AuraDemo : public Application {
119 public: 119 public:
120 explicit AuraDemo(ScopedShellHandle shell_handle) 120 explicit AuraDemo(MojoHandle shell_handle) : Application(shell_handle) {
121 : shell_(shell_handle.Pass(), this) {
122 screen_.reset(DemoScreen::Create()); 121 screen_.reset(DemoScreen::Create());
123 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); 122 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
124 123
125 InterfacePipe<NativeViewport, AnyInterface> pipe; 124 InterfacePipe<NativeViewport, AnyInterface> pipe;
126 125
127 mojo::AllocationScope scope; 126 mojo::AllocationScope scope;
128 shell_->Connect("mojo:mojo_native_viewport_service", 127 shell()->Connect("mojo:mojo_native_viewport_service",
129 pipe.handle_to_peer.Pass()); 128 pipe.handle_to_peer.Pass());
130 root_window_host_.reset(new WindowTreeHostMojo( 129 root_window_host_.reset(new WindowTreeHostMojo(
131 pipe.handle_to_self.Pass(), 130 pipe.handle_to_self.Pass(),
132 gfx::Rect(800, 600), 131 gfx::Rect(800, 600),
133 base::Bind(&AuraDemo::HostContextCreated, base::Unretained(this)))); 132 base::Bind(&AuraDemo::HostContextCreated, base::Unretained(this))));
134 } 133 }
135 134
136 virtual void AcceptConnection(const mojo::String& url,
137 ScopedMessagePipeHandle handle) MOJO_OVERRIDE {
138 NOTREACHED() << "AuraDemo can't be connected to.";
139 }
140
141 private: 135 private:
142 void HostContextCreated() { 136 void HostContextCreated() {
143 aura::RootWindow::CreateParams params( 137 aura::RootWindow::CreateParams params(
144 gfx::Rect(root_window_host_->bounds().size())); 138 gfx::Rect(root_window_host_->bounds().size()));
145 params.host = root_window_host_.get(); 139 params.host = root_window_host_.get();
146 root_window_.reset(new aura::RootWindow(params)); 140 root_window_.reset(new aura::RootWindow(params));
147 root_window_host_->set_delegate(root_window_.get()); 141 root_window_host_->set_delegate(root_window_.get());
148 root_window_->Init(); 142 root_window_->Init();
149 143
150 window_tree_client_.reset(new DemoWindowTreeClient(root_window_->window())); 144 window_tree_client_.reset(new DemoWindowTreeClient(root_window_->window()));
(...skipping 27 matching lines...) Expand all
178 scoped_ptr<DemoWindowTreeClient> window_tree_client_; 172 scoped_ptr<DemoWindowTreeClient> window_tree_client_;
179 173
180 scoped_ptr<DemoWindowDelegate> delegate1_; 174 scoped_ptr<DemoWindowDelegate> delegate1_;
181 scoped_ptr<DemoWindowDelegate> delegate2_; 175 scoped_ptr<DemoWindowDelegate> delegate2_;
182 scoped_ptr<DemoWindowDelegate> delegate21_; 176 scoped_ptr<DemoWindowDelegate> delegate21_;
183 177
184 aura::Window* window1_; 178 aura::Window* window1_;
185 aura::Window* window2_; 179 aura::Window* window2_;
186 aura::Window* window21_; 180 aura::Window* window21_;
187 181
188 RemotePtr<Shell> shell_;
189 scoped_ptr<WindowTreeHostMojo> root_window_host_; 182 scoped_ptr<WindowTreeHostMojo> root_window_host_;
190 scoped_ptr<aura::RootWindow> root_window_; 183 scoped_ptr<aura::RootWindow> root_window_;
191 }; 184 };
192 185
193 } // namespace examples 186 } // namespace examples
194 } // namespace mojo 187 } // namespace mojo
195 188
196 extern "C" AURA_DEMO_EXPORT MojoResult CDECL MojoMain( 189 extern "C" AURA_DEMO_EXPORT MojoResult CDECL MojoMain(
197 MojoHandle shell_handle) { 190 MojoHandle shell_handle) {
198 CommandLine::Init(0, NULL); 191 CommandLine::Init(0, NULL);
199 base::AtExitManager at_exit; 192 base::AtExitManager at_exit;
200 base::MessageLoop loop; 193 base::MessageLoop loop;
201 mojo::GLES2Initializer gles2; 194 mojo::GLES2Initializer gles2;
202 195
203 // TODO(beng): This crashes in a DCHECK on X11 because this thread's 196 // TODO(beng): This crashes in a DCHECK on X11 because this thread's
204 // MessageLoop is not of TYPE_UI. I think we need a way to build 197 // MessageLoop is not of TYPE_UI. I think we need a way to build
205 // Aura that doesn't define platform-specific stuff. 198 // Aura that doesn't define platform-specific stuff.
206 aura::Env::CreateInstance(); 199 aura::Env::CreateInstance();
207 mojo::examples::AuraDemo app( 200 mojo::examples::AuraDemo app(shell_handle);
208 mojo::MakeScopedHandle(mojo::ShellHandle(shell_handle)).Pass());
209 loop.Run(); 201 loop.Run();
210 202
211 return MOJO_RESULT_OK; 203 return MOJO_RESULT_OK;
212 } 204 }
OLDNEW
« no previous file with comments | « no previous file | mojo/examples/compositor_app/compositor_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698