| OLD | NEW |
| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/i18n/icu_util.h" | 11 #include "base/i18n/icu_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "mojo/examples/aura_demo/demo_screen.h" | 14 #include "mojo/examples/aura_demo/demo_screen.h" |
| 15 #include "mojo/examples/aura_demo/root_window_host_mojo.h" | 15 #include "mojo/examples/aura_demo/root_window_host_mojo.h" |
| 16 #include "mojo/public/bindings/allocation_scope.h" | 16 #include "mojo/public/bindings/allocation_scope.h" |
| 17 #include "mojo/public/bindings/remote_ptr.h" | 17 #include "mojo/public/bindings/remote_ptr.h" |
| 18 #include "mojo/public/gles2/gles2_cpp.h" | 18 #include "mojo/public/gles2/gles2_cpp.h" |
| 19 #include "mojo/public/shell/application.h" |
| 19 #include "mojo/public/system/core.h" | 20 #include "mojo/public/system/core.h" |
| 20 #include "mojo/public/system/macros.h" | 21 #include "mojo/public/system/macros.h" |
| 21 #include "mojom/launcher.h" | 22 #include "mojom/launcher.h" |
| 22 #include "mojom/native_viewport.h" | 23 #include "mojom/native_viewport.h" |
| 23 #include "mojom/shell.h" | 24 #include "mojom/shell.h" |
| 24 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
| 25 #include "ui/aura/client/default_activation_client.h" | 26 #include "ui/aura/client/default_activation_client.h" |
| 26 #include "ui/aura/client/default_capture_client.h" | 27 #include "ui/aura/client/default_capture_client.h" |
| 27 #include "ui/aura/client/window_tree_client.h" | 28 #include "ui/aura/client/window_tree_client.h" |
| 28 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 url_receiver_->OnURLEntered(url.spec()); | 181 url_receiver_->OnURLEntered(url.spec()); |
| 181 } | 182 } |
| 182 return false; | 183 return false; |
| 183 } | 184 } |
| 184 | 185 |
| 185 URLReceiver* url_receiver_; | 186 URLReceiver* url_receiver_; |
| 186 | 187 |
| 187 DISALLOW_COPY_AND_ASSIGN(LauncherController); | 188 DISALLOW_COPY_AND_ASSIGN(LauncherController); |
| 188 }; | 189 }; |
| 189 | 190 |
| 190 class LauncherImpl : public ShellClient, | 191 class LauncherImpl : public Application, |
| 191 public Launcher, | 192 public Launcher, |
| 192 public URLReceiver { | 193 public URLReceiver { |
| 193 public: | 194 public: |
| 194 explicit LauncherImpl(ScopedShellHandle shell_handle) | 195 explicit LauncherImpl(MojoHandle shell_handle) |
| 195 : launcher_controller_(this), | 196 : Application(shell_handle), |
| 196 shell_(shell_handle.Pass(), this), | 197 launcher_controller_(this), |
| 197 pending_show_(false) { | 198 pending_show_(false) { |
| 198 screen_.reset(DemoScreen::Create()); | 199 screen_.reset(DemoScreen::Create()); |
| 199 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 200 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
| 200 | 201 |
| 201 InterfacePipe<NativeViewport, AnyInterface> pipe; | 202 InterfacePipe<NativeViewport, AnyInterface> pipe; |
| 202 | 203 |
| 203 AllocationScope scope; | 204 AllocationScope scope; |
| 204 shell_->Connect("mojo:mojo_native_viewport_service", | 205 shell()->Connect("mojo:mojo_native_viewport_service", |
| 205 pipe.handle_to_peer.Pass()); | 206 pipe.handle_to_peer.Pass()); |
| 206 | 207 |
| 207 root_window_host_.reset(new WindowTreeHostMojo( | 208 root_window_host_.reset(new WindowTreeHostMojo( |
| 208 pipe.handle_to_self.Pass(), gfx::Rect(50, 50, 450, 60), | 209 pipe.handle_to_self.Pass(), gfx::Rect(50, 50, 450, 60), |
| 209 base::Bind(&LauncherImpl::HostContextCreated, base::Unretained(this)))); | 210 base::Bind(&LauncherImpl::HostContextCreated, base::Unretained(this)))); |
| 210 } | 211 } |
| 211 | 212 |
| 212 private: | 213 private: |
| 213 // Overridden from ShellClient: | 214 // Overridden from Application: |
| 214 virtual void AcceptConnection(const mojo::String& url, | 215 virtual void AcceptConnection(const mojo::String& url, |
| 215 ScopedMessagePipeHandle handle) MOJO_OVERRIDE { | 216 ScopedMessagePipeHandle handle) MOJO_OVERRIDE { |
| 216 launcher_client_.reset( | 217 launcher_client_.reset( |
| 217 MakeScopedHandle(LauncherClientHandle(handle.release().value())).Pass(), | 218 MakeScopedHandle(LauncherClientHandle(handle.release().value())).Pass(), |
| 218 this); | 219 this); |
| 219 } | 220 } |
| 220 | 221 |
| 221 // Overridden from Launcher: | 222 // Overridden from Launcher: |
| 222 virtual void Show() OVERRIDE { | 223 virtual void Show() OVERRIDE { |
| 223 if (!root_window_.get()) { | 224 if (!root_window_.get()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 266 |
| 266 scoped_ptr<DemoScreen> screen_; | 267 scoped_ptr<DemoScreen> screen_; |
| 267 scoped_ptr<LauncherWindowTreeClient> window_tree_client_; | 268 scoped_ptr<LauncherWindowTreeClient> window_tree_client_; |
| 268 scoped_ptr<aura::client::DefaultActivationClient> activation_client_; | 269 scoped_ptr<aura::client::DefaultActivationClient> activation_client_; |
| 269 scoped_ptr<aura::client::FocusClient> focus_client_; | 270 scoped_ptr<aura::client::FocusClient> focus_client_; |
| 270 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 271 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 271 scoped_ptr<ui::EventHandler> ime_filter_; | 272 scoped_ptr<ui::EventHandler> ime_filter_; |
| 272 | 273 |
| 273 LauncherController launcher_controller_; | 274 LauncherController launcher_controller_; |
| 274 | 275 |
| 275 RemotePtr<Shell> shell_; | |
| 276 RemotePtr<LauncherClient> launcher_client_; | 276 RemotePtr<LauncherClient> launcher_client_; |
| 277 scoped_ptr<WindowTreeHostMojo> root_window_host_; | 277 scoped_ptr<WindowTreeHostMojo> root_window_host_; |
| 278 scoped_ptr<aura::RootWindow> root_window_; | 278 scoped_ptr<aura::RootWindow> root_window_; |
| 279 | 279 |
| 280 bool pending_show_; | 280 bool pending_show_; |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 } // namespace examples | 283 } // namespace examples |
| 284 } // namespace mojo | 284 } // namespace mojo |
| 285 | 285 |
| 286 extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain( | 286 extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain( |
| 287 MojoHandle shell_handle) { | 287 MojoHandle shell_handle) { |
| 288 CommandLine::Init(0, NULL); | 288 CommandLine::Init(0, NULL); |
| 289 base::AtExitManager at_exit; | 289 base::AtExitManager at_exit; |
| 290 base::i18n::InitializeICU(); | 290 base::i18n::InitializeICU(); |
| 291 | 291 |
| 292 base::FilePath pak_dir; | 292 base::FilePath pak_dir; |
| 293 PathService::Get(base::DIR_MODULE, &pak_dir); | 293 PathService::Get(base::DIR_MODULE, &pak_dir); |
| 294 base::FilePath pak_file; | 294 base::FilePath pak_file; |
| 295 pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak")); | 295 pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak")); |
| 296 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 296 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
| 297 | 297 |
| 298 base::MessageLoop loop; | 298 base::MessageLoop loop; |
| 299 mojo::GLES2Initializer gles2; | 299 mojo::GLES2Initializer gles2; |
| 300 | 300 |
| 301 // TODO(beng): This crashes in a DCHECK on X11 because this thread's | 301 // TODO(beng): This crashes in a DCHECK on X11 because this thread's |
| 302 // MessageLoop is not of TYPE_UI. I think we need a way to build | 302 // MessageLoop is not of TYPE_UI. I think we need a way to build |
| 303 // Aura that doesn't define platform-specific stuff. | 303 // Aura that doesn't define platform-specific stuff. |
| 304 aura::Env::CreateInstance(); | 304 aura::Env::CreateInstance(); |
| 305 mojo::examples::LauncherImpl launcher( | 305 mojo::examples::LauncherImpl launcher(shell_handle); |
| 306 mojo::MakeScopedHandle(mojo::ShellHandle(shell_handle)).Pass()); | |
| 307 loop.Run(); | 306 loop.Run(); |
| 308 | 307 |
| 309 return MOJO_RESULT_OK; | 308 return MOJO_RESULT_OK; |
| 310 } | 309 } |
| OLD | NEW |