1 // Copyright 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.android_webview; 6 7 import org.chromium.base.CalledByNative; 8 import org.chromium.base.JNINamespace; 9 10 @JNINamespace("android_webview") 11 public class AwHttpAuthHandler { 12 13 private long mNativeAwHttpAuthHandler; 14 private final boolean mFirstAttempt; 15 proceed(String username, String password)16 public void proceed(String username, String password) { 17 if (mNativeAwHttpAuthHandler != 0) { 18 nativeProceed(mNativeAwHttpAuthHandler, username, password); 19 mNativeAwHttpAuthHandler = 0; 20 } 21 } 22 cancel()23 public void cancel() { 24 if (mNativeAwHttpAuthHandler != 0) { 25 nativeCancel(mNativeAwHttpAuthHandler); 26 mNativeAwHttpAuthHandler = 0; 27 } 28 } 29 isFirstAttempt()30 public boolean isFirstAttempt() { 31 return mFirstAttempt; 32 } 33 34 @CalledByNative create(long nativeAwAuthHandler, boolean firstAttempt)35 public static AwHttpAuthHandler create(long nativeAwAuthHandler, boolean firstAttempt) { 36 return new AwHttpAuthHandler(nativeAwAuthHandler, firstAttempt); 37 } 38 AwHttpAuthHandler(long nativeAwHttpAuthHandler, boolean firstAttempt)39 private AwHttpAuthHandler(long nativeAwHttpAuthHandler, boolean firstAttempt) { 40 mNativeAwHttpAuthHandler = nativeAwHttpAuthHandler; 41 mFirstAttempt = firstAttempt; 42 } 43 44 @CalledByNative handlerDestroyed()45 void handlerDestroyed() { 46 mNativeAwHttpAuthHandler = 0; 47 } 48 nativeProceed(long nativeAwHttpAuthHandler, String username, String password)49 private native void nativeProceed(long nativeAwHttpAuthHandler, 50 String username, String password); nativeCancel(long nativeAwHttpAuthHandler)51 private native void nativeCancel(long nativeAwHttpAuthHandler); 52 } 53