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

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

Issue 287143003: Mojo: Internalize ServiceConnector<> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing function 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 | « mojo/dbus/dbus_external_service.h ('k') | 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 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
209 // Overridden from InterfaceImpl:
210 virtual void OnConnectionError() OVERRIDE {}
211
211 private: 212 private:
212 // Overridden from Launcher: 213 // Overridden from Launcher:
213 virtual void Show() OVERRIDE { 214 virtual void Show() OVERRIDE {
214 if (!window_tree_host_.get()) { 215 if (!window_tree_host_.get()) {
215 pending_show_ = true; 216 pending_show_ = true;
216 return; 217 return;
217 } 218 }
218 window_tree_host_->Show(); 219 window_tree_host_->Show();
219 } 220 }
220 virtual void Hide() OVERRIDE { 221 virtual void Hide() OVERRIDE {
(...skipping 22 matching lines...) Expand all
243 new LauncherWindowTreeClient(window_tree_host_->window())); 244 new LauncherWindowTreeClient(window_tree_host_->window()));
244 245
245 launcher_controller_.InitInWindow(window_tree_host_->window()); 246 launcher_controller_.InitInWindow(window_tree_host_->window());
246 247
247 if (pending_show_) { 248 if (pending_show_) {
248 pending_show_ = false; 249 pending_show_ = false;
249 Show(); 250 Show();
250 } 251 }
251 } 252 }
252 253
254 Application* app_;
253 scoped_ptr<ScreenMojo> screen_; 255 scoped_ptr<ScreenMojo> screen_;
254 scoped_ptr<LauncherWindowTreeClient> window_tree_client_; 256 scoped_ptr<LauncherWindowTreeClient> window_tree_client_;
255 scoped_ptr<aura::client::FocusClient> focus_client_; 257 scoped_ptr<aura::client::FocusClient> focus_client_;
256 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; 258 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
257 scoped_ptr<ui::EventHandler> ime_filter_; 259 scoped_ptr<ui::EventHandler> ime_filter_;
258 260
259 LauncherController launcher_controller_; 261 LauncherController launcher_controller_;
260 262
261 scoped_ptr<aura::WindowTreeHost> window_tree_host_; 263 scoped_ptr<aura::WindowTreeHost> window_tree_host_;
262 264
(...skipping 17 matching lines...) Expand all
280 282
281 base::MessageLoop loop; 283 base::MessageLoop loop;
282 mojo::GLES2Initializer gles2; 284 mojo::GLES2Initializer gles2;
283 285
284 // TODO(beng): This crashes in a DCHECK on X11 because this thread's 286 // 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 287 // MessageLoop is not of TYPE_UI. I think we need a way to build
286 // Aura that doesn't define platform-specific stuff. 288 // Aura that doesn't define platform-specific stuff.
287 aura::Env::CreateInstance(true); 289 aura::Env::CreateInstance(true);
288 290
289 mojo::Application app(shell_handle); 291 mojo::Application app(shell_handle);
290 app.AddServiceConnector( 292 app.AddService<mojo::examples::LauncherImpl>(&app);
291 new mojo::ServiceConnector<mojo::examples::LauncherImpl>());
292 293
293 loop.Run(); 294 loop.Run();
294 return MOJO_RESULT_OK; 295 return MOJO_RESULT_OK;
295 } 296 }
OLDNEW
« no previous file with comments | « mojo/dbus/dbus_external_service.h ('k') | mojo/mojo_public.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698