| 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/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "mojo/application/application_runner_chromium.h" | 10 #include "mojo/application/application_runner_chromium.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 bool LauncherApp::ConfigureIncomingConnection( | 39 bool LauncherApp::ConfigureIncomingConnection( |
| 40 mojo::ApplicationConnection* connection) { | 40 mojo::ApplicationConnection* connection) { |
| 41 // Only present the launcher interface to the shell. | 41 // Only present the launcher interface to the shell. |
| 42 if (connection->GetRemoteApplicationURL().empty()) { | 42 if (connection->GetRemoteApplicationURL().empty()) { |
| 43 connection->AddService<Launcher>(this); | 43 connection->AddService<Launcher>(this); |
| 44 } | 44 } |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void LauncherApp::Create(mojo::ApplicationConnection* connection, | 48 void LauncherApp::Create(const mojo::ConnectionContext& connection_context, |
| 49 mojo::InterfaceRequest<Launcher> request) { | 49 mojo::InterfaceRequest<Launcher> request) { |
| 50 bindings_.AddBinding(this, request.Pass()); | 50 bindings_.AddBinding(this, request.Pass()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void LauncherApp::Launch(const mojo::String& application_url) { | 53 void LauncherApp::Launch(const mojo::String& application_url) { |
| 54 uint32_t next_id = next_id_++; | 54 uint32_t next_id = next_id_++; |
| 55 std::unique_ptr<LaunchInstance> instance(new LaunchInstance( | 55 std::unique_ptr<LaunchInstance> instance(new LaunchInstance( |
| 56 app_impl_, application_url, base::Bind(&LauncherApp::OnLaunchTermination, | 56 app_impl_, application_url, base::Bind(&LauncherApp::OnLaunchTermination, |
| 57 base::Unretained(this), next_id))); | 57 base::Unretained(this), next_id))); |
| 58 instance->Launch(); | 58 instance->Launch(); |
| 59 launch_instances_.emplace(next_id, std::move(instance)); | 59 launch_instances_.emplace(next_id, std::move(instance)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void LauncherApp::OnLaunchTermination(uint32_t id) { | 62 void LauncherApp::OnLaunchTermination(uint32_t id) { |
| 63 launch_instances_.erase(id); | 63 launch_instances_.erase(id); |
| 64 if (launch_instances_.empty()) { | 64 if (launch_instances_.empty()) { |
| 65 app_impl_->Terminate(); | 65 app_impl_->Terminate(); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace launcher | 69 } // namespace launcher |
| OLD | NEW |