| 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 "mojo/services/view_manager/public/cpp/view_manager.h" | 5 #include "mojo/services/view_manager/public/cpp/view_manager.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "mojo/application_manager/application_manager.h" | 10 #include "mojo/application_manager/application_manager.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 void QuitRunLoop() { | 42 void QuitRunLoop() { |
| 43 current_run_loop->Quit(); | 43 current_run_loop->Quit(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 class ConnectApplicationLoader : public ApplicationLoader, | 46 class ConnectApplicationLoader : public ApplicationLoader, |
| 47 public ApplicationDelegate, | 47 public ApplicationDelegate, |
| 48 public ViewManagerDelegate { | 48 public ViewManagerDelegate { |
| 49 public: | 49 public: |
| 50 typedef base::Callback<void(ViewManager*, View*)> LoadedCallback; | 50 typedef base::Callback<void(View*)> LoadedCallback; |
| 51 | 51 |
| 52 explicit ConnectApplicationLoader(const LoadedCallback& callback) | 52 explicit ConnectApplicationLoader(const LoadedCallback& callback) |
| 53 : callback_(callback) {} | 53 : callback_(callback) {} |
| 54 ~ConnectApplicationLoader() override {} | 54 ~ConnectApplicationLoader() override {} |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // Overridden from ApplicationDelegate: | 57 // Overridden from ApplicationDelegate: |
| 58 void Initialize(ApplicationImpl* app) override { | 58 void Initialize(ApplicationImpl* app) override { |
| 59 view_manager_client_factory_.reset( | 59 view_manager_client_factory_.reset( |
| 60 new ViewManagerClientFactory(app->shell(), this)); | 60 new ViewManagerClientFactory(app->shell(), this)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 void OnApplicationError(ApplicationManager* manager, | 74 void OnApplicationError(ApplicationManager* manager, |
| 75 const GURL& url) override {} | 75 const GURL& url) override {} |
| 76 | 76 |
| 77 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 77 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
| 78 connection->AddService(view_manager_client_factory_.get()); | 78 connection->AddService(view_manager_client_factory_.get()); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Overridden from ViewManagerDelegate: | 82 // Overridden from ViewManagerDelegate: |
| 83 void OnEmbed(ViewManager* view_manager, | 83 void OnEmbed(View* root, |
| 84 View* root, | |
| 85 ServiceProviderImpl* exported_services, | 84 ServiceProviderImpl* exported_services, |
| 86 scoped_ptr<ServiceProvider> imported_services) override { | 85 scoped_ptr<ServiceProvider> imported_services) override { |
| 87 callback_.Run(view_manager, root); | 86 callback_.Run(root); |
| 88 } | 87 } |
| 89 void OnViewManagerDisconnected(ViewManager* view_manager) override {} | 88 void OnViewManagerDisconnected(ViewManager* view_manager) override {} |
| 90 | 89 |
| 91 ScopedVector<ApplicationImpl> apps_; | 90 ScopedVector<ApplicationImpl> apps_; |
| 92 LoadedCallback callback_; | 91 LoadedCallback callback_; |
| 93 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; | 92 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; |
| 94 | 93 |
| 95 DISALLOW_COPY_AND_ASSIGN(ConnectApplicationLoader); | 94 DISALLOW_COPY_AND_ASSIGN(ConnectApplicationLoader); |
| 96 }; | 95 }; |
| 97 | 96 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 new ConnectApplicationLoader(ready_callback)), | 309 new ConnectApplicationLoader(ready_callback)), |
| 311 GURL(kWindowManagerURL)); | 310 GURL(kWindowManagerURL)); |
| 312 test_helper_.SetLoaderForURL( | 311 test_helper_.SetLoaderForURL( |
| 313 scoped_ptr<ApplicationLoader>( | 312 scoped_ptr<ApplicationLoader>( |
| 314 new ConnectApplicationLoader(ready_callback)), | 313 new ConnectApplicationLoader(ready_callback)), |
| 315 GURL(kEmbeddedApp1URL)); | 314 GURL(kEmbeddedApp1URL)); |
| 316 | 315 |
| 317 // TODO(sky): resolve this. Need to establish initial connection. | 316 // TODO(sky): resolve this. Need to establish initial connection. |
| 318 } | 317 } |
| 319 | 318 |
| 320 void OnViewManagerLoaded(ViewManager* view_manager, View* root) { | 319 void OnViewManagerLoaded(View* root) { |
| 321 loaded_view_manager_ = view_manager; | 320 loaded_view_manager_ = root->view_manager(); |
| 322 connect_loop_->Quit(); | 321 connect_loop_->Quit(); |
| 323 } | 322 } |
| 324 | 323 |
| 325 void RunRunLoop() { | 324 void RunRunLoop() { |
| 326 base::RunLoop run_loop; | 325 base::RunLoop run_loop; |
| 327 connect_loop_ = &run_loop; | 326 connect_loop_ = &run_loop; |
| 328 connect_loop_->Run(); | 327 connect_loop_->Run(); |
| 329 connect_loop_ = NULL; | 328 connect_loop_ = NULL; |
| 330 } | 329 } |
| 331 | 330 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 643 |
| 645 // TODO(beng): tests for focus: | 644 // TODO(beng): tests for focus: |
| 646 // - focus between two views known to a connection | 645 // - focus between two views known to a connection |
| 647 // - focus between views unknown to one of the connections. | 646 // - focus between views unknown to one of the connections. |
| 648 // - focus between views unknown to either connection. | 647 // - focus between views unknown to either connection. |
| 649 | 648 |
| 650 // TODO(sky): need test of root being destroyed with existing views. See | 649 // TODO(sky): need test of root being destroyed with existing views. See |
| 651 // 434555 for specific case. | 650 // 434555 for specific case. |
| 652 | 651 |
| 653 } // namespace mojo | 652 } // namespace mojo |
| OLD | NEW |