summaryrefslogtreecommitdiffstats
path: root/mojo/shell/run.cc
blob: 7cd120016f2e1e5929dc899ef0578e6517f67e3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/shell/run.h"

#include "base/logging.h"
#include "mojo/service_manager/service_manager.h"
#include "mojo/shell/context.h"
#include "mojo/shell/keep_alive.h"

namespace mojo {
namespace shell {

class StubServiceProvider : public InterfaceImpl<ServiceProvider> {
 private:
  virtual void ConnectToService(const mojo::String& service_name,
                                ScopedMessagePipeHandle client_handle)
      MOJO_OVERRIDE {
  }
};


void Run(Context* context, const std::vector<GURL>& app_urls) {
  KeepAlive keep_alive(context);

  if (app_urls.empty()) {
    LOG(ERROR) << "No app path specified";
    return;
  }

  for (std::vector<GURL>::const_iterator it = app_urls.begin();
       it != app_urls.end();
       ++it) {
    // TODO(davemoore): These leak...need refs to them.
    StubServiceProvider* stub_sp = new StubServiceProvider;
    ServiceProviderPtr spp;
    BindToProxy(stub_sp, &spp);

    context->service_manager()->ConnectToApplication(
        *it, GURL(), spp.Pass());
  }
}

}  // namespace shell
}  // namespace mojo