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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 LAZY_INSTANCE_INITIALIZER; | 31 LAZY_INSTANCE_INITIALIZER; |
32 | 32 |
33 LazyInstance<scoped_ptr<shell::Context> > g_context = | 33 LazyInstance<scoped_ptr<shell::Context> > g_context = |
34 LAZY_INSTANCE_INITIALIZER; | 34 LAZY_INSTANCE_INITIALIZER; |
35 | 35 |
36 LazyInstance<scoped_ptr<base::android::JavaHandlerThread> > g_shell_thread = | 36 LazyInstance<scoped_ptr<base::android::JavaHandlerThread> > g_shell_thread = |
37 LAZY_INSTANCE_INITIALIZER; | 37 LAZY_INSTANCE_INITIALIZER; |
38 | 38 |
39 void RunShell(std::vector<GURL> app_urls) { | 39 void RunShell(std::vector<GURL> app_urls) { |
40 shell::Context* shell_context = new shell::Context(); | 40 shell::Context* shell_context = new shell::Context(); |
41 shell_context->set_activity(base::android::GetApplicationContext()); | |
42 shell_context->set_ui_loop(g_java_message_loop.Get().get()); | 41 shell_context->set_ui_loop(g_java_message_loop.Get().get()); |
43 | 42 |
44 g_context.Get().reset(shell_context); | 43 g_context.Get().reset(shell_context); |
45 shell::Run(shell_context, app_urls); | 44 shell::Run(shell_context, app_urls); |
46 } | 45 } |
47 | 46 |
48 } // namespace | 47 } // namespace |
49 | 48 |
50 static void Init(JNIEnv* env, jclass clazz, jobject context) { | 49 static void Init(JNIEnv* env, jclass clazz, jobject context) { |
51 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); | 50 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); |
(...skipping 28 matching lines...) Expand all Loading... |
80 g_shell_thread.Get()->Start(); | 79 g_shell_thread.Get()->Start(); |
81 g_shell_thread.Get()->message_loop()->PostTask( | 80 g_shell_thread.Get()->message_loop()->PostTask( |
82 FROM_HERE, base::Bind(&RunShell, app_urls)); | 81 FROM_HERE, base::Bind(&RunShell, app_urls)); |
83 } | 82 } |
84 | 83 |
85 bool RegisterMojoMain(JNIEnv* env) { | 84 bool RegisterMojoMain(JNIEnv* env) { |
86 return RegisterNativesImpl(env); | 85 return RegisterNativesImpl(env); |
87 } | 86 } |
88 | 87 |
89 } // namespace mojo | 88 } // namespace mojo |
OLD | NEW |