From 7239ea752d0486bed93d1c3e97c26a8556822362 Mon Sep 17 00:00:00 2001 From: stippi Date: Tue, 9 Mar 2010 11:49:34 +0000 Subject: [PATCH] * Added a class CookieJarClient to WebCore's CookieJar.h which provides the same functionality as the global methods for managing cookies. This is only enabled for the Haiku platform. Since the global cookie methods get a Document pointer, I envision, the CookieJarClient could eventually be a member of Document instances. It would then be passed upon WebCore::Page creation. Still waiting on feedback from other WebKit developers on this one. This change is more elegant than what the Qt port does, which is to use WebKit classes in WebCore (layering violation). Right now, a single global instance of a CookieJarClient can be assigned. * Implemented CookieJarClientHaiku which uses a BNetworkCookieJar to forward the requests. Eventually, the behaviour could be browser specific. * Added all the necessary wiring to BrowserApplication to make the cookie jar persistent. * TODO: Actually parse cookies and handle at least the expiration date, but other stuff like matching the domain of the cookie and the URL and "HTTP-only" cookies seems important as well. Even though I have confirmed that cookies are stored and restored correctly, and also retrieved via the global cookie methods, I can see no change in browser behaviour. For example enabling "Stay signed in" on googlemail.com does not work in WebPositive, although BeZillaBrowser automatically logs in in a new session when surfing to googlemail.com. No idea if this is even implemented with cookies, although it seems like it should be. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@303 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/BrowserApp.cpp | 16 ++++++++++++++++ src/apps/webpositive/BrowserApp.h | 3 +++ src/apps/webpositive/BrowserWindow.cpp | 14 ++++++-------- src/apps/webpositive/support/SettingsMessage.cpp | 6 +++--- src/apps/webpositive/support/SettingsMessage.h | 2 +- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/apps/webpositive/BrowserApp.cpp b/src/apps/webpositive/BrowserApp.cpp index 89bd3aeaeb..29fe7b6ccd 100644 --- a/src/apps/webpositive/BrowserApp.cpp +++ b/src/apps/webpositive/BrowserApp.cpp @@ -34,6 +34,7 @@ #include "DownloadWindow.h" #include "SettingsMessage.h" #include "SettingsWindow.h" +#include "NetworkCookieJar.h" #include "WebPage.h" #include "WebSettings.h" #include "WebView.h" @@ -61,6 +62,7 @@ BrowserApp::BrowserApp() fLaunchRefsMessage(0), fInitialized(false), fSettings(NULL), + fCookieJar(NULL), fDownloadWindow(NULL), fSettingsWindow(NULL) { @@ -72,6 +74,8 @@ BrowserApp::~BrowserApp() { delete fLaunchRefsMessage; delete fSettings; + delete fCookies; + delete fCookieJar; } @@ -125,6 +129,14 @@ BrowserApp::ReadyToRun() mainSettingsPath << "/Application"; fSettings = new SettingsMessage(B_USER_SETTINGS_DIRECTORY, mainSettingsPath.String()); + mainSettingsPath = kApplicationName; + mainSettingsPath << "/Cookies"; + fCookies = new SettingsMessage(B_USER_SETTINGS_DIRECTORY, + mainSettingsPath.String()); + BMessage cookieArchive; + cookieArchive = fCookies->GetValue("cookies", cookieArchive); + fCookieJar = new BNetworkCookieJar(cookieArchive); + BWebPage::SetCookieJar(fCookieJar); fLastWindowFrame = fSettings->GetValue("window frame", fLastWindowFrame); BRect downloadWindowFrame = fSettings->GetValue("downloads window frame", @@ -261,6 +273,10 @@ BrowserApp::QuitRequested() fSettingsWindow->Unlock(); } + BMessage cookieArchive; + if (fCookieJar->Archive(&cookieArchive) == B_OK) + fCookies->SetValue("cookies", cookieArchive); + return true; } diff --git a/src/apps/webpositive/BrowserApp.h b/src/apps/webpositive/BrowserApp.h index d4fb9fbf59..dfc9433e5e 100644 --- a/src/apps/webpositive/BrowserApp.h +++ b/src/apps/webpositive/BrowserApp.h @@ -33,6 +33,7 @@ #include #include +class BNetworkCookieJar; class DownloadWindow; class BrowserWindow; class SettingsMessage; @@ -66,6 +67,8 @@ private: bool fInitialized; SettingsMessage* fSettings; + SettingsMessage* fCookies; + BNetworkCookieJar* fCookieJar; DownloadWindow* fDownloadWindow; SettingsWindow* fSettingsWindow; diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index a2ff746a89..4b0ef6b758 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -197,10 +197,11 @@ private: BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener, ToolbarPolicy toolbarPolicy) - : BWebWindow(frame, kApplicationName, + : + BWebWindow(frame, kApplicationName, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, - B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS) - , fDownloadListener(downloadListener) + B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS), + fDownloadListener(downloadListener) { BMessage* newTabMessage = new BMessage(NEW_TAB); newTabMessage->AddString("url", ""); @@ -346,11 +347,8 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener, fStatusText = 0; fLoadingProgressBar = 0; - BWebView* webView = new BWebView("web_view"); - SetCurrentWebView(webView); - - AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) - .Add(CurrentWebView()) + AddChild(BGroupLayoutBuilder(B_VERTICAL) + .Add(fTabManager->ContainerView()) ); } diff --git a/src/apps/webpositive/support/SettingsMessage.cpp b/src/apps/webpositive/support/SettingsMessage.cpp index 7c2edddfc5..98e9ef1c94 100644 --- a/src/apps/webpositive/support/SettingsMessage.cpp +++ b/src/apps/webpositive/support/SettingsMessage.cpp @@ -186,11 +186,11 @@ SettingsMessage::SetValue(const char* name, const entry_ref& value) status_t -SettingsMessage::SetValue(const char* name, const BMessage* value) +SettingsMessage::SetValue(const char* name, const BMessage& value) { - if (ReplaceMessage(name, value) == B_OK) + if (ReplaceMessage(name, &value) == B_OK) return B_OK; - return AddMessage(name, value); + return AddMessage(name, &value); } diff --git a/src/apps/webpositive/support/SettingsMessage.h b/src/apps/webpositive/support/SettingsMessage.h index 85a29320b8..8420238be8 100644 --- a/src/apps/webpositive/support/SettingsMessage.h +++ b/src/apps/webpositive/support/SettingsMessage.h @@ -41,7 +41,7 @@ public: status_t SetValue(const char* name, const BRect& value); status_t SetValue(const char* name, const entry_ref& value); status_t SetValue(const char* name, - const BMessage* value); + const BMessage& value); status_t SetValue(const char* name, const BFlattenable* value); status_t SetValue(const char* name,