| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/view_manager/view_manager_app.h" | 5 #include "services/ui/view_manager/view_manager_app.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // Connect to compositor. | 38 // Connect to compositor. |
| 39 mojo::gfx::composition::CompositorPtr compositor; | 39 mojo::gfx::composition::CompositorPtr compositor; |
| 40 mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service", | 40 mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service", |
| 41 GetProxy(&compositor)); | 41 GetProxy(&compositor)); |
| 42 compositor.set_connection_error_handler(base::Bind( | 42 compositor.set_connection_error_handler(base::Bind( |
| 43 &ViewManagerApp::OnCompositorConnectionError, base::Unretained(this))); | 43 &ViewManagerApp::OnCompositorConnectionError, base::Unretained(this))); |
| 44 | 44 |
| 45 // Create the registry. | 45 // Create the registry. |
| 46 registry_.reset(new ViewRegistry(compositor.Pass())); | 46 registry_.reset(new ViewRegistry(compositor.Pass())); |
| 47 | |
| 48 // Connect to associates. | |
| 49 // TODO(jeffbrown): Consider making the launcher register associates | |
| 50 // with the view manager or perhaps per view tree. | |
| 51 std::vector<std::string> associate_urls = command_line->GetArgs(); | |
| 52 if (associate_urls.empty()) { | |
| 53 // TODO(jeffbrown): Replace this hardcoded list. | |
| 54 associate_urls.push_back("mojo:input_manager_service"); | |
| 55 } | |
| 56 registry_->ConnectAssociates( | |
| 57 app_impl_, associate_urls, | |
| 58 base::Bind(&ViewManagerApp::OnAssociateConnectionError, | |
| 59 base::Unretained(this))); | |
| 60 } | 47 } |
| 61 | 48 |
| 62 bool ViewManagerApp::ConfigureIncomingConnection( | 49 bool ViewManagerApp::ConfigureIncomingConnection( |
| 63 mojo::ServiceProviderImpl* service_provider_impl) { | 50 mojo::ServiceProviderImpl* service_provider_impl) { |
| 64 service_provider_impl->AddService<mojo::ui::ViewManager>([this]( | 51 service_provider_impl->AddService<mojo::ui::ViewManager>([this]( |
| 65 const mojo::ConnectionContext& connection_context, | 52 const mojo::ConnectionContext& connection_context, |
| 66 mojo::InterfaceRequest<mojo::ui::ViewManager> view_manager_request) { | 53 mojo::InterfaceRequest<mojo::ui::ViewManager> view_manager_request) { |
| 67 DCHECK(registry_); | 54 DCHECK(registry_); |
| 68 view_managers_.AddBinding(new ViewManagerImpl(registry_.get()), | 55 view_managers_.AddBinding(new ViewManagerImpl(registry_.get()), |
| 69 view_manager_request.Pass()); | 56 view_manager_request.Pass()); |
| 70 }); | 57 }); |
| 71 return true; | 58 return true; |
| 72 } | 59 } |
| 73 | 60 |
| 74 void ViewManagerApp::OnCompositorConnectionError() { | 61 void ViewManagerApp::OnCompositorConnectionError() { |
| 75 LOG(ERROR) << "Exiting due to compositor connection error."; | 62 LOG(ERROR) << "Exiting due to compositor connection error."; |
| 76 Shutdown(); | 63 Shutdown(); |
| 77 } | 64 } |
| 78 | 65 |
| 79 void ViewManagerApp::OnAssociateConnectionError(const std::string& url) { | |
| 80 LOG(ERROR) << "Exiting due to view associate connection error: url=" << url; | |
| 81 Shutdown(); | |
| 82 } | |
| 83 | |
| 84 void ViewManagerApp::Shutdown() { | 66 void ViewManagerApp::Shutdown() { |
| 85 app_impl_->Terminate(); | 67 app_impl_->Terminate(); |
| 86 } | 68 } |
| 87 | 69 |
| 88 } // namespace view_manager | 70 } // namespace view_manager |
| OLD | NEW |