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 17 package android.webkit; 18 19 import android.net.Uri; 20 21 import java.util.Map; 22 23 /** 24 * Encompasses parameters to the {@link WebViewClient#shouldInterceptRequest} method. 25 */ 26 public interface WebResourceRequest { 27 /** 28 * Gets the URL for which the resource request was made. 29 * 30 * @return the URL for which the resource request was made. 31 */ getUrl()32 Uri getUrl(); 33 34 /** 35 * Gets whether the request was made for the main frame. 36 * 37 * @return whether the request was made for the main frame. Will be {@code false} for iframes, 38 * for example. 39 */ isForMainFrame()40 boolean isForMainFrame(); 41 42 /** 43 * Gets whether the request was a result of a server-side redirect. 44 * 45 * @return whether the request was a result of a server-side redirect. 46 */ isRedirect()47 boolean isRedirect(); 48 49 /** 50 * Gets whether a gesture (such as a click) was associated with the request. 51 * For security reasons in certain situations this method may return {@code false} even though 52 * the sequence of events which caused the request to be created was initiated by a user 53 * gesture. 54 * 55 * @return whether a gesture was associated with the request. 56 */ hasGesture()57 boolean hasGesture(); 58 59 /** 60 * Gets the method associated with the request, for example "GET". 61 * 62 * @return the method associated with the request. 63 */ getMethod()64 String getMethod(); 65 66 /** 67 * Gets the headers associated with the request. These are represented as a mapping of header 68 * name to header value. 69 * 70 * @return the headers associated with the request. 71 */ getRequestHeaders()72 Map<String, String> getRequestHeaders(); 73 } 74