1 /* 2 * Copyright (C) 2006 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.os.Handler; 20 21 /** 22 * Represents a request for HTTP authentication. Instances of this class are 23 * created by the WebView and passed to 24 * {@link WebViewClient#onReceivedHttpAuthRequest}. The host application must 25 * call either {@link #proceed} or {@link #cancel} to set the WebView's 26 * response to the request. 27 */ 28 public class HttpAuthHandler extends Handler { 29 30 /** 31 * @hide Only for use by WebViewProvider implementations. 32 */ 33 public HttpAuthHandler() { 34 } 35 36 /** 37 * Gets whether the credentials stored for the current host (i.e. the host 38 * for which {@link WebViewClient#onReceivedHttpAuthRequest} was called) 39 * are suitable for use. Credentials are not suitable if they have 40 * previously been rejected by the server for the current request. 41 * 42 * @return whether the credentials are suitable for use 43 * @see WebView#getHttpAuthUsernamePassword 44 */ 45 public boolean useHttpAuthUsernamePassword() { 46 return false; 47 } 48 49 /** 50 * Instructs the WebView to cancel the authentication request. 51 */ 52 public void cancel() { 53 } 54 55 /** 56 * Instructs the WebView to proceed with the authentication with the given 57 * credentials. Credentials for use with this method can be retrieved from 58 * the WebView's store using {@link WebView#getHttpAuthUsernamePassword}. 59 */ 60 public void proceed(String username, String password) { 61 } 62 63 /** 64 * Gets whether the prompt dialog should be suppressed. 65 * 66 * @return whether the prompt dialog should be suppressed 67 * @hide 68 */ 69 public boolean suppressDialog() { 70 return false; 71 } 72 } 73