| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/native/aw_http_auth_handler.h" | 5 #include "android_webview/native/aw_http_auth_handler.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_login_delegate.h" | 7 #include "android_webview/browser/aw_login_delegate.h" |
| 8 #include "android_webview/native/aw_contents.h" | 8 #include "android_webview/native/aw_contents.h" |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "jni/AwHttpAuthHandler_jni.h" | 11 #include "jni/AwHttpAuthHandler_jni.h" |
| 12 #include "net/base/auth.h" | 12 #include "net/base/auth.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 | 14 |
| 15 using base::android::ConvertJavaStringToUTF16; | 15 using base::android::ConvertJavaStringToUTF16; |
| 16 | 16 |
| 17 namespace android_webview { | 17 namespace android_webview { |
| 18 | 18 |
| 19 AwHttpAuthHandler::AwHttpAuthHandler( | 19 AwHttpAuthHandler::AwHttpAuthHandler( |
| 20 AwLoginDelegate* login_delegate, net::AuthChallengeInfo* auth_info) : | 20 AwLoginDelegate* login_delegate, net::AuthChallengeInfo* auth_info) : |
| 21 login_delegate_(make_scoped_refptr(login_delegate)), | 21 login_delegate_(make_scoped_refptr(login_delegate)), |
| 22 host_(auth_info->challenger.host()), | 22 host_(auth_info->challenger.host()), |
| 23 realm_(auth_info->realm) { | 23 realm_(auth_info->realm) { |
| 24 JNIEnv* env = base::android::AttachCurrentThread(); | 24 JNIEnv* env = base::android::AttachCurrentThread(); |
| 25 http_auth_handler_.Reset( | 25 http_auth_handler_.Reset( |
| 26 Java_AwHttpAuthHandler_create(env, reinterpret_cast<jint>(this))); | 26 Java_AwHttpAuthHandler_create(env, reinterpret_cast<jint>(this))); |
| 27 } | 27 } |
| 28 | 28 |
| 29 AwHttpAuthHandler:: ~AwHttpAuthHandler() { |
| 30 } |
| 31 |
| 29 void AwHttpAuthHandler::Proceed(JNIEnv* env, | 32 void AwHttpAuthHandler::Proceed(JNIEnv* env, |
| 30 jobject obj, | 33 jobject obj, |
| 31 jstring user, | 34 jstring user, |
| 32 jstring password) { | 35 jstring password) { |
| 33 login_delegate_->Proceed(ConvertJavaStringToUTF16(env, user), | 36 login_delegate_->Proceed(ConvertJavaStringToUTF16(env, user), |
| 34 ConvertJavaStringToUTF16(env, password)); | 37 ConvertJavaStringToUTF16(env, password)); |
| 35 } | 38 } |
| 36 | 39 |
| 37 void AwHttpAuthHandler::Cancel(JNIEnv* env, jobject obj) { | 40 void AwHttpAuthHandler::Cancel(JNIEnv* env, jobject obj) { |
| 38 login_delegate_->Cancel(); | 41 login_delegate_->Cancel(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 AwHttpAuthHandlerBase* AwHttpAuthHandlerBase::Create( | 53 AwHttpAuthHandlerBase* AwHttpAuthHandlerBase::Create( |
| 51 AwLoginDelegate* login_delegate, net::AuthChallengeInfo* auth_info) { | 54 AwLoginDelegate* login_delegate, net::AuthChallengeInfo* auth_info) { |
| 52 return new AwHttpAuthHandler(login_delegate, auth_info); | 55 return new AwHttpAuthHandler(login_delegate, auth_info); |
| 53 } | 56 } |
| 54 | 57 |
| 55 bool RegisterAwHttpAuthHandler(JNIEnv* env) { | 58 bool RegisterAwHttpAuthHandler(JNIEnv* env) { |
| 56 return RegisterNativesImpl(env) >= 0; | 59 return RegisterNativesImpl(env) >= 0; |
| 57 } | 60 } |
| 58 | 61 |
| 59 } // namespace android_webview | 62 } // namespace android_webview |
| OLD | NEW |