Chromium Code Reviews| 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" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 url_receiver_->OnURLEntered(url.spec()); | 181 url_receiver_->OnURLEntered(url.spec()); |
| 182 } | 182 } |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 | 185 |
| 186 URLReceiver* url_receiver_; | 186 URLReceiver* url_receiver_; |
| 187 | 187 |
| 188 DISALLOW_COPY_AND_ASSIGN(LauncherController); | 188 DISALLOW_COPY_AND_ASSIGN(LauncherController); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 class LauncherImpl : public ServiceConnection<Launcher, LauncherImpl>, | 191 class LauncherImpl : public InterfaceImpl<Launcher>, |
|
darin (slow to review)
2014/05/12 22:04:52
looks nice! :)
| |
| 192 public URLReceiver { | 192 public URLReceiver { |
| 193 public: | 193 public: |
| 194 LauncherImpl() | 194 LauncherImpl(Application* app) |
|
darin (slow to review)
2014/05/12 22:04:52
nit: explicit ctor
DaveMoore
2014/05/14 16:50:31
Done.
| |
| 195 : launcher_controller_(this), | 195 : app_(app), |
| 196 launcher_controller_(this), | |
| 196 launcher_client_(NULL), | 197 launcher_client_(NULL), |
| 197 pending_show_(false) { | 198 pending_show_(false) { |
| 198 } | 199 } |
| 199 | 200 |
| 200 void Initialize() { | 201 void Initialize() { |
| 201 screen_.reset(ScreenMojo::Create()); | 202 screen_.reset(ScreenMojo::Create()); |
| 202 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 203 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
| 203 | 204 |
| 204 NativeViewportPtr viewport; | 205 NativeViewportPtr viewport; |
| 205 ConnectTo(shell(), "mojo:mojo_native_viewport_service", &viewport); | 206 ConnectTo(app_->shell(), "mojo:mojo_native_viewport_service", &viewport); |
|
darin (slow to review)
2014/05/12 22:04:52
You could write app_->ConnectTo("mojo:...", &viewp
DaveMoore
2014/05/14 16:50:31
Done.
| |
| 206 | 207 |
| 207 window_tree_host_.reset(new WindowTreeHostMojo( | 208 window_tree_host_.reset(new WindowTreeHostMojo( |
| 208 viewport.Pass(), gfx::Rect(50, 50, 450, 60), | 209 viewport.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 Launcher: | 214 // Overridden from Launcher: |
| 214 virtual void SetClient(LauncherClient* client) OVERRIDE { | 215 virtual void SetClient(LauncherClient* client) OVERRIDE { |
| 215 launcher_client_ = client; | 216 launcher_client_ = client; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 new LauncherWindowTreeClient(window_tree_host_->window())); | 248 new LauncherWindowTreeClient(window_tree_host_->window())); |
| 248 | 249 |
| 249 launcher_controller_.InitInWindow(window_tree_host_->window()); | 250 launcher_controller_.InitInWindow(window_tree_host_->window()); |
| 250 | 251 |
| 251 if (pending_show_) { | 252 if (pending_show_) { |
| 252 pending_show_ = false; | 253 pending_show_ = false; |
| 253 Show(); | 254 Show(); |
| 254 } | 255 } |
| 255 } | 256 } |
| 256 | 257 |
| 258 Application* app_; | |
| 257 scoped_ptr<ScreenMojo> screen_; | 259 scoped_ptr<ScreenMojo> screen_; |
| 258 scoped_ptr<LauncherWindowTreeClient> window_tree_client_; | 260 scoped_ptr<LauncherWindowTreeClient> window_tree_client_; |
| 259 scoped_ptr<aura::client::FocusClient> focus_client_; | 261 scoped_ptr<aura::client::FocusClient> focus_client_; |
| 260 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 262 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 261 scoped_ptr<ui::EventHandler> ime_filter_; | 263 scoped_ptr<ui::EventHandler> ime_filter_; |
| 262 | 264 |
| 263 LauncherController launcher_controller_; | 265 LauncherController launcher_controller_; |
| 264 | 266 |
| 265 LauncherClient* launcher_client_; | 267 LauncherClient* launcher_client_; |
| 266 scoped_ptr<aura::WindowTreeHost> window_tree_host_; | 268 scoped_ptr<aura::WindowTreeHost> window_tree_host_; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 285 | 287 |
| 286 base::MessageLoop loop; | 288 base::MessageLoop loop; |
| 287 mojo::GLES2Initializer gles2; | 289 mojo::GLES2Initializer gles2; |
| 288 | 290 |
| 289 // TODO(beng): This crashes in a DCHECK on X11 because this thread's | 291 // TODO(beng): This crashes in a DCHECK on X11 because this thread's |
| 290 // MessageLoop is not of TYPE_UI. I think we need a way to build | 292 // MessageLoop is not of TYPE_UI. I think we need a way to build |
| 291 // Aura that doesn't define platform-specific stuff. | 293 // Aura that doesn't define platform-specific stuff. |
| 292 aura::Env::CreateInstance(true); | 294 aura::Env::CreateInstance(true); |
| 293 | 295 |
| 294 mojo::Application app(shell_handle); | 296 mojo::Application app(shell_handle); |
| 295 app.AddServiceConnector( | 297 app.AddService<mojo::examples::LauncherImpl>(&app); |
|
darin (slow to review)
2014/05/12 22:04:52
oh, that's an interesting way of using the Context
| |
| 296 new mojo::ServiceConnector<mojo::examples::LauncherImpl>()); | |
| 297 | 298 |
| 298 loop.Run(); | 299 loop.Run(); |
| 299 return MOJO_RESULT_OK; | 300 return MOJO_RESULT_OK; |
| 300 } | 301 } |
| OLD | NEW |