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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | |
| 21 | /** |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 22 | * HTTP authentication request that must be handled by the user interface. |
| 23 | * WebView creates the object and hands it to the current {@link WebViewClient}, |
| 24 | * which must call either {@link #proceed(String, String)} or {@link #cancel()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | */ |
| 26 | public class HttpAuthHandler extends Handler { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 29 | * Package-private constructor needed for API compatibility. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | */ |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 31 | HttpAuthHandler() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @return True if we can use user credentials on record |
| 36 | * (ie, if we did not fail trying to use them last time) |
| 37 | */ |
| 38 | public boolean useHttpAuthUsernamePassword() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | return false; |
| 40 | } |
| 41 | |
| 42 | /** |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 43 | * Cancel the authorization request. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | */ |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 45 | public void cancel() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | /** |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 49 | * Proceed with the authorization with the given credentials. |
Steve Block | c877c6b | 2010-03-12 18:49:48 +0000 | [diff] [blame] | 50 | */ |
Iain Merrick | 10229b2 | 2010-08-31 11:57:15 +0100 | [diff] [blame] | 51 | public void proceed(String username, String password) { |
Steve Block | c6a90a5 | 2010-03-25 15:38:04 +0000 | [diff] [blame] | 52 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | } |