| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "mojo/application/application_runner_chromium.h" | 6 #include "mojo/application/application_runner_chromium.h" |
| 7 #include "mojo/public/c/system/main.h" | 7 #include "mojo/public/c/system/main.h" |
| 8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
| 9 #include "mojo/public/cpp/application/service_provider_impl.h" | 9 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 10 #include "mojo/services/view_manager/public/cpp/view_manager.h" | 10 #include "mojo/services/view_manager/public/cpp/view_manager.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 window_manager_app_->Initialize(impl); | 38 window_manager_app_->Initialize(impl); |
| 39 } | 39 } |
| 40 bool ConfigureIncomingConnection( | 40 bool ConfigureIncomingConnection( |
| 41 mojo::ApplicationConnection* connection) override { | 41 mojo::ApplicationConnection* connection) override { |
| 42 window_manager_app_->ConfigureIncomingConnection(connection); | 42 window_manager_app_->ConfigureIncomingConnection(connection); |
| 43 return true; | 43 return true; |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Overridden from ViewManagerDelegate: | 46 // Overridden from ViewManagerDelegate: |
| 47 void OnEmbed(View* root, | 47 void OnEmbed(View* root, |
| 48 mojo::ServiceProviderImpl* exported_services, | 48 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 49 scoped_ptr<mojo::ServiceProvider> imported_services) override { | 49 mojo::ServiceProviderPtr exposed_services) override { |
| 50 root_ = root; | 50 root_ = root; |
| 51 } | 51 } |
| 52 void OnViewManagerDisconnected(ViewManager* view_manager) override {} | 52 void OnViewManagerDisconnected(ViewManager* view_manager) override {} |
| 53 | 53 |
| 54 // Overridden from WindowManagerDelegate: | 54 // Overridden from WindowManagerDelegate: |
| 55 void Embed( | 55 void Embed(const mojo::String& url, |
| 56 const mojo::String& url, | 56 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 57 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) override { | 57 mojo::ServiceProviderPtr exposed_services) override { |
| 58 DCHECK(root_); | 58 DCHECK(root_); |
| 59 View* view = root_->view_manager()->CreateView(); | 59 View* view = root_->view_manager()->CreateView(); |
| 60 root_->AddChild(view); | 60 root_->AddChild(view); |
| 61 | 61 |
| 62 mojo::Rect rect; | 62 mojo::Rect rect; |
| 63 rect.x = rect.y = window_offset_; | 63 rect.x = rect.y = window_offset_; |
| 64 rect.width = rect.height = 100; | 64 rect.width = rect.height = 100; |
| 65 view->SetBounds(rect); | 65 view->SetBounds(rect); |
| 66 window_offset_ += 10; | 66 window_offset_ += 10; |
| 67 | 67 |
| 68 view->SetVisible(true); | 68 view->SetVisible(true); |
| 69 view->Embed(url, service_provider.Pass()); | 69 view->Embed(url, services.Pass(), exposed_services.Pass()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 scoped_ptr<WindowManagerApp> window_manager_app_; | 72 scoped_ptr<WindowManagerApp> window_manager_app_; |
| 73 | 73 |
| 74 View* root_; | 74 View* root_; |
| 75 int window_offset_; | 75 int window_offset_; |
| 76 | 76 |
| 77 MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager); | 77 MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace window_manager | 80 } // namespace window_manager |
| 81 | 81 |
| 82 MojoResult MojoMain(MojoHandle shell_handle) { | 82 MojoResult MojoMain(MojoHandle shell_handle) { |
| 83 mojo::ApplicationRunnerChromium runner( | 83 mojo::ApplicationRunnerChromium runner( |
| 84 new window_manager::DefaultWindowManager); | 84 new window_manager::DefaultWindowManager); |
| 85 return runner.Run(shell_handle); | 85 return runner.Run(shell_handle); |
| 86 } | 86 } |
| OLD | NEW |