Clang roll script: fix error when GYP_DEFINES isn't defined
[chromium-blink-merge.git] / mojo / shell / run.cc
blob5e0f2145079c67ff5efbd8448a2d3b0df18b6fab
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.
5 #include "mojo/shell/run.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h"
10 #include "mojo/shell/context.h"
11 #include "mojo/shell/service_manager.h"
12 #include "mojo/shell/switches.h"
13 #include "url/gurl.h"
15 namespace mojo {
16 namespace shell {
18 void Run(Context* context) {
19 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
20 CommandLine::StringVector args = command_line.GetArgs();
22 if (args.empty()) {
23 LOG(ERROR) << "No app path specified.";
24 base::MessageLoop::current()->Quit();
25 return;
28 for (CommandLine::StringVector::const_iterator it = args.begin();
29 it != args.end(); ++it) {
30 GURL url(*it);
31 if (url.scheme() == "mojo" && !command_line.HasSwitch(switches::kOrigin)) {
32 LOG(ERROR) << "mojo: url passed with no --origin specified.";
33 base::MessageLoop::current()->Quit();
34 return;
36 ScopedMessagePipeHandle no_handle;
37 context->service_manager()->Connect(GURL(*it), no_handle.Pass());
39 // TODO(davemoore): Currently we leak |service_manager|.
42 } // namespace shell
43 } // namespace mojo