Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 19 | import android.annotation.Nullable; |
| 20 | |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 21 | /** |
| 22 | * Base class for clients to capture Service Worker related callbacks, |
| 23 | * see {@link ServiceWorkerController} for usage example. |
| 24 | */ |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 25 | public class ServiceWorkerClient { |
| 26 | |
| 27 | /** |
| 28 | * Notify the host application of a resource request and allow the |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 29 | * application to return the data. If the return value is {@code null}, the |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 30 | * Service Worker will continue to load the resource as usual. |
| 31 | * Otherwise, the return response and data will be used. |
Nate Fischer | 7051dd1 | 2017-10-26 14:51:25 -0700 | [diff] [blame] | 32 | * |
| 33 | * <p class="note"><b>Note:</b> This method is called on a thread other than the UI thread so |
| 34 | * clients should exercise caution when accessing private data or the view system. |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 35 | * |
| 36 | * @param request Object containing the details of the request. |
| 37 | * @return A {@link android.webkit.WebResourceResponse} containing the |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 38 | * response information or {@code null} if the WebView should load the |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 39 | * resource itself. |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 40 | * @see WebViewClient#shouldInterceptRequest(WebView, WebResourceRequest) |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 41 | */ |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 42 | @Nullable |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 43 | public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) { |
| 44 | return null; |
| 45 | } |
| 46 | } |
| 47 | |