| 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 "shell/android/main.h" | 5 #include "shell/android/main.h" |
| 6 | 6 |
| 7 #include "base/android/fifo_utils.h" | 7 #include "base/android/fifo_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/synchronization/waitable_event.h" | 21 #include "base/synchronization/waitable_event.h" |
| 22 #include "base/threading/simple_thread.h" | 22 #include "base/threading/simple_thread.h" |
| 23 #include "jni/ShellMain_jni.h" | 23 #include "jni/ShellMain_jni.h" |
| 24 #include "mojo/common/message_pump_mojo.h" | 24 #include "mojo/common/message_pump_mojo.h" |
| 25 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h" | 25 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h" |
| 26 #include "shell/android/android_handler_loader.h" | 26 #include "shell/android/android_handler_loader.h" |
| 27 #include "shell/android/background_application_loader.h" | |
| 28 #include "shell/android/native_viewport_application_loader.h" | 27 #include "shell/android/native_viewport_application_loader.h" |
| 29 #include "shell/android/ui_application_loader_android.h" | 28 #include "shell/android/ui_application_loader_android.h" |
| 30 #include "shell/application_manager/application_loader.h" | 29 #include "shell/application_manager/application_loader.h" |
| 30 #include "shell/background_application_loader.h" |
| 31 #include "shell/command_line_util.h" | 31 #include "shell/command_line_util.h" |
| 32 #include "shell/context.h" | 32 #include "shell/context.h" |
| 33 #include "shell/init.h" | 33 #include "shell/init.h" |
| 34 #include "shell/switches.h" | 34 #include "shell/switches.h" |
| 35 #include "shell/tracer.h" | 35 #include "shell/tracer.h" |
| 36 #include "ui/gl/gl_surface_egl.h" | 36 #include "ui/gl/gl_surface_egl.h" |
| 37 | 37 |
| 38 using base::LazyInstance; | 38 using base::LazyInstance; |
| 39 | 39 |
| 40 namespace shell { | 40 namespace shell { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace | 176 } // namespace |
| 177 | 177 |
| 178 static void Init(JNIEnv* env, | 178 static void Init(JNIEnv* env, |
| 179 jclass clazz, | 179 jclass clazz, |
| 180 jobject activity, | 180 jobject activity, |
| 181 jstring mojo_shell_child_path, | 181 jstring mojo_shell_child_path, |
| 182 jobjectArray jparameters, | 182 jobjectArray jparameters, |
| 183 jstring j_local_apps_directory, | 183 jstring j_local_apps_directory, |
| 184 jstring j_tmp_dir) { | 184 jstring j_tmp_dir, |
| 185 jstring j_home_dir) { |
| 185 g_internal_data.Get().main_activity.Reset(env, activity); | 186 g_internal_data.Get().main_activity.Reset(env, activity); |
| 186 // Initially, the shell runner is not ready. | 187 // Initially, the shell runner is not ready. |
| 187 g_internal_data.Get().shell_runner_ready.reset( | 188 g_internal_data.Get().shell_runner_ready.reset( |
| 188 new base::WaitableEvent(true, false)); | 189 new base::WaitableEvent(true, false)); |
| 189 | 190 |
| 190 std::string tmp_dir = base::android::ConvertJavaStringToUTF8(env, j_tmp_dir); | 191 std::string tmp_dir = base::android::ConvertJavaStringToUTF8(env, j_tmp_dir); |
| 191 // Setting the TMPDIR environment variable so that applications can use it. | 192 // Setting the TMPDIR and HOME environment variables so that applications can |
| 193 // use it. |
| 192 // TODO(qsr) We will need our subprocesses to inherit this. | 194 // TODO(qsr) We will need our subprocesses to inherit this. |
| 193 int return_value = setenv("TMPDIR", tmp_dir.c_str(), 1); | 195 int return_value = setenv("TMPDIR", tmp_dir.c_str(), 1); |
| 194 DCHECK_EQ(return_value, 0); | 196 DCHECK_EQ(return_value, 0); |
| 197 return_value = setenv( |
| 198 "HOME", base::android::ConvertJavaStringToUTF8(env, j_home_dir).c_str(), |
| 199 1); |
| 200 DCHECK_EQ(return_value, 0); |
| 195 | 201 |
| 196 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity); | 202 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity); |
| 197 base::android::InitApplicationContext(env, scoped_activity); | 203 base::android::InitApplicationContext(env, scoped_activity); |
| 198 | 204 |
| 199 std::vector<std::string> parameters; | 205 std::vector<std::string> parameters; |
| 200 parameters.push_back("mojo_shell"); | 206 parameters.push_back("mojo_shell"); |
| 201 base::android::AppendJavaStringArrayToStringVector(env, jparameters, | 207 base::android::AppendJavaStringArrayToStringVector(env, jparameters, |
| 202 ¶meters); | 208 ¶meters); |
| 203 base::CommandLine::Init(0, nullptr); | 209 base::CommandLine::Init(0, nullptr); |
| 204 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 210 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 std::string url = base::android::ConvertJavaStringToUTF8(env, jurl); | 276 std::string url = base::android::ConvertJavaStringToUTF8(env, jurl); |
| 271 g_internal_data.Get().shell_task_runner->PostTask( | 277 g_internal_data.Get().shell_task_runner->PostTask( |
| 272 FROM_HERE, base::Bind(&EmbedApplicationByURL, context, url)); | 278 FROM_HERE, base::Bind(&EmbedApplicationByURL, context, url)); |
| 273 } | 279 } |
| 274 | 280 |
| 275 bool RegisterShellMain(JNIEnv* env) { | 281 bool RegisterShellMain(JNIEnv* env) { |
| 276 return RegisterNativesImpl(env); | 282 return RegisterNativesImpl(env); |
| 277 } | 283 } |
| 278 | 284 |
| 279 } // namespace shell | 285 } // namespace shell |
| OLD | NEW |