1 // Copyright 2020 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. 4 5 #include "chrome/browser/policy/android/jni_headers/PolicyServiceFactory_jni.h" 6 7 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/policy/chrome_browser_policy_connector.h" 9 #include "chrome/browser/policy/profile_policy_connector.h" 10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile_android.h" 12 #include "components/policy/core/common/android/policy_service_android.h" 13 #include "components/policy/core/common/policy_service.h" 14 15 namespace policy { 16 namespace android { 17 18 base::android::ScopedJavaLocalRef<jobject> JNI_PolicyServiceFactory_GetGlobalPolicyService(JNIEnv * env)19JNI_PolicyServiceFactory_GetGlobalPolicyService(JNIEnv* env) { 20 return g_browser_process->policy_service() 21 ->GetPolicyServiceAndroid() 22 ->GetJavaObject(); 23 } 24 25 base::android::ScopedJavaLocalRef<jobject> JNI_PolicyServiceFactory_GetProfilePolicyService(JNIEnv * env,const base::android::JavaParamRef<jobject> & j_profile)26JNI_PolicyServiceFactory_GetProfilePolicyService( 27 JNIEnv* env, 28 const base::android::JavaParamRef<jobject>& j_profile) { 29 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); 30 DCHECK(profile); 31 return profile->GetProfilePolicyConnector() 32 ->policy_service() 33 ->GetPolicyServiceAndroid() 34 ->GetJavaObject(); 35 } 36 37 } // namespace android 38 } // namespace policy 39