Index: services/ui/view_manager/view_manager_app.cc |
diff --git a/services/ui/view_manager/view_manager_app.cc b/services/ui/view_manager/view_manager_app.cc |
index 2190590211927da938ae1b2e5c4282d0938a5cc6..589993192746eed4cec2ba2d23094321ab5e83a3 100644 |
--- a/services/ui/view_manager/view_manager_app.cc |
+++ b/services/ui/view_manager/view_manager_app.cc |
@@ -2,13 +2,19 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "services/ui/view_manager/view_manager_app.h" |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/command_line.h" |
+#include "base/logging.h" |
#include "base/trace_event/trace_event.h" |
#include "mojo/application/application_runner_chromium.h" |
#include "mojo/common/tracing_impl.h" |
#include "mojo/public/c/system/main.h" |
#include "mojo/public/cpp/application/application_connection.h" |
#include "mojo/public/cpp/application/application_impl.h" |
-#include "services/ui/view_manager/view_manager_app.h" |
#include "services/ui/view_manager/view_manager_impl.h" |
namespace view_manager { |
@@ -19,13 +25,34 @@ ViewManagerApp::~ViewManagerApp() {} |
void ViewManagerApp::Initialize(mojo::ApplicationImpl* app_impl) { |
app_impl_ = app_impl; |
- tracing_.Initialize(app_impl); |
- mojo::SurfacePtr surfaces; |
- app_impl->ConnectToService("mojo:surfaces_service", &surfaces); |
- surface_manager_.reset(new SurfaceManager(surfaces.Pass())); |
+ auto command_line = base::CommandLine::ForCurrentProcess(); |
+ command_line->InitFromArgv(app_impl_->args()); |
+ logging::LoggingSettings settings; |
+ settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
+ logging::InitLogging(settings); |
+ |
+ tracing_.Initialize(app_impl_); |
+ |
+ // Connect to compositor. |
+ mojo::gfx::composition::CompositorPtr compositor; |
+ app_impl_->ConnectToService("mojo:compositor_service", &compositor); |
+ compositor.set_connection_error_handler(base::Bind( |
+ &ViewManagerApp::OnCompositorConnectionError, base::Unretained(this))); |
+ |
+ // Create the registry. |
+ registry_.reset(new ViewRegistry(compositor.Pass())); |
- registry_.reset(new ViewRegistry(surface_manager_.get())); |
+ // Connect to associates. |
+ std::vector<std::string> associate_urls = command_line->GetArgs(); |
abarth
2016/01/10 01:42:55
If you flip the registration of these associates,
jeffbrown
2016/01/26 05:59:13
Command-line arguments are substituting for the la
|
+ if (associate_urls.empty()) { |
+ // TODO(jeffbrown): Replace this hardcoded list. |
+ associate_urls.push_back("mojo:input_manager_service"); |
+ } |
+ registry_->ConnectAssociates( |
+ app_impl_, associate_urls, |
+ base::Bind(&ViewManagerApp::OnAssociateConnectionError, |
+ base::Unretained(this))); |
} |
bool ViewManagerApp::ConfigureIncomingConnection( |
@@ -37,8 +64,23 @@ bool ViewManagerApp::ConfigureIncomingConnection( |
void ViewManagerApp::Create( |
mojo::ApplicationConnection* connection, |
mojo::InterfaceRequest<mojo::ui::ViewManager> request) { |
- view_managers.AddBinding(new ViewManagerImpl(registry_.get()), |
- request.Pass()); |
+ DCHECK(registry_); |
+ view_managers_.AddBinding(new ViewManagerImpl(registry_.get()), |
+ request.Pass()); |
+} |
+ |
+void ViewManagerApp::OnCompositorConnectionError() { |
+ LOG(ERROR) << "Exiting due to compositor connection error."; |
+ Shutdown(); |
+} |
+ |
+void ViewManagerApp::OnAssociateConnectionError(const std::string& url) { |
+ LOG(ERROR) << "Exiting due to view associate connection error: url=" << url; |
+ Shutdown(); |
+} |
+ |
+void ViewManagerApp::Shutdown() { |
+ app_impl_->Terminate(); |
} |
} // namespace view_manager |