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

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

Issue 280003003: Add SetClient method implementation to InterfaceImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ServiceConnection<Launcher, LauncherImpl>,
192 public URLReceiver { 192 public URLReceiver {
193 public: 193 public:
194 LauncherImpl() 194 LauncherImpl()
195 : launcher_controller_(this), 195 : launcher_controller_(this),
196 launcher_client_(NULL),
197 pending_show_(false) { 196 pending_show_(false) {
198 } 197 }
199 198
200 void Initialize() { 199 void Initialize() {
201 screen_.reset(ScreenMojo::Create()); 200 screen_.reset(ScreenMojo::Create());
202 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); 201 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
203 202
204 NativeViewportPtr viewport; 203 NativeViewportPtr viewport;
205 ConnectTo(shell(), "mojo:mojo_native_viewport_service", &viewport); 204 ConnectTo(shell(), "mojo:mojo_native_viewport_service", &viewport);
206 205
207 window_tree_host_.reset(new WindowTreeHostMojo( 206 window_tree_host_.reset(new WindowTreeHostMojo(
208 viewport.Pass(), gfx::Rect(50, 50, 450, 60), 207 viewport.Pass(), gfx::Rect(50, 50, 450, 60),
209 base::Bind(&LauncherImpl::HostContextCreated, base::Unretained(this)))); 208 base::Bind(&LauncherImpl::HostContextCreated, base::Unretained(this))));
210 } 209 }
211 210
212 private: 211 private:
213 // Overridden from Launcher: 212 // Overridden from Launcher:
214 virtual void SetClient(LauncherClient* client) OVERRIDE {
215 launcher_client_ = client;
216 }
217 virtual void Show() OVERRIDE { 213 virtual void Show() OVERRIDE {
218 if (!window_tree_host_.get()) { 214 if (!window_tree_host_.get()) {
219 pending_show_ = true; 215 pending_show_ = true;
220 return; 216 return;
221 } 217 }
222 window_tree_host_->Show(); 218 window_tree_host_->Show();
223 } 219 }
224 virtual void Hide() OVERRIDE { 220 virtual void Hide() OVERRIDE {
225 window_tree_host_->Hide(); 221 window_tree_host_->Hide();
226 } 222 }
227 223
228 // Overridden from URLReceiver: 224 // Overridden from URLReceiver:
229 virtual void OnURLEntered(const std::string& url_text) OVERRIDE { 225 virtual void OnURLEntered(const std::string& url_text) OVERRIDE {
230 AllocationScope scope; 226 AllocationScope scope;
231 launcher_client_->OnURLEntered(url_text); 227 client()->OnURLEntered(url_text);
232 } 228 }
233 229
234 void HostContextCreated() { 230 void HostContextCreated() {
235 window_tree_host_->InitHost(); 231 window_tree_host_->InitHost();
236 window_tree_host_->window()->SetBounds(gfx::Rect(450, 60)); 232 window_tree_host_->window()->SetBounds(gfx::Rect(450, 60));
237 233
238 focus_client_.reset(new aura::test::TestFocusClient()); 234 focus_client_.reset(new aura::test::TestFocusClient());
239 aura::client::SetFocusClient(window_tree_host_->window(), 235 aura::client::SetFocusClient(window_tree_host_->window(),
240 focus_client_.get()); 236 focus_client_.get());
241 new wm::DefaultActivationClient(window_tree_host_->window()); 237 new wm::DefaultActivationClient(window_tree_host_->window());
(...skipping 13 matching lines...) Expand all
255 } 251 }
256 252
257 scoped_ptr<ScreenMojo> screen_; 253 scoped_ptr<ScreenMojo> screen_;
258 scoped_ptr<LauncherWindowTreeClient> window_tree_client_; 254 scoped_ptr<LauncherWindowTreeClient> window_tree_client_;
259 scoped_ptr<aura::client::FocusClient> focus_client_; 255 scoped_ptr<aura::client::FocusClient> focus_client_;
260 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; 256 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
261 scoped_ptr<ui::EventHandler> ime_filter_; 257 scoped_ptr<ui::EventHandler> ime_filter_;
262 258
263 LauncherController launcher_controller_; 259 LauncherController launcher_controller_;
264 260
265 LauncherClient* launcher_client_;
266 scoped_ptr<aura::WindowTreeHost> window_tree_host_; 261 scoped_ptr<aura::WindowTreeHost> window_tree_host_;
267 262
268 bool pending_show_; 263 bool pending_show_;
269 }; 264 };
270 265
271 } // namespace examples 266 } // namespace examples
272 } // namespace mojo 267 } // namespace mojo
273 268
274 extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain( 269 extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain(
275 MojoHandle shell_handle) { 270 MojoHandle shell_handle) {
(...skipping 15 matching lines...) Expand all
291 // Aura that doesn't define platform-specific stuff. 286 // Aura that doesn't define platform-specific stuff.
292 aura::Env::CreateInstance(true); 287 aura::Env::CreateInstance(true);
293 288
294 mojo::Application app(shell_handle); 289 mojo::Application app(shell_handle);
295 app.AddServiceConnector( 290 app.AddServiceConnector(
296 new mojo::ServiceConnector<mojo::examples::LauncherImpl>()); 291 new mojo::ServiceConnector<mojo::examples::LauncherImpl>());
297 292
298 loop.Run(); 293 loop.Run();
299 return MOJO_RESULT_OK; 294 return MOJO_RESULT_OK;
300 } 295 }
OLDNEW
« no previous file with comments | « content/browser/mojo/mojo_application_host.cc ('k') | mojo/public/cpp/bindings/interface_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698