Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: components/policy/core/browser/android/policy_converter.h

Issue 1220683008: Move AppRestriction to Policy code out of //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address bauerb@'s comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/policy/core/browser/android/policy_converter.h
diff --git a/components/policy/core/browser/android/policy_converter.h b/components/policy/core/browser/android/policy_converter.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f48b59203620b75a0d6462f6607a0cb4706eae7
--- /dev/null
+++ b/components/policy/core/browser/android/policy_converter.h
@@ -0,0 +1,94 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_POLICY_CORE_BROWSER_ANDROID_POLICY_CONVERTER_H
+#define COMPONENTS_POLICY_CORE_BROWSER_ANDROID_POLICY_CONVERTER_H
+
+#include <jni.h>
+#include <string>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "components/policy/policy_export.h"
+
+namespace base {
+
+class Value;
+
+} // namespace base
+
+namespace policy {
+
+class PolicyBundle;
+class PolicyProviderAndroid;
+class Schema;
+struct PolicyNamespace;
+
+namespace android {
+
+// Populates natives policies from Java values key/value pairs. With its
Mattias Nissler (ping if slow) 2015/07/13 09:46:05 nit: remove "values"
dgn 2015/07/14 12:50:26 Done.
+// associated java classes, allows transforming Android |Bundle|s into
+// |PolicyBundle|s and updating the native policies.
Mattias Nissler (ping if slow) 2015/07/13 09:46:05 nit: I don't see how this class would "update the
dgn 2015/07/14 12:50:26 I forgot to remove this after moving FlushPolicies
+class POLICY_EXPORT PolicyConverter {
+ public:
+ explicit PolicyConverter(const Schema* policy_schema);
+ ~PolicyConverter();
+
+ // Returns a policy bundle containing all policies collected since the last
+ // call to this method. The caller gains ownership of the bundle.
Mattias Nissler (ping if slow) 2015/07/13 09:46:05 nit: Ownership comment is redundant with scoped_pt
dgn 2015/07/14 12:50:26 Done.
+ scoped_ptr<PolicyBundle> GetPolicyBundle();
+
+ base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
+
+ // To be called from Java:
+ void SetPolicyBoolean(JNIEnv* env,
+ jobject obj,
+ jstring policyKey,
+ jboolean value);
+ void SetPolicyInteger(JNIEnv* env,
+ jobject obj,
+ jstring policyKey,
+ jint value);
+ void SetPolicyString(JNIEnv* env,
+ jobject obj,
+ jstring policyKey,
+ jstring value);
+ void SetPolicyStringArray(JNIEnv* env,
+ jobject obj,
+ jstring policyKey,
+ jobjectArray value);
+
+ // Converts the passed in value to the type desired by the schema. If the
+ // value is not convertible, it is returned unchanged, so the policy system
+ // can report the error.
+ // Note that this method will only look at the type of the schema, not at any
+ // additional restrictions, or the schema for value's items or properties in
+ // the case of a list or dictionary value.
+ // This method takes ownership of the passed in value, and the caller takes
+ // ownership of the return value.
+ // Public for testing.
+ static scoped_ptr<base::Value> ConvertValueToSchema(
+ scoped_ptr<base::Value> value,
+ const Schema& schema);
+
+ // Register native methods
+ static bool Register(JNIEnv* env);
+
+ private:
+ const Schema* const policy_schema_;
+
+ scoped_ptr<PolicyBundle> policy_bundle_;
+
+ base::android::ScopedJavaGlobalRef<jobject> java_obj_;
+
+ void SetPolicyValue(const std::string& key, base::Value* raw_value);
Mattias Nissler (ping if slow) 2015/07/13 09:46:05 Should have a comment saying that it takes ownersh
dgn 2015/07/14 12:50:26 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(PolicyConverter);
+};
+
+} // namespace android
+} // namespace policy
+
+#endif // COMPONENTS_POLICY_CORE_BROWSER_ANDROID_POLICY_CONVERTER_H

Powered by Google App Engine
This is Rietveld 408576698