Index: chrome/android/java_staging/src/org/chromium/chrome/browser/policy/PolicyProvider.java |
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/policy/PolicyProvider.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/policy/PolicyProvider.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f26e4de91b0c0b11c256d1fce14a8ba2c1b42ef5 |
--- /dev/null |
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/policy/PolicyProvider.java |
@@ -0,0 +1,59 @@ |
+// 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. |
+ |
+package org.chromium.chrome.browser.policy; |
+ |
+import android.content.Context; |
+import android.os.Bundle; |
+ |
+/** |
+ * Base class for Policy providers. |
+ */ |
+public abstract class PolicyProvider { |
+ private PolicyManager mPolicyManager; |
+ protected final Context mContext; |
+ private int mSource = -1; |
+ |
+ protected PolicyProvider(Context context) { |
+ mContext = context.getApplicationContext(); |
+ } |
+ |
+ protected void notifySettingsAvailable(Bundle settings) { |
+ mPolicyManager.onSettingsAvailable(mSource, settings); |
+ } |
+ |
+ protected void terminateIncognitoSession() { |
+ mPolicyManager.terminateIncognitoSession(); |
+ } |
+ |
+ /** |
+ * Called to request a refreshed set of policies. |
+ * This method must handle notifying the PolicyManager whenever applicable. |
+ */ |
+ public abstract void refresh(); |
+ |
+ /** |
+ * Register the PolicyProvider for receiving policy changes. |
+ */ |
+ protected void startListeningForPolicyChanges() { |
+ } |
+ |
+ /** |
+ * Called by the {@link PolicyManager} to correctly hook it with the Policy system. |
+ * @param policyManager reference to the PolicyManager to be used like a delegate. |
+ * @param source tags the PolicyProvider with a source. |
+ */ |
+ final void setManagerAndSource(PolicyManager policyManager, int source) { |
+ assert mSource < 0; |
+ assert source >= 0; |
+ mSource = source; |
+ assert mPolicyManager == null; |
+ mPolicyManager = policyManager; |
+ startListeningForPolicyChanges(); |
+ } |
+ |
+ /** Called when the provider is unregistered */ |
+ public void destroy() { |
+ } |
+} |