OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/basictypes.h" | 6 #include "base/basictypes.h" |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/icu_util.h" | 9 #include "base/i18n/icu_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "sky/shell/platform_view.h" | 12 #include "sky/shell/platform_view.h" |
13 #include "sky/shell/service_provider.h" | 13 #include "sky/shell/service_provider.h" |
14 #include "sky/shell/shell.h" | 14 #include "sky/shell/shell.h" |
15 #include "sky/shell/shell_view.h" | 15 #include "sky/shell/shell_view.h" |
16 | 16 |
17 namespace sky { | 17 namespace sky { |
18 namespace shell { | 18 namespace shell { |
19 | 19 |
| 20 const char kMain[] = "main"; |
| 21 const char kPackageRoot[] = "package-root"; |
| 22 |
20 void Init() { | 23 void Init() { |
21 Shell::Init(make_scoped_ptr(new ServiceProviderContext( | 24 Shell::Init(make_scoped_ptr(new ServiceProviderContext( |
22 base::MessageLoop::current()->task_runner()))); | 25 base::MessageLoop::current()->task_runner()))); |
23 | 26 |
24 // TODO(abarth): Currently we leak the ShellView. | 27 // TODO(abarth): Currently we leak the ShellView. |
25 ShellView* shell_view = new ShellView(Shell::Shared()); | 28 ShellView* shell_view = new ShellView(Shell::Shared()); |
26 | 29 |
27 ViewportObserverPtr viewport_observer; | 30 ViewportObserverPtr viewport_observer; |
28 shell_view->view()->ConnectToViewportObserver(GetProxy(&viewport_observer)); | 31 shell_view->view()->ConnectToViewportObserver(GetProxy(&viewport_observer)); |
29 | 32 |
30 // TODO(abarth): At this point we should load some content into the view. | 33 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
31 // viewport_observer->LoadURL("https://domokit.github.io/home.dart"); | 34 |
| 35 std::string main = command_line.GetSwitchValueASCII(kMain); |
| 36 std::string package_root = command_line.GetSwitchValueASCII(kPackageRoot); |
| 37 |
| 38 viewport_observer->RunFromFile(main, package_root); |
32 } | 39 } |
33 | 40 |
34 } // namespace shell | 41 } // namespace shell |
35 } // namespace sky | 42 } // namespace sky |
36 | 43 |
37 int main(int argc, const char* argv[]) { | 44 int main(int argc, const char* argv[]) { |
38 base::AtExitManager exit_manager; | 45 base::AtExitManager exit_manager; |
39 base::CommandLine::Init(argc, argv); | 46 base::CommandLine::Init(argc, argv); |
40 | 47 |
41 base::MessageLoop message_loop; | 48 base::MessageLoop message_loop; |
42 | 49 |
43 base::i18n::InitializeICU(); | 50 base::i18n::InitializeICU(); |
44 | 51 |
45 message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init)); | 52 message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init)); |
46 message_loop.Run(); | 53 message_loop.Run(); |
47 | 54 |
48 return 0; | 55 return 0; |
49 } | 56 } |
OLD | NEW |