| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/login/login_prompt.h" | 5 #include "chrome/browser/ui/login/login_prompt.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 26 #include "net/base/auth.h" | 26 #include "net/base/auth.h" |
| 27 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
| 28 #include "net/http/http_transaction_factory.h" | 28 #include "net/http/http_transaction_factory.h" |
| 29 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
| 30 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/text/text_elider.h" | 32 #include "ui/base/text/text_elider.h" |
| 33 | 33 |
| 34 using content::BrowserThread; | 34 using content::BrowserThread; |
| 35 using content::NavigationController; |
| 35 using webkit::forms::PasswordForm; | 36 using webkit::forms::PasswordForm; |
| 36 | 37 |
| 37 class LoginHandlerImpl; | 38 class LoginHandlerImpl; |
| 38 | 39 |
| 39 // Helper to remove the ref from an net::URLRequest to the LoginHandler. | 40 // Helper to remove the ref from an net::URLRequest to the LoginHandler. |
| 40 // Should only be called from the IO thread, since it accesses an | 41 // Should only be called from the IO thread, since it accesses an |
| 41 // net::URLRequest. | 42 // net::URLRequest. |
| 42 void ResetLoginHandlerForRequest(net::URLRequest* request) { | 43 void ResetLoginHandlerForRequest(net::URLRequest* request) { |
| 43 ResourceDispatcherHostRequestInfo* info = | 44 ResourceDispatcherHostRequestInfo* info = |
| 44 ResourceDispatcherHost::InfoForRequest(request); | 45 ResourceDispatcherHost::InfoForRequest(request); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 dialog_ = dialog; | 272 dialog_ = dialog; |
| 272 } | 273 } |
| 273 | 274 |
| 274 void LoginHandler::NotifyAuthNeeded() { | 275 void LoginHandler::NotifyAuthNeeded() { |
| 275 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 276 if (WasAuthHandled()) | 277 if (WasAuthHandled()) |
| 277 return; | 278 return; |
| 278 | 279 |
| 279 content::NotificationService* service = | 280 content::NotificationService* service = |
| 280 content::NotificationService::current(); | 281 content::NotificationService::current(); |
| 281 content::NavigationController* controller = NULL; | 282 NavigationController* controller = NULL; |
| 282 | 283 |
| 283 TabContents* requesting_contents = GetTabContentsForLogin(); | 284 TabContents* requesting_contents = GetTabContentsForLogin(); |
| 284 if (requesting_contents) | 285 if (requesting_contents) |
| 285 controller = &requesting_contents->GetController(); | 286 controller = &requesting_contents->GetController(); |
| 286 | 287 |
| 287 LoginNotificationDetails details(this); | 288 LoginNotificationDetails details(this); |
| 288 | 289 |
| 289 service->Notify(chrome::NOTIFICATION_AUTH_NEEDED, | 290 service->Notify(chrome::NOTIFICATION_AUTH_NEEDED, |
| 290 content::Source<content::NavigationController>(controller), | 291 content::Source<NavigationController>(controller), |
| 291 content::Details<LoginNotificationDetails>(&details)); | 292 content::Details<LoginNotificationDetails>(&details)); |
| 292 } | 293 } |
| 293 | 294 |
| 294 void LoginHandler::NotifyAuthCancelled() { | 295 void LoginHandler::NotifyAuthCancelled() { |
| 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 296 DCHECK(WasAuthHandled()); | 297 DCHECK(WasAuthHandled()); |
| 297 | 298 |
| 298 content::NotificationService* service = | 299 content::NotificationService* service = |
| 299 content::NotificationService::current(); | 300 content::NotificationService::current(); |
| 300 content::NavigationController* controller = NULL; | 301 NavigationController* controller = NULL; |
| 301 | 302 |
| 302 TabContents* requesting_contents = GetTabContentsForLogin(); | 303 TabContents* requesting_contents = GetTabContentsForLogin(); |
| 303 if (requesting_contents) | 304 if (requesting_contents) |
| 304 controller = &requesting_contents->GetController(); | 305 controller = &requesting_contents->GetController(); |
| 305 | 306 |
| 306 LoginNotificationDetails details(this); | 307 LoginNotificationDetails details(this); |
| 307 | 308 |
| 308 service->Notify(chrome::NOTIFICATION_AUTH_CANCELLED, | 309 service->Notify(chrome::NOTIFICATION_AUTH_CANCELLED, |
| 309 content::Source<content::NavigationController>(controller), | 310 content::Source<NavigationController>(controller), |
| 310 content::Details<LoginNotificationDetails>(&details)); | 311 content::Details<LoginNotificationDetails>(&details)); |
| 311 } | 312 } |
| 312 | 313 |
| 313 void LoginHandler::NotifyAuthSupplied(const string16& username, | 314 void LoginHandler::NotifyAuthSupplied(const string16& username, |
| 314 const string16& password) { | 315 const string16& password) { |
| 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 316 DCHECK(WasAuthHandled()); | 317 DCHECK(WasAuthHandled()); |
| 317 | 318 |
| 318 TabContents* requesting_contents = GetTabContentsForLogin(); | 319 TabContents* requesting_contents = GetTabContentsForLogin(); |
| 319 if (!requesting_contents) | 320 if (!requesting_contents) |
| 320 return; | 321 return; |
| 321 | 322 |
| 322 content::NotificationService* service = | 323 content::NotificationService* service = |
| 323 content::NotificationService::current(); | 324 content::NotificationService::current(); |
| 324 content::NavigationController* controller = | 325 NavigationController* controller = |
| 325 &requesting_contents->GetController(); | 326 &requesting_contents->GetController(); |
| 326 AuthSuppliedLoginNotificationDetails details(this, username, password); | 327 AuthSuppliedLoginNotificationDetails details(this, username, password); |
| 327 | 328 |
| 328 service->Notify( | 329 service->Notify( |
| 329 chrome::NOTIFICATION_AUTH_SUPPLIED, | 330 chrome::NOTIFICATION_AUTH_SUPPLIED, |
| 330 content::Source<content::NavigationController>(controller), | 331 content::Source<NavigationController>(controller), |
| 331 content::Details<AuthSuppliedLoginNotificationDetails>(&details)); | 332 content::Details<AuthSuppliedLoginNotificationDetails>(&details)); |
| 332 } | 333 } |
| 333 | 334 |
| 334 void LoginHandler::ReleaseSoon() { | 335 void LoginHandler::ReleaseSoon() { |
| 335 if (!TestAndSetAuthHandled()) { | 336 if (!TestAndSetAuthHandled()) { |
| 336 BrowserThread::PostTask( | 337 BrowserThread::PostTask( |
| 337 BrowserThread::IO, FROM_HERE, | 338 BrowserThread::IO, FROM_HERE, |
| 338 base::Bind(&LoginHandler::CancelAuthDeferred, this)); | 339 base::Bind(&LoginHandler::CancelAuthDeferred, this)); |
| 339 BrowserThread::PostTask( | 340 BrowserThread::PostTask( |
| 340 BrowserThread::UI, FROM_HERE, | 341 BrowserThread::UI, FROM_HERE, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 482 |
| 482 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 483 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 483 net::URLRequest* request) { | 484 net::URLRequest* request) { |
| 484 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 485 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 485 BrowserThread::PostTask( | 486 BrowserThread::PostTask( |
| 486 BrowserThread::UI, FROM_HERE, | 487 BrowserThread::UI, FROM_HERE, |
| 487 base::Bind(&LoginDialogCallback, request->url(), | 488 base::Bind(&LoginDialogCallback, request->url(), |
| 488 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 489 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
| 489 return handler; | 490 return handler; |
| 490 } | 491 } |
| OLD | NEW |