From 2871febb19c02c2d11c0aa3835e884361e60c580 Mon Sep 17 00:00:00 2001 From: Tao Bai Date: Wed, 16 Jul 2014 13:54:15 -0700 Subject: WebView permission change As requested by API council, the following were changed - Changed the PermissionRequest to abstract. - Used String for resources instead of long. - Also remove the WebView.preauthorizePermission() which we didn't think BUG: 15432556 Change-Id: I900a98b4e0288d2bcd8faf0bbcd84970600548a5 --- api/current.txt | 15 ++++++------- core/java/android/webkit/PermissionRequest.java | 30 +++++++++++++------------ core/java/android/webkit/WebChromeClient.java | 2 +- core/java/android/webkit/WebView.java | 17 -------------- core/java/android/webkit/WebViewProvider.java | 2 -- 5 files changed, 24 insertions(+), 42 deletions(-) diff --git a/api/current.txt b/api/current.txt index a49e0f77b4ed..8f446a0b7e1d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -36715,15 +36715,15 @@ package android.webkit { method public boolean hasMimeType(java.lang.String); } - public abstract interface PermissionRequest { + public abstract class PermissionRequest { + ctor public PermissionRequest(); method public abstract void deny(); method public abstract android.net.Uri getOrigin(); - method public abstract long getResources(); - method public abstract void grant(long); - field public static final long RESOURCE_AUDIO_CAPTURE = 4L; // 0x4L - field public static final long RESOURCE_GEOLOCATION = 1L; // 0x1L - field public static final long RESOURCE_PROTECTED_MEDIA_ID = 8L; // 0x8L - field public static final long RESOURCE_VIDEO_CAPTURE = 2L; // 0x2L + method public abstract java.lang.String[] getResources(); + method public abstract void grant(java.lang.String[]); + field public static final java.lang.String RESOURCE_AUDIO_CAPTURE = "android.webkit.resource.AUDIO_CAPTURE"; + field public static final java.lang.String RESOURCE_PROTECTED_MEDIA_ID = "android.webkit.resource.PROTECTED_MEDIA_ID"; + field public static final java.lang.String RESOURCE_VIDEO_CAPTURE = "android.webkit.resource.VIDEO_CAPTURE"; } public abstract interface PluginStub { @@ -37102,7 +37102,6 @@ package android.webkit { method public boolean pageUp(boolean); method public void pauseTimers(); method public void postUrl(java.lang.String, byte[]); - method public void preauthorizePermission(android.net.Uri, long); method public void reload(); method public void removeJavascriptInterface(java.lang.String); method public void requestFocusNodeHref(android.os.Message); diff --git a/core/java/android/webkit/PermissionRequest.java b/core/java/android/webkit/PermissionRequest.java index 0a0507ecb5c3..862e8c2d0d6e 100644 --- a/core/java/android/webkit/PermissionRequest.java +++ b/core/java/android/webkit/PermissionRequest.java @@ -22,39 +22,41 @@ import android.net.Uri; * This interface defines a permission request and is used when web content * requests access to protected resources. * - * Either {@link #grant(long) grant()} or {@link #deny()} must be called in UI + * Either {@link #grant(String[]) grant()} or {@link #deny()} must be called in UI * thread to respond to the request. */ -public interface PermissionRequest { - /** - * Resource belongs to geolocation service. - */ - public final static long RESOURCE_GEOLOCATION = 1 << 0; +public abstract class PermissionRequest { /** * Resource belongs to video capture device, like camera. */ - public final static long RESOURCE_VIDEO_CAPTURE = 1 << 1; + public final static String RESOURCE_VIDEO_CAPTURE = "android.webkit.resource.VIDEO_CAPTURE"; /** * Resource belongs to audio capture device, like microphone. */ - public final static long RESOURCE_AUDIO_CAPTURE = 1 << 2; + public final static String RESOURCE_AUDIO_CAPTURE = "android.webkit.resource.AUDIO_CAPTURE"; /** * Resource belongs to protected media identifier. * After the user grants this resource, the origin can use EME APIs to generate the license * requests. */ - public final static long RESOURCE_PROTECTED_MEDIA_ID = 1 << 3; + public final static String RESOURCE_PROTECTED_MEDIA_ID = + "android.webkit.resource.PROTECTED_MEDIA_ID"; /** + * Call this method to get the origin of the web page which is trying to access + * the restricted resources. + * * @return the origin of web content which attempt to access the restricted * resources. */ - public Uri getOrigin(); + public abstract Uri getOrigin(); /** - * @return a bit mask of resources the web content wants to access. + * Call this method to get the resources the web page is trying to access. + * + * @return the array of resources the web content wants to access. */ - public long getResources(); + public abstract String[] getResources(); /** * Call this method to grant origin the permission to access the given resources. @@ -66,10 +68,10 @@ public interface PermissionRequest { * This parameter is designed to avoid granting permission by accident * especially when new resources are requested by web content. */ - public void grant(long resources); + public abstract void grant(String[] resources); /** * Call this method to deny the request. */ - public void deny(); + public abstract void deny(); } diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java index 470d4134c0b7..03cb95235e38 100644 --- a/core/java/android/webkit/WebChromeClient.java +++ b/core/java/android/webkit/WebChromeClient.java @@ -298,7 +298,7 @@ public class WebChromeClient { /** * Notify the host application that web content is requesting permission to * access the specified resources and the permission currently isn't granted - * or denied. The host application must invoke {@link PermissionRequest#grant(long)} + * or denied. The host application must invoke {@link PermissionRequest#grant(String[])} * or {@link PermissionRequest#deny()}. * * If this method isn't overridden, the permission is denied. diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 9cf3e4f1eb1a..cc41669659c4 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1680,23 +1680,6 @@ public class WebView extends AbsoluteLayout mProvider.setWebChromeClient(client); } - /** - * Preauthorize the given origin to access resources. - * The authorization only valid for this WebView instance's life cycle and - * will not retained. - * - * In the case that an origin has had resources preauthorized, calls to - * {@link WebChromeClient#onPermissionRequest(PermissionRequest)} will not be - * made for those resources from that origin. - * - * @param origin the origin authorized to access resources - * @param resources the resource authorized to be accessed by origin. - */ - public void preauthorizePermission(Uri origin, long resources) { - checkThread(); - mProvider.preauthorizePermission(origin, resources); - } - /** * Sets the Picture listener. This is an interface used to receive * notifications of a new Picture. diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java index 13cd2bdd4969..fe18138892ad 100644 --- a/core/java/android/webkit/WebViewProvider.java +++ b/core/java/android/webkit/WebViewProvider.java @@ -248,8 +248,6 @@ public interface WebViewProvider { public View findHierarchyView(String className, int hashCode); - public void preauthorizePermission(Uri origin, long resources); - //------------------------------------------------------------------------- // Provider internal methods //------------------------------------------------------------------------- -- cgit v1.2.3-59-g8ed1b