| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/service_manager/service_manager.h" | 10 #include "mojo/service_manager/service_manager.h" |
| 11 #include "mojo/shell/context.h" | 11 #include "mojo/shell/context.h" |
| 12 #include "mojo/shell/keep_alive.h" | 12 #include "mojo/shell/keep_alive.h" |
| 13 #include "mojo/shell/switches.h" | 13 #include "mojo/shell/switches.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace shell { | 17 namespace shell { |
| 18 | 18 |
| 19 void Run(Context* context) { | 19 void Run(Context* context) { |
| 20 KeepAlive keep_alive(context); | 20 KeepAlive keep_alive(context); |
| 21 | 21 |
| 22 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 22 const base::CommandLine& command_line = |
| 23 CommandLine::StringVector args = command_line.GetArgs(); | 23 *base::CommandLine::ForCurrentProcess(); |
| 24 base::CommandLine::StringVector args = command_line.GetArgs(); |
| 24 | 25 |
| 25 if (args.empty()) { | 26 if (args.empty()) { |
| 26 LOG(ERROR) << "No app path specified."; | 27 LOG(ERROR) << "No app path specified."; |
| 27 return; | 28 return; |
| 28 } | 29 } |
| 29 | 30 |
| 30 for (CommandLine::StringVector::const_iterator it = args.begin(); | 31 for (base::CommandLine::StringVector::const_iterator it = args.begin(); |
| 31 it != args.end(); ++it) { | 32 it != args.end(); ++it) { |
| 32 GURL url(*it); | 33 GURL url(*it); |
| 33 if (url.scheme() == "mojo" && !command_line.HasSwitch(switches::kOrigin)) { | 34 if (url.scheme() == "mojo" && !command_line.HasSwitch(switches::kOrigin)) { |
| 34 LOG(ERROR) << "mojo: url passed with no --origin specified."; | 35 LOG(ERROR) << "mojo: url passed with no --origin specified."; |
| 35 return; | 36 return; |
| 36 } | 37 } |
| 37 ScopedMessagePipeHandle no_handle; | 38 ScopedMessagePipeHandle no_handle; |
| 38 context->service_manager()->Connect(GURL(*it), no_handle.Pass()); | 39 context->service_manager()->Connect(GURL(*it), no_handle.Pass()); |
| 39 } | 40 } |
| 40 } | 41 } |
| 41 | 42 |
| 42 } // namespace shell | 43 } // namespace shell |
| 43 } // namespace mojo | 44 } // namespace mojo |
| OLD | NEW |