| Index: content/shell/android/shell_library_loader.cc
|
| diff --git a/content/shell/android/shell_library_loader.cc b/content/shell/android/shell_library_loader.cc
|
| index e447d7e729bbbd013f31bac1ab5a41bda22ba14b..3b6757eaf10bad7ac1aee9e321990fd40cdf680e 100644
|
| --- a/content/shell/android/shell_library_loader.cc
|
| +++ b/content/shell/android/shell_library_loader.cc
|
| @@ -3,8 +3,11 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/debug/debugger.h"
|
| +#include "base/logging.h"
|
| #include "base/android/jni_android.h"
|
| #include "base/android/jni_registrar.h"
|
| +#include "content/public/app/content_main_runner.h"
|
| #include "content/public/browser/android_library_loader_hooks.h"
|
| #include "content/shell/shell_main_delegate.h"
|
| #include "content/shell/android/shell_manager.h"
|
| @@ -15,8 +18,32 @@ static base::android::RegistrationMethod kRegistrationMethods[] = {
|
| { "ShellView", content::ShellView::Register },
|
| };
|
|
|
| +namespace {
|
| + content::ContentMainRunner* g_content_main_runner = NULL;
|
| +}
|
| +
|
| // This is called by the VM when the shared library is first loaded.
|
| JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
| +
|
| + // Don't call anything in base without initializing it.
|
| + // ContentMainRunner will do what we need.
|
| + g_content_main_runner = content::ContentMainRunner::Create();
|
| +
|
| + // TODO(tedchoc): Set this to the main delegate once the Android specific
|
| + // browser process initialization gets checked in.
|
| + ShellMainDelegate* delegate = new ShellMainDelegate();
|
| +
|
| + // We use a ShellContentClient, created as a member of
|
| + // ShellMainDelegate and set with a call to
|
| + // content::SetContentClient() in PreSandboxStartup().
|
| + // That must be done before ContentMainRunner::Initialize().
|
| + // TODO(jrg): resolve the upstream/downstream discrepancy; we
|
| + // shouldn't need to do this.
|
| + delegate->PreSandboxStartup();
|
| +
|
| + // TODO(jrg): find command line info from java; pass down in here.
|
| + g_content_main_runner->Initialize(0, NULL, NULL);
|
| +
|
| base::android::InitVM(vm);
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| if (!RegisterLibraryLoaderEntryHook(env)) {
|
| @@ -29,9 +56,12 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
| arraysize(kRegistrationMethods)))
|
| return -1;
|
|
|
| - // TODO(tedchoc): Set this to the main delegate once the Android specific
|
| - // browser process initialization gets checked in.
|
| - new ShellMainDelegate();
|
| -
|
| return JNI_VERSION_1_4;
|
| }
|
| +
|
| +
|
| +JNI_EXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) {
|
| + delete g_content_main_runner;
|
| + g_content_main_runner = NULL;
|
| +}
|
| +
|
|
|