Chromium Code Reviews| Index: components/policy/core/browser/android/app_restrictions_importer.h |
| diff --git a/components/policy/core/browser/android/app_restrictions_importer.h b/components/policy/core/browser/android/app_restrictions_importer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a8a52ea6b1fa054c4ba0a20bf3d6d738037c8d3d |
| --- /dev/null |
| +++ b/components/policy/core/browser/android/app_restrictions_importer.h |
| @@ -0,0 +1,106 @@ |
| +// 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_APP_RESTRICTIONS_IMPORTER_H |
| +#define COMPONENTS_POLICY_CORE_BROWSER_ANDROID_APP_RESTRICTIONS_IMPORTER_H |
| + |
| +#include <jni.h> |
| +#include <string> |
| + |
| +#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; |
| + |
| +// Provides to AppRestrictionsImporter a way to access the PolicyProvider |
| +// and submit the policy changes. |
| +class POLICY_EXPORT AppRestrictionsImporterDelegate { |
|
Bernhard Bauer
2015/07/08 09:54:33
Move this into an android namespace?
dgn
2015/07/08 18:16:01
Removed.
|
| + public: |
| + AppRestrictionsImporterDelegate(){}; |
|
Bernhard Bauer
2015/07/08 09:54:33
Space before braces, and no semicolon afterwards.
dgn
2015/07/08 18:16:01
Removed.
|
| + |
| + // Returns the PolicyProvider that will receive the new policies. |
| + virtual PolicyProviderAndroid* GetPolicyProvider() = 0; |
|
Bernhard Bauer
2015/07/08 09:54:33
In general, instead of interfaces with only one me
dgn
2015/07/08 11:25:45
A method allows to know when the pointer has been
dgn
2015/07/08 18:16:01
Removed.
|
| + |
| + protected: |
| + virtual ~AppRestrictionsImporterDelegate(){}; |
|
Bernhard Bauer
2015/07/08 09:54:33
Space before braces, and no semicolon afterwards.
dgn
2015/07/08 18:16:01
Removed.
|
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(AppRestrictionsImporterDelegate); |
| +}; |
| + |
| +// Populates natives policies from Java values key/value pairs. With its |
| +// associated java classes, allows transforming App Restriction bundles into |
| +// |PolicyBundle|s and updating the native policies. |
| +class POLICY_EXPORT AppRestrictionsImporter { |
| + public: |
| + AppRestrictionsImporter(AppRestrictionsImporterDelegate* delegate); |
| + |
| + // 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); |
| + void FlushPolicies(JNIEnv* env, jobject obj); |
| + |
| + // 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); |
| + |
| + protected: |
| + ~AppRestrictionsImporter(); |
|
Bernhard Bauer
2015/07/08 09:54:33
Is this class going to be subclassed? If not, you
dgn
2015/07/08 18:16:01
The constructor is called from PolicyManager now.
|
| + |
| + private: |
| + // Delegate that will allow accessing the PolicyProvider to submit the policy |
| + // changes. In Chrome the object is a PolicyManager owned by |
| + // BrowserPolicyConnector. |
| + AppRestrictionsImporterDelegate* delegate_; |
|
Bernhard Bauer
2015/07/08 09:54:33
How do you guarantee that this object will be aliv
dgn
2015/07/08 11:25:45
Calls to this object's methods are initiated from
|
| + |
| + scoped_ptr<PolicyBundle> policy_bundle_; |
| + |
| + void SetPolicyValue(const std::string& key, base::Value* raw_value); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppRestrictionsImporter); |
| +}; |
| + |
| +namespace android { |
| + |
| +// Register native methods |
| +bool RegisterAppRestrictionsImporter(JNIEnv* env); |
| + |
| +} // namespace android |
| + |
| +} // namespace policy |
| + |
| +#endif // COMPONENTS_POLICY_CORE_BROWSER_ANDROID_APP_RESTRICTIONS_IMPORTER_H |