Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: chrome/browser/ui/android/chrome_http_auth_handler.h

Issue 378633002: Upstream support for basic Http authentication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indentation Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_UI_ANDROID_CHROME_HTTP_AUTH_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_ANDROID_CHROME_HTTP_AUTH_HANDLER_H_
6 #define CHROME_BROWSER_UI_ANDROID_CHROME_HTTP_AUTH_HANDLER_H_ 6 #define CHROME_BROWSER_UI_ANDROID_CHROME_HTTP_AUTH_HANDLER_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/login/login_prompt.h" 12 #include "chrome/browser/ui/login/login_prompt.h"
13 13
14 // This class facilitates communication between a native LoginHandler 14 // This class facilitates communication between a native LoginHandler
15 // and a Java land ChromeHttpAuthHandler, which is passed to a 15 // and a Java land ChromeHttpAuthHandler, which is passed to a
16 // ContentViewClient to allow it to respond to HTTP authentication requests 16 // ContentViewClient to allow it to respond to HTTP authentication requests
17 // by, e.g., showing the user a login dialog. 17 // by, e.g., showing the user a login dialog.
18 class ChromeHttpAuthHandler { 18 class ChromeHttpAuthHandler {
19 public: 19 public:
20 ChromeHttpAuthHandler(const base::string16& explanation); 20 explicit ChromeHttpAuthHandler(const base::string16& explanation);
21 ~ChromeHttpAuthHandler(); 21 ~ChromeHttpAuthHandler();
22 22
23 // This must be called before using the object. 23 // This must be called before using the object.
24 // Constructs a corresponding Java land ChromeHttpAuthHandler. 24 // Constructs a corresponding Java land ChromeHttpAuthHandler.
25 void Init(); 25 void Init();
26 26
27 // Registers an observer to receive callbacks when SetAuth() and CancelAuth() 27 // Registers an observer to receive callbacks when SetAuth() and CancelAuth()
28 // are called. |observer| may be NULL in which case the callbacks are skipped. 28 // are called. |observer| may be NULL in which case the callbacks are skipped.
29 void SetObserver(LoginHandler* observer); 29 void SetObserver(LoginHandler* observer);
30 30
31 // Returns a reference to the Java land ChromeHttpAuthHandler. This 31 // Show the dialog prompting for login credentials.
32 // reference must not be released, and remains valid until the native 32 void ShowDialog(jobject window_android);
33 // ChromeHttpAuthHandler is destructed.
34 jobject GetJavaObject();
35 33
36 // Forwards the autofill data to the Java land object. 34 // Forwards the autofill data to the Java land object.
37 void OnAutofillDataAvailable( 35 void OnAutofillDataAvailable(
38 const base::string16& username, 36 const base::string16& username,
39 const base::string16& password); 37 const base::string16& password);
40 38
41 // -------------------------------------------------------------- 39 // --------------------------------------------------------------
42 // JNI Methods 40 // JNI Methods
43 // -------------------------------------------------------------- 41 // --------------------------------------------------------------
44 42
45 // Submits the username and password to the observer. 43 // Submits the username and password to the observer.
46 void SetAuth(JNIEnv* env, jobject, jstring username, jstring password); 44 void SetAuth(JNIEnv* env, jobject, jstring username, jstring password);
47 45
48 // Cancels the authentication attempt of the observer. 46 // Cancels the authentication attempt of the observer.
49 void CancelAuth(JNIEnv* env, jobject); 47 void CancelAuth(JNIEnv* env, jobject);
50 48
51 // These functions return the strings needed to display a login form. 49 // These functions return the strings needed to display a login form.
52 base::android::ScopedJavaLocalRef<jstring> GetMessageTitle( 50 base::android::ScopedJavaLocalRef<jstring> GetMessageTitle(
David Trainor- moved to gerrit 2014/07/07 21:00:42 Do we still need most of these?
Yaron 2014/07/08 00:22:25 Ya. I decided it's a separate change to switch to
53 JNIEnv* env, jobject); 51 JNIEnv* env, jobject);
54 base::android::ScopedJavaLocalRef<jstring> GetMessageBody( 52 base::android::ScopedJavaLocalRef<jstring> GetMessageBody(
55 JNIEnv* env, jobject); 53 JNIEnv* env, jobject);
56 base::android::ScopedJavaLocalRef<jstring> GetUsernameLabelText( 54 base::android::ScopedJavaLocalRef<jstring> GetUsernameLabelText(
57 JNIEnv* env, jobject); 55 JNIEnv* env, jobject);
58 base::android::ScopedJavaLocalRef<jstring> GetPasswordLabelText( 56 base::android::ScopedJavaLocalRef<jstring> GetPasswordLabelText(
59 JNIEnv* env, jobject); 57 JNIEnv* env, jobject);
60 base::android::ScopedJavaLocalRef<jstring> GetOkButtonText( 58 base::android::ScopedJavaLocalRef<jstring> GetOkButtonText(
61 JNIEnv* env, jobject); 59 JNIEnv* env, jobject);
62 base::android::ScopedJavaLocalRef<jstring> GetCancelButtonText( 60 base::android::ScopedJavaLocalRef<jstring> GetCancelButtonText(
63 JNIEnv* env, jobject); 61 JNIEnv* env, jobject);
64 // Registers the ChromeHttpAuthHandler native methods. 62 // Registers the ChromeHttpAuthHandler native methods.
65 static bool RegisterChromeHttpAuthHandler(JNIEnv* env); 63 static bool RegisterChromeHttpAuthHandler(JNIEnv* env);
66 private: 64 private:
67 LoginHandler* observer_; 65 LoginHandler* observer_;
68 base::android::ScopedJavaGlobalRef<jobject> java_chrome_http_auth_handler_; 66 base::android::ScopedJavaGlobalRef<jobject> java_chrome_http_auth_handler_;
69 // e.g. "The server example.com:80 requires a username and password." 67 // e.g. "The server example.com:80 requires a username and password."
70 base::string16 explanation_; 68 base::string16 explanation_;
71 69
72 DISALLOW_COPY_AND_ASSIGN(ChromeHttpAuthHandler); 70 DISALLOW_COPY_AND_ASSIGN(ChromeHttpAuthHandler);
73 }; 71 };
74 72
75 #endif // CHROME_BROWSER_UI_ANDROID_CHROME_HTTP_AUTH_HANDLER_H_ 73 #endif // CHROME_BROWSER_UI_ANDROID_CHROME_HTTP_AUTH_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698