Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / invalidation / invalidation_service_factory_android.cc
blobe42da0e2e16b76aadab16f144ebd6753e5d1f979
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 "chrome/browser/invalidation/invalidation_service_factory_android.h"
7 #include "base/android/jni_android.h"
8 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_android.h"
11 #include "components/invalidation/impl/invalidation_service_android.h"
12 #include "components/invalidation/impl/profile_invalidation_provider.h"
13 #include "jni/InvalidationServiceFactory_jni.h"
15 using base::android::ScopedJavaLocalRef;
17 namespace invalidation {
19 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForProfile(
20 JNIEnv* env,
21 jclass clazz,
22 jobject j_profile) {
23 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
24 invalidation::ProfileInvalidationProvider* provider =
25 ProfileInvalidationProviderFactory::GetForProfile(profile);
26 InvalidationServiceAndroid* service_android =
27 static_cast<InvalidationServiceAndroid*>(
28 provider->GetInvalidationService());
29 return ScopedJavaLocalRef<jobject>(service_android->java_ref_);
32 ScopedJavaLocalRef<jobject> InvalidationServiceFactoryAndroid::GetForTest(
33 JNIEnv* env,
34 jclass clazz,
35 jobject j_context) {
36 InvalidationServiceAndroid* service_android =
37 new InvalidationServiceAndroid(j_context);
38 return ScopedJavaLocalRef<jobject>(service_android->java_ref_);
41 ScopedJavaLocalRef<jobject> GetForProfile(
42 JNIEnv* env,
43 const JavaParamRef<jclass>& clazz,
44 const JavaParamRef<jobject>& j_profile) {
45 return InvalidationServiceFactoryAndroid::GetForProfile(env, clazz,
46 j_profile);
49 ScopedJavaLocalRef<jobject> GetForTest(JNIEnv* env,
50 const JavaParamRef<jclass>& clazz,
51 const JavaParamRef<jobject>& j_context) {
52 return InvalidationServiceFactoryAndroid::GetForTest(env, clazz, j_context);
55 bool InvalidationServiceFactoryAndroid::Register(JNIEnv* env) {
56 return RegisterNativesImpl(env);
59 } // namespace invalidation