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

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

Issue 2067933002: Use correct origin when prompting for proxy authentication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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_LOGIN_LOGIN_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_LOGIN_LOGIN_HANDLER_H_
6 #define CHROME_BROWSER_UI_LOGIN_LOGIN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_LOGIN_LOGIN_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
14 #include "components/password_manager/core/browser/password_manager.h" 15 #include "components/password_manager/core/browser/password_manager.h"
15 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 17 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
17 #include "content/public/browser/resource_request_info.h" 18 #include "content/public/browser/resource_request_info.h"
18 19
19 class GURL; 20 class GURL;
20 class LoginInterstitialDelegate; 21 class LoginInterstitialDelegate;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // Notify observers that authentication is needed. 129 // Notify observers that authentication is needed.
129 void NotifyAuthNeeded(); 130 void NotifyAuthNeeded();
130 131
131 // Performs necessary cleanup before deletion. 132 // Performs necessary cleanup before deletion.
132 void ReleaseSoon(); 133 void ReleaseSoon();
133 134
134 // Closes the native dialog. 135 // Closes the native dialog.
135 virtual void CloseDialog() = 0; 136 virtual void CloseDialog() = 0;
136 137
137 private: 138 private:
139 friend LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
140 net::URLRequest* request);
141 FRIEND_TEST_ALL_PREFIXES(LoginHandlerTest, Outputs);
142
138 // Starts observing notifications from other LoginHandlers. 143 // Starts observing notifications from other LoginHandlers.
139 void AddObservers(); 144 void AddObservers();
140 145
141 // Stops observing notifications from other LoginHandlers. 146 // Stops observing notifications from other LoginHandlers.
142 void RemoveObservers(); 147 void RemoveObservers();
143 148
144 // Notify observers that authentication is supplied. 149 // Notify observers that authentication is supplied.
145 void NotifyAuthSupplied(const base::string16& username, 150 void NotifyAuthSupplied(const base::string16& username,
146 const base::string16& password); 151 const base::string16& password);
147 152
(...skipping 11 matching lines...) Expand all
159 // Cancels the auth. If |cancel_navigation| is true, the existing login 164 // Cancels the auth. If |cancel_navigation| is true, the existing login
160 // interstitial (if any) is closed and the pending navigation is cancelled. 165 // interstitial (if any) is closed and the pending navigation is cancelled.
161 void DoCancelAuth(bool cancel_navigation); 166 void DoCancelAuth(bool cancel_navigation);
162 167
163 // Calls CancelAuth from the IO loop. 168 // Calls CancelAuth from the IO loop.
164 void CancelAuthDeferred(); 169 void CancelAuthDeferred();
165 170
166 // Closes the view_contents from the UI loop. 171 // Closes the view_contents from the UI loop.
167 void CloseContentsDeferred(); 172 void CloseContentsDeferred();
168 173
174 // Get the signon_realm under which this auth info should be stored.
175 //
176 // The format of the signon_realm for proxy auth is:
177 // proxy-host:proxy-port/auth-realm
178 // The format of the signon_realm for server auth is:
179 // url-scheme://url-host[:url-port]/auth-realm
180 //
181 // Be careful when changing this function, since you could make existing
182 // saved logins un-retrievable.
183 static std::string GetSignonRealm(const GURL& url,
184 const net::AuthChallengeInfo& auth_info);
185
186 // Helper to create a PasswordForm for PasswordManager to start looking for
187 // saved credentials.
188 static autofill::PasswordForm MakeInputForPasswordManager(
189 const GURL& url,
190 const net::AuthChallengeInfo& auth_info);
191
192 static void GetDialogStrings(const GURL& request_url,
193 const net::AuthChallengeInfo& auth_info,
194 base::string16* authority,
195 base::string16* explanation);
196
197 static void ShowLoginPrompt(const GURL& request_url,
198 net::AuthChallengeInfo* auth_info,
199 LoginHandler* handler);
200
201 // This callback is run on the UI thread and creates a constrained window with
202 // a LoginView to prompt the user. If the prompt is triggered because of a
203 // cross origin navigation in the main frame, a blank interstitial is first
204 // created which in turn creates the LoginView. Otherwise, a LoginView is
205 // directly in this callback. In both cases, the response will be sent to
meacer 2016/06/16 01:12:15 directly -> created directly
asanka 2016/06/16 16:25:47 Done.
206 // LoginHandler, which then routes it to the net::URLRequest on the I/O
207 // thread.
208 static void LoginDialogCallback(const GURL& request_url,
209 net::AuthChallengeInfo* auth_info,
210 LoginHandler* handler,
211 bool is_main_frame);
212
169 // True if we've handled auth (SetAuth or CancelAuth has been called). 213 // True if we've handled auth (SetAuth or CancelAuth has been called).
170 bool handled_auth_; 214 bool handled_auth_;
171 mutable base::Lock handled_auth_lock_; 215 mutable base::Lock handled_auth_lock_;
172 216
173 // Who/where/what asked for the authentication. 217 // Who/where/what asked for the authentication.
174 scoped_refptr<net::AuthChallengeInfo> auth_info_; 218 scoped_refptr<net::AuthChallengeInfo> auth_info_;
175 219
176 // The request that wants login data. 220 // The request that wants login data.
177 // This should only be accessed on the IO loop. 221 // This should only be accessed on the IO loop.
178 net::URLRequest* request_; 222 net::URLRequest* request_;
179 223
180 // The HttpNetworkSession |request_| is associated with. 224 // The HttpNetworkSession |request_| is associated with.
181 const net::HttpNetworkSession* http_network_session_; 225 const net::HttpNetworkSession* http_network_session_;
182 226
183 // The PasswordForm sent to the PasswordManager. This is so we can refer to it 227 // The PasswordForm sent to the PasswordManager. This is so we can refer to
vabr (Chromium) 2016/06/15 08:50:06 nit: Seems like these two lines could have stayed
asanka 2016/06/16 16:25:47 Reformatted.
184 // when later notifying the password manager if the credentials were accepted 228 // it
229 // when later notifying the password manager if the credentials were
230 // accepted
185 // or rejected. 231 // or rejected.
186 // This should only be accessed on the UI loop. 232 // This should only be accessed on the UI loop.
187 autofill::PasswordForm password_form_; 233 autofill::PasswordForm password_form_;
188 234
189 // Points to the password manager owned by the WebContents requesting auth. 235 // Points to the password manager owned by the WebContents requesting auth.
190 // This should only be accessed on the UI loop. 236 // This should only be accessed on the UI loop.
191 password_manager::PasswordManager* password_manager_; 237 password_manager::PasswordManager* password_manager_;
192 238
193 // Cached from the net::URLRequest, in case it goes NULL on us. 239 // Cached from the net::URLRequest, in case it goes NULL on us.
194 content::ResourceRequestInfo::WebContentsGetter web_contents_getter_; 240 content::ResourceRequestInfo::WebContentsGetter web_contents_getter_;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // net::URLRequest::Delegate::OnAuthRequired. The prompt will be created 295 // net::URLRequest::Delegate::OnAuthRequired. The prompt will be created
250 // on the main UI thread via a call to UI loop's InvokeLater, and will send the 296 // on the main UI thread via a call to UI loop's InvokeLater, and will send the
251 // credentials back to the net::URLRequest on the calling thread. 297 // credentials back to the net::URLRequest on the calling thread.
252 // A LoginHandler object (which lives on the calling thread) is returned, 298 // A LoginHandler object (which lives on the calling thread) is returned,
253 // which can be used to set or cancel authentication programmatically. The 299 // which can be used to set or cancel authentication programmatically. The
254 // caller must invoke OnRequestCancelled() on this LoginHandler before 300 // caller must invoke OnRequestCancelled() on this LoginHandler before
255 // destroying the net::URLRequest. 301 // destroying the net::URLRequest.
256 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, 302 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
257 net::URLRequest* request); 303 net::URLRequest* request);
258 304
259 // Get the signon_realm under which the identity should be saved.
260 std::string GetSignonRealm(const GURL& url,
261 const net::AuthChallengeInfo& auth_info);
262
263 #endif // CHROME_BROWSER_UI_LOGIN_LOGIN_HANDLER_H_ 305 #endif // CHROME_BROWSER_UI_LOGIN_LOGIN_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/login/login_handler.cc » ('j') | chrome/browser/ui/login/login_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698