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

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

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

Powered by Google App Engine
This is Rietveld 408576698