[haiku-webkit-commits] r481 - in webkit/trunk/WebKit/haiku: API WebCoreSupport WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 04 May 2010 12:02:24 +0000

Author: stippi
Date: Tue May  4 12:02:24 2010
New Revision: 481
URL: http://mmlr.dyndns.org/changeset/481

Log:
Moved handling/display of "main site error" alert into client.

Modified:
   webkit/trunk/WebKit/haiku/API/WebViewConstants.h
   webkit/trunk/WebKit/haiku/API/WebWindow.cpp
   webkit/trunk/WebKit/haiku/API/WebWindow.h
   webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h

Modified: webkit/trunk/WebKit/haiku/API/WebViewConstants.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Tue May  4 10:49:16 
2010        (r480)
+++ webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Tue May  4 12:02:24 
2010        (r481)
@@ -46,7 +46,8 @@
     UPDATE_NAVIGATION_INTERFACE =                       314,
     AUTHENTICATION_CHALLENGE =                          315,
     ICON_RECEIVED =                                     316,
-    CLOSE_WINDOW_REQUESTED =                            317
+    CLOSE_WINDOW_REQUESTED =                            317,
+    MAIN_DOCUMENT_ERROR =                               318
 };
 
 enum {

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.cpp Tue May  4 10:49:16 2010        
(r480)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.cpp Tue May  4 12:02:24 2010        
(r481)
@@ -35,6 +35,7 @@
 #include "WebView.h"
 #include "WebViewConstants.h"
 
+#include <Alert.h>
 #include <Application.h>
 #include <Bitmap.h>
 #include <Button.h>
@@ -168,6 +169,16 @@
             LoadFinished(url, _WebViewForMessage(message));
         break;
     }
+    case MAIN_DOCUMENT_ERROR: { 
+        BString failingURL;
+        BString localizedErrorString;
+        if (message->FindString("url", &failingURL) == B_OK
+               && message->FindString("error", &localizedErrorString) == B_OK) 
{
+            MainDocumentError(failingURL, localizedErrorString,
+                _WebViewForMessage(message));
+        }
+        break;
+    }
     case TITLE_CHANGED: {
         BString title;
         if (message->FindString("title", &title) == B_OK)
@@ -359,6 +370,18 @@
 {
 }
 
+void BWebWindow::MainDocumentError(const BString& failingURL,
+       const BString& localizedDescription, BWebView* view)
+{
+    BString errorString("Error loading ");
+    errorString << failingURL;
+    errorString << ":\n\n";
+    errorString << localizedDescription;
+    BAlert* alert = new BAlert("Main document error", errorString.String(),
+        "OK");
+    alert->Go(NULL);
+}
+
 void BWebWindow::TitleChanged(const BString& title, BWebView* view)
 {
     SetTitle(title.String());

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.h   Tue May  4 10:49:16 2010        
(r480)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.h   Tue May  4 12:02:24 2010        
(r481)
@@ -69,6 +69,9 @@
        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,

Modified: webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp Tue May 
 4 10:49:16 2010        (r480)
+++ webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp Tue May 
 4 12:02:24 2010        (r481)
@@ -538,13 +538,10 @@
     if (error.isCancellation())
         return;
 
-    // FIXME: This should be moved into LauncherWindow.
-    BString errorString("Error loading ");
-    errorString << error.failingURL();
-    errorString << ":\n\n";
-    errorString << error.localizedDescription();
-    BAlert* alert = new BAlert("Main document error", errorString.String(), 
"OK");
-    alert->Go(NULL);
+       BMessage message(MAIN_DOCUMENT_ERROR);
+       message.AddString("url", error.failingURL());
+       message.AddString("error", error.localizedDescription());
+    dispatchMessage(message);
 }
 
 void FrameLoaderClientHaiku::postProgressStartedNotification()
@@ -668,6 +665,8 @@
 
 bool FrameLoaderClientHaiku::shouldGoToHistoryItem(WebCore::HistoryItem*) const
 {
+    // FIXME: Should probably be refuse to go to the item when it contains
+    // form data that has already been sent or something.
     return true;
 }
 

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Tue May  4 
10:49:16 2010        (r480)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Tue May  4 
12:02:24 2010        (r481)
@@ -1010,6 +1010,43 @@
 
 
 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)
 {
        if (view != CurrentWebView())
@@ -1091,29 +1128,6 @@
 
 
 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)
 {
        if (view != CurrentWebView())
@@ -1174,16 +1188,9 @@
                }
        }
        // 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 @@
                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;
+}

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Tue May  4 
10:49:16 2010        (r480)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Tue May  4 
12:02:24 2010        (r481)
@@ -113,6 +113,9 @@
        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 @@
                        void                            _UpdateHistoryMenu();
                        void                            _UpdateClipboardItems();
 
+                       bool                            _ShowPage(BWebView* 
view);
+
 private:
                        BMenu*                          fHistoryMenu;
                        int32                           
fHistoryMenuFixedItemCount;

Other related posts:

  • » [haiku-webkit-commits] r481 - in webkit/trunk/WebKit/haiku: API WebCoreSupport WebPositive - webkit