From 50c04c441db77a54512b0eff6f6e3323fe403f46 Mon Sep 17 00:00:00 2001 From: stippi Date: Sat, 27 Feb 2010 13:31:29 +0000 Subject: [PATCH] Actually, the authentication challenge needs to know for which page it is, otherwise we may display the login panel above an unrelated page. Tested by clicking Login on dev.haiku-os.org and Cmd-T to open a new tab before the login panel shows. Works. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@237 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/LauncherWindow.cpp | 8 +++++++- src/apps/webpositive/LauncherWindow.h | 2 +- src/apps/webpositive/WebTabView.cpp | 14 ++++++++++++++ src/apps/webpositive/WebTabView.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/apps/webpositive/LauncherWindow.cpp b/src/apps/webpositive/LauncherWindow.cpp index 63ace8ba70..37ff504ae6 100644 --- a/src/apps/webpositive/LauncherWindow.cpp +++ b/src/apps/webpositive/LauncherWindow.cpp @@ -654,8 +654,14 @@ void LauncherWindow::UpdateGlobalHistory(const BString& url) } bool LauncherWindow::AuthenticationChallenge(BString message, BString& inOutUser, - BString& inOutPassword, bool& inOutRememberCredentials, uint32 failureCount) + BString& inOutPassword, bool& inOutRememberCredentials, uint32 failureCount, + BWebView* view) { + // Switch to the page for which this authentication is required. + if (view != CurrentWebView()) { + m_tabManager->SelectTab(view); + UpdateIfNeeded(); + } AuthenticationPanel* panel = new AuthenticationPanel(Frame()); // Panel auto-destructs. return panel->getAuthentication(message, inOutUser, inOutPassword, diff --git a/src/apps/webpositive/LauncherWindow.h b/src/apps/webpositive/LauncherWindow.h index e502360f49..018ac29a16 100644 --- a/src/apps/webpositive/LauncherWindow.h +++ b/src/apps/webpositive/LauncherWindow.h @@ -93,7 +93,7 @@ private: virtual void UpdateGlobalHistory(const BString& url); virtual bool AuthenticationChallenge(BString message, BString& inOutUser, BString& inOutPassword, bool& inOutRememberCredentials, - uint32 failureCount); + uint32 failureCount, BWebView* view); void updateTitle(const BString &title); void updateTabGroupVisibility(); diff --git a/src/apps/webpositive/WebTabView.cpp b/src/apps/webpositive/WebTabView.cpp index e635c03cc8..1b491385c0 100644 --- a/src/apps/webpositive/WebTabView.cpp +++ b/src/apps/webpositive/WebTabView.cpp @@ -1137,6 +1137,20 @@ TabManager::SelectTab(int32 tabIndex) } +void +TabManager::SelectTab(BView* containedView) +{ + int32 count = fCardLayout->CountItems(); + for (int32 i = 0; i < count; i++) { + BLayoutItem* item = fCardLayout->ItemAt(i); + if (item->View() == containedView) { + SelectTab(i); + break; + } + } +} + + int32 TabManager::SelectedTabIndex() const { diff --git a/src/apps/webpositive/WebTabView.h b/src/apps/webpositive/WebTabView.h index 9965e62a9a..3f9f086755 100644 --- a/src/apps/webpositive/WebTabView.h +++ b/src/apps/webpositive/WebTabView.h @@ -56,6 +56,7 @@ public: BView* ViewForTab(int32 tabIndex) const; void SelectTab(int32 tabIndex); + void SelectTab(BView* containedView); int32 SelectedTabIndex() const; void CloseTab(int32 tabIndex);