| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "examples/recipes/window_manager/window_manager.h" | 7 #include "examples/recipes/window_manager/window_manager.h" |
| 8 #include "mojo/application/application_runner_chromium.h" | 8 #include "mojo/application/application_runner_chromium.h" |
| 9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/application/application_delegate.h" | 10 #include "mojo/public/cpp/application/application_delegate.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 : window_manager_app_( | 28 : window_manager_app_( |
| 29 new ::window_manager::WindowManagerApp(this, this)) {} | 29 new ::window_manager::WindowManagerApp(this, this)) {} |
| 30 ~Main() override {} | 30 ~Main() override {} |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // Overridden from mojo::ApplicationDelegate: | 33 // Overridden from mojo::ApplicationDelegate: |
| 34 void Initialize(mojo::ApplicationImpl* impl) override { | 34 void Initialize(mojo::ApplicationImpl* impl) override { |
| 35 window_manager_app_->Initialize(impl); | 35 window_manager_app_->Initialize(impl); |
| 36 | 36 |
| 37 for (size_t i = 1; i < impl->args().size(); ++i) { | 37 for (size_t i = 1; i < impl->args().size(); ++i) { |
| 38 mojo::InterfaceRequest<mojo::ServiceProvider> empty_request; | 38 window_manager_app_->Embed(impl->args()[i], nullptr, nullptr); |
| 39 window_manager_app_->Embed(impl->args()[i], empty_request.Pass()); | |
| 40 } | 39 } |
| 41 } | 40 } |
| 42 bool ConfigureIncomingConnection( | 41 bool ConfigureIncomingConnection( |
| 43 mojo::ApplicationConnection* connection) override { | 42 mojo::ApplicationConnection* connection) override { |
| 44 window_manager_app_->ConfigureIncomingConnection(connection); | 43 window_manager_app_->ConfigureIncomingConnection(connection); |
| 45 return true; | 44 return true; |
| 46 } | 45 } |
| 47 | 46 |
| 48 // Overridden from mojo::ViewManagerDelegate: | 47 // Overridden from mojo::ViewManagerDelegate: |
| 49 void OnEmbed( | 48 void OnEmbed(mojo::View* root, |
| 50 mojo::View* root, | 49 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 51 mojo::ServiceProviderImpl* exported_services, | 50 mojo::ServiceProviderPtr exposed_services) override { |
| 52 scoped_ptr<mojo::ServiceProvider> remote_service_provider) override { | |
| 53 window_manager_.reset(new WindowManager(root)); | 51 window_manager_.reset(new WindowManager(root)); |
| 54 | 52 |
| 55 window_manager_app_->InitFocus( | 53 window_manager_app_->InitFocus( |
| 56 make_scoped_ptr(new ::window_manager::BasicFocusRules(root))); | 54 make_scoped_ptr(new ::window_manager::BasicFocusRules(root))); |
| 57 } | 55 } |
| 58 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override { | 56 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override { |
| 59 // TODO(sky): quit here? | 57 // TODO(sky): quit here? |
| 60 } | 58 } |
| 61 | 59 |
| 62 // Overridden from ::window_manager::WindowManagerDelegate: | 60 // Overridden from ::window_manager::WindowManagerDelegate: |
| 63 void Embed( | 61 void Embed(const mojo::String& url, |
| 64 const mojo::String& url, | 62 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 65 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) override { | 63 mojo::ServiceProviderPtr exposed_services) override { |
| 66 DCHECK(window_manager_.get()); | 64 DCHECK(window_manager_.get()); |
| 67 mojo::View* view = window_manager_->Create(); | 65 mojo::View* view = window_manager_->Create(); |
| 68 view->Embed(url, service_provider.Pass()); | 66 view->Embed(url, services.Pass(), exposed_services.Pass()); |
| 69 } | 67 } |
| 70 | 68 |
| 71 scoped_ptr<::window_manager::WindowManagerApp> window_manager_app_; | 69 scoped_ptr<::window_manager::WindowManagerApp> window_manager_app_; |
| 72 scoped_ptr<WindowManager> window_manager_; | 70 scoped_ptr<WindowManager> window_manager_; |
| 73 | 71 |
| 74 DISALLOW_COPY_AND_ASSIGN(Main); | 72 DISALLOW_COPY_AND_ASSIGN(Main); |
| 75 }; | 73 }; |
| 76 | 74 |
| 77 } // window_manager | 75 } // window_manager |
| 78 } // recipes | 76 } // recipes |
| 79 | 77 |
| 80 MojoResult MojoMain(MojoHandle shell_handle) { | 78 MojoResult MojoMain(MojoHandle shell_handle) { |
| 81 mojo::ApplicationRunnerChromium runner(new recipes::window_manager::Main); | 79 mojo::ApplicationRunnerChromium runner(new recipes::window_manager::Main); |
| 82 return runner.Run(shell_handle); | 80 return runner.Run(shell_handle); |
| 83 } | 81 } |
| OLD | NEW |