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

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Mon, 01 Mar 2010 17:41:43 +0000

Author: stippi
Date: Mon Mar  1 17:41:43 2010
New Revision: 257
URL: http://mmlr.dyndns.org/changeset/257

Log:
Added BWebSettings and BPrivate::WebSettingsPrivate. Added all the wiring
necessary. The only usable effect as of yet is that favicons arrive at the
BrowserWindow. Favicons are stored in a database and are not fetched when they
alreary exist. The application is expected to try and fetch an icon for a given
url. This is currently done in BWebWindow when the URL for loading has been
initiated. Otherwise it fetches the URL upon the new ICON_RECEIVED notification
from the FrameLoaderClientHaiku. In any case it ends up at 
BWebWindow::IconReceived(),
so derived classes don't have to worry about the difference. In any case, via
BWebSettings, icons can also be fetched manually, like for the forthcomming
autocompletion text control.

Added:
   webkit/trunk/WebKit/haiku/API/WebSettings.cpp
   webkit/trunk/WebKit/haiku/API/WebSettings.h
   webkit/trunk/WebKit/haiku/API/WebSettingsPrivate.cpp
   webkit/trunk/WebKit/haiku/API/WebSettingsPrivate.h
Modified:
   webkit/trunk/WebKit/Jamfile
   webkit/trunk/WebKit/haiku/API/WebPage.cpp
   webkit/trunk/WebKit/haiku/API/WebPage.h
   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/BrowserApp.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h

Modified: webkit/trunk/WebKit/Jamfile
==============================================================================
--- webkit/trunk/WebKit/Jamfile Mon Mar  1 17:32:57 2010        (r256)
+++ webkit/trunk/WebKit/Jamfile Mon Mar  1 17:41:43 2010        (r257)
@@ -36,6 +36,8 @@
 SubDirHdrs $(TOP) WebCore html ;
 SubDirHdrs $(TOP) WebCore inspector ;
 SubDirHdrs $(TOP) WebCore loader ;
+SubDirHdrs $(TOP) WebCore loader appcache ;
+SubDirHdrs $(TOP) WebCore loader icon ;
 SubDirHdrs $(TOP) WebCore page ;
 SubDirHdrs $(TOP) WebCore page animation ;
 SubDirHdrs $(TOP) WebCore platform ;
@@ -46,9 +48,11 @@
 SubDirHdrs $(TOP) WebCore platform network ;
 SubDirHdrs $(TOP) WebCore platform network curl ;
 SubDirHdrs $(TOP) WebCore platform text ;
+SubDirHdrs $(TOP) WebCore platform sql ;
 SubDirHdrs $(TOP) WebCore plugins ;
 SubDirHdrs $(TOP) WebCore rendering ;
 SubDirHdrs $(TOP) WebCore rendering style ;
+SubDirHdrs $(TOP) WebCore storage ;
 SubDirHdrs $(TOP) WebCore svg ;
 SubDirHdrs $(TOP) WebCore svg animation ;
 SubDirHdrs $(TOP) WebCore svg graphics ;
@@ -71,6 +75,8 @@
        WebDownloadPrivate.cpp
        WebFrame.cpp
        WebPage.cpp
+       WebSettings.cpp
+       WebSettingsPrivate.cpp
        WebView.cpp
        WebWindow.cpp
 

Modified: webkit/trunk/WebKit/haiku/API/WebPage.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.cpp   Mon Mar  1 17:32:57 2010        
(r256)
+++ webkit/trunk/WebKit/haiku/API/WebPage.cpp   Mon Mar  1 17:41:43 2010        
(r257)
@@ -61,6 +61,7 @@
 #include "WebDownloadPrivate.h"
 #include "WebFrame.h"
 #include "WebFramePrivate.h"
+#include "WebSettings.h"
 #include "WebView.h"
 #include "WebViewConstants.h"
 
@@ -159,6 +160,7 @@
     : BHandler("BWebPage")
     , m_webView(webView)
     , m_mainFrame(0)
+    , m_settings(0)
     , m_page(0)
     , m_pageVisible(true)
     , m_pageDirty(false)
@@ -174,28 +176,7 @@
                                0,
                                0);
 
-    // Default settings - We should have BWebSettings class for this.
-    WebCore::Settings* settings = m_page->settings();
-    settings->setLoadsImagesAutomatically(true);
-    settings->setMinimumFontSize(5);
-    settings->setMinimumLogicalFontSize(5);
-    settings->setShouldPrintBackgrounds(true);
-    settings->setJavaScriptEnabled(true);
-    settings->setShowsURLsInToolTips(true);
-    settings->setShouldPaintCustomScrollbars(true);
-    settings->setEditingBehavior(EditingMacBehavior);
-//    settings->setLocalStorageEnabled(true);
-//    settings->setLocalStorageDatabasePath();
-
-    settings->setDefaultFixedFontSize(14);
-    settings->setDefaultFontSize(14);
-
-    // TODO: Init from system fonts or application settings.
-    settings->setSerifFontFamily("DejaVu Serif");
-    settings->setSansSerifFontFamily("DejaVu Sans");
-    settings->setFixedFontFamily("DejaVu Sans Mono");
-    settings->setStandardFontFamily("DejaVu Serif");
-    settings->setDefaultTextEncodingName("UTF-8");
+    m_settings = new BWebSettings(m_page->settings());
 }
 
 BWebPage::~BWebPage()
@@ -292,6 +273,11 @@
     return m_mainFrame;
 };
 
+BWebSettings* BWebPage::Settings() const
+{
+    return m_settings;
+};
+
 BWebView* BWebPage::WebView() const
 {
     return m_webView;

Modified: webkit/trunk/WebKit/haiku/API/WebPage.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.h     Mon Mar  1 17:32:57 2010        
(r256)
+++ webkit/trunk/WebKit/haiku/API/WebPage.h     Mon Mar  1 17:41:43 2010        
(r257)
@@ -36,6 +36,7 @@
 
 class BWebDownload;
 class BWebFrame;
+class BWebSettings;
 class BWebView;
 
 namespace WebCore {
@@ -79,6 +80,7 @@
                        void                            
SetDownloadListener(const BMessenger& listener);
 
                        BWebFrame*                      MainFrame() const;
+                       BWebSettings*           Settings() const;
                        BWebView*                       WebView() const;
                                // NOTE: Using the BWebView requires locking 
it's looper!
 
@@ -192,6 +194,7 @@
        BMessenger m_downloadListener;
        BWebView* m_webView;
        BWebFrame* m_mainFrame;
+       BWebSettings* m_settings;
        WebCore::Page* m_page;
 
     bool m_pageVisible;

Added: webkit/trunk/WebKit/haiku/API/WebSettings.cpp
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/API/WebSettings.cpp       Mon Mar  1 17:41:43 
2010        (r257)
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "WebSettings.h"
+
+#include "ApplicationCacheStorage.h"
+#include "DatabaseTracker.h"
+#include "IconDatabase.h"
+#include "Image.h"
+#include "IntSize.h"
+#include "Settings.h"
+#include "WebSettingsPrivate.h"
+#include <Application.h>
+#include <Bitmap.h>
+#include <Directory.h>
+#include <Entry.h>
+#include <FindDirectory.h>
+#include <Path.h>
+#include <stdio.h>
+
+enum {
+       HANDLE_SET_PERSISTENT_STORAGE_PATH = 'hspp',
+       HANDLE_SET_ICON_DATABASE_PATH = 'hsip',
+       HANDLE_CLEAR_ICON_DATABASE = 'hcli',
+       HANDLE_SEND_ICON_FOR_URL = 'sifu',
+       HANDLE_SET_OFFLINE_STORAGE_PATH = 'hsop',
+       HANDLE_SET_OFFLINE_STORAGE_DEFAULT_QUOTA = 'hsoq',
+       HANDLE_SET_OFFLINE_WEB_APPLICATION_CACHE_PATH = 'hsap',
+       HANDLE_SET_OFFLINE_WEB_APPLICATION_CACHE_QUOTA = 'hsaq',
+       HANDLE_SET_LOCAL_STORAGE_PATH = 'hslp'
+};
+
+BWebSettings::BWebSettings()
+    : fData(new BPrivate::WebSettingsPrivate())
+{
+       // This constructor is used only for the default (global) settings.
+       if (be_app->Lock()) {
+               be_app->AddHandler(this);
+               be_app->Unlock();
+       }
+}
+
+BWebSettings::BWebSettings(WebCore::Settings* settings)
+    : fData(new BPrivate::WebSettingsPrivate(settings))
+{
+       if (be_app->Lock()) {
+               be_app->AddHandler(this);
+               be_app->Unlock();
+       }
+}
+
+BWebSettings::~BWebSettings()
+{
+       if (be_app->Lock()) {
+               be_app->RemoveHandler(this);
+               be_app->Unlock();
+       }
+       delete fData;
+}
+
+BWebSettings* BWebSettings::Default()
+{
+       static BWebSettings defaultInstance;
+       return &defaultInstance;
+}
+
+void BWebSettings::SetPersistentStoragePath(const BString& path)
+{
+       _PostSetPath(Default(), HANDLE_SET_PERSISTENT_STORAGE_PATH, path);
+}
+
+void BWebSettings::SetIconDatabasePath(const BString& path)
+{
+       _PostSetPath(Default(), HANDLE_SET_ICON_DATABASE_PATH, path);
+}
+
+void BWebSettings::ClearIconDatabase()
+{
+       Default()->Looper()->PostMessage(HANDLE_CLEAR_ICON_DATABASE, Default());
+}
+
+void BWebSettings::SendIconForURL(const BString& url, const BMessage& reply,
+    const BMessenger& target)
+{
+       BMessage message(HANDLE_SEND_ICON_FOR_URL);
+       message.AddString("url", url.String());
+       message.AddMessage("reply", &reply);
+       message.AddMessenger("target", target);
+       Default()->Looper()->PostMessage(&message, Default());
+}
+
+void BWebSettings::SetOfflineStoragePath(const BString& path)
+{
+       _PostSetPath(Default(), HANDLE_SET_OFFLINE_STORAGE_PATH, path);
+}
+
+void BWebSettings::SetOfflineStorageDefaultQuota(int64 maximumSize)
+{
+       _PostSetQuota(Default(), HANDLE_SET_OFFLINE_STORAGE_DEFAULT_QUOTA, 
maximumSize);
+}
+
+void BWebSettings::SetOfflineWebApplicationCachePath(const BString& path)
+{
+       _PostSetPath(Default(), HANDLE_SET_OFFLINE_WEB_APPLICATION_CACHE_PATH, 
path);
+}
+
+void BWebSettings::SetOfflineWebApplicationCacheQuota(int64 maximumSize)
+{
+       _PostSetQuota(Default(), 
HANDLE_SET_OFFLINE_WEB_APPLICATION_CACHE_QUOTA, maximumSize);
+}
+
+void BWebSettings::SetLocalStoragePath(const BString& path)
+{
+       _PostSetPath(this, HANDLE_SET_LOCAL_STORAGE_PATH, path);
+}
+
+// #pragma mark - private
+
+void BWebSettings::_PostSetPath(BHandler* handler, uint32 what, const BString& 
path)
+{
+       BMessage message(what);
+       message.AddString("path", path.String());
+       if (find_thread(0) == handler->Looper()->Thread())
+           handler->MessageReceived(&message);
+       else
+           handler->Looper()->PostMessage(&message, handler);
+}
+
+void BWebSettings::_PostSetQuota(BHandler* handler, uint32 what, int64 
maximumSize)
+{
+       BMessage message(what);
+       message.AddInt64("quota", maximumSize);
+       if (find_thread(0) == handler->Looper()->Thread())
+           handler->MessageReceived(&message);
+       else
+           handler->Looper()->PostMessage(&message, handler);
+}
+
+void BWebSettings::MessageReceived(BMessage* message)
+{
+       switch (message->what) {
+       case HANDLE_SET_PERSISTENT_STORAGE_PATH: {
+               BString path;
+               if (message->FindString("path", &path) == B_OK)
+                   _HandleSetPersistentStoragePath(path);
+               break;
+       }
+       case HANDLE_SET_ICON_DATABASE_PATH: {
+               BString path;
+               if (message->FindString("path", &path) == B_OK)
+                   _HandleSetIconDatabasePath(path);
+               break;
+       }
+       case HANDLE_CLEAR_ICON_DATABASE:
+           _HandleClearIconDatabase();
+               break;
+       case HANDLE_SEND_ICON_FOR_URL: {
+               _HandleSendIconForURL(message);
+        break;
+       }
+       case HANDLE_SET_OFFLINE_STORAGE_PATH: {
+               BString path;
+               if (message->FindString("path", &path) == B_OK)
+                   _HandleSetOfflineStoragePath(path);
+               break;
+       }
+       case HANDLE_SET_OFFLINE_STORAGE_DEFAULT_QUOTA: {
+               int64 maximumSize;
+               if (message->FindInt64("quota", &maximumSize) == B_OK)
+                   _HandleSetOfflineStorageDefaultQuota(maximumSize);
+               break;
+       }
+       case HANDLE_SET_OFFLINE_WEB_APPLICATION_CACHE_PATH: {
+               BString path;
+               if (message->FindString("path", &path) == B_OK)
+                   _HandleSetWebApplicationCachePath(path);
+               break;
+       }
+       case HANDLE_SET_OFFLINE_WEB_APPLICATION_CACHE_QUOTA: {
+               int64 maximumSize;
+               if (message->FindInt64("quota", &maximumSize) == B_OK)
+                   _HandleSetWebApplicationCacheQuota(maximumSize);
+               break;
+       }
+       case HANDLE_SET_LOCAL_STORAGE_PATH: {
+               BString path;
+               if (message->FindString("path", &path) == B_OK)
+                   _HandleSetLocalStoragePath(path);
+               break;
+       }
+       default:
+               BHandler::MessageReceived(message);
+       }
+}
+
+void BWebSettings::_HandleSetPersistentStoragePath(const BString& path)
+{
+printf("BWebSettings::_HandleSetPersistentStoragePath(%s)\n", path.String());
+    BPath storagePath;
+
+    if (!path.Length())
+        find_directory(B_USER_DATA_DIRECTORY, &storagePath);
+    else
+        storagePath.SetTo(path.String());
+
+       create_directory(storagePath.Path(), 0777);
+
+    _HandleSetIconDatabasePath(storagePath.Path());
+    _HandleSetWebApplicationCachePath(storagePath.Path());
+    BPath dataBasePath(storagePath);
+    dataBasePath.Append("Databases");
+    _HandleSetOfflineStoragePath(dataBasePath.Path());
+    BPath localStoragePath(storagePath);
+    dataBasePath.Append("LocalStorage");
+    Default()->_HandleSetLocalStoragePath(localStoragePath.Path());
+
+    Default()->fData->localStorageEnabled = true;
+    Default()->fData->databasesEnabled = true;
+    Default()->fData->offlineWebApplicationCacheEnabled = true;
+    Default()->fData->apply();
+}
+
+void BWebSettings::_HandleSetIconDatabasePath(const BString& path)
+{
+    WebCore::iconDatabase()->delayDatabaseCleanup();
+
+    if (path.Length()) {
+        WebCore::iconDatabase()->setEnabled(true);
+        BEntry entry(path.String());
+        if (entry.IsDirectory())
+            WebCore::iconDatabase()->open(path);
+    } else {
+        WebCore::iconDatabase()->setEnabled(false);
+        WebCore::iconDatabase()->close();
+    }
+}
+
+void BWebSettings::_HandleClearIconDatabase()
+{
+    if (WebCore::iconDatabase()->isEnabled() && 
WebCore::iconDatabase()->isOpen())
+        WebCore::iconDatabase()->removeAllIcons();
+}
+
+void BWebSettings::_HandleSendIconForURL(BMessage* message)
+{
+       BString url;
+       BMessage reply;
+       BMessenger target;
+       if (message->FindString("url", &url) != B_OK
+           || message->FindMessage("reply", &reply) != B_OK
+               || message->FindMessenger("target", &target) != B_OK) {
+               return;
+       }
+    WebCore::Image* image = 
WebCore::iconDatabase()->iconForPageURL(url.String(),
+        WebCore::IntSize(16, 16));
+
+    if (image) {
+        const BBitmap* bitmap = image->nativeImageForCurrentFrame();
+        BMessage iconArchive;
+        if (bitmap && bitmap->Archive(&iconArchive) == B_OK) {
+            reply.AddString("url", url.String());
+            reply.AddMessage("icon", &iconArchive);
+            target.SendMessage(&reply);
+        }
+    }
+}
+
+void BWebSettings::_HandleSetOfflineStoragePath(const BString& path)
+{
+    WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(path);
+}
+
+void BWebSettings::_HandleSetOfflineStorageDefaultQuota(int64 maximumSize)
+{
+    fData->offlineStorageDefaultQuota = maximumSize;
+}
+
+void BWebSettings::_HandleSetWebApplicationCachePath(const BString& path)
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    WebCore::cacheStorage().setCacheDirectory(path);
+#endif
+}
+
+void BWebSettings::_HandleSetWebApplicationCacheQuota(int64 maximumSize)
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    WebCore::cacheStorage().setMaximumSize(maximumSize);
+#endif
+}
+
+void BWebSettings::_HandleSetLocalStoragePath(const BString& path)
+{
+    if (!fData->settings)
+        return;
+
+    fData->localStoragePath = path;
+    fData->apply();
+}
+

Added: webkit/trunk/WebKit/haiku/API/WebSettings.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/API/WebSettings.h Mon Mar  1 17:41:43 2010        
(r257)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _WEB_SETTINGS_H_
+#define _WEB_SETTINGS_H_
+
+#include <Handler.h>
+#include <String.h>
+
+
+class BBitmap;
+class BMessenger;
+class BWebPage;
+
+namespace WebCore {
+class Settings;
+}
+
+namespace BPrivate {
+class WebSettingsPrivate;
+}
+
+class BWebSettings : public BHandler {
+// TODO: Inherit from BReferenceable.
+public:
+       static  BWebSettings*           Default();
+
+       // This will call all the storage methods below with default paths 
relative to
+       // the given path. An empty path will use the default 
B_USER_DATA_DIRECTORY.
+       static  void                            SetPersistentStoragePath(const 
BString& path = BString());
+
+       static  void                            SetIconDatabasePath(const 
BString& path);
+       static  void                            ClearIconDatabase();
+
+       // This method triggers sending the provided message when the favicon
+       // for the given URL can be found.
+       // It is dispatched to the BMessenger provided to SendIconForURL().
+       // The icon will be stored as archived BBitmap "icon" in the message, 
which is
+       // otherwise a copy of the provided message
+       static  void                            SendIconForURL(const BString& 
url,
+                                                                       const 
BMessage& reply,
+                                                                       const 
BMessenger& target);
+
+       static  void                            SetOfflineStoragePath(const 
BString& path);
+       static  void                            
SetOfflineStorageDefaultQuota(int64 maximumSize);
+
+       static  void                            
SetOfflineWebApplicationCachePath(const BString& path);
+       static  void                            
SetOfflineWebApplicationCacheQuota(int64 maximumSize);
+    
+                       void                            
SetLocalStoragePath(const BString& path);
+
+private:
+                       friend class BWebPage;
+                       friend class BPrivate::WebSettingsPrivate;
+
+                                                               BWebSettings();
+                                                               
BWebSettings(WebCore::Settings* settings);
+       virtual                                         ~BWebSettings();
+
+private:
+       static  void                            _PostSetPath(BHandler* handler, 
uint32 what, const BString& path);
+       static  void                            _PostSetQuota(BHandler* 
handler, uint32 what, int64 maximumSize);
+
+       virtual void                            MessageReceived(BMessage* 
message);
+
+                       void                            
_HandleSetPersistentStoragePath(const BString& path);
+                       void                            
_HandleSetIconDatabasePath(const BString& path);
+                       void                            
_HandleClearIconDatabase();
+                       void                            
_HandleSendIconForURL(BMessage* message);
+                       void                            
_HandleSetOfflineStoragePath(const BString& path);
+                       void                            
_HandleSetOfflineStorageDefaultQuota(int64 maximumSize);
+                       void                            
_HandleSetWebApplicationCachePath(const BString& path);
+                       void                            
_HandleSetWebApplicationCacheQuota(int64 maximumSize);
+                       void                            
_HandleSetLocalStoragePath(const BString& path);
+private:
+                       BPrivate::WebSettingsPrivate* fData;
+};
+
+#endif // _WEB_SETTINGS_H_

Added: webkit/trunk/WebKit/haiku/API/WebSettingsPrivate.cpp
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/API/WebSettingsPrivate.cpp        Mon Mar  1 
17:41:43 2010        (r257)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSettingsPrivate.h"
+
+#include "PlatformString.h"
+#include "Settings.h"
+#include "WebSettings.h"
+
+namespace BPrivate {
+
+BList WebSettingsPrivate::sAllSettings(128);
+
+WebSettingsPrivate::WebSettingsPrivate(WebCore::Settings* settings)
+    : settings(settings)
+    , localStoragePath()
+    , offlineStorageDefaultQuota(5 * 1024 * 1024)
+    , localStorageEnabled(false)
+    , databasesEnabled(false)
+    , offlineWebApplicationCacheEnabled(false)
+{
+       apply();
+       if (settings)
+           sAllSettings.AddItem(this);
+}
+
+WebSettingsPrivate::~WebSettingsPrivate()
+{
+       if (settings)
+           sAllSettings.RemoveItem(this);
+}
+
+void WebSettingsPrivate::apply()
+{
+       if (settings) {
+               WebSettingsPrivate* global = BWebSettings::Default()->fData;
+           // Default settings
+           // TODO: Get attributes from hash map and fall back to global 
settings if
+           // attributes are not set.
+           settings->setLoadsImagesAutomatically(true);
+           settings->setMinimumFontSize(5);
+           settings->setMinimumLogicalFontSize(5);
+           settings->setShouldPrintBackgrounds(true);
+           settings->setJavaScriptEnabled(true);
+//         settings->setShowsURLsInToolTips(true);
+           settings->setShouldPaintCustomScrollbars(true);
+           settings->setEditingBehavior(WebCore::EditingMacBehavior);
+           settings->setLocalStorageEnabled(global->localStorageEnabled);
+           settings->setLocalStorageDatabasePath(global->localStoragePath);
+       
+           settings->setDefaultFixedFontSize(14);
+           settings->setDefaultFontSize(14);
+       
+           settings->setSerifFontFamily("DejaVu Serif");
+           settings->setSansSerifFontFamily("DejaVu Sans");
+           settings->setFixedFontFamily("DejaVu Sans Mono");
+           settings->setStandardFontFamily("DejaVu Serif");
+           settings->setDefaultTextEncodingName("UTF-8");
+       } else {
+           int32 count = sAllSettings.CountItems();
+           for (int32 i = 0; i < count; i++) {
+               WebSettingsPrivate* webSettings = 
reinterpret_cast<WebSettingsPrivate*>(
+                   sAllSettings.ItemAtFast(i));
+               if (webSettings != this)
+                   webSettings->apply();
+           }
+       }
+}
+
+} // namespace BPrivate

Added: webkit/trunk/WebKit/haiku/API/WebSettingsPrivate.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/API/WebSettingsPrivate.h  Mon Mar  1 17:41:43 
2010        (r257)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSettingsPrivate_h
+#define WebSettingsPrivate_h
+
+#include <List.h>
+#include <String.h>
+
+namespace WebCore {
+class Settings;
+}
+
+namespace BPrivate {
+
+class WebSettingsPrivate {
+public:
+    WebSettingsPrivate(WebCore::Settings* settings = 0);
+    ~WebSettingsPrivate();
+
+    void apply();
+
+    WebCore::Settings* settings;
+
+    BString localStoragePath;
+    int64 offlineStorageDefaultQuota;
+    bool localStorageEnabled;
+    bool databasesEnabled;
+    bool offlineWebApplicationCacheEnabled;
+
+private:
+       static BList sAllSettings;
+};
+
+} // namespace BPrivate
+
+#endif // WebSettingsPrivate_h

Modified: webkit/trunk/WebKit/haiku/API/WebViewConstants.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Mon Mar  1 17:32:57 
2010        (r256)
+++ webkit/trunk/WebKit/haiku/API/WebViewConstants.h    Mon Mar  1 17:41:43 
2010        (r257)
@@ -44,7 +44,8 @@
     JAVASCRIPT_WINDOW_OBJECT_CLEARED =                  312,
     UPDATE_HISTORY =                                    313,
     UPDATE_NAVIGATION_INTERFACE =                       314,
-    AUTHENTICATION_CHALLENGE =                          315
+    AUTHENTICATION_CHALLENGE =                          315,
+    ICON_RECEIVED =                                     316
 };
 
 enum {

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.cpp Mon Mar  1 17:32:57 2010        
(r256)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.cpp Mon Mar  1 17:41:43 2010        
(r257)
@@ -31,10 +31,12 @@
 #include "config.h"
 #include "WebWindow.h"
 
+#include "WebSettings.h"
 #include "WebView.h"
 #include "WebViewConstants.h"
 
 #include <Application.h>
+#include <Bitmap.h>
 #include <Button.h>
 #include <GridLayoutBuilder.h>
 #include <GroupLayout.h>
@@ -44,6 +46,10 @@
 
 #include <stdio.h>
 
+enum {
+    ICON_FOR_URL_RECEIVED = 'icfu'
+};
+
 BWebWindow::BWebWindow(BRect frame, const char* title, window_look look,
         window_feel feel, uint32 flags, uint32 workspace)
     : BWindow(frame, title, look, feel, flags, workspace)
@@ -113,8 +119,10 @@
     }
     case LOAD_NEGOTIATING: {
         BString url;
-        if (message->FindString("url", &url) == B_OK)
+        if (message->FindString("url", &url) == B_OK) {
             LoadNegotiating(url, _WebViewForMessage(message));
+            _FetchIconForURL(url, *message);
+        }
         break;
     }
     case LOAD_COMMITTED: {
@@ -147,6 +155,21 @@
             TitleChanged(title, _WebViewForMessage(message));
         break;
     }
+    case ICON_RECEIVED: {
+       // The icon is now in the database.
+        BString url;
+        if (message->FindString("url", &url) == B_OK)
+            _FetchIconForURL(url, *message);
+        break;
+    }
+    case ICON_FOR_URL_RECEIVED: {
+        BMessage iconArchive;
+        if (message->FindMessage("icon", &iconArchive) == B_OK) {
+               BBitmap icon(&iconArchive);
+            IconReceived(&icon, _WebViewForMessage(message));
+        }
+       break;
+    }
     case RESIZING_REQUESTED: {
         BRect rect;
         if (message->FindRect("rect", &rect) == B_OK)
@@ -297,6 +320,10 @@
     SetTitle(title.String());
 }
 
+void BWebWindow::IconReceived(const BBitmap* icon, BWebView* view)
+{
+}
+
 void BWebWindow::ResizeRequested(float width, float height, BWebView* view)
 {
     ResizeTo(width, height);
@@ -344,6 +371,14 @@
 
 // #pragma mark - private
 
+void BWebWindow::_FetchIconForURL(const BString& url, const BMessage& message)
+{
+       BMessage reply(message);
+       reply.what = ICON_FOR_URL_RECEIVED;
+       BMessenger target(this);
+       BWebSettings::SendIconForURL(url, reply, target);
+}
+
 BWebView* BWebWindow::_WebViewForMessage(const BMessage* message) const
 {
        // Default to the current BWebView, if there is none in the message.

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.h   Mon Mar  1 17:32:57 2010        
(r256)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.h   Mon Mar  1 17:41:43 2010        
(r257)
@@ -68,6 +68,8 @@
                                                                        
BWebView* view);
        virtual void                            TitleChanged(const BString& 
title,
                                                                        
BWebView* view);
+       virtual void                            IconReceived(const BBitmap* 
icon,
+                                                                       
BWebView* view);
        virtual void                            ResizeRequested(float width, 
float height,
                                                                        
BWebView* view);
        virtual void                            SetToolBarsVisible(bool flag, 
BWebView* view);
@@ -86,6 +88,8 @@
                                                                        uint32 
failureCount, BWebView* view);
 
 private:
+                       void                            _FetchIconForURL(const 
BString& url,
+                                                                       const 
BMessage& message);
                        BWebView*                       _WebViewForMessage(
                                                                        const 
BMessage* message) const;
 

Modified: webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp Mon Mar 
 1 17:32:57 2010        (r256)
+++ webkit/trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp Mon Mar 
 1 17:41:43 2010        (r257)
@@ -46,6 +46,7 @@
 #include "FrameView.h"
 #include "HTMLFormElement.h"
 #include "HTMLFrameOwnerElement.h"
+#include "IconDatabase.h"
 #include "MouseEvent.h"
 #include "MIMETypeRegistry.h"
 #include "NotImplemented.h"
@@ -65,6 +66,7 @@
 #include "WebViewConstants.h"
 
 #include <Alert.h>
+#include <Bitmap.h>
 #include <Entry.h>
 #include <Message.h>
 #include <MimeType.h>
@@ -294,7 +296,9 @@
     if (m_loadingErrorPage)
         return;
 
-    notImplemented();
+    BMessage message(ICON_RECEIVED);
+       message.AddString("url", m_webFrame->Frame()->loader()->url().string());
+    dispatchMessage(message);
 }
 
 void FrameLoaderClientHaiku::dispatchDidStartProvisionalLoad()

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp        Mon Mar  1 
17:32:57 2010        (r256)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserApp.cpp        Mon Mar  1 
17:41:43 2010        (r257)
@@ -32,8 +32,8 @@
 #include "BrowserWindow.h"
 #include "DownloadWindow.h"
 #include "WebPage.h"
+#include "WebSettings.h"
 #include "WebView.h"
-#include "WebViewConstants.h"
 #include <Alert.h>
 #include <Autolock.h>
 #include <Directory.h>
@@ -104,6 +104,8 @@
        BWebPage::InitializeOnce();
        BWebPage::SetCacheModel(B_WEBKIT_CACHE_MODEL_WEB_BROWSER);
 
+       
BWebSettings::SetPersistentStoragePath("/boot/home/config/settings/WebPositive");
+
        BFile settingsFile;
        BRect windowFrameFromSettings = fLastWindowFrame;
        BRect downloadWindowFrame(100, 100, 300, 250);

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Mon Mar  1 
17:32:57 2010        (r256)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Mon Mar  1 
17:41:43 2010        (r257)
@@ -701,6 +701,13 @@
 
 
 void
+BrowserWindow::IconReceived(const BBitmap* icon, BWebView* view)
+{
+       printf("BrowserWindow::IconReceived(%p, %p)\n", icon, view);
+}
+
+
+void
 BrowserWindow::StatusChanged(const BString& statusText, BWebView* view)
 {
        if (view != CurrentWebView())

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Mon Mar  1 
17:32:57 2010        (r256)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Mon Mar  1 
17:41:43 2010        (r257)
@@ -94,6 +94,8 @@
                                                                        
BWebView* view);
        virtual void                            TitleChanged(const BString& 
title,
                                                                        
BWebView* view);
+       virtual void                            IconReceived(const BBitmap* 
icon,
+                                                                       
BWebView* view);
        virtual void                            ResizeRequested(float width, 
float height,
                                                                        
BWebView* view);
        virtual void                            SetToolBarsVisible(bool flag, 
BWebView* view);

Other related posts:

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