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

Side by Side Diff: chrome/browser/ui/login/login_prompt.h

Issue 6312154: Remove wstring from RVH's run Javascript command.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 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_UI_LOGIN_LOGIN_PROMPT_H_ 5 #ifndef CHROME_BROWSER_UI_LOGIN_LOGIN_PROMPT_H_
6 #define CHROME_BROWSER_UI_LOGIN_LOGIN_PROMPT_H_ 6 #define CHROME_BROWSER_UI_LOGIN_LOGIN_PROMPT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 23 matching lines...) Expand all
34 LoginHandler(net::AuthChallengeInfo* auth_info, net::URLRequest* request); 34 LoginHandler(net::AuthChallengeInfo* auth_info, net::URLRequest* request);
35 virtual ~LoginHandler(); 35 virtual ~LoginHandler();
36 36
37 // Builds the platform specific LoginHandler. Used from within 37 // Builds the platform specific LoginHandler. Used from within
38 // CreateLoginPrompt() which creates tasks. 38 // CreateLoginPrompt() which creates tasks.
39 static LoginHandler* Create(net::AuthChallengeInfo* auth_info, 39 static LoginHandler* Create(net::AuthChallengeInfo* auth_info,
40 net::URLRequest* request); 40 net::URLRequest* request);
41 41
42 // Initializes the underlying platform specific view. 42 // Initializes the underlying platform specific view.
43 virtual void BuildViewForPasswordManager(PasswordManager* manager, 43 virtual void BuildViewForPasswordManager(PasswordManager* manager,
44 std::wstring explanation) = 0; 44 const string16& explanation) = 0;
45 45
46 // Sets information about the authentication type (|form|) and the 46 // Sets information about the authentication type (|form|) and the
47 // |password_manager| for this profile. 47 // |password_manager| for this profile.
48 void SetPasswordForm(const webkit_glue::PasswordForm& form); 48 void SetPasswordForm(const webkit_glue::PasswordForm& form);
49 void SetPasswordManager(PasswordManager* password_manager); 49 void SetPasswordManager(PasswordManager* password_manager);
50 50
51 // Returns the TabContents that needs authentication. 51 // Returns the TabContents that needs authentication.
52 TabContents* GetTabContentsForLogin() const; 52 TabContents* GetTabContentsForLogin() const;
53 53
54 // Returns the RenderViewHostDelegate for the page that needs authentication. 54 // Returns the RenderViewHostDelegate for the page that needs authentication.
55 RenderViewHostDelegate* GetRenderViewHostDelegate() const; 55 RenderViewHostDelegate* GetRenderViewHostDelegate() const;
56 56
57 // Resend the request with authentication credentials. 57 // Resend the request with authentication credentials.
58 // This function can be called from either thread. 58 // This function can be called from either thread.
59 void SetAuth(const std::wstring& username, const std::wstring& password); 59 void SetAuth(const string16& username, const string16& password);
60 60
61 // Display the error page without asking for credentials again. 61 // Display the error page without asking for credentials again.
62 // This function can be called from either thread. 62 // This function can be called from either thread.
63 void CancelAuth(); 63 void CancelAuth();
64 64
65 // Notify the handler that the request was cancelled. 65 // Notify the handler that the request was cancelled.
66 // This function can only be called from the IO thread. 66 // This function can only be called from the IO thread.
67 void OnRequestCancelled(); 67 void OnRequestCancelled();
68 68
69 // Implements the NotificationObserver interface. 69 // Implements the NotificationObserver interface.
(...skipping 22 matching lines...) Expand all
92 void ReleaseSoon(); 92 void ReleaseSoon();
93 93
94 private: 94 private:
95 // Starts observing notifications from other LoginHandlers. 95 // Starts observing notifications from other LoginHandlers.
96 void AddObservers(); 96 void AddObservers();
97 97
98 // Stops observing notifications from other LoginHandlers. 98 // Stops observing notifications from other LoginHandlers.
99 void RemoveObservers(); 99 void RemoveObservers();
100 100
101 // Notify observers that authentication is supplied. 101 // Notify observers that authentication is supplied.
102 void NotifyAuthSupplied(const std::wstring& username, 102 void NotifyAuthSupplied(const string16& username,
103 const std::wstring& password); 103 const string16& password);
104 104
105 // Notify observers that authentication is cancelled. 105 // Notify observers that authentication is cancelled.
106 void NotifyAuthCancelled(); 106 void NotifyAuthCancelled();
107 107
108 // Marks authentication as handled and returns the previous handled 108 // Marks authentication as handled and returns the previous handled
109 // state. 109 // state.
110 bool TestAndSetAuthHandled(); 110 bool TestAndSetAuthHandled();
111 111
112 // Calls SetAuth from the IO loop. 112 // Calls SetAuth from the IO loop.
113 void SetAuthDeferred(const std::wstring& username, 113 void SetAuthDeferred(const string16& username,
114 const std::wstring& password); 114 const string16& password);
115 115
116 // Calls CancelAuth from the IO loop. 116 // Calls CancelAuth from the IO loop.
117 void CancelAuthDeferred(); 117 void CancelAuthDeferred();
118 118
119 // Closes the view_contents from the UI loop. 119 // Closes the view_contents from the UI loop.
120 void CloseContentsDeferred(); 120 void CloseContentsDeferred();
121 121
122 // True if we've handled auth (SetAuth or CancelAuth has been called). 122 // True if we've handled auth (SetAuth or CancelAuth has been called).
123 bool handled_auth_; 123 bool handled_auth_;
124 mutable base::Lock handled_auth_lock_; 124 mutable base::Lock handled_auth_lock_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 DISALLOW_COPY_AND_ASSIGN(LoginNotificationDetails); 173 DISALLOW_COPY_AND_ASSIGN(LoginNotificationDetails);
174 }; 174 };
175 175
176 // Details to provide the NotificationObserver. Used by the automation proxy 176 // Details to provide the NotificationObserver. Used by the automation proxy
177 // for testing and by other LoginHandlers to dismiss themselves when an 177 // for testing and by other LoginHandlers to dismiss themselves when an
178 // identical auth is supplied. 178 // identical auth is supplied.
179 class AuthSuppliedLoginNotificationDetails : public LoginNotificationDetails { 179 class AuthSuppliedLoginNotificationDetails : public LoginNotificationDetails {
180 public: 180 public:
181 AuthSuppliedLoginNotificationDetails(LoginHandler* handler, 181 AuthSuppliedLoginNotificationDetails(LoginHandler* handler,
182 const std::wstring& username, 182 const string16& username,
183 const std::wstring& password) 183 const string16& password)
184 : LoginNotificationDetails(handler), 184 : LoginNotificationDetails(handler),
185 username_(username), 185 username_(username),
186 password_(password) {} 186 password_(password) {}
187 const std::wstring& username() const { return username_; } 187 const string16& username() const { return username_; }
188 const std::wstring& password() const { return password_; } 188 const string16& password() const { return password_; }
189 189
190 private: 190 private:
191 // The username that was used for the authentication. 191 // The username that was used for the authentication.
192 const std::wstring username_; 192 const string16 username_;
193 193
194 // The password that was used for the authentication. 194 // The password that was used for the authentication.
195 const std::wstring password_; 195 const string16 password_;
196 196
197 DISALLOW_COPY_AND_ASSIGN(AuthSuppliedLoginNotificationDetails); 197 DISALLOW_COPY_AND_ASSIGN(AuthSuppliedLoginNotificationDetails);
198 }; 198 };
199 199
200 // Prompts the user for their username and password. This is designed to 200 // Prompts the user for their username and password. This is designed to
201 // be called on the background (I/O) thread, in response to 201 // be called on the background (I/O) thread, in response to
202 // net::URLRequest::Delegate::OnAuthRequired. The prompt will be created 202 // net::URLRequest::Delegate::OnAuthRequired. The prompt will be created
203 // on the main UI thread via a call to UI loop's InvokeLater, and will send the 203 // on the main UI thread via a call to UI loop's InvokeLater, and will send the
204 // credentials back to the net::URLRequest on the calling thread. 204 // credentials back to the net::URLRequest on the calling thread.
205 // A LoginHandler object (which lives on the calling thread) is returned, 205 // A LoginHandler object (which lives on the calling thread) is returned,
206 // which can be used to set or cancel authentication programmatically. The 206 // which can be used to set or cancel authentication programmatically. The
207 // caller must invoke OnRequestCancelled() on this LoginHandler before 207 // caller must invoke OnRequestCancelled() on this LoginHandler before
208 // destroying the net::URLRequest. 208 // destroying the net::URLRequest.
209 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, 209 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
210 net::URLRequest* request); 210 net::URLRequest* request);
211 211
212 // Helper to remove the ref from an net::URLRequest to the LoginHandler. 212 // Helper to remove the ref from an net::URLRequest to the LoginHandler.
213 // Should only be called from the IO thread, since it accesses an 213 // Should only be called from the IO thread, since it accesses an
214 // net::URLRequest. 214 // net::URLRequest.
215 void ResetLoginHandlerForRequest(net::URLRequest* request); 215 void ResetLoginHandlerForRequest(net::URLRequest* request);
216 216
217 // Get the signon_realm under which the identity should be saved. 217 // Get the signon_realm under which the identity should be saved.
218 std::string GetSignonRealm(const GURL& url, 218 std::string GetSignonRealm(const GURL& url,
219 const net::AuthChallengeInfo& auth_info); 219 const net::AuthChallengeInfo& auth_info);
220 220
221 #endif // CHROME_BROWSER_UI_LOGIN_LOGIN_PROMPT_H_ 221 #endif // CHROME_BROWSER_UI_LOGIN_LOGIN_PROMPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698