| 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/public/cpp/application/service_provider_impl.h" |
| 17 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 17 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| 18 #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" |
| 19 #include "mojo/services/public/cpp/view_manager/view.h" | 19 #include "mojo/services/public/cpp/view_manager/view.h" |
| 20 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 20 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 21 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 21 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 22 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 22 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| 23 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" | 23 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" |
| 24 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" | 24 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" |
| 25 #include "mojo/services/public/interfaces/launcher/launcher.mojom.h" | |
| 26 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 25 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
| 27 #include "mojo/services/window_manager/window_manager_app.h" | 26 #include "mojo/services/window_manager/window_manager_app.h" |
| 28 #include "mojo/views/views_init.h" | 27 #include "mojo/views/views_init.h" |
| 29 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
| 30 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
| 31 #include "ui/events/event_constants.h" | 30 #include "ui/events/event_constants.h" |
| 32 #include "ui/gfx/geometry/size_conversions.h" | 31 #include "ui/gfx/geometry/size_conversions.h" |
| 33 | 32 |
| 34 #if defined CreateWindow | 33 #if defined CreateWindow |
| 35 #undef CreateWindow | 34 #undef CreateWindow |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 66 |
| 68 class NavigatorHostImpl : public InterfaceImpl<NavigatorHost> { | 67 class NavigatorHostImpl : public InterfaceImpl<NavigatorHost> { |
| 69 public: | 68 public: |
| 70 explicit NavigatorHostImpl(WindowManager* window_manager, Id view_id) | 69 explicit NavigatorHostImpl(WindowManager* window_manager, Id view_id) |
| 71 : window_manager_(window_manager), view_id_(view_id) {} | 70 : window_manager_(window_manager), view_id_(view_id) {} |
| 72 virtual ~NavigatorHostImpl() { | 71 virtual ~NavigatorHostImpl() { |
| 73 } | 72 } |
| 74 | 73 |
| 75 private: | 74 private: |
| 76 virtual void DidNavigateLocally(const mojo::String& url) OVERRIDE; | 75 virtual void DidNavigateLocally(const mojo::String& url) OVERRIDE; |
| 77 virtual void RequestNavigate( | 76 virtual void RequestNavigate(Target target, URLRequestPtr request) OVERRIDE; |
| 78 Target target, | |
| 79 NavigationDetailsPtr nav_details) OVERRIDE; | |
| 80 | 77 |
| 81 WindowManager* window_manager_; | 78 WindowManager* window_manager_; |
| 82 Id view_id_; | 79 Id view_id_; |
| 83 | 80 |
| 84 DISALLOW_COPY_AND_ASSIGN(NavigatorHostImpl); | 81 DISALLOW_COPY_AND_ASSIGN(NavigatorHostImpl); |
| 85 }; | 82 }; |
| 86 | 83 |
| 87 class KeyboardManager : public KeyboardClient, | 84 class KeyboardManager : public KeyboardClient, |
| 88 public ViewObserver { | 85 public ViewObserver { |
| 89 public: | 86 public: |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 LOG(ERROR) << "DidNavigateLocally: source_view_id: " << source_view_id | 332 LOG(ERROR) << "DidNavigateLocally: source_view_id: " << source_view_id |
| 336 << " url: " << url.To<std::string>(); | 333 << " url: " << url.To<std::string>(); |
| 337 } | 334 } |
| 338 | 335 |
| 339 // Overridden from DebugPanel::Delegate: | 336 // Overridden from DebugPanel::Delegate: |
| 340 virtual void CloseTopWindow() OVERRIDE { | 337 virtual void CloseTopWindow() OVERRIDE { |
| 341 if (!windows_.empty()) | 338 if (!windows_.empty()) |
| 342 CloseWindow(windows_.back()->view()->id()); | 339 CloseWindow(windows_.back()->view()->id()); |
| 343 } | 340 } |
| 344 | 341 |
| 345 virtual void RequestNavigate( | 342 virtual void RequestNavigate(uint32 source_view_id, |
| 346 uint32 source_view_id, | 343 Target target, |
| 347 Target target, | 344 URLRequestPtr request) OVERRIDE { |
| 348 NavigationDetailsPtr nav_details) OVERRIDE { | 345 OnLaunch(source_view_id, target, request->url); |
| 349 OnLaunch(source_view_id, target, nav_details->request->url); | |
| 350 } | 346 } |
| 351 | 347 |
| 352 private: | 348 private: |
| 353 typedef std::vector<Window*> WindowVector; | 349 typedef std::vector<Window*> WindowVector; |
| 354 | 350 |
| 355 // Overridden from ApplicationDelegate: | 351 // Overridden from ApplicationDelegate: |
| 356 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { | 352 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { |
| 357 app_ = app; | 353 app_ = app; |
| 358 views_init_.reset(new ViewsInit); | 354 views_init_.reset(new ViewsInit); |
| 359 window_manager_app_->Initialize(app); | 355 window_manager_app_->Initialize(app); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 if (!dest_view) { | 441 if (!dest_view) { |
| 446 dest_view = CreateWindow(); | 442 dest_view = CreateWindow(); |
| 447 windows_.push_back(dest_view); | 443 windows_.push_back(dest_view); |
| 448 } | 444 } |
| 449 | 445 |
| 450 dest_view->Embed(url); | 446 dest_view->Embed(url); |
| 451 } | 447 } |
| 452 | 448 |
| 453 // TODO(beng): proper layout manager!! | 449 // TODO(beng): proper layout manager!! |
| 454 Id CreateLauncherUI() { | 450 Id CreateLauncherUI() { |
| 455 NavigationDetailsPtr nav_details; | |
| 456 ResponseDetailsPtr response; | |
| 457 View* view = view_manager_->GetViewById(content_view_id_); | 451 View* view = view_manager_->GetViewById(content_view_id_); |
| 458 gfx::Rect bounds = view->bounds(); | 452 gfx::Rect bounds = view->bounds(); |
| 459 bounds.Inset(kBorderInset, kBorderInset); | 453 bounds.Inset(kBorderInset, kBorderInset); |
| 460 bounds.set_height(kTextfieldHeight); | 454 bounds.set_height(kTextfieldHeight); |
| 461 launcher_ui_ = CreateWindow(bounds); | 455 launcher_ui_ = CreateWindow(bounds); |
| 462 launcher_ui_->Embed("mojo:mojo_browser"); | 456 launcher_ui_->Embed("mojo:mojo_browser"); |
| 463 return launcher_ui_->view()->id(); | 457 return launcher_ui_->view()->id(); |
| 464 } | 458 } |
| 465 | 459 |
| 466 Window* CreateWindow() { | 460 Window* CreateWindow() { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 544 } |
| 551 | 545 |
| 552 void WindowManagerConnection::HideKeyboard(Id view_id) { | 546 void WindowManagerConnection::HideKeyboard(Id view_id) { |
| 553 window_manager_->HideKeyboard(view_id); | 547 window_manager_->HideKeyboard(view_id); |
| 554 } | 548 } |
| 555 | 549 |
| 556 void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) { | 550 void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) { |
| 557 window_manager_->DidNavigateLocally(view_id_, url); | 551 window_manager_->DidNavigateLocally(view_id_, url); |
| 558 } | 552 } |
| 559 | 553 |
| 560 void NavigatorHostImpl::RequestNavigate(Target target, | 554 void NavigatorHostImpl::RequestNavigate(Target target, URLRequestPtr request) { |
| 561 NavigationDetailsPtr nav_details) { | 555 window_manager_->RequestNavigate(view_id_, target, request.Pass()); |
| 562 window_manager_->RequestNavigate(view_id_, target, nav_details.Pass()); | |
| 563 } | 556 } |
| 564 | 557 |
| 565 } // namespace examples | 558 } // namespace examples |
| 566 } // namespace mojo | 559 } // namespace mojo |
| 567 | 560 |
| 568 MojoResult MojoMain(MojoHandle shell_handle) { | 561 MojoResult MojoMain(MojoHandle shell_handle) { |
| 569 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); | 562 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); |
| 570 return runner.Run(shell_handle); | 563 return runner.Run(shell_handle); |
| 571 } | 564 } |
| OLD | NEW |