OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_LOGIN_PROMPT_H_ | 5 #ifndef CHROME_BROWSER_LOGIN_PROMPT_H_ |
6 #define CHROME_BROWSER_LOGIN_PROMPT_H_ | 6 #define CHROME_BROWSER_LOGIN_PROMPT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/lock.h" | 12 #include "base/lock.h" |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
14 #include "chrome/browser/password_manager/password_manager.h" | 14 #include "chrome/browser/password_manager/password_manager.h" |
15 #include "chrome/common/notification_observer.h" | 15 #include "chrome/common/notification_observer.h" |
16 #include "chrome/common/notification_registrar.h" | 16 #include "chrome/common/notification_registrar.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 class AuthChallengeInfo; | 19 class AuthChallengeInfo; |
20 } | 20 class URLRequest; |
| 21 } // namespace net |
21 | 22 |
22 class ConstrainedWindow; | 23 class ConstrainedWindow; |
23 class GURL; | 24 class GURL; |
24 class URLRequest; | |
25 | 25 |
26 // This is the base implementation for the OS-specific classes that route | 26 // This is the base implementation for the OS-specific classes that route |
27 // authentication info to the URLRequest that needs it. These functions must | 27 // authentication info to the URLRequest that needs it. These functions must |
28 // be implemented in a thread safe manner. | 28 // be implemented in a thread safe manner. |
29 class LoginHandler : public base::RefCountedThreadSafe<LoginHandler>, | 29 class LoginHandler : public base::RefCountedThreadSafe<LoginHandler>, |
30 public LoginModelObserver, | 30 public LoginModelObserver, |
31 public NotificationObserver { | 31 public NotificationObserver { |
32 public: | 32 public: |
33 LoginHandler(net::AuthChallengeInfo* auth_info, URLRequest* request); | 33 LoginHandler(net::AuthChallengeInfo* auth_info, net::URLRequest* request); |
34 virtual ~LoginHandler(); | 34 virtual ~LoginHandler(); |
35 | 35 |
36 // Builds the platform specific LoginHandler. Used from within | 36 // Builds the platform specific LoginHandler. Used from within |
37 // CreateLoginPrompt() which creates tasks. | 37 // CreateLoginPrompt() which creates tasks. |
38 static LoginHandler* Create(net::AuthChallengeInfo* auth_info, | 38 static LoginHandler* Create(net::AuthChallengeInfo* auth_info, |
39 URLRequest* request); | 39 net::URLRequest* request); |
40 | 40 |
41 // Initializes the underlying platform specific view. | 41 // Initializes the underlying platform specific view. |
42 virtual void BuildViewForPasswordManager(PasswordManager* manager, | 42 virtual void BuildViewForPasswordManager(PasswordManager* manager, |
43 std::wstring explanation) = 0; | 43 std::wstring explanation) = 0; |
44 | 44 |
45 // Sets information about the authentication type (|form|) and the | 45 // Sets information about the authentication type (|form|) and the |
46 // |password_manager| for this profile. | 46 // |password_manager| for this profile. |
47 void SetPasswordForm(const webkit_glue::PasswordForm& form); | 47 void SetPasswordForm(const webkit_glue::PasswordForm& form); |
48 void SetPasswordManager(PasswordManager* password_manager); | 48 void SetPasswordManager(PasswordManager* password_manager); |
49 | 49 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 // The ConstrainedWindow that is hosting our LoginView. | 119 // The ConstrainedWindow that is hosting our LoginView. |
120 // This should only be accessed on the UI loop. | 120 // This should only be accessed on the UI loop. |
121 ConstrainedWindow* dialog_; | 121 ConstrainedWindow* dialog_; |
122 | 122 |
123 // Who/where/what asked for the authentication. | 123 // Who/where/what asked for the authentication. |
124 scoped_refptr<net::AuthChallengeInfo> auth_info_; | 124 scoped_refptr<net::AuthChallengeInfo> auth_info_; |
125 | 125 |
126 // The request that wants login data. | 126 // The request that wants login data. |
127 // This should only be accessed on the IO loop. | 127 // This should only be accessed on the IO loop. |
128 URLRequest* request_; | 128 net::URLRequest* request_; |
129 | 129 |
130 // The PasswordForm sent to the PasswordManager. This is so we can refer to it | 130 // The PasswordForm sent to the PasswordManager. This is so we can refer to it |
131 // when later notifying the password manager if the credentials were accepted | 131 // when later notifying the password manager if the credentials were accepted |
132 // or rejected. | 132 // or rejected. |
133 // This should only be accessed on the UI loop. | 133 // This should only be accessed on the UI loop. |
134 webkit_glue::PasswordForm password_form_; | 134 webkit_glue::PasswordForm password_form_; |
135 | 135 |
136 // Points to the password manager owned by the TabContents requesting auth. | 136 // Points to the password manager owned by the TabContents requesting auth. |
137 // Can be null if the TabContents is not a TabContents. | 137 // Can be null if the TabContents is not a TabContents. |
138 // This should only be accessed on the UI loop. | 138 // This should only be accessed on the UI loop. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Prompts the user for their username and password. This is designed to | 193 // Prompts the user for their username and password. This is designed to |
194 // be called on the background (I/O) thread, in response to | 194 // be called on the background (I/O) thread, in response to |
195 // URLRequest::Delegate::OnAuthRequired. The prompt will be created | 195 // URLRequest::Delegate::OnAuthRequired. The prompt will be created |
196 // on the main UI thread via a call to UI loop's InvokeLater, and will send the | 196 // on the main UI thread via a call to UI loop's InvokeLater, and will send the |
197 // credentials back to the URLRequest on the calling thread. | 197 // credentials back to the URLRequest on the calling thread. |
198 // A LoginHandler object (which lives on the calling thread) is returned, | 198 // A LoginHandler object (which lives on the calling thread) is returned, |
199 // which can be used to set or cancel authentication programmatically. The | 199 // which can be used to set or cancel authentication programmatically. The |
200 // caller must invoke OnRequestCancelled() on this LoginHandler before | 200 // caller must invoke OnRequestCancelled() on this LoginHandler before |
201 // destroying the URLRequest. | 201 // destroying the URLRequest. |
202 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 202 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
203 URLRequest* request); | 203 net::URLRequest* request); |
204 | 204 |
205 // Helper to remove the ref from an URLRequest to the LoginHandler. | 205 // Helper to remove the ref from an URLRequest to the LoginHandler. |
206 // Should only be called from the IO thread, since it accesses an URLRequest. | 206 // Should only be called from the IO thread, since it accesses an URLRequest. |
207 void ResetLoginHandlerForRequest(URLRequest* request); | 207 void ResetLoginHandlerForRequest(net::URLRequest* request); |
208 | 208 |
209 // Get the signon_realm under which the identity should be saved. | 209 // Get the signon_realm under which the identity should be saved. |
210 std::string GetSignonRealm(const GURL& url, | 210 std::string GetSignonRealm(const GURL& url, |
211 const net::AuthChallengeInfo& auth_info); | 211 const net::AuthChallengeInfo& auth_info); |
212 | 212 |
213 #endif // CHROME_BROWSER_LOGIN_PROMPT_H_ | 213 #endif // CHROME_BROWSER_LOGIN_PROMPT_H_ |
OLD | NEW |