| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/android_handler.h" | 5 #include "shell/android/android_handler.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, j_context); | 60 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, j_context); |
| 61 init_application_context(scoped_context); | 61 init_application_context(scoped_context); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Run the application. | 64 // Run the application. |
| 65 base::ScopedNativeLibrary app_library_from_runner( | 65 base::ScopedNativeLibrary app_library_from_runner( |
| 66 shell::DynamicServiceRunner::LoadAndRunService(app_path, handle.Pass())); | 66 shell::DynamicServiceRunner::LoadAndRunService(app_path, handle.Pass())); |
| 67 } | 67 } |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 AndroidHandler::AndroidHandler() : content_handler_factory_(this) { |
| 71 } |
| 72 |
| 73 AndroidHandler::~AndroidHandler() { |
| 74 } |
| 75 |
| 70 void AndroidHandler::RunApplication(ShellPtr shell, URLResponsePtr response) { | 76 void AndroidHandler::RunApplication(ShellPtr shell, URLResponsePtr response) { |
| 71 JNIEnv* env = AttachCurrentThread(); | 77 JNIEnv* env = AttachCurrentThread(); |
| 72 ScopedJavaLocalRef<jstring> j_archive_path = | 78 ScopedJavaLocalRef<jstring> j_archive_path = |
| 73 Java_AndroidHandler_getNewTempArchivePath(env, GetApplicationContext()); | 79 Java_AndroidHandler_getNewTempArchivePath(env, GetApplicationContext()); |
| 74 base::FilePath archive_path( | 80 base::FilePath archive_path( |
| 75 ConvertJavaStringToUTF8(env, j_archive_path.obj())); | 81 ConvertJavaStringToUTF8(env, j_archive_path.obj())); |
| 76 | 82 |
| 77 mojo::common::BlockingCopyToFile(response->body.Pass(), archive_path); | 83 mojo::common::BlockingCopyToFile(response->body.Pass(), archive_path); |
| 78 RunAndroidApplicationFn run_android_application_fn = &RunAndroidApplication; | 84 RunAndroidApplicationFn run_android_application_fn = &RunAndroidApplication; |
| 79 Java_AndroidHandler_bootstrap( | 85 Java_AndroidHandler_bootstrap( |
| 80 env, GetApplicationContext(), j_archive_path.obj(), | 86 env, GetApplicationContext(), j_archive_path.obj(), |
| 81 shell.PassMessagePipe().release().value(), | 87 shell.PassMessagePipe().release().value(), |
| 82 reinterpret_cast<jlong>(run_android_application_fn)); | 88 reinterpret_cast<jlong>(run_android_application_fn)); |
| 83 } | 89 } |
| 84 | 90 |
| 85 void AndroidHandler::Initialize(ApplicationImpl* app) { | 91 void AndroidHandler::Initialize(ApplicationImpl* app) { |
| 86 } | 92 } |
| 87 | 93 |
| 88 bool AndroidHandler::ConfigureIncomingConnection( | 94 bool AndroidHandler::ConfigureIncomingConnection( |
| 89 ApplicationConnection* connection) { | 95 ApplicationConnection* connection) { |
| 90 connection->AddService(&content_handler_factory_); | 96 connection->AddService(&content_handler_factory_); |
| 91 return true; | 97 return true; |
| 92 } | 98 } |
| 93 | 99 |
| 94 bool RegisterAndroidHandlerJni(JNIEnv* env) { | 100 bool RegisterAndroidHandlerJni(JNIEnv* env) { |
| 95 return RegisterNativesImpl(env); | 101 return RegisterNativesImpl(env); |
| 96 } | 102 } |
| 97 | 103 |
| 98 } // namespace mojo | 104 } // namespace mojo |
| OLD | NEW |