The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | |
| 22 | /** |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 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. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | */ |
| 29 | public class HttpAuthHandler extends Handler { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
| 31 | /** |
Ben Murdoch | 2433fe9 | 2012-08-22 19:46:45 +0100 | [diff] [blame] | 32 | * @hide Only for use by WebViewProvider implementations. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 34 | @SystemApi |
Ben Murdoch | 2433fe9 | 2012-08-22 19:46:45 +0100 | [diff] [blame] | 35 | public HttpAuthHandler() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /** |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 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 |
Jonathan Dixon | 47aaba3 | 2012-11-30 16:32:17 -0800 | [diff] [blame] | 45 | * @see WebView#getHttpAuthUsernamePassword |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | */ |
| 47 | public boolean useHttpAuthUsernamePassword() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | return false; |
| 49 | } |
| 50 | |
| 51 | /** |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 52 | * Instructs the WebView to cancel the authentication request. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | */ |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 54 | public void cancel() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | /** |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 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}. |
Steve Block | c877c6b | 2010-03-12 18:49:48 +0000 | [diff] [blame] | 61 | */ |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 62 | public void proceed(String username, String password) { |
Steve Block | c6a90a5 | 2010-03-25 15:38:04 +0000 | [diff] [blame] | 63 | } |
Ben Murdoch | a7f0ed4 | 2011-08-05 15:46:52 +0100 | [diff] [blame] | 64 | |
| 65 | /** |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 66 | * Gets whether the prompt dialog should be suppressed. |
| 67 | * |
| 68 | * @return whether the prompt dialog should be suppressed |
Ben Murdoch | a7f0ed4 | 2011-08-05 15:46:52 +0100 | [diff] [blame] | 69 | * @hide |
| 70 | */ |
| 71 | public boolean suppressDialog() { |
| 72 | return false; |
| 73 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | } |