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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" // TODO(vtl): Remove. | 8 #include "base/macros.h" // TODO(vtl): Remove. |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "mojo/common/message_pump_mojo.h" // TODO(vtl): Remove. | 10 #include "mojo/common/message_pump_mojo.h" // TODO(vtl): Remove. |
11 #include "mojo/public/cpp/environment/environment.h" | 11 #include "mojo/public/cpp/environment/environment.h" |
12 #include "mojo/shell/child_process.h" | 12 #include "mojo/shell/child_process.h" |
13 #include "mojo/shell/child_process_host.h" // TODO(vtl): Remove. | 13 #include "mojo/shell/child_process_host.h" // TODO(vtl): Remove. |
14 #include "mojo/shell/context.h" | 14 #include "mojo/shell/context.h" |
15 #include "mojo/shell/init.h" | 15 #include "mojo/shell/init.h" |
16 #include "mojo/shell/run.h" | 16 #include "mojo/shell/run.h" |
| 17 #include "mojo/shell/switches.h" |
17 #include "ui/gl/gl_surface.h" | 18 #include "ui/gl/gl_surface.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // TODO(vtl): Remove. | 22 // TODO(vtl): Remove. |
22 class TestChildProcessHostDelegate | 23 class TestChildProcessHostDelegate |
23 : public mojo::shell::ChildProcessHost::Delegate { | 24 : public mojo::shell::ChildProcessHost::Delegate { |
24 public: | 25 public: |
25 TestChildProcessHostDelegate() {} | 26 TestChildProcessHostDelegate() {} |
26 virtual ~TestChildProcessHostDelegate() {} | 27 virtual ~TestChildProcessHostDelegate() {} |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 61 |
61 // TODO(vtl): Unify parent and child process cases to the extent possible. | 62 // TODO(vtl): Unify parent and child process cases to the extent possible. |
62 if (scoped_ptr<mojo::shell::ChildProcess> child_process = | 63 if (scoped_ptr<mojo::shell::ChildProcess> child_process = |
63 mojo::shell::ChildProcess::Create( | 64 mojo::shell::ChildProcess::Create( |
64 *base::CommandLine::ForCurrentProcess())) { | 65 *base::CommandLine::ForCurrentProcess())) { |
65 child_process->Main(); | 66 child_process->Main(); |
66 } else { | 67 } else { |
67 gfx::GLSurface::InitializeOneOff(); | 68 gfx::GLSurface::InitializeOneOff(); |
68 | 69 |
69 base::MessageLoop message_loop; | 70 base::MessageLoop message_loop; |
70 mojo::shell::Context context; | 71 mojo::shell::Context shell_context; |
71 message_loop.PostTask(FROM_HERE, base::Bind(mojo::shell::Run, &context)); | 72 |
| 73 const base::CommandLine& command_line = |
| 74 *base::CommandLine::ForCurrentProcess(); |
| 75 if (command_line.HasSwitch(switches::kOrigin)) { |
| 76 shell_context.set_mojo_origin( |
| 77 command_line.GetSwitchValueASCII(switches::kOrigin)); |
| 78 } |
| 79 |
| 80 std::vector<GURL> app_urls; |
| 81 base::CommandLine::StringVector args = command_line.GetArgs(); |
| 82 for (base::CommandLine::StringVector::const_iterator it = args.begin(); |
| 83 it != args.end(); |
| 84 ++it) |
| 85 app_urls.push_back(GURL(*it)); |
| 86 |
| 87 message_loop.PostTask(FROM_HERE, |
| 88 base::Bind(mojo::shell::Run, |
| 89 &shell_context, |
| 90 app_urls)); |
72 | 91 |
73 message_loop.Run(); | 92 message_loop.Run(); |
74 } | 93 } |
75 | 94 |
76 return 0; | 95 return 0; |
77 } | 96 } |
OLD | NEW |