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