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/android/mojo_main.h" | 5 #include "mojo/shell/android/mojo_main.h" |
6 | 6 |
7 #include "base/android/java_handler_thread.h" | 7 #include "base/android/java_handler_thread.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "jni/MojoMain_jni.h" | 16 #include "jni/MojoMain_jni.h" |
17 #include "mojo/application_manager/application_loader.h" | 17 #include "mojo/application_manager/application_loader.h" |
18 #include "mojo/application_manager/application_manager.h" | 18 #include "mojo/application_manager/application_manager.h" |
19 #include "mojo/shell/context.h" | 19 #include "mojo/shell/context.h" |
20 #include "mojo/shell/init.h" | 20 #include "mojo/shell/init.h" |
21 #include "mojo/shell/run.h" | |
22 #include "ui/gl/gl_surface_egl.h" | 21 #include "ui/gl/gl_surface_egl.h" |
23 | 22 |
24 using base::LazyInstance; | 23 using base::LazyInstance; |
25 | 24 |
26 namespace mojo { | 25 namespace mojo { |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 LazyInstance<scoped_ptr<base::MessageLoop> > g_java_message_loop = | 29 LazyInstance<scoped_ptr<base::MessageLoop> > g_java_message_loop = |
31 LAZY_INSTANCE_INITIALIZER; | 30 LAZY_INSTANCE_INITIALIZER; |
32 | 31 |
33 LazyInstance<scoped_ptr<shell::Context> > g_context = | 32 LazyInstance<scoped_ptr<shell::Context> > g_context = |
34 LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
35 | 34 |
36 LazyInstance<scoped_ptr<base::android::JavaHandlerThread> > g_shell_thread = | 35 LazyInstance<scoped_ptr<base::android::JavaHandlerThread> > g_shell_thread = |
37 LAZY_INSTANCE_INITIALIZER; | 36 LAZY_INSTANCE_INITIALIZER; |
38 | 37 |
39 void RunShell(std::vector<GURL> app_urls) { | 38 void RunShell(std::vector<GURL> app_urls) { |
40 g_context.Get()->Init(); | 39 shell::Context* context = g_context.Pointer()->get(); |
41 g_context.Get()->set_ui_loop(g_java_message_loop.Get().get()); | 40 context->Init(); |
42 shell::Run(g_context.Get().get(), app_urls); | 41 context->set_ui_loop(g_java_message_loop.Get().get()); |
| 42 for (std::vector<GURL>::const_iterator it = app_urls.begin(); |
| 43 it != app_urls.end(); ++it) { |
| 44 context->Run(*it); |
| 45 } |
43 } | 46 } |
44 | 47 |
45 } // namespace | 48 } // namespace |
46 | 49 |
47 static void Init(JNIEnv* env, jclass clazz, jobject context) { | 50 static void Init(JNIEnv* env, jclass clazz, jobject context) { |
48 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); | 51 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); |
49 | 52 |
50 base::android::InitApplicationContext(env, scoped_context); | 53 base::android::InitApplicationContext(env, scoped_context); |
51 | 54 |
52 base::CommandLine::Init(0, 0); | 55 base::CommandLine::Init(0, 0); |
(...skipping 29 matching lines...) Expand all Loading... |
82 g_shell_thread.Get()->Start(); | 85 g_shell_thread.Get()->Start(); |
83 g_shell_thread.Get()->message_loop()->PostTask( | 86 g_shell_thread.Get()->message_loop()->PostTask( |
84 FROM_HERE, base::Bind(&RunShell, app_urls)); | 87 FROM_HERE, base::Bind(&RunShell, app_urls)); |
85 } | 88 } |
86 | 89 |
87 bool RegisterMojoMain(JNIEnv* env) { | 90 bool RegisterMojoMain(JNIEnv* env) { |
88 return RegisterNativesImpl(env); | 91 return RegisterNativesImpl(env); |
89 } | 92 } |
90 | 93 |
91 } // namespace mojo | 94 } // namespace mojo |
OLD | NEW |