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/policy_converter.h" | 5 #include "components/policy/core/browser/android/policy_converter.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 PolicyConverter::PolicyConverter(const Schema* policy_schema) | 32 PolicyConverter::PolicyConverter(const Schema* policy_schema) |
33 : policy_schema_(policy_schema), policy_bundle_(new PolicyBundle) { | 33 : policy_schema_(policy_schema), policy_bundle_(new PolicyBundle) { |
34 JNIEnv* env = base::android::AttachCurrentThread(); | 34 JNIEnv* env = base::android::AttachCurrentThread(); |
35 java_obj_.Reset(env, Java_PolicyConverter_create( | 35 java_obj_.Reset(env, Java_PolicyConverter_create( |
36 env, reinterpret_cast<long>(this)).obj()); | 36 env, reinterpret_cast<long>(this)).obj()); |
37 DCHECK(!java_obj_.is_null()); | 37 DCHECK(!java_obj_.is_null()); |
38 } | 38 } |
39 | 39 |
40 PolicyConverter::~PolicyConverter() { | 40 PolicyConverter::~PolicyConverter() { |
41 Java_PolicyConverter_onNativeDestroyed(base::android::AttachCurrentThread(), | 41 Java_PolicyConverter_onNativeDestroyed(base::android::AttachCurrentThread(), |
42 java_obj_.obj()); | 42 java_obj_); |
43 } | 43 } |
44 | 44 |
45 std::unique_ptr<PolicyBundle> PolicyConverter::GetPolicyBundle() { | 45 std::unique_ptr<PolicyBundle> PolicyConverter::GetPolicyBundle() { |
46 std::unique_ptr<PolicyBundle> filled_bundle(std::move(policy_bundle_)); | 46 std::unique_ptr<PolicyBundle> filled_bundle(std::move(policy_bundle_)); |
47 policy_bundle_.reset(new PolicyBundle); | 47 policy_bundle_.reset(new PolicyBundle); |
48 return filled_bundle; | 48 return filled_bundle; |
49 } | 49 } |
50 | 50 |
51 base::android::ScopedJavaLocalRef<jobject> PolicyConverter::GetJavaObject() { | 51 base::android::ScopedJavaLocalRef<jobject> PolicyConverter::GetJavaObject() { |
52 return base::android::ScopedJavaLocalRef<jobject>(java_obj_); | 52 return base::android::ScopedJavaLocalRef<jobject>(java_obj_); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 std::unique_ptr<base::Value> value) { | 193 std::unique_ptr<base::Value> value) { |
194 const Schema schema = policy_schema_->GetKnownProperty(key); | 194 const Schema schema = policy_schema_->GetKnownProperty(key); |
195 const PolicyNamespace ns(POLICY_DOMAIN_CHROME, std::string()); | 195 const PolicyNamespace ns(POLICY_DOMAIN_CHROME, std::string()); |
196 policy_bundle_->Get(ns).Set( | 196 policy_bundle_->Get(ns).Set( |
197 key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM, | 197 key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM, |
198 ConvertValueToSchema(std::move(value), schema), nullptr); | 198 ConvertValueToSchema(std::move(value), schema), nullptr); |
199 } | 199 } |
200 | 200 |
201 } // namespace android | 201 } // namespace android |
202 } // namespace policy | 202 } // namespace policy |
OLD | NEW |