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

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

Issue 275363002: Internalize ServiceConnector<> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add OnConnectionEstablished() Created 6 years, 7 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 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
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>,
192 public URLReceiver { 192 public URLReceiver {
193 public: 193 public:
194 LauncherImpl() 194 explicit LauncherImpl(Application* app)
195 : launcher_controller_(this), 195 : app_(app),
196 launcher_controller_(this),
196 pending_show_(false) { 197 pending_show_(false) {
197 }
198
199 void Initialize() {
200 screen_.reset(ScreenMojo::Create()); 198 screen_.reset(ScreenMojo::Create());
201 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); 199 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
202 200
203 NativeViewportPtr viewport; 201 NativeViewportPtr viewport;
204 ConnectTo(shell(), "mojo:mojo_native_viewport_service", &viewport); 202 app_->ConnectTo("mojo:mojo_native_viewport_service", &viewport);
205 203
206 window_tree_host_.reset(new WindowTreeHostMojo( 204 window_tree_host_.reset(new WindowTreeHostMojo(
207 viewport.Pass(), gfx::Rect(50, 50, 450, 60), 205 viewport.Pass(), gfx::Rect(50, 50, 450, 60),
208 base::Bind(&LauncherImpl::HostContextCreated, base::Unretained(this)))); 206 base::Bind(&LauncherImpl::HostContextCreated, base::Unretained(this))));
209 } 207 }
210 208
211 private: 209 private:
212 // Overridden from Launcher: 210 // Overridden from Launcher:
213 virtual void Show() OVERRIDE { 211 virtual void Show() OVERRIDE {
214 if (!window_tree_host_.get()) { 212 if (!window_tree_host_.get()) {
(...skipping 28 matching lines...) Expand all
243 new LauncherWindowTreeClient(window_tree_host_->window())); 241 new LauncherWindowTreeClient(window_tree_host_->window()));
244 242
245 launcher_controller_.InitInWindow(window_tree_host_->window()); 243 launcher_controller_.InitInWindow(window_tree_host_->window());
246 244
247 if (pending_show_) { 245 if (pending_show_) {
248 pending_show_ = false; 246 pending_show_ = false;
249 Show(); 247 Show();
250 } 248 }
251 } 249 }
252 250
251 Application* app_;
253 scoped_ptr<ScreenMojo> screen_; 252 scoped_ptr<ScreenMojo> screen_;
254 scoped_ptr<LauncherWindowTreeClient> window_tree_client_; 253 scoped_ptr<LauncherWindowTreeClient> window_tree_client_;
255 scoped_ptr<aura::client::FocusClient> focus_client_; 254 scoped_ptr<aura::client::FocusClient> focus_client_;
256 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; 255 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
257 scoped_ptr<ui::EventHandler> ime_filter_; 256 scoped_ptr<ui::EventHandler> ime_filter_;
258 257
259 LauncherController launcher_controller_; 258 LauncherController launcher_controller_;
260 259
261 scoped_ptr<aura::WindowTreeHost> window_tree_host_; 260 scoped_ptr<aura::WindowTreeHost> window_tree_host_;
262 261
(...skipping 17 matching lines...) Expand all
280 279
281 base::MessageLoop loop; 280 base::MessageLoop loop;
282 mojo::GLES2Initializer gles2; 281 mojo::GLES2Initializer gles2;
283 282
284 // TODO(beng): This crashes in a DCHECK on X11 because this thread's 283 // TODO(beng): This crashes in a DCHECK on X11 because this thread's
285 // MessageLoop is not of TYPE_UI. I think we need a way to build 284 // MessageLoop is not of TYPE_UI. I think we need a way to build
286 // Aura that doesn't define platform-specific stuff. 285 // Aura that doesn't define platform-specific stuff.
287 aura::Env::CreateInstance(true); 286 aura::Env::CreateInstance(true);
288 287
289 mojo::Application app(shell_handle); 288 mojo::Application app(shell_handle);
290 app.AddServiceConnector( 289 app.AddService<mojo::examples::LauncherImpl>(&app);
291 new mojo::ServiceConnector<mojo::examples::LauncherImpl>());
292 290
293 loop.Run(); 291 loop.Run();
294 return MOJO_RESULT_OK; 292 return MOJO_RESULT_OK;
295 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698