Index: services/ui/launcher/launch_instance.cc |
diff --git a/services/ui/launcher/launch_instance.cc b/services/ui/launcher/launch_instance.cc |
index c2aa2cbf26146038d47dec8fd4d115f81db39e97..27dfae09d43816ce385b122eb54b03eee7374c5a 100644 |
--- a/services/ui/launcher/launch_instance.cc |
+++ b/services/ui/launcher/launch_instance.cc |
@@ -4,8 +4,10 @@ |
#include "services/ui/launcher/launch_instance.h" |
+#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/logging.h" |
+#include "base/strings/string_split.h" |
#include "base/trace_event/trace_event.h" |
#include "mojo/application/application_runner_chromium.h" |
#include "mojo/public/c/system/main.h" |
@@ -18,9 +20,11 @@ namespace launcher { |
LaunchInstance::LaunchInstance(mojo::ApplicationImpl* app_impl, |
const std::string& app_url, |
+ const std::string& view_associate_urls, |
const base::Closure& shutdown_callback) |
: app_impl_(app_impl), |
app_url_(app_url), |
+ view_associate_urls_(view_associate_urls), |
shutdown_callback_(shutdown_callback), |
viewport_event_dispatcher_binding_(this) {} |
@@ -40,6 +44,35 @@ void LaunchInstance::Launch() { |
view_manager_.set_connection_error_handler(base::Bind( |
&LaunchInstance::OnViewManagerConnectionError, base::Unretained(this))); |
+ // Connect to ViewAssociates. |
+ std::vector<std::string> associate_urls = SplitString( |
+ view_associate_urls_, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); |
+ if (associate_urls.empty()) { |
+ // TODO(jeffbrown): Replace this hardcoded list. |
+ associate_urls.push_back("mojo:input_manager_service"); |
+ } |
+ |
+ view_associate_owners_.reserve(associate_urls.size()); |
+ |
+ for (const auto& url : associate_urls) { |
+ // Connect to the ViewAssociate. |
+ DVLOG(2) << "Connecting to ViewAssociate " << url; |
+ mojo::ui::ViewAssociatePtr view_associate; |
+ mojo::ConnectToService(app_impl_->shell(), url, GetProxy(&view_associate)); |
+ |
+ // Wire up the associate to the ViewManager. |
+ mojo::ui::ViewAssociateOwnerPtr view_associate_owner; |
+ view_manager_->RegisterViewAssociate(view_associate.Pass(), |
+ GetProxy(&view_associate_owner), url); |
+ |
+ view_associate_owner.set_connection_error_handler( |
+ base::Bind(&LaunchInstance::OnViewAssociateConnectionError, |
+ base::Unretained(this))); |
+ |
+ view_associate_owners_.push_back(view_associate_owner.Pass()); |
+ } |
+ view_manager_->FinishedRegisteringViewAssociates(); |
+ |
InitViewport(); |
mojo::ui::ViewProviderPtr client_view_provider; |
@@ -50,6 +83,11 @@ void LaunchInstance::Launch() { |
nullptr); |
} |
+void LaunchInstance::OnViewAssociateConnectionError() { |
+ LOG(ERROR) << "Exiting due to view associate connection error."; |
+ shutdown_callback_.Run(); |
+}; |
+ |
void LaunchInstance::OnCompositorConnectionError() { |
LOG(ERROR) << "Exiting due to compositor connection error."; |
shutdown_callback_.Run(); |