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
21import java.util.Map;
22
23/**
24 * Encompasses parameters to the {@link WebViewClient#shouldInterceptRequest} method.
25 */
26public 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     */
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 false for iframes,
38     *         for example.
39     */
40    boolean isForMainFrame();
41
42    /**
43     * Gets whether a gesture (such as a click) was associated with the request.
44     * For security reasons in certain situations this method may return false even though the
45     * sequence of events which caused the request to be created was initiated by a user gesture.
46     *
47     * @return whether a gesture was associated with the request.
48     */
49    boolean hasGesture();
50
51    /**
52     * Gets the method associated with the request, for example "GET".
53     *
54     * @return the method associated with the request.
55     */
56    String getMethod();
57
58    /**
59     * Gets the headers associated with the request. These are represented as a mapping of header
60     * name to header value.
61     *
62     * @return the headers associated with the request.
63     */
64    Map<String, String> getRequestHeaders();
65}
66