From 9a6307059ae614b24fb17805b0ed916aa09d6a9f Mon Sep 17 00:00:00 2001 From: stippi Date: Tue, 4 May 2010 12:02:24 +0000 Subject: [PATCH] Moved handling/display of "main site error" alert into client. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@481 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/BrowserWindow.cpp | 90 ++++++++++++++++---------- src/apps/webpositive/BrowserWindow.h | 5 ++ 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index e64906eaf7..742b910562 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -1009,6 +1009,43 @@ BrowserWindow::LoadFinished(const BString& url, BWebView* view) } +void +BrowserWindow::MainDocumentError(const BString& failingURL, + const BString& localizedDescription, BWebView* view) +{ + // Make sure we show the page that contains the view. + if (!_ShowPage(view)) + return; + + BWebWindow::MainDocumentError(failingURL, localizedDescription, view); + + // TODO: Remove the failing URL from the BrowsingHistory! +} + + +void +BrowserWindow::TitleChanged(const BString& title, BWebView* view) +{ + for (int32 i = 0; i < fTabManager->CountTabs(); i++) { + if (fTabManager->ViewForTab(i) == view) { + fTabManager->SetTabLabel(i, title); + break; + } + } + if (view != CurrentWebView()) + return; + + _UpdateTitle(title); +} + + +void +BrowserWindow::IconReceived(const BBitmap* icon, BWebView* view) +{ + _SetPageIcon(view, icon); +} + + void BrowserWindow::ResizeRequested(float width, float height, BWebView* view) { @@ -1090,29 +1127,6 @@ BrowserWindow::SetResizable(bool flag, BWebView* view) } -void -BrowserWindow::TitleChanged(const BString& title, BWebView* view) -{ - for (int32 i = 0; i < fTabManager->CountTabs(); i++) { - if (fTabManager->ViewForTab(i) == view) { - fTabManager->SetTabLabel(i, title); - break; - } - } - if (view != CurrentWebView()) - return; - - _UpdateTitle(title); -} - - -void -BrowserWindow::IconReceived(const BBitmap* icon, BWebView* view) -{ - _SetPageIcon(view, icon); -} - - void BrowserWindow::StatusChanged(const BString& statusText, BWebView* view) { @@ -1174,16 +1188,9 @@ BrowserWindow::AuthenticationChallenge(BString message, BString& inOutUser, } } // Switch to the page for which this authentication is required. - if (view != CurrentWebView()) { - int32 tabIndex = fTabManager->TabForView(view); - if (tabIndex < 0) { - // Page seems to be gone already? - return false; - } - fTabManager->SelectTab(tabIndex); - _TabChanged(tabIndex); - UpdateIfNeeded(); - } + if (!_ShowPage(view)) + return false; + AuthenticationPanel* panel = new AuthenticationPanel(Frame()); // Panel auto-destructs. bool success = panel->getAuthentication(message, inOutUser, inOutPassword, @@ -1669,3 +1676,20 @@ BrowserWindow::_UpdateClipboardItems() CurrentWebView()->WebPage()->SendEditingCapabilities(); } } + + +bool +BrowserWindow::_ShowPage(BWebView* view) +{ + if (view != CurrentWebView()) { + int32 tabIndex = fTabManager->TabForView(view); + if (tabIndex < 0) { + // Page seems to be gone already? + return false; + } + fTabManager->SelectTab(tabIndex); + _TabChanged(tabIndex); + UpdateIfNeeded(); + } + return true; +} diff --git a/src/apps/webpositive/BrowserWindow.h b/src/apps/webpositive/BrowserWindow.h index 1dd2951410..610029ac3d 100644 --- a/src/apps/webpositive/BrowserWindow.h +++ b/src/apps/webpositive/BrowserWindow.h @@ -113,6 +113,9 @@ private: virtual void LoadFailed(const BString& url, BWebView* view); virtual void LoadFinished(const BString& url, BWebView* view); + virtual void MainDocumentError(const BString& failingURL, + const BString& localizedDescription, + BWebView* view); virtual void TitleChanged(const BString& title, BWebView* view); virtual void IconReceived(const BBitmap* icon, @@ -159,6 +162,8 @@ private: void _UpdateHistoryMenu(); void _UpdateClipboardItems(); + bool _ShowPage(BWebView* view); + private: BMenu* fHistoryMenu; int32 fHistoryMenuFixedItemCount;