Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / mojo / android / javatests / init_library.cc
blob92d11d99bb3d85b42b0bc6031b457531bc955a11
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
3 // found in the LICENSE file.
5 #include "base/android/base_jni_onload.h"
6 #include "base/android/base_jni_registrar.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_registrar.h"
9 #include "base/bind.h"
10 #include "mojo/android/javatests/mojo_test_case.h"
11 #include "mojo/android/javatests/validation_test_util.h"
12 #include "mojo/android/system/core_impl.h"
13 #include "mojo/edk/embedder/embedder.h"
14 #include "mojo/edk/embedder/simple_platform_support.h"
16 namespace {
18 base::android::RegistrationMethod kMojoRegisteredMethods[] = {
19 { "CoreImpl", mojo::android::RegisterCoreImpl },
20 { "MojoTestCase", mojo::android::RegisterMojoTestCase },
21 { "ValidationTestUtil", mojo::android::RegisterValidationTestUtil },
24 bool RegisterJNI(JNIEnv* env) {
25 return base::android::RegisterJni(env) &&
26 RegisterNativeMethods(env, kMojoRegisteredMethods,
27 arraysize(kMojoRegisteredMethods));
30 bool Init() {
31 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
32 new mojo::embedder::SimplePlatformSupport()));
33 return true;
36 } // namespace
38 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
39 std::vector<base::android::RegisterCallback> register_callbacks;
40 register_callbacks.push_back(base::Bind(&RegisterJNI));
41 std::vector<base::android::InitCallback> init_callbacks;
42 init_callbacks.push_back(base::Bind(&Init));
43 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
44 !base::android::OnJNIOnLoadInit(init_callbacks))
45 return -1;
47 return JNI_VERSION_1_4;