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 #ifndef ANDROID_WEBVIEW_BROWSER_AW_HTTP_AUTH_HANDLER_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_HTTP_AUTH_HANDLER_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_AW_HTTP_AUTH_HANDLER_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_AW_HTTP_AUTH_HANDLER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "android_webview/browser/aw_http_auth_handler_base.h" | |
12 #include "android_webview/browser/aw_login_delegate.h" | |
13 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
14 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
15 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
16 | 14 |
17 namespace content { | 15 namespace content { |
18 class WebContents; | 16 class WebContents; |
19 }; | 17 }; |
20 | 18 |
21 namespace net { | 19 namespace net { |
22 class AuthChallengeInfo; | 20 class AuthChallengeInfo; |
23 }; | 21 }; |
24 | 22 |
25 namespace android_webview { | 23 namespace android_webview { |
26 | 24 |
| 25 class AwLoginDelegate; |
| 26 |
27 // Native class for Java class of same name and owns an instance | 27 // Native class for Java class of same name and owns an instance |
28 // of that Java object. | 28 // of that Java object. |
29 // One instance of this class is created per underlying AwLoginDelegate. | 29 // One instance of this class is created per underlying AwLoginDelegate. |
30 class AwHttpAuthHandler : public AwHttpAuthHandlerBase { | 30 class AwHttpAuthHandler { |
31 public: | 31 public: |
| 32 static AwHttpAuthHandler* Create(AwLoginDelegate* login_delegate, |
| 33 net::AuthChallengeInfo* auth_info, |
| 34 bool first_auth_attempt); |
32 AwHttpAuthHandler(AwLoginDelegate* login_delegate, | 35 AwHttpAuthHandler(AwLoginDelegate* login_delegate, |
33 net::AuthChallengeInfo* auth_info, | 36 net::AuthChallengeInfo* auth_info, |
34 bool first_auth_attempt); | 37 bool first_auth_attempt); |
35 ~AwHttpAuthHandler() override; | 38 ~AwHttpAuthHandler(); |
36 | 39 |
37 // from AwHttpAuthHandler | 40 // from AwHttpAuthHandler |
38 bool HandleOnUIThread(content::WebContents* web_contents) override; | 41 bool HandleOnUIThread(content::WebContents* web_contents); |
39 | 42 |
40 void Proceed(JNIEnv* env, | 43 void Proceed(JNIEnv* env, |
41 const base::android::JavaParamRef<jobject>& obj, | 44 const base::android::JavaParamRef<jobject>& obj, |
42 const base::android::JavaParamRef<jstring>& username, | 45 const base::android::JavaParamRef<jstring>& username, |
43 const base::android::JavaParamRef<jstring>& password); | 46 const base::android::JavaParamRef<jstring>& password); |
44 void Cancel(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 47 void Cancel(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
45 | 48 |
46 private: | 49 private: |
47 scoped_refptr<AwLoginDelegate> login_delegate_; | 50 scoped_refptr<AwLoginDelegate> login_delegate_; |
48 base::android::ScopedJavaGlobalRef<jobject> http_auth_handler_; | 51 base::android::ScopedJavaGlobalRef<jobject> http_auth_handler_; |
49 std::string host_; | 52 std::string host_; |
50 std::string realm_; | 53 std::string realm_; |
51 }; | 54 }; |
52 | 55 |
53 bool RegisterAwHttpAuthHandler(JNIEnv* env); | 56 bool RegisterAwHttpAuthHandler(JNIEnv* env); |
54 | 57 |
55 } // namespace android_webview | 58 } // namespace android_webview |
56 | 59 |
57 #endif // ANDROID_WEBVIEW_BROWSER_AW_HTTP_AUTH_HANDLER_H_ | 60 #endif // ANDROID_WEBVIEW_BROWSER_AW_HTTP_AUTH_HANDLER_H_ |
OLD | NEW |