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