Chromium Code Reviews| 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; | |
|
ppi
2016/05/30 09:21:00
Need a space after "Launching"
qsr
2016/05/30 09:37:57
Done.
| |
| 109 | |
| 110 mojo::ui::ViewProviderPtr view_provider; | |
| 111 mojo::ConnectToService(app_impl_->shell(), application_url, | |
| 112 GetProxy(&view_provider)); | |
| 113 | |
| 114 LaunchInternal(mojo::NativeViewportPtr(), view_provider.Pass()); | |
|
ppi
2016/05/30 09:21:00
Should we get the native viewport from mojo:native
qsr
2016/05/30 09:37:57
Done.
| |
| 115 } | |
| 116 void LauncherApp::LaunchOnViewport( | |
| 117 mojo::InterfaceHandle<mojo::NativeViewport> viewport, | |
| 118 mojo::InterfaceHandle<mojo::ui::ViewProvider> view_provider) { | |
| 119 LaunchInternal(mojo::NativeViewportPtr::Create(viewport.Pass()), | |
| 120 mojo::ui::ViewProviderPtr::Create(view_provider.Pass())); | |
| 121 } | |
| 122 | |
| 123 void LauncherApp::LaunchInternal(mojo::NativeViewportPtr viewport, | |
| 124 mojo::ui::ViewProviderPtr view_provider) { | |
| 108 uint32_t next_id = next_id_++; | 125 uint32_t next_id = next_id_++; |
| 109 std::unique_ptr<LaunchInstance> instance(new LaunchInstance( | 126 std::unique_ptr<LaunchInstance> instance(new LaunchInstance( |
| 110 app_impl_, application_url, compositor_.get(), view_manager_.get(), | 127 app_impl_, viewport.Pass(), view_provider.Pass(), compositor_.get(), |
| 111 base::Bind(&LauncherApp::OnLaunchTermination, base::Unretained(this), | 128 view_manager_.get(), base::Bind(&LauncherApp::OnLaunchTermination, |
| 112 next_id))); | 129 base::Unretained(this), next_id))); |
| 113 instance->Launch(); | 130 instance->Launch(); |
| 114 launch_instances_.emplace(next_id, std::move(instance)); | 131 launch_instances_.emplace(next_id, std::move(instance)); |
| 115 } | 132 } |
| 116 | 133 |
| 117 void LauncherApp::OnLaunchTermination(uint32_t id) { | 134 void LauncherApp::OnLaunchTermination(uint32_t id) { |
| 118 launch_instances_.erase(id); | 135 launch_instances_.erase(id); |
| 119 if (launch_instances_.empty()) { | 136 if (launch_instances_.empty()) { |
| 120 app_impl_->Terminate(); | 137 app_impl_->Terminate(); |
| 121 } | 138 } |
| 122 } | 139 } |
| 123 | 140 |
| 124 void LauncherApp::OnCompositorConnectionError() { | 141 void LauncherApp::OnCompositorConnectionError() { |
| 125 LOG(ERROR) << "Exiting due to compositor connection error."; | 142 LOG(ERROR) << "Exiting due to compositor connection error."; |
| 126 app_impl_->Terminate(); | 143 app_impl_->Terminate(); |
| 127 } | 144 } |
| 128 | 145 |
| 129 void LauncherApp::OnViewManagerConnectionError() { | 146 void LauncherApp::OnViewManagerConnectionError() { |
| 130 LOG(ERROR) << "Exiting due to view manager connection error."; | 147 LOG(ERROR) << "Exiting due to view manager connection error."; |
| 131 app_impl_->Terminate(); | 148 app_impl_->Terminate(); |
| 132 } | 149 } |
| 133 | 150 |
| 134 void LauncherApp::OnViewAssociateConnectionError() { | 151 void LauncherApp::OnViewAssociateConnectionError() { |
| 135 LOG(ERROR) << "Exiting due to view associate connection error."; | 152 LOG(ERROR) << "Exiting due to view associate connection error."; |
| 136 app_impl_->Terminate(); | 153 app_impl_->Terminate(); |
| 137 }; | 154 }; |
| 138 | 155 |
| 139 } // namespace launcher | 156 } // namespace launcher |
| OLD | NEW |