11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file. 41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/android/base_jni_registrar.h" 61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/android/jni_android.h" 71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/android/jni_registrar.h" 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/android/library_loader/library_loader_hooks.h" 91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "base/logging.h" 106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "mojo/services/native_viewport/platform_viewport_android.h" 111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "mojo/shell/android/mojo_main.h" 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "net/android/net_jni_registrar.h" 131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace { 151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)base::android::RegistrationMethod kMojoRegisteredMethods[] = { 171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) { "MojoMain", mojo::RegisterMojoMain }, 186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) { "PlatformViewportAndroid", 196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) mojo::PlatformViewportAndroid::Register }, 201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}; 211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool RegisterMojoJni(JNIEnv* env) { 231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return RegisterNativeMethods(env, kMojoRegisteredMethods, 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) arraysize(kMojoRegisteredMethods)); 251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} // namespace 281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// This is called by the VM when the shared library is first loaded. 301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { 311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::android::InitVM(vm); 321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) JNIEnv* env = base::android::AttachCurrentThread(); 331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!base::android::RegisterLibraryLoaderEntryHook(env)) 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return -1; 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!base::android::RegisterJni(env)) 381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return -1; 391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!net::android::RegisterJni(env)) 411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return -1; 421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!RegisterMojoJni(env)) 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return -1; 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return JNI_VERSION_1_4; 471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 48