| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.policy; | 5 package org.chromium.policy; |
| 6 | 6 |
| 7 import android.content.BroadcastReceiver; | 7 import android.content.BroadcastReceiver; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.IntentFilter; | 10 import android.content.IntentFilter; |
| 11 import android.os.Bundle; | 11 import android.os.Bundle; |
| 12 import android.os.Handler; | 12 import android.os.Handler; |
| 13 import android.os.StrictMode; | 13 import android.os.StrictMode; |
| 14 | 14 |
| 15 import org.chromium.base.Log; | 15 import org.chromium.base.Log; |
| 16 import org.chromium.base.ThreadUtils; | 16 import org.chromium.base.ThreadUtils; |
| 17 import org.chromium.base.VisibleForTesting; | 17 import org.chromium.base.VisibleForTesting; |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Retrieves app restrictions and provides them to the parent class as Bundles. | 20 * Retrieves app restrictions and provides them to the parent class as Bundles. |
| 21 * | 21 * |
| 22 * Needs to be subclassed to specify how to retrieve the restrictions. | 22 * Needs to be subclassed to specify how to retrieve the restrictions. |
| 23 */ | 23 */ |
| 24 public abstract class AbstractAppRestrictionsProvider extends PolicyProvider { | 24 public abstract class AbstractAppRestrictionsProvider extends PolicyProvider { |
| 25 private static final String TAG = "policy"; | 25 private static final String TAG = "policy"; |
| 26 | 26 |
| 27 /** {@link Bundle} holding the restrictions to be used during tests. */ | 27 /** {@link Bundle} holding the restrictions to be used during tests. */ |
| 28 private static Bundle sTestRestrictions = null; | 28 private static Bundle sTestRestrictions; |
| 29 | 29 |
| 30 private final Context mContext; | 30 private final Context mContext; |
| 31 private final BroadcastReceiver mAppRestrictionsChangedReceiver = new Broadc
astReceiver() { | 31 private final BroadcastReceiver mAppRestrictionsChangedReceiver = new Broadc
astReceiver() { |
| 32 @Override | 32 @Override |
| 33 public void onReceive(Context context, Intent intent) { | 33 public void onReceive(Context context, Intent intent) { |
| 34 refresh(); | 34 refresh(); |
| 35 } | 35 } |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /** | 38 /** |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 * restrictions to an empty bundle if nothing is specified. To stop using a
test bundle, | 122 * restrictions to an empty bundle if nothing is specified. To stop using a
test bundle, |
| 123 * provide {@code null} as value instead. | 123 * provide {@code null} as value instead. |
| 124 */ | 124 */ |
| 125 @VisibleForTesting | 125 @VisibleForTesting |
| 126 public static void setTestRestrictions(Bundle policies) { | 126 public static void setTestRestrictions(Bundle policies) { |
| 127 Log.d(TAG, "Test Restrictions: %s", | 127 Log.d(TAG, "Test Restrictions: %s", |
| 128 (policies == null ? null : policies.keySet().toArray())); | 128 (policies == null ? null : policies.keySet().toArray())); |
| 129 sTestRestrictions = policies; | 129 sTestRestrictions = policies; |
| 130 } | 130 } |
| 131 } | 131 } |
| OLD | NEW |