Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProvider.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProvider.java |
| index 88bd0ea071e86442d5127e0046fa7e6618d9c795..87bfd7690272d8245ff71df616be47bbd2cdda00 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProvider.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/superviseduser/SupervisedUserContentProvider.java |
| @@ -9,6 +9,7 @@ import android.content.BroadcastReceiver; |
| import android.content.Context; |
| import android.content.Intent; |
| import android.content.IntentFilter; |
| +import android.net.Uri; |
| import android.os.Build; |
| import android.os.Bundle; |
| import android.os.SystemClock; |
| @@ -45,6 +46,9 @@ public class SupervisedUserContentProvider extends WebRestrictionsContentProvide |
| private static final String TAG = "SupervisedUserContent"; |
| + private static final Object ACCOUNTS_GOOGLE_COM = "accounts.google.com"; |
| + private static final Object GOOGLE_PLAY_SERVICES_UI_PACKAGE = "com.google.android.gms.ui"; |
| + |
| // Three value "boolean" caching enabled state, null if not yet known. |
| private static Boolean sEnabled; |
| @@ -159,7 +163,7 @@ public class SupervisedUserContentProvider extends WebRestrictionsContentProvide |
| } |
| @Override |
| - protected WebRestrictionsResult shouldProceed(final String url) { |
| + protected WebRestrictionsResult shouldProceed(String callingPackage, final String url) { |
| // This will be called on multiple threads (but never the UI thread), |
| // see http://developer.android.com/guide/components/processes-and-threads.html#ThreadSafe. |
| // The reply comes back on a different thread (possibly the UI thread) some time later. |
| @@ -167,12 +171,17 @@ public class SupervisedUserContentProvider extends WebRestrictionsContentProvide |
| // reply object for each query, and passing this through the callback structure. The reply |
| // object also handles waiting for the reply. |
| long startTimeMs = SystemClock.elapsedRealtime(); |
| - final SupervisedUserQueryReply queryReply = new SupervisedUserQueryReply(); |
| + if (requestIsWhitelisted(callingPackage, url)) { |
| + return new WebRestrictionsResult(true, null, null); |
| + } |
| + |
| final long contentProvider = getSupervisedUserContentProvider(); |
| if (contentProvider == 0) { |
| return new WebRestrictionsResult( |
| false, new int[] {FilteringBehaviorReason.NOT_SIGNED_IN}, null); |
| } |
| + |
| + final SupervisedUserQueryReply queryReply = new SupervisedUserQueryReply(); |
| ThreadUtils.runOnUiThread(new Runnable() { |
| @Override |
| public void run() { |
| @@ -197,6 +206,13 @@ public class SupervisedUserContentProvider extends WebRestrictionsContentProvide |
| } |
| } |
| + private boolean requestIsWhitelisted(String callingPackage, String url) { |
| + // Always allow Google Play Services to show the reauthentication page (which is necessary |
| + // to fix account issues). |
| + return callingPackage != null && callingPackage.equals(GOOGLE_PLAY_SERVICES_UI_PACKAGE) |
|
dgn
2017/02/23 12:19:49
nit: TextUtils.equals() to avoid having to check f
Bernhard Bauer
2017/02/23 16:36:21
Good idea! Done.
|
| + && Uri.parse(url).getHost().equals(ACCOUNTS_GOOGLE_COM); |
| + } |
| + |
| @Override |
| protected boolean canInsert() { |
| // Chrome always allows insertion requests. |