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