OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/policy/core/browser/android/android_combined_policy_provide
r.h" | 5 #include "components/policy/core/browser/android/android_combined_policy_provide
r.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "components/policy/core/browser/android/policy_converter.h" | 9 #include "components/policy/core/browser/android/policy_converter.h" |
10 #include "jni/CombinedPolicyProvider_jni.h" | 10 #include "jni/CombinedPolicyProvider_jni.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace android { | 22 namespace android { |
23 | 23 |
24 AndroidCombinedPolicyProvider::AndroidCombinedPolicyProvider( | 24 AndroidCombinedPolicyProvider::AndroidCombinedPolicyProvider( |
25 SchemaRegistry* registry) | 25 SchemaRegistry* registry) |
26 : initialized_(!g_wait_for_policies) { | 26 : initialized_(!g_wait_for_policies) { |
27 PolicyNamespace ns(POLICY_DOMAIN_CHROME, std::string()); | 27 PolicyNamespace ns(POLICY_DOMAIN_CHROME, std::string()); |
28 const Schema* schema = registry->schema_map()->GetSchema(ns); | 28 const Schema* schema = registry->schema_map()->GetSchema(ns); |
29 policy_converter_.reset(new policy::android::PolicyConverter(schema)); | 29 policy_converter_.reset(new policy::android::PolicyConverter(schema)); |
30 java_combined_policy_provider_.Reset(Java_CombinedPolicyProvider_linkNative( | 30 java_combined_policy_provider_.Reset(Java_CombinedPolicyProvider_linkNative( |
31 AttachCurrentThread(), reinterpret_cast<intptr_t>(this), | 31 AttachCurrentThread(), reinterpret_cast<intptr_t>(this), |
32 policy_converter_->GetJavaObject().obj())); | 32 policy_converter_->GetJavaObject())); |
33 } | 33 } |
34 | 34 |
35 AndroidCombinedPolicyProvider::~AndroidCombinedPolicyProvider() { | 35 AndroidCombinedPolicyProvider::~AndroidCombinedPolicyProvider() { |
36 Java_CombinedPolicyProvider_linkNative(AttachCurrentThread(), 0, jobject()); | 36 Java_CombinedPolicyProvider_linkNative(AttachCurrentThread(), 0, jobject()); |
37 java_combined_policy_provider_.Reset(); | 37 java_combined_policy_provider_.Reset(); |
38 } | 38 } |
39 | 39 |
40 void AndroidCombinedPolicyProvider::RefreshPolicies() { | 40 void AndroidCombinedPolicyProvider::RefreshPolicies() { |
41 JNIEnv* env = AttachCurrentThread(); | 41 JNIEnv* env = AttachCurrentThread(); |
42 Java_CombinedPolicyProvider_refreshPolicies( | 42 Java_CombinedPolicyProvider_refreshPolicies(env, |
43 env, java_combined_policy_provider_.obj()); | 43 java_combined_policy_provider_); |
44 } | 44 } |
45 | 45 |
46 void AndroidCombinedPolicyProvider::FlushPolicies( | 46 void AndroidCombinedPolicyProvider::FlushPolicies( |
47 JNIEnv* env, | 47 JNIEnv* env, |
48 const JavaParamRef<jobject>& obj) { | 48 const JavaParamRef<jobject>& obj) { |
49 initialized_ = true; | 49 initialized_ = true; |
50 UpdatePolicy(policy_converter_->GetPolicyBundle()); | 50 UpdatePolicy(policy_converter_->GetPolicyBundle()); |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 void AndroidCombinedPolicyProvider::SetShouldWaitForPolicy( | 54 void AndroidCombinedPolicyProvider::SetShouldWaitForPolicy( |
55 bool should_wait_for_policy) { | 55 bool should_wait_for_policy) { |
56 g_wait_for_policies = should_wait_for_policy; | 56 g_wait_for_policies = should_wait_for_policy; |
57 } | 57 } |
58 | 58 |
59 bool AndroidCombinedPolicyProvider::IsInitializationComplete( | 59 bool AndroidCombinedPolicyProvider::IsInitializationComplete( |
60 PolicyDomain domain) const { | 60 PolicyDomain domain) const { |
61 return initialized_; | 61 return initialized_; |
62 } | 62 } |
63 | 63 |
64 bool AndroidCombinedPolicyProvider::Register(JNIEnv* env) { | 64 bool AndroidCombinedPolicyProvider::Register(JNIEnv* env) { |
65 return RegisterNativesImpl(env); | 65 return RegisterNativesImpl(env); |
66 } | 66 } |
67 | 67 |
68 } // namespace android | 68 } // namespace android |
69 } // namespace policy | 69 } // namespace policy |
OLD | NEW |