| OLD | NEW |
| 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 #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" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/password_manager/password_manager.h" | 13 #include "chrome/browser/password_manager/password_manager.h" |
| 14 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
| 15 #include "chrome/browser/ui/constrained_window.h" | 15 #include "chrome/browser/ui/constrained_window.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 19 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | |
| 20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 22 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/render_view_host_delegate.h" | 23 #include "content/public/browser/render_view_host_delegate.h" |
| 24 #include "content/public/browser/resource_request_info.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "net/base/auth.h" | 27 #include "net/base/auth.h" |
| 28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
| 29 #include "net/http/http_transaction_factory.h" | 29 #include "net/http/http_transaction_factory.h" |
| 30 #include "net/url_request/url_request.h" | 30 #include "net/url_request/url_request.h" |
| 31 #include "net/url_request/url_request_context.h" | 31 #include "net/url_request/url_request_context.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/text/text_elider.h" | 33 #include "ui/base/text/text_elider.h" |
| 34 | 34 |
| 35 using content::BrowserThread; | 35 using content::BrowserThread; |
| 36 using content::NavigationController; | 36 using content::NavigationController; |
| 37 using content::RenderViewHost; | 37 using content::RenderViewHost; |
| 38 using content::RenderViewHostDelegate; | 38 using content::RenderViewHostDelegate; |
| 39 using content::ResourceRequestInfo; |
| 39 using content::WebContents; | 40 using content::WebContents; |
| 40 using webkit::forms::PasswordForm; | 41 using webkit::forms::PasswordForm; |
| 41 | 42 |
| 42 class LoginHandlerImpl; | 43 class LoginHandlerImpl; |
| 43 | 44 |
| 44 // Helper to remove the ref from an net::URLRequest to the LoginHandler. | 45 // Helper to remove the ref from an net::URLRequest to the LoginHandler. |
| 45 // Should only be called from the IO thread, since it accesses an | 46 // Should only be called from the IO thread, since it accesses an |
| 46 // net::URLRequest. | 47 // net::URLRequest. |
| 47 void ResetLoginHandlerForRequest(net::URLRequest* request) { | 48 void ResetLoginHandlerForRequest(net::URLRequest* request) { |
| 48 ResourceDispatcherHostRequestInfo* info = | 49 ResourceDispatcherHost::ClearLoginDelegate(request); |
| 49 ResourceDispatcherHost::InfoForRequest(request); | |
| 50 if (!info) | |
| 51 return; | |
| 52 | |
| 53 info->set_login_delegate(NULL); | |
| 54 } | 50 } |
| 55 | 51 |
| 56 // Get the signon_realm under which this auth info should be stored. | 52 // Get the signon_realm under which this auth info should be stored. |
| 57 // | 53 // |
| 58 // The format of the signon_realm for proxy auth is: | 54 // The format of the signon_realm for proxy auth is: |
| 59 // proxy-host/auth-realm | 55 // proxy-host/auth-realm |
| 60 // The format of the signon_realm for server auth is: | 56 // The format of the signon_realm for server auth is: |
| 61 // url-scheme://url-host[:url-port]/auth-realm | 57 // url-scheme://url-host[:url-port]/auth-realm |
| 62 // | 58 // |
| 63 // Be careful when changing this function, since you could make existing | 59 // Be careful when changing this function, since you could make existing |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // later, so wait with loading the nib until then. | 91 // later, so wait with loading the nib until then. |
| 96 DCHECK(request_) << "LoginHandler constructed with NULL request"; | 92 DCHECK(request_) << "LoginHandler constructed with NULL request"; |
| 97 DCHECK(auth_info_) << "LoginHandler constructed with NULL auth info"; | 93 DCHECK(auth_info_) << "LoginHandler constructed with NULL auth info"; |
| 98 | 94 |
| 99 AddRef(); // matched by LoginHandler::ReleaseSoon(). | 95 AddRef(); // matched by LoginHandler::ReleaseSoon(). |
| 100 | 96 |
| 101 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
| 102 BrowserThread::UI, FROM_HERE, | 98 BrowserThread::UI, FROM_HERE, |
| 103 base::Bind(&LoginHandler::AddObservers, this)); | 99 base::Bind(&LoginHandler::AddObservers, this)); |
| 104 | 100 |
| 105 if (!ResourceDispatcherHost::RenderViewForRequest( | 101 if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderView( |
| 106 request_, &render_process_host_id_, &tab_contents_id_)) { | 102 &render_process_host_id_, &tab_contents_id_)) { |
| 107 NOTREACHED(); | 103 NOTREACHED(); |
| 108 } | 104 } |
| 109 } | 105 } |
| 110 | 106 |
| 111 LoginHandler::~LoginHandler() { | 107 LoginHandler::~LoginHandler() { |
| 112 SetModel(NULL); | 108 SetModel(NULL); |
| 113 } | 109 } |
| 114 | 110 |
| 115 void LoginHandler::SetPasswordForm(const webkit::forms::PasswordForm& form) { | 111 void LoginHandler::SetPasswordForm(const webkit::forms::PasswordForm& form) { |
| 116 password_form_ = form; | 112 password_form_ = form; |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 476 |
| 481 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 477 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 482 net::URLRequest* request) { | 478 net::URLRequest* request) { |
| 483 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 479 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 484 BrowserThread::PostTask( | 480 BrowserThread::PostTask( |
| 485 BrowserThread::UI, FROM_HERE, | 481 BrowserThread::UI, FROM_HERE, |
| 486 base::Bind(&LoginDialogCallback, request->url(), | 482 base::Bind(&LoginDialogCallback, request->url(), |
| 487 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 483 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
| 488 return handler; | 484 return handler; |
| 489 } | 485 } |
| OLD | NEW |