OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "mojo/examples/keyboard/keyboard.mojom.h" | 7 #include "mojo/examples/keyboard/keyboard.mojom.h" |
8 #include "mojo/examples/window_manager/debug_panel.h" | 8 #include "mojo/examples/window_manager/debug_panel.h" |
9 #include "mojo/examples/window_manager/window_manager.mojom.h" | 9 #include "mojo/examples/window_manager/window_manager.mojom.h" |
10 #include "mojo/public/c/system/main.h" | 10 #include "mojo/public/c/system/main.h" |
11 #include "mojo/public/cpp/application/application_connection.h" | 11 #include "mojo/public/cpp/application/application_connection.h" |
12 #include "mojo/public/cpp/application/application_delegate.h" | 12 #include "mojo/public/cpp/application/application_delegate.h" |
13 #include "mojo/public/cpp/application/application_impl.h" | 13 #include "mojo/public/cpp/application/application_impl.h" |
14 #include "mojo/public/cpp/application/application_runner_chromium.h" | 14 #include "mojo/public/cpp/application/application_runner_chromium.h" |
15 #include "mojo/public/cpp/application/interface_factory_impl.h" | 15 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 16 #include "mojo/public/cpp/application/service_provider_impl.h" |
16 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 17 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
17 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" | 18 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" |
18 #include "mojo/services/public/cpp/view_manager/view.h" | 19 #include "mojo/services/public/cpp/view_manager/view.h" |
19 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 20 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
20 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 21 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
21 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 22 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
22 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" | 23 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" |
23 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" | 24 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" |
24 #include "mojo/services/public/interfaces/launcher/launcher.mojom.h" | 25 #include "mojo/services/public/interfaces/launcher/launcher.mojom.h" |
25 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 26 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 virtual void ShowKeyboard(Id view_id, RectPtr bounds) OVERRIDE; | 60 virtual void ShowKeyboard(Id view_id, RectPtr bounds) OVERRIDE; |
60 virtual void HideKeyboard(Id view_id) OVERRIDE; | 61 virtual void HideKeyboard(Id view_id) OVERRIDE; |
61 | 62 |
62 WindowManager* window_manager_; | 63 WindowManager* window_manager_; |
63 | 64 |
64 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); | 65 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnection); |
65 }; | 66 }; |
66 | 67 |
67 class NavigatorHostImpl : public InterfaceImpl<NavigatorHost> { | 68 class NavigatorHostImpl : public InterfaceImpl<NavigatorHost> { |
68 public: | 69 public: |
69 explicit NavigatorHostImpl(WindowManager* window_manager) | 70 explicit NavigatorHostImpl(WindowManager* window_manager, Id view_id) |
70 : window_manager_(window_manager) {} | 71 : window_manager_(window_manager), view_id_(view_id) {} |
71 virtual ~NavigatorHostImpl() { | 72 virtual ~NavigatorHostImpl() { |
72 } | 73 } |
73 | 74 |
74 private: | 75 private: |
75 virtual void DidNavigateLocally(uint32 source_view_id, | 76 virtual void DidNavigateLocally(const mojo::String& url) OVERRIDE; |
76 const mojo::String& url) OVERRIDE; | |
77 virtual void RequestNavigate( | 77 virtual void RequestNavigate( |
78 uint32 source_view_id, | |
79 Target target, | 78 Target target, |
80 NavigationDetailsPtr nav_details) OVERRIDE; | 79 NavigationDetailsPtr nav_details) OVERRIDE; |
| 80 |
81 WindowManager* window_manager_; | 81 WindowManager* window_manager_; |
| 82 Id view_id_; |
82 | 83 |
83 DISALLOW_COPY_AND_ASSIGN(NavigatorHostImpl); | 84 DISALLOW_COPY_AND_ASSIGN(NavigatorHostImpl); |
84 }; | 85 }; |
85 | 86 |
86 class KeyboardManager : public KeyboardClient, | 87 class KeyboardManager : public KeyboardClient, |
87 public ViewObserver { | 88 public ViewObserver { |
88 public: | 89 public: |
89 KeyboardManager() : view_manager_(NULL), view_(NULL) { | 90 KeyboardManager() : view_manager_(NULL), view_(NULL) { |
90 } | 91 } |
91 virtual ~KeyboardManager() { | 92 virtual ~KeyboardManager() { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 243 |
243 View* root_; | 244 View* root_; |
244 ViewManager* view_manager_; | 245 ViewManager* view_manager_; |
245 const Id content_view_id_; | 246 const Id content_view_id_; |
246 const Id launcher_ui_view_id_; | 247 const Id launcher_ui_view_id_; |
247 const Id control_panel_view_id_; | 248 const Id control_panel_view_id_; |
248 | 249 |
249 DISALLOW_COPY_AND_ASSIGN(RootLayoutManager); | 250 DISALLOW_COPY_AND_ASSIGN(RootLayoutManager); |
250 }; | 251 }; |
251 | 252 |
| 253 class Window : public InterfaceFactory<NavigatorHost> { |
| 254 public: |
| 255 Window(WindowManager* window_manager, View* view) |
| 256 : window_manager_(window_manager), view_(view) {} |
| 257 |
| 258 virtual ~Window() {} |
| 259 |
| 260 View* view() const { return view_; } |
| 261 |
| 262 void Embed(const std::string& url) { |
| 263 scoped_ptr<ServiceProviderImpl> service_provider_impl( |
| 264 new ServiceProviderImpl()); |
| 265 service_provider_impl->AddService<NavigatorHost>(this); |
| 266 view_->Embed(url, service_provider_impl.Pass()); |
| 267 } |
| 268 |
| 269 private: |
| 270 // InterfaceFactory<NavigatorHost> |
| 271 virtual void Create(ApplicationConnection* connection, |
| 272 InterfaceRequest<NavigatorHost> request) OVERRIDE { |
| 273 BindToRequest(new NavigatorHostImpl(window_manager_, view_->id()), |
| 274 &request); |
| 275 } |
| 276 |
| 277 WindowManager* window_manager_; |
| 278 View* view_; |
| 279 }; |
| 280 |
252 class WindowManager | 281 class WindowManager |
253 : public ApplicationDelegate, | 282 : public ApplicationDelegate, |
254 public DebugPanel::Delegate, | 283 public DebugPanel::Delegate, |
255 public ViewManagerDelegate, | 284 public ViewManagerDelegate, |
256 public WindowManagerDelegate, | 285 public WindowManagerDelegate, |
257 public ui::EventHandler { | 286 public ui::EventHandler { |
258 public: | 287 public: |
259 WindowManager() | 288 WindowManager() |
260 : window_manager_factory_(this), | 289 : window_manager_factory_(this), |
261 navigator_host_factory_(this), | |
262 launcher_ui_(NULL), | 290 launcher_ui_(NULL), |
263 view_manager_(NULL), | 291 view_manager_(NULL), |
264 window_manager_app_(new WindowManagerApp(this, this)), | 292 window_manager_app_(new WindowManagerApp(this, this)), |
265 app_(NULL) {} | 293 app_(NULL) {} |
266 | 294 |
267 virtual ~WindowManager() { | 295 virtual ~WindowManager() { |
268 // host() may be destroyed by the time we get here. | 296 // host() may be destroyed by the time we get here. |
269 // TODO: figure out a way to always cleanly remove handler. | 297 // TODO: figure out a way to always cleanly remove handler. |
270 if (window_manager_app_->host()) | 298 if (window_manager_app_->host()) |
271 window_manager_app_->host()->window()->RemovePreTargetHandler(this); | 299 window_manager_app_->host()->window()->RemovePreTargetHandler(this); |
272 } | 300 } |
273 | 301 |
274 void CloseWindow(Id view_id) { | 302 void CloseWindow(Id view_id) { |
275 View* view = view_manager_->GetViewById(view_id); | 303 WindowVector::iterator iter = GetWindowByViewId(view_id); |
276 DCHECK(view); | |
277 std::vector<View*>::iterator iter = | |
278 std::find(windows_.begin(), windows_.end(), view); | |
279 DCHECK(iter != windows_.end()); | 304 DCHECK(iter != windows_.end()); |
280 windows_.erase(iter); | 305 windows_.erase(iter); |
281 view->Destroy(); | 306 (*iter)->view()->Destroy(); |
282 } | 307 } |
283 | 308 |
284 void ShowKeyboard(Id view_id, const gfx::Rect& bounds) { | 309 void ShowKeyboard(Id view_id, const gfx::Rect& bounds) { |
285 // TODO: this needs to validate |view_id|. That is, it shouldn't assume | 310 // TODO: this needs to validate |view_id|. That is, it shouldn't assume |
286 // |view_id| is valid and it also needs to make sure the client that sent | 311 // |view_id| is valid and it also needs to make sure the client that sent |
287 // this really owns |view_id|. | 312 // this really owns |view_id|. |
288 // TODO: honor |bounds|. | 313 // TODO: honor |bounds|. |
289 if (!keyboard_manager_) { | 314 if (!keyboard_manager_) { |
290 keyboard_manager_.reset(new KeyboardManager); | 315 keyboard_manager_.reset(new KeyboardManager); |
291 View* parent = view_manager_->GetRoots().back(); | 316 View* parent = view_manager_->GetRoots().back(); |
(...skipping 15 matching lines...) Expand all Loading... |
307 } | 332 } |
308 | 333 |
309 void DidNavigateLocally(uint32 source_view_id, const mojo::String& url) { | 334 void DidNavigateLocally(uint32 source_view_id, const mojo::String& url) { |
310 LOG(ERROR) << "DidNavigateLocally: source_view_id: " << source_view_id | 335 LOG(ERROR) << "DidNavigateLocally: source_view_id: " << source_view_id |
311 << " url: " << url.To<std::string>(); | 336 << " url: " << url.To<std::string>(); |
312 } | 337 } |
313 | 338 |
314 // Overridden from DebugPanel::Delegate: | 339 // Overridden from DebugPanel::Delegate: |
315 virtual void CloseTopWindow() OVERRIDE { | 340 virtual void CloseTopWindow() OVERRIDE { |
316 if (!windows_.empty()) | 341 if (!windows_.empty()) |
317 CloseWindow(windows_.back()->id()); | 342 CloseWindow(windows_.back()->view()->id()); |
318 } | 343 } |
319 | 344 |
320 virtual void RequestNavigate( | 345 virtual void RequestNavigate( |
321 uint32 source_view_id, | 346 uint32 source_view_id, |
322 Target target, | 347 Target target, |
323 NavigationDetailsPtr nav_details) OVERRIDE { | 348 NavigationDetailsPtr nav_details) OVERRIDE { |
324 OnLaunch(source_view_id, target, nav_details->request->url); | 349 OnLaunch(source_view_id, target, nav_details->request->url); |
325 } | 350 } |
326 | 351 |
327 private: | 352 private: |
| 353 typedef std::vector<Window*> WindowVector; |
| 354 |
328 // Overridden from ApplicationDelegate: | 355 // Overridden from ApplicationDelegate: |
329 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { | 356 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { |
330 app_ = app; | 357 app_ = app; |
331 views_init_.reset(new ViewsInit); | 358 views_init_.reset(new ViewsInit); |
332 window_manager_app_->Initialize(app); | 359 window_manager_app_->Initialize(app); |
333 } | 360 } |
334 | 361 |
335 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 362 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
336 MOJO_OVERRIDE { | 363 MOJO_OVERRIDE { |
337 connection->AddService(&window_manager_factory_); | 364 connection->AddService(&window_manager_factory_); |
338 connection->AddService(&navigator_host_factory_); | |
339 window_manager_app_->ConfigureIncomingConnection(connection); | 365 window_manager_app_->ConfigureIncomingConnection(connection); |
340 return true; | 366 return true; |
341 } | 367 } |
342 | 368 |
343 // Overridden from ViewManagerDelegate: | 369 // Overridden from ViewManagerDelegate: |
344 virtual void OnEmbed(ViewManager* view_manager, | 370 virtual void OnEmbed(ViewManager* view_manager, |
345 View* root, | 371 View* root, |
346 ServiceProviderImpl* exported_services, | 372 ServiceProviderImpl* exported_services, |
347 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { | 373 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { |
348 DCHECK(!view_manager_); | 374 DCHECK(!view_manager_); |
(...skipping 21 matching lines...) Expand all Loading... |
370 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE { | 396 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE { |
371 DCHECK_EQ(view_manager_, view_manager); | 397 DCHECK_EQ(view_manager_, view_manager); |
372 view_manager_ = NULL; | 398 view_manager_ = NULL; |
373 base::MessageLoop::current()->Quit(); | 399 base::MessageLoop::current()->Quit(); |
374 } | 400 } |
375 | 401 |
376 // Overridden from WindowManagerDelegate: | 402 // Overridden from WindowManagerDelegate: |
377 virtual void Embed( | 403 virtual void Embed( |
378 const String& url, | 404 const String& url, |
379 InterfaceRequest<ServiceProvider> service_provider) OVERRIDE { | 405 InterfaceRequest<ServiceProvider> service_provider) OVERRIDE { |
380 CreateWindow(url); | 406 const Id kInvalidSourceViewId = 0; |
| 407 OnLaunch(kInvalidSourceViewId, TARGET_DEFAULT, url); |
381 } | 408 } |
382 virtual void DispatchEvent(EventPtr event) MOJO_OVERRIDE {} | 409 virtual void DispatchEvent(EventPtr event) MOJO_OVERRIDE {} |
383 | 410 |
384 // Overridden from ui::EventHandler: | 411 // Overridden from ui::EventHandler: |
385 virtual void OnEvent(ui::Event* event) OVERRIDE { | 412 virtual void OnEvent(ui::Event* event) OVERRIDE { |
386 View* view = WindowManagerApp::GetViewForWindow( | 413 View* view = WindowManagerApp::GetViewForWindow( |
387 static_cast<aura::Window*>(event->target())); | 414 static_cast<aura::Window*>(event->target())); |
388 if (event->type() == ui::ET_MOUSE_PRESSED && | 415 if (event->type() == ui::ET_MOUSE_PRESSED && |
389 !IsDescendantOfKeyboard(view)) { | 416 !IsDescendantOfKeyboard(view)) { |
390 view->SetFocus(); | 417 view->SetFocus(); |
391 } | 418 } |
392 } | 419 } |
393 | 420 |
394 void OnLaunch(uint32 source_view_id, | 421 void OnLaunch(uint32 source_view_id, |
395 Target requested_target, | 422 Target requested_target, |
396 const mojo::String& url) { | 423 const mojo::String& url) { |
397 Target target = debug_panel_->navigation_target(); | 424 Target target = debug_panel_->navigation_target(); |
398 if (target == TARGET_DEFAULT) { | 425 if (target == TARGET_DEFAULT) { |
399 if (requested_target != TARGET_DEFAULT) { | 426 if (requested_target != TARGET_DEFAULT) { |
400 target = requested_target; | 427 target = requested_target; |
401 } else { | 428 } else { |
402 // TODO(aa): Should be TARGET_NEW_NODE if source origin and dest origin | 429 // TODO(aa): Should be TARGET_NEW_NODE if source origin and dest origin |
403 // are different? | 430 // are different? |
404 target = TARGET_SOURCE_NODE; | 431 target = TARGET_SOURCE_NODE; |
405 } | 432 } |
406 } | 433 } |
407 | 434 |
408 View* dest_view = NULL; | 435 Window* dest_view = NULL; |
409 if (target == TARGET_SOURCE_NODE) { | 436 if (target == TARGET_SOURCE_NODE) { |
410 View* source_view = view_manager_->GetViewById(source_view_id); | 437 WindowVector::iterator source_view = GetWindowByViewId(source_view_id); |
411 bool app_initiated = std::find(windows_.begin(), windows_.end(), | 438 bool app_initiated = source_view != windows_.end(); |
412 source_view) != windows_.end(); | |
413 if (app_initiated) | 439 if (app_initiated) |
414 dest_view = source_view; | 440 dest_view = *source_view; |
415 else if (!windows_.empty()) | 441 else if (!windows_.empty()) |
416 dest_view = windows_.back(); | 442 dest_view = windows_.back(); |
417 } | 443 } |
418 | 444 |
419 if (dest_view) | 445 if (!dest_view) { |
420 dest_view->Embed(url); | 446 dest_view = CreateWindow(); |
421 else | 447 windows_.push_back(dest_view); |
422 CreateWindow(url); | 448 } |
| 449 |
| 450 dest_view->Embed(url); |
423 } | 451 } |
424 | 452 |
425 // TODO(beng): proper layout manager!! | 453 // TODO(beng): proper layout manager!! |
426 Id CreateLauncherUI() { | 454 Id CreateLauncherUI() { |
427 NavigationDetailsPtr nav_details; | 455 NavigationDetailsPtr nav_details; |
428 ResponseDetailsPtr response; | 456 ResponseDetailsPtr response; |
429 View* view = view_manager_->GetViewById(content_view_id_); | 457 View* view = view_manager_->GetViewById(content_view_id_); |
430 gfx::Rect bounds = view->bounds(); | 458 gfx::Rect bounds = view->bounds(); |
431 bounds.Inset(kBorderInset, kBorderInset); | 459 bounds.Inset(kBorderInset, kBorderInset); |
432 bounds.set_height(kTextfieldHeight); | 460 bounds.set_height(kTextfieldHeight); |
433 launcher_ui_ = CreateChild(content_view_id_, "mojo:mojo_browser", bounds); | 461 launcher_ui_ = CreateWindow(bounds); |
434 return launcher_ui_->id(); | 462 launcher_ui_->Embed("mojo:mojo_browser"); |
| 463 return launcher_ui_->view()->id(); |
435 } | 464 } |
436 | 465 |
437 void CreateWindow(const std::string& url) { | 466 Window* CreateWindow() { |
438 View* view = view_manager_->GetViewById(content_view_id_); | 467 View* view = view_manager_->GetViewById(content_view_id_); |
439 gfx::Rect bounds(kBorderInset, | 468 gfx::Rect bounds(kBorderInset, |
440 2 * kBorderInset + kTextfieldHeight, | 469 2 * kBorderInset + kTextfieldHeight, |
441 view->bounds().width() - 3 * kBorderInset - | 470 view->bounds().width() - 3 * kBorderInset - |
442 kControlPanelWidth, | 471 kControlPanelWidth, |
443 view->bounds().height() - | 472 view->bounds().height() - |
444 (3 * kBorderInset + kTextfieldHeight)); | 473 (3 * kBorderInset + kTextfieldHeight)); |
445 if (!windows_.empty()) { | 474 if (!windows_.empty()) { |
446 gfx::Point position = windows_.back()->bounds().origin(); | 475 gfx::Point position = windows_.back()->view()->bounds().origin(); |
447 position.Offset(35, 35); | 476 position.Offset(35, 35); |
448 bounds.set_origin(position); | 477 bounds.set_origin(position); |
449 } | 478 } |
450 windows_.push_back(CreateChild(content_view_id_, url, bounds)); | 479 return CreateWindow(bounds); |
451 } | 480 } |
452 | 481 |
453 View* CreateChild(Id parent_id, | 482 Window* CreateWindow(const gfx::Rect& bounds) { |
454 const std::string& url, | 483 View* content = view_manager_->GetViewById(content_view_id_); |
455 const gfx::Rect& bounds) { | 484 View* view = View::Create(view_manager_); |
456 View* view = view_manager_->GetViewById(parent_id); | 485 content->AddChild(view); |
457 View* embedded = View::Create(view_manager_); | 486 view->SetBounds(bounds); |
458 view->AddChild(embedded); | 487 view->SetFocus(); |
459 embedded->SetBounds(bounds); | 488 return new Window(this, view); |
460 embedded->Embed(url); | |
461 embedded->SetFocus(); | |
462 return embedded; | |
463 } | 489 } |
464 | 490 |
465 bool IsDescendantOfKeyboard(View* target) { | 491 bool IsDescendantOfKeyboard(View* target) { |
466 return keyboard_manager_.get() && | 492 return keyboard_manager_.get() && |
467 keyboard_manager_->view()->Contains(target); | 493 keyboard_manager_->view()->Contains(target); |
468 } | 494 } |
469 | 495 |
470 Id CreateControlPanel(View* root) { | 496 Id CreateControlPanel(View* root) { |
471 View* view = View::Create(view_manager_); | 497 View* view = View::Create(view_manager_); |
472 root->AddChild(view); | 498 root->AddChild(view); |
473 | 499 |
474 gfx::Rect bounds(root->bounds().width() - kControlPanelWidth - | 500 gfx::Rect bounds(root->bounds().width() - kControlPanelWidth - |
475 kBorderInset, | 501 kBorderInset, |
476 kBorderInset * 2 + kTextfieldHeight, | 502 kBorderInset * 2 + kTextfieldHeight, |
477 kControlPanelWidth, | 503 kControlPanelWidth, |
478 root->bounds().height() - kBorderInset * 3 - | 504 root->bounds().height() - kBorderInset * 3 - |
479 kTextfieldHeight); | 505 kTextfieldHeight); |
480 view->SetBounds(bounds); | 506 view->SetBounds(bounds); |
481 | 507 |
482 debug_panel_ = new DebugPanel(this, view); | 508 debug_panel_ = new DebugPanel(this, view); |
483 return view->id(); | 509 return view->id(); |
484 } | 510 } |
485 | 511 |
| 512 WindowVector::iterator GetWindowByViewId(Id view_id) { |
| 513 for (std::vector<Window*>::iterator iter = windows_.begin(); |
| 514 iter != windows_.end(); |
| 515 ++iter) { |
| 516 if ((*iter)->view()->id() == view_id) { |
| 517 return iter; |
| 518 } |
| 519 } |
| 520 return windows_.end(); |
| 521 } |
| 522 |
486 InterfaceFactoryImplWithContext<WindowManagerConnection, WindowManager> | 523 InterfaceFactoryImplWithContext<WindowManagerConnection, WindowManager> |
487 window_manager_factory_; | 524 window_manager_factory_; |
488 InterfaceFactoryImplWithContext<NavigatorHostImpl, WindowManager> | |
489 navigator_host_factory_; | |
490 | 525 |
491 scoped_ptr<ViewsInit> views_init_; | 526 scoped_ptr<ViewsInit> views_init_; |
492 DebugPanel* debug_panel_; | 527 DebugPanel* debug_panel_; |
493 View* launcher_ui_; | 528 Window* launcher_ui_; |
494 std::vector<View*> windows_; | 529 WindowVector windows_; |
495 ViewManager* view_manager_; | 530 ViewManager* view_manager_; |
496 scoped_ptr<RootLayoutManager> root_layout_manager_; | 531 scoped_ptr<RootLayoutManager> root_layout_manager_; |
497 | 532 |
498 scoped_ptr<WindowManagerApp> window_manager_app_; | 533 scoped_ptr<WindowManagerApp> window_manager_app_; |
499 | 534 |
500 // Id of the view most content is added to. The keyboard is NOT added here. | 535 // Id of the view most content is added to. The keyboard is NOT added here. |
501 Id content_view_id_; | 536 Id content_view_id_; |
502 | 537 |
503 scoped_ptr<KeyboardManager> keyboard_manager_; | 538 scoped_ptr<KeyboardManager> keyboard_manager_; |
504 ApplicationImpl* app_; | 539 ApplicationImpl* app_; |
505 | 540 |
506 DISALLOW_COPY_AND_ASSIGN(WindowManager); | 541 DISALLOW_COPY_AND_ASSIGN(WindowManager); |
507 }; | 542 }; |
508 | 543 |
509 void WindowManagerConnection::CloseWindow(Id view_id) { | 544 void WindowManagerConnection::CloseWindow(Id view_id) { |
510 window_manager_->CloseWindow(view_id); | 545 window_manager_->CloseWindow(view_id); |
511 } | 546 } |
512 | 547 |
513 void WindowManagerConnection::ShowKeyboard(Id view_id, RectPtr bounds) { | 548 void WindowManagerConnection::ShowKeyboard(Id view_id, RectPtr bounds) { |
514 window_manager_->ShowKeyboard(view_id, bounds.To<gfx::Rect>()); | 549 window_manager_->ShowKeyboard(view_id, bounds.To<gfx::Rect>()); |
515 } | 550 } |
516 | 551 |
517 void WindowManagerConnection::HideKeyboard(Id view_id) { | 552 void WindowManagerConnection::HideKeyboard(Id view_id) { |
518 window_manager_->HideKeyboard(view_id); | 553 window_manager_->HideKeyboard(view_id); |
519 } | 554 } |
520 | 555 |
521 void NavigatorHostImpl::DidNavigateLocally(uint32 source_view_id, | 556 void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) { |
522 const mojo::String& url) { | 557 window_manager_->DidNavigateLocally(view_id_, url); |
523 window_manager_->DidNavigateLocally(source_view_id, url); | |
524 } | 558 } |
525 | 559 |
526 void NavigatorHostImpl::RequestNavigate( | 560 void NavigatorHostImpl::RequestNavigate(Target target, |
527 uint32 source_view_id, | 561 NavigationDetailsPtr nav_details) { |
528 Target target, | 562 window_manager_->RequestNavigate(view_id_, target, nav_details.Pass()); |
529 NavigationDetailsPtr nav_details) { | |
530 window_manager_->RequestNavigate(source_view_id, target, nav_details.Pass()); | |
531 } | 563 } |
532 | 564 |
533 } // namespace examples | 565 } // namespace examples |
534 } // namespace mojo | 566 } // namespace mojo |
535 | 567 |
536 MojoResult MojoMain(MojoHandle shell_handle) { | 568 MojoResult MojoMain(MojoHandle shell_handle) { |
537 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); | 569 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); |
538 return runner.Run(shell_handle); | 570 return runner.Run(shell_handle); |
539 } | 571 } |
OLD | NEW |