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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/policy/PolicyProvider.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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: 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() {
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698