| 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 class URLRequest; | 20 class URLRequest; |
| 21 } // namespace net | 21 } // namespace net |
| 22 | 22 |
| 23 class ConstrainedWindow; | 23 class ConstrainedWindow; |
| 24 class GURL; | 24 class GURL; |
| 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 net::URLRequest that needs it. These functions |
| 28 // be implemented in a thread safe manner. | 28 // must 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, net::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, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. |
| 139 PasswordManager* password_manager_; | 139 PasswordManager* password_manager_; |
| 140 | 140 |
| 141 // Cached from the URLRequest, in case it goes NULL on us. | 141 // Cached from the net::URLRequest, in case it goes NULL on us. |
| 142 int render_process_host_id_; | 142 int render_process_host_id_; |
| 143 int tab_contents_id_; | 143 int tab_contents_id_; |
| 144 | 144 |
| 145 // If not null, points to a model we need to notify of our own destruction | 145 // If not null, points to a model we need to notify of our own destruction |
| 146 // so it doesn't try and access this when its too late. | 146 // so it doesn't try and access this when its too late. |
| 147 LoginModel* login_model_; | 147 LoginModel* login_model_; |
| 148 | 148 |
| 149 // Observes other login handlers so this login handler can respond. | 149 // Observes other login handlers so this login handler can respond. |
| 150 NotificationRegistrar registrar_; | 150 NotificationRegistrar registrar_; |
| 151 }; | 151 }; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 const std::wstring username_; | 185 const std::wstring username_; |
| 186 | 186 |
| 187 // The password that was used for the authentication. | 187 // The password that was used for the authentication. |
| 188 const std::wstring password_; | 188 const std::wstring password_; |
| 189 | 189 |
| 190 DISALLOW_COPY_AND_ASSIGN(AuthSuppliedLoginNotificationDetails); | 190 DISALLOW_COPY_AND_ASSIGN(AuthSuppliedLoginNotificationDetails); |
| 191 }; | 191 }; |
| 192 | 192 |
| 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 // net::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 net::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 net::URLRequest. |
| 202 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 202 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 203 net::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 net::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 |
| 207 // net::URLRequest. |
| 207 void ResetLoginHandlerForRequest(net::URLRequest* request); | 208 void ResetLoginHandlerForRequest(net::URLRequest* request); |
| 208 | 209 |
| 209 // Get the signon_realm under which the identity should be saved. | 210 // Get the signon_realm under which the identity should be saved. |
| 210 std::string GetSignonRealm(const GURL& url, | 211 std::string GetSignonRealm(const GURL& url, |
| 211 const net::AuthChallengeInfo& auth_info); | 212 const net::AuthChallengeInfo& auth_info); |
| 212 | 213 |
| 213 #endif // CHROME_BROWSER_LOGIN_PROMPT_H_ | 214 #endif // CHROME_BROWSER_LOGIN_PROMPT_H_ |
| OLD | NEW |