| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/shell/run.h" | 5 #include "mojo/shell/run.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/application_manager/application_manager.h" | 8 #include "mojo/application_manager/application_manager.h" |
| 9 #include "mojo/shell/context.h" | 9 #include "mojo/shell/context.h" |
| 10 #include "mojo/shell/keep_alive.h" | |
| 11 | 10 |
| 12 namespace mojo { | 11 namespace mojo { |
| 13 namespace shell { | 12 namespace shell { |
| 14 | 13 |
| 15 class StubServiceProvider : public InterfaceImpl<ServiceProvider> { | 14 class StubServiceProvider : public InterfaceImpl<ServiceProvider> { |
| 16 private: | 15 private: |
| 17 virtual void ConnectToService(const mojo::String& service_name, | 16 virtual void ConnectToService(const mojo::String& service_name, |
| 18 ScopedMessagePipeHandle client_handle) | 17 ScopedMessagePipeHandle client_handle) |
| 19 MOJO_OVERRIDE { | 18 MOJO_OVERRIDE { |
| 20 } | 19 } |
| 21 }; | 20 }; |
| 22 | 21 |
| 23 | 22 |
| 24 void Run(Context* context, const std::vector<GURL>& app_urls) { | 23 void Run(Context* context, const std::vector<GURL>& app_urls) { |
| 25 KeepAlive keep_alive(context); | |
| 26 | |
| 27 if (app_urls.empty()) { | 24 if (app_urls.empty()) { |
| 28 LOG(ERROR) << "No app path specified"; | 25 LOG(ERROR) << "No app path specified"; |
| 29 return; | 26 return; |
| 30 } | 27 } |
| 31 | 28 |
| 32 for (std::vector<GURL>::const_iterator it = app_urls.begin(); | 29 for (std::vector<GURL>::const_iterator it = app_urls.begin(); |
| 33 it != app_urls.end(); | 30 it != app_urls.end(); |
| 34 ++it) { | 31 ++it) { |
| 35 // TODO(davemoore): These leak...need refs to them. | 32 // TODO(davemoore): These leak...need refs to them. |
| 36 StubServiceProvider* stub_sp = new StubServiceProvider; | 33 StubServiceProvider* stub_sp = new StubServiceProvider; |
| 37 ServiceProviderPtr spp; | 34 ServiceProviderPtr spp; |
| 38 BindToProxy(stub_sp, &spp); | 35 BindToProxy(stub_sp, &spp); |
| 39 | 36 |
| 40 context->application_manager()->ConnectToApplication( | 37 context->application_manager()->ConnectToApplication( |
| 41 *it, GURL(), spp.Pass()); | 38 *it, GURL(), spp.Pass()); |
| 42 } | 39 } |
| 43 } | 40 } |
| 44 | 41 |
| 45 } // namespace shell | 42 } // namespace shell |
| 46 } // namespace mojo | 43 } // namespace mojo |
| OLD | NEW |