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/launcher/launcher_app.h" | 5 #include "services/ui/launcher/launcher_app.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 service_provider_impl->AddService<Launcher>( | 98 service_provider_impl->AddService<Launcher>( |
99 [this](const mojo::ConnectionContext& connection_context, | 99 [this](const mojo::ConnectionContext& connection_context, |
100 mojo::InterfaceRequest<Launcher> launcher_request) { | 100 mojo::InterfaceRequest<Launcher> launcher_request) { |
101 bindings_.AddBinding(this, launcher_request.Pass()); | 101 bindings_.AddBinding(this, launcher_request.Pass()); |
102 }); | 102 }); |
103 } | 103 } |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 void LauncherApp::Launch(const mojo::String& application_url) { | 107 void LauncherApp::Launch(const mojo::String& application_url) { |
| 108 DVLOG(1) << "Launching " << application_url; |
| 109 |
| 110 mojo::NativeViewportPtr viewport; |
| 111 mojo::ConnectToService(app_impl_->shell(), "mojo:native_viewport_service", |
| 112 GetProxy(&viewport)); |
| 113 |
| 114 mojo::ui::ViewProviderPtr view_provider; |
| 115 mojo::ConnectToService(app_impl_->shell(), application_url, |
| 116 GetProxy(&view_provider)); |
| 117 |
| 118 LaunchInternal(viewport.Pass(), view_provider.Pass()); |
| 119 } |
| 120 void LauncherApp::LaunchOnViewport( |
| 121 mojo::InterfaceHandle<mojo::NativeViewport> viewport, |
| 122 mojo::InterfaceHandle<mojo::ui::ViewProvider> view_provider) { |
| 123 LaunchInternal(mojo::NativeViewportPtr::Create(viewport.Pass()), |
| 124 mojo::ui::ViewProviderPtr::Create(view_provider.Pass())); |
| 125 } |
| 126 |
| 127 void LauncherApp::LaunchInternal(mojo::NativeViewportPtr viewport, |
| 128 mojo::ui::ViewProviderPtr view_provider) { |
108 uint32_t next_id = next_id_++; | 129 uint32_t next_id = next_id_++; |
109 std::unique_ptr<LaunchInstance> instance(new LaunchInstance( | 130 std::unique_ptr<LaunchInstance> instance(new LaunchInstance( |
110 app_impl_, application_url, compositor_.get(), view_manager_.get(), | 131 app_impl_, viewport.Pass(), view_provider.Pass(), compositor_.get(), |
111 base::Bind(&LauncherApp::OnLaunchTermination, base::Unretained(this), | 132 view_manager_.get(), base::Bind(&LauncherApp::OnLaunchTermination, |
112 next_id))); | 133 base::Unretained(this), next_id))); |
113 instance->Launch(); | 134 instance->Launch(); |
114 launch_instances_.emplace(next_id, std::move(instance)); | 135 launch_instances_.emplace(next_id, std::move(instance)); |
115 } | 136 } |
116 | 137 |
117 void LauncherApp::OnLaunchTermination(uint32_t id) { | 138 void LauncherApp::OnLaunchTermination(uint32_t id) { |
118 launch_instances_.erase(id); | 139 launch_instances_.erase(id); |
119 if (launch_instances_.empty()) { | 140 if (launch_instances_.empty()) { |
120 app_impl_->Terminate(); | 141 app_impl_->Terminate(); |
121 } | 142 } |
122 } | 143 } |
123 | 144 |
124 void LauncherApp::OnCompositorConnectionError() { | 145 void LauncherApp::OnCompositorConnectionError() { |
125 LOG(ERROR) << "Exiting due to compositor connection error."; | 146 LOG(ERROR) << "Exiting due to compositor connection error."; |
126 app_impl_->Terminate(); | 147 app_impl_->Terminate(); |
127 } | 148 } |
128 | 149 |
129 void LauncherApp::OnViewManagerConnectionError() { | 150 void LauncherApp::OnViewManagerConnectionError() { |
130 LOG(ERROR) << "Exiting due to view manager connection error."; | 151 LOG(ERROR) << "Exiting due to view manager connection error."; |
131 app_impl_->Terminate(); | 152 app_impl_->Terminate(); |
132 } | 153 } |
133 | 154 |
134 void LauncherApp::OnViewAssociateConnectionError() { | 155 void LauncherApp::OnViewAssociateConnectionError() { |
135 LOG(ERROR) << "Exiting due to view associate connection error."; | 156 LOG(ERROR) << "Exiting due to view associate connection error."; |
136 app_impl_->Terminate(); | 157 app_impl_->Terminate(); |
137 }; | 158 }; |
138 | 159 |
139 } // namespace launcher | 160 } // namespace launcher |
OLD | NEW |