diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-04 18:02:31 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-04 18:02:31 +0000 |
commit | 549e89a687830b2a6782a9fabdd1da8845532920 (patch) | |
tree | cfb8b58a6779062c4b3f160f091f7d6ea264c1b9 /chrome/browser/ui/login | |
parent | 9e94cca6f859d9f44538975382679f1ebe322c9a (diff) | |
download | chromium_src-549e89a687830b2a6782a9fabdd1da8845532920.zip chromium_src-549e89a687830b2a6782a9fabdd1da8845532920.tar.gz chromium_src-549e89a687830b2a6782a9fabdd1da8845532920.tar.bz2 |
Cancel a prerender should some part of the page request an http authentication prompt.
Contributed by: dominich@chromium.org
TEST=Navigate to a page with a <link rel="prefetch"> referencing a page that contains an iframe whose source requires http authentication. The page should not be prerendered and navigating to the page should show the login prompt as expected.
BUG=71211
Review URL: http://codereview.chromium.org/6410003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73817 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/login')
-rw-r--r-- | chrome/browser/ui/login/login_prompt.cc | 29 | ||||
-rw-r--r-- | chrome/browser/ui/login/login_prompt.h | 4 |
2 files changed, 25 insertions, 8 deletions
diff --git a/chrome/browser/ui/login/login_prompt.cc b/chrome/browser/ui/login/login_prompt.cc index 9dbe724..380f7b5 100644 --- a/chrome/browser/ui/login/login_prompt.cc +++ b/chrome/browser/ui/login/login_prompt.cc @@ -12,6 +12,8 @@ #include "chrome/browser/browser_thread.h" #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/renderer_host/render_process_host.h" +#include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "chrome/browser/tab_contents/constrained_window.h" @@ -113,6 +115,15 @@ TabContents* LoginHandler::GetTabContentsForLogin() const { tab_contents_id_); } +RenderViewHostDelegate* LoginHandler::GetRenderViewHostDelegate() const { + RenderViewHost* rvh = RenderViewHost::FromID(render_process_host_id_, + tab_contents_id_); + if (!rvh) + return NULL; + + return rvh->delegate(); +} + void LoginHandler::SetAuth(const std::wstring& username, const std::wstring& password) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -250,12 +261,13 @@ void LoginHandler::NotifyAuthNeeded() { if (WasAuthHandled()) return; + NotificationService* service = NotificationService::current(); + NavigationController* controller = NULL; + TabContents* requesting_contents = GetTabContentsForLogin(); - if (!requesting_contents) - return; + if (requesting_contents) + controller = &requesting_contents->controller(); - NotificationService* service = NotificationService::current(); - NavigationController* controller = &requesting_contents->controller(); LoginNotificationDetails details(this); service->Notify(NotificationType::AUTH_NEEDED, @@ -267,12 +279,13 @@ void LoginHandler::NotifyAuthCancelled() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(WasAuthHandled()); + NotificationService* service = NotificationService::current(); + NavigationController* controller = NULL; + TabContents* requesting_contents = GetTabContentsForLogin(); - if (!requesting_contents) - return; + if (requesting_contents) + controller = &requesting_contents->controller(); - NotificationService* service = NotificationService::current(); - NavigationController* controller = &requesting_contents->controller(); LoginNotificationDetails details(this); service->Notify(NotificationType::AUTH_CANCELLED, diff --git a/chrome/browser/ui/login/login_prompt.h b/chrome/browser/ui/login/login_prompt.h index 868da20..7c8ae9d 100644 --- a/chrome/browser/ui/login/login_prompt.h +++ b/chrome/browser/ui/login/login_prompt.h @@ -22,6 +22,7 @@ class URLRequest; class ConstrainedWindow; class GURL; +class RenderViewHostDelegate; // This is the base implementation for the OS-specific classes that route // authentication info to the net::URLRequest that needs it. These functions @@ -50,6 +51,9 @@ class LoginHandler : public base::RefCountedThreadSafe<LoginHandler>, // Returns the TabContents that needs authentication. TabContents* GetTabContentsForLogin() const; + // Returns the RenderViewHostDelegate for the page that needs authentication. + RenderViewHostDelegate* GetRenderViewHostDelegate() const; + // Resend the request with authentication credentials. // This function can be called from either thread. void SetAuth(const std::wstring& username, const std::wstring& password); |