1 /* 2 * Copyright (C) 2007 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.annotation.SystemApi; 20 import android.os.Handler; 21 22 /** 23 * Represents a request for handling an SSL error. 24 * 25 * <p>A {@link WebView} creates an instance of this class. The instance is 26 * passed to {@link WebViewClient#onReceivedSslError(WebView, SslErrorHandler, 27 * SslError)}. 28 * 29 * <p>The host application must call {@link #cancel()} or, contrary to secure 30 * web communication standards, {@link #proceed()} to provide the web view's 31 * response to the request. 32 */ 33 public class SslErrorHandler extends Handler { 34 35 /** 36 * @hide Only for use by WebViewProvider implementations. 37 */ 38 @SystemApi SslErrorHandler()39 public SslErrorHandler() {} 40 41 /** 42 * Instructs the {@code WebView} that encountered the SSL certificate error 43 * to ignore the error and continue communicating with the server. 44 * 45 * <p class="warning"><b>Warning:</b> When an SSL error occurs, the host 46 * application should always call {@link #cancel()} rather than 47 * {@code proceed()} because an invalid SSL certificate means the connection 48 * is not secure. 49 * 50 * @see WebViewClient#onReceivedSslError(WebView, SslErrorHandler, 51 * SslError) 52 */ proceed()53 public void proceed() {} 54 55 /** 56 * Instructs the {@code WebView} that encountered the SSL certificate error 57 * to terminate communication with the server. Cancels the current server 58 * request and all pending requests for the {@code WebView}. 59 * 60 * <p>The host application must call this method to prevent a resource from 61 * loading when an SSL certificate is invalid. 62 * 63 * @see WebViewClient#onReceivedSslError(WebView, SslErrorHandler, 64 * SslError) 65 */ cancel()66 public void cancel() {} 67 } 68