* 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
This commit is contained in:
stippi
2012-07-03 15:37:51 +02:00
committed by Alexandre Deckner
parent 6faa5c3d74
commit 7239ea752d
5 changed files with 29 additions and 12 deletions
+16
View File
@@ -34,6 +34,7 @@
#include "DownloadWindow.h" #include "DownloadWindow.h"
#include "SettingsMessage.h" #include "SettingsMessage.h"
#include "SettingsWindow.h" #include "SettingsWindow.h"
#include "NetworkCookieJar.h"
#include "WebPage.h" #include "WebPage.h"
#include "WebSettings.h" #include "WebSettings.h"
#include "WebView.h" #include "WebView.h"
@@ -61,6 +62,7 @@ BrowserApp::BrowserApp()
fLaunchRefsMessage(0), fLaunchRefsMessage(0),
fInitialized(false), fInitialized(false),
fSettings(NULL), fSettings(NULL),
fCookieJar(NULL),
fDownloadWindow(NULL), fDownloadWindow(NULL),
fSettingsWindow(NULL) fSettingsWindow(NULL)
{ {
@@ -72,6 +74,8 @@ BrowserApp::~BrowserApp()
{ {
delete fLaunchRefsMessage; delete fLaunchRefsMessage;
delete fSettings; delete fSettings;
delete fCookies;
delete fCookieJar;
} }
@@ -125,6 +129,14 @@ BrowserApp::ReadyToRun()
mainSettingsPath << "/Application"; mainSettingsPath << "/Application";
fSettings = new SettingsMessage(B_USER_SETTINGS_DIRECTORY, fSettings = new SettingsMessage(B_USER_SETTINGS_DIRECTORY,
mainSettingsPath.String()); 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); fLastWindowFrame = fSettings->GetValue("window frame", fLastWindowFrame);
BRect downloadWindowFrame = fSettings->GetValue("downloads window frame", BRect downloadWindowFrame = fSettings->GetValue("downloads window frame",
@@ -261,6 +273,10 @@ BrowserApp::QuitRequested()
fSettingsWindow->Unlock(); fSettingsWindow->Unlock();
} }
BMessage cookieArchive;
if (fCookieJar->Archive(&cookieArchive) == B_OK)
fCookies->SetValue("cookies", cookieArchive);
return true; return true;
} }
+3
View File
@@ -33,6 +33,7 @@
#include <Catalog.h> #include <Catalog.h>
#include <Rect.h> #include <Rect.h>
class BNetworkCookieJar;
class DownloadWindow; class DownloadWindow;
class BrowserWindow; class BrowserWindow;
class SettingsMessage; class SettingsMessage;
@@ -66,6 +67,8 @@ private:
bool fInitialized; bool fInitialized;
SettingsMessage* fSettings; SettingsMessage* fSettings;
SettingsMessage* fCookies;
BNetworkCookieJar* fCookieJar;
DownloadWindow* fDownloadWindow; DownloadWindow* fDownloadWindow;
SettingsWindow* fSettingsWindow; SettingsWindow* fSettingsWindow;
+6 -8
View File
@@ -197,10 +197,11 @@ private:
BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener, BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
ToolbarPolicy toolbarPolicy) ToolbarPolicy toolbarPolicy)
: BWebWindow(frame, kApplicationName, :
BWebWindow(frame, kApplicationName,
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS) B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS),
, fDownloadListener(downloadListener) fDownloadListener(downloadListener)
{ {
BMessage* newTabMessage = new BMessage(NEW_TAB); BMessage* newTabMessage = new BMessage(NEW_TAB);
newTabMessage->AddString("url", ""); newTabMessage->AddString("url", "");
@@ -346,11 +347,8 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
fStatusText = 0; fStatusText = 0;
fLoadingProgressBar = 0; fLoadingProgressBar = 0;
BWebView* webView = new BWebView("web_view"); AddChild(BGroupLayoutBuilder(B_VERTICAL)
SetCurrentWebView(webView); .Add(fTabManager->ContainerView())
AddChild(BGroupLayoutBuilder(B_VERTICAL, 7)
.Add(CurrentWebView())
); );
} }
@@ -186,11 +186,11 @@ SettingsMessage::SetValue(const char* name, const entry_ref& value)
status_t 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 B_OK;
return AddMessage(name, value); return AddMessage(name, &value);
} }
@@ -41,7 +41,7 @@ public:
status_t SetValue(const char* name, const BRect& value); 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 entry_ref& value);
status_t SetValue(const char* name, status_t SetValue(const char* name,
const BMessage* value); const BMessage& value);
status_t SetValue(const char* name, status_t SetValue(const char* name,
const BFlattenable* value); const BFlattenable* value);
status_t SetValue(const char* name, status_t SetValue(const char* name,