PermissionRequest.java revision 93415a2713ccee26400c75b2b6a39c2f1b32eb96
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.webkit; 18 19import android.net.Uri; 20 21/** 22 * This interface defines a permission request and is used when web content 23 * requests access to protected resources. 24 * 25 * Either {@link #grant(long) grant()} or {@link #deny()} must be called in UI 26 * thread to respond to the request. 27 */ 28public interface PermissionRequest { 29 /** 30 * Resource belongs to geolocation service. 31 * @hide - see b/14668406 32 */ 33 public final static long RESOURCE_GEOLOCATION = 1 << 0; 34 /** 35 * Resource belongs to video capture device, like camera. 36 */ 37 public final static long RESOURCE_VIDEO_CAPTURE = 1 << 1; 38 /** 39 * Resource belongs to audio capture device, like microphone. 40 */ 41 public final static long RESOURCE_AUDIO_CAPTURE = 1 << 2; 42 /** 43 * Resource belongs to protected media identifier. 44 * After the user grants this resource, the origin can use EME APIs to generate the license 45 * requests. 46 */ 47 public final static long RESOURCE_PROTECTED_MEDIA_ID = 1 << 3; 48 49 /** 50 * @return the origin of web content which attempt to access the restricted 51 * resources. 52 */ 53 public Uri getOrigin(); 54 55 /** 56 * @return a bit mask of resources the web content wants to access. 57 */ 58 public long getResources(); 59 60 /** 61 * Call this method to grant origin the permission to access the given resources. 62 * The granted permission is only valid for this WebView. 63 * 64 * @param resources the resources granted to be accessed by origin, to grant 65 * request, the requested resources returned by {@link #getResources()} 66 * must be equals or a subset of granted resources. 67 * This parameter is designed to avoid granting permission by accident 68 * especially when new resources are requested by web content. 69 */ 70 public void grant(long resources); 71 72 /** 73 * Call this method to deny the request. 74 */ 75 public void deny(); 76} 77