1 // Copyright (c) 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.
5 package org.xwalk.core;
7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace;
10 @JNINamespace("xwalk")
11 // TODO(yongsheng): remove public modifier.
12 public class XWalkHttpAuthHandler {
14 private int mNativeXWalkHttpAuthHandler;
15 private final boolean mFirstAttempt;
17 public void proceed(String username, String password) {
18 if (mNativeXWalkHttpAuthHandler != 0) {
19 nativeProceed(mNativeXWalkHttpAuthHandler, username, password);
20 mNativeXWalkHttpAuthHandler = 0;
24 public void cancel() {
25 if (mNativeXWalkHttpAuthHandler != 0) {
26 nativeCancel(mNativeXWalkHttpAuthHandler);
27 mNativeXWalkHttpAuthHandler = 0;
31 public boolean isFirstAttempt() {
36 public static XWalkHttpAuthHandler create(int nativeXWalkAuthHandler, boolean firstAttempt) {
37 return new XWalkHttpAuthHandler(nativeXWalkAuthHandler, firstAttempt);
40 private XWalkHttpAuthHandler(int nativeXWalkHttpAuthHandler, boolean firstAttempt) {
41 mNativeXWalkHttpAuthHandler = nativeXWalkHttpAuthHandler;
42 mFirstAttempt = firstAttempt;
46 void handlerDestroyed() {
47 mNativeXWalkHttpAuthHandler = 0;
50 private native void nativeProceed(int nativeXWalkHttpAuthHandler,
51 String username, String password);
52 private native void nativeCancel(int nativeXWalkHttpAuthHandler);