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

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: Removed the Delegate, reworked the relationship between classes 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/chrome/browser/android/policy/policy_manager.h b/components/policy/core/browser/android/policy_converter.h
similarity index 50%
copy from chrome/browser/android/policy/policy_manager.h
copy to components/policy/core/browser/android/policy_converter.h
index a24650d6f131d61961b37c0b1d4f58dd1d046ae0..9d3ff1f90027ea6a33eb590432f49f086a1412f7 100644
--- a/chrome/browser/android/policy/policy_manager.h
+++ b/components/policy/core/browser/android/policy_converter.h
@@ -2,27 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_ANDROID_POLICY_POLICY_MANAGER_H_
-#define CHROME_BROWSER_ANDROID_POLICY_POLICY_MANAGER_H_
+#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/jni_weak_ref.h"
-#include "components/policy/core/common/policy_bundle.h"
-#include "components/policy/core/common/policy_provider_android_delegate.h"
+#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 policy {
+class PolicyBundle;
class PolicyProviderAndroid;
class Schema;
+struct PolicyNamespace;
-} // namespace policy
-
-class PolicyManager : public policy::PolicyProviderAndroidDelegate {
+// Populates natives policies from Java values key/value pairs. With its
Bernhard Bauer 2015/07/09 08:53:58 I would move this into the android namespace, and
dgn 2015/07/09 10:53:41 Done. Also moved the methods around to have a cons
+// associated java classes, allows transforming Android |Bundle|s into
+// |PolicyBundle|s and updating the native policies.
+class POLICY_EXPORT PolicyConverter {
public:
- PolicyManager(JNIEnv* env, jobject obj);
+ PolicyConverter(const Schema* policy_schema);
Bernhard Bauer 2015/07/09 08:53:58 Single-argument constructors should be marked expl
dgn 2015/07/09 10:53:41 Done.
+ ~PolicyConverter();
- // Called from Java:
+ // To be called from Java:
void SetPolicyBoolean(JNIEnv* env,
jobject obj,
jstring policyKey,
@@ -39,9 +50,12 @@ class PolicyManager : public policy::PolicyProviderAndroidDelegate {
jobject obj,
jstring policyKey,
jobjectArray value);
- void FlushPolicies(JNIEnv* env, jobject obj);
- void Destroy(JNIEnv* env, jobject obj);
+ // Returns a policy bundle containing all policies collected since the last
+ // call to this method. The caller gains ownership of the bundle.
+ scoped_ptr<PolicyBundle> GetPolicyBundle();
+
+ base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
// 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
@@ -52,27 +66,29 @@ class PolicyManager : public policy::PolicyProviderAndroidDelegate {
// This method takes ownership of the passed in value, and the caller takes
// ownership of the return value.
// Public for testing.
- static base::Value* ConvertValueToSchema(base::Value* raw_value,
- const policy::Schema& schema);
-
- // PolicyProviderAndroidDelegate:
- void RefreshPolicies() override;
- void PolicyProviderShutdown() override;
+ static scoped_ptr<base::Value> ConvertValueToSchema(
+ scoped_ptr<base::Value> value,
+ const Schema& schema);
private:
- ~PolicyManager() override;
+ const Schema* const policy_schema_;
- JavaObjectWeakGlobalRef weak_java_policy_manager_;
+ scoped_ptr<PolicyBundle> policy_bundle_;
- scoped_ptr<policy::PolicyBundle> policy_bundle_;
- policy::PolicyProviderAndroid* policy_provider_;
+ JavaObjectWeakGlobalRef weak_java_obj_;
Bernhard Bauer 2015/07/09 08:53:58 Make this a strong reference? I'm a bit worried ab
dgn 2015/07/09 10:53:41 Done.
- void SetPolicyValue(const std::string& key, base::Value* value);
+ void SetPolicyValue(const std::string& key, base::Value* raw_value);
- DISALLOW_COPY_AND_ASSIGN(PolicyManager);
+ DISALLOW_COPY_AND_ASSIGN(PolicyConverter);
};
+namespace android {
+
// Register native methods
-bool RegisterPolicyManager(JNIEnv* env);
+bool RegisterPolicyConverter(JNIEnv* env);
+
+} // namespace android
+
+} // namespace policy
-#endif // CHROME_BROWSER_ANDROID_POLICY_POLICY_MANAGER_H_
+#endif // COMPONENTS_POLICY_CORE_BROWSER_ANDROID_POLICY_CONVERTER_H

Powered by Google App Engine
This is Rietveld 408576698