summaryrefslogtreecommitdiff
path: root/Source/WebKit/blackberry/Api
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/blackberry/Api')
-rw-r--r--Source/WebKit/blackberry/Api/BlackBerryGlobal.cpp3
-rw-r--r--Source/WebKit/blackberry/Api/WebCookieJar.cpp60
-rw-r--r--Source/WebKit/blackberry/Api/WebCookieJar.h70
-rw-r--r--Source/WebKit/blackberry/Api/WebPage.cpp28
-rw-r--r--Source/WebKit/blackberry/Api/WebPage.h3
-rw-r--r--Source/WebKit/blackberry/Api/WebPage_p.h4
-rw-r--r--Source/WebKit/blackberry/Api/WebString.cpp5
-rw-r--r--Source/WebKit/blackberry/Api/WebString.h1
8 files changed, 160 insertions, 14 deletions
diff --git a/Source/WebKit/blackberry/Api/BlackBerryGlobal.cpp b/Source/WebKit/blackberry/Api/BlackBerryGlobal.cpp
index d8b5c5124..fc9cd5aae 100644
--- a/Source/WebKit/blackberry/Api/BlackBerryGlobal.cpp
+++ b/Source/WebKit/blackberry/Api/BlackBerryGlobal.cpp
@@ -20,7 +20,6 @@
#include "BlackBerryGlobal.h"
#include "ApplicationCacheStorage.h"
-#include "AuthenticationChallengeManager.h"
#include "CacheClientBlackBerry.h"
#include "CookieManager.h"
#include "CrossOriginPreflightResultCache.h"
@@ -81,8 +80,6 @@ void globalInitialize()
BlackBerry::Platform::Settings* settings = BlackBerry::Platform::Settings::instance();
ImageSource::setMaxPixelsPerDecodedImage(settings->maxPixelsPerDecodedImage());
-
- AuthenticationChallengeManager::init();
}
void collectJavascriptGarbageNow()
diff --git a/Source/WebKit/blackberry/Api/WebCookieJar.cpp b/Source/WebKit/blackberry/Api/WebCookieJar.cpp
new file mode 100644
index 000000000..da8964fa8
--- /dev/null
+++ b/Source/WebKit/blackberry/Api/WebCookieJar.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "WebCookieJar.h"
+
+#include "CookieManager.h"
+#include "KURL.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace BlackBerry {
+namespace WebKit {
+
+WebCookieJar::WebCookieJar()
+{
+}
+
+std::vector<WebString> WebCookieJar::cookies(const char* url)
+{
+ KURL kurl = KURL(KURL(), String(url));
+
+ Vector<ParsedCookie*> rawCookies;
+ cookieManager().getRawCookies(rawCookies, kurl, WithHttpOnlyCookies);
+
+ std::vector<WebString> result;
+ for (size_t i = 0; i < rawCookies.size(); ++i)
+ result.push_back(WebString(rawCookies[i]->toNameValuePair().impl()));
+
+ return result;
+}
+
+void WebCookieJar::setCookies(const char* url, const std::vector<WebString>& cookies)
+{
+ KURL kurl = KURL(KURL(), String(url));
+ Vector<String> coreCookies;
+ for (size_t i = 0; i < cookies.size(); ++i)
+ coreCookies.append(String(cookies[i].impl()));
+ cookieManager().setCookies(kurl, coreCookies, WithHttpOnlyCookies);
+}
+
+}
+}
diff --git a/Source/WebKit/blackberry/Api/WebCookieJar.h b/Source/WebKit/blackberry/Api/WebCookieJar.h
new file mode 100644
index 000000000..0c174e404
--- /dev/null
+++ b/Source/WebKit/blackberry/Api/WebCookieJar.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef WebCookieJar_h
+#define WebCookieJar_h
+
+#include "BlackBerryGlobal.h"
+
+#include <vector>
+
+namespace BlackBerry {
+namespace WebKit {
+
+class WebPage;
+class WebString;
+
+/**
+ * Represents the cookie database.
+ *
+ * You can obtain an instance of WebCookieJar by calling WebPage::cookieJar().
+ */
+class BLACKBERRY_EXPORT WebCookieJar {
+public:
+ /**
+ * Returns a list of cookies for the URL specified.
+ *
+ * All cookies whose domain and path match the provided URL will be returned.
+ */
+ std::vector<WebString> cookies(const char* url);
+
+ /**
+ * This will add the cookies provided in the list to the cookie database.
+ * If a cookie with the same name and domain+path as one of the cookies
+ * provided already exists, it will be replaced. Other cookies that already
+ * existed will remain.
+ *
+ * If no domain and/or path is provided in a cookie, the domain and/or path
+ * will be inferred from the provided URL.
+ */
+ void setCookies(const char* url, const std::vector<WebString>& cookies);
+
+private:
+ friend class WebPage;
+
+ WebCookieJar();
+
+ // Disable copy constructor and operator=.
+ WebCookieJar(const WebCookieJar&);
+ WebCookieJar& operator=(const WebCookieJar&);
+};
+
+}
+}
+
+#endif // WebCookieJar_h
diff --git a/Source/WebKit/blackberry/Api/WebPage.cpp b/Source/WebKit/blackberry/Api/WebPage.cpp
index 128075704..78a2858c2 100644
--- a/Source/WebKit/blackberry/Api/WebPage.cpp
+++ b/Source/WebKit/blackberry/Api/WebPage.cpp
@@ -124,6 +124,7 @@
#include "VibrationClientBlackBerry.h"
#endif
#include "VisiblePosition.h"
+#include "WebCookieJar.h"
#if ENABLE(WEBDOM)
#include "WebDOMDocument.h"
#endif
@@ -349,6 +350,7 @@ WebPagePrivate::WebPagePrivate(WebPage* webPage, WebPageClient* client, const In
, m_mainFrame(0) // Initialized by init.
, m_currentContextNode(0)
, m_webSettings(0) // Initialized by init.
+ , m_cookieJar(0)
, m_visible(false)
, m_activationState(ActivationActive)
, m_shouldResetTilesWhenShown(false)
@@ -427,8 +429,6 @@ WebPagePrivate::WebPagePrivate(WebPage* webPage, WebPageClient* client, const In
BlackBerry::Platform::DeviceInfo::instance();
defaultUserAgent();
}
-
- AuthenticationChallengeManager::instance()->pageCreated(this);
}
WebPage::WebPage(WebPageClient* client, const WebString& pageGroupName, const Platform::IntRect& rect)
@@ -440,7 +440,6 @@ WebPage::WebPage(WebPageClient* client, const WebString& pageGroupName, const Pl
WebPagePrivate::~WebPagePrivate()
{
- AuthenticationChallengeManager::instance()->pageDeleted(this);
// Hand the backingstore back to another owner if necessary.
m_webPage->setVisible(false);
if (BackingStorePrivate::currentBackingStoreOwner() == m_webPage)
@@ -449,6 +448,9 @@ WebPagePrivate::~WebPagePrivate()
delete m_webSettings;
m_webSettings = 0;
+ delete m_cookieJar;
+ m_cookieJar = 0;
+
delete m_backingStoreClient;
m_backingStoreClient = 0;
m_backingStore = 0;
@@ -2213,19 +2215,18 @@ bool WebPagePrivate::isActive() const
return m_client->isActive();
}
-void WebPagePrivate::authenticationChallenge(const KURL& url, const ProtectionSpace& protectionSpace, const Credential& inputCredential)
+void WebPagePrivate::authenticationChallenge(const KURL& url, const ProtectionSpace& protectionSpace, const Credential& inputCredential, AuthenticationChallengeClient* client)
{
WebString username;
WebString password;
- AuthenticationChallengeManager* authmgr = AuthenticationChallengeManager::instance();
#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
if (m_dumpRenderTree) {
Credential credential(inputCredential, inputCredential.persistence());
if (m_dumpRenderTree->didReceiveAuthenticationChallenge(credential))
- authmgr->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+ client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
else
- authmgr->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
+ client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
return;
}
#endif
@@ -2246,9 +2247,9 @@ void WebPagePrivate::authenticationChallenge(const KURL& url, const ProtectionSp
#endif
if (isConfirmed)
- authmgr->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+ client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
else
- authmgr->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
+ client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
}
PageClientBlackBerry::SaveCredentialType WebPagePrivate::notifyShouldSaveCredential(bool isNew)
@@ -3191,6 +3192,14 @@ WebSettings* WebPage::settings() const
return d->m_webSettings;
}
+WebCookieJar* WebPage::cookieJar() const
+{
+ if (!d->m_cookieJar)
+ d->m_cookieJar = new WebCookieJar();
+
+ return d->m_cookieJar;
+}
+
bool WebPage::isVisible() const
{
return d->m_visible;
@@ -3240,7 +3249,6 @@ void WebPage::setVisible(bool visible)
return;
d->setVisible(visible);
- AuthenticationChallengeManager::instance()->pageVisibilityChanged(d, visible);
if (!visible) {
d->suspendBackingStore();
diff --git a/Source/WebKit/blackberry/Api/WebPage.h b/Source/WebKit/blackberry/Api/WebPage.h
index 20c48f00e..31b990808 100644
--- a/Source/WebKit/blackberry/Api/WebPage.h
+++ b/Source/WebKit/blackberry/Api/WebPage.h
@@ -66,6 +66,7 @@ class BackingStoreClient;
class BackingStorePrivate;
class InRegionScroller;
class RenderQueue;
+class WebCookieJar;
class WebOverlay;
class WebPageClient;
class WebPageCompositor;
@@ -127,6 +128,8 @@ public:
WebSettings* settings() const;
+ WebCookieJar* cookieJar() const;
+
void setVisible(bool);
bool isVisible() const;
diff --git a/Source/WebKit/blackberry/Api/WebPage_p.h b/Source/WebKit/blackberry/Api/WebPage_p.h
index bcb7d5009..ca0c180c0 100644
--- a/Source/WebKit/blackberry/Api/WebPage_p.h
+++ b/Source/WebKit/blackberry/Api/WebPage_p.h
@@ -77,6 +77,7 @@ class InPageSearchManager;
class InputHandler;
class SelectionHandler;
class TouchEventHandler;
+class WebCookieJar;
class WebPageClient;
#if USE(ACCELERATED_COMPOSITING)
@@ -201,7 +202,7 @@ public:
virtual int showAlertDialog(WebPageClient::AlertType atype);
virtual bool isActive() const;
virtual bool isVisible() const { return m_visible; }
- virtual void authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, const WebCore::Credential&);
+ virtual void authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, const WebCore::Credential&, WebCore::AuthenticationChallengeClient*);
virtual SaveCredentialType notifyShouldSaveCredential(bool);
virtual void syncProxyCredential(const WebCore::Credential&);
@@ -469,6 +470,7 @@ public:
WebCore::Frame* m_mainFrame;
RefPtr<WebCore::Node> m_currentContextNode;
WebSettings* m_webSettings;
+ WebCookieJar* m_cookieJar;
OwnPtr<WebTapHighlight> m_tapHighlight;
WebSelectionOverlay* m_selectionOverlay;
diff --git a/Source/WebKit/blackberry/Api/WebString.cpp b/Source/WebKit/blackberry/Api/WebString.cpp
index 640b673c9..0e75fc1a6 100644
--- a/Source/WebKit/blackberry/Api/WebString.cpp
+++ b/Source/WebKit/blackberry/Api/WebString.cpp
@@ -65,6 +65,11 @@ WebString WebString::fromUtf8(const char* utf8)
return String::fromUTF8(utf8);
}
+WebString WebString::fromUtf8(const char* utf8, size_t length)
+{
+ return String::fromUTF8(utf8, length);
+}
+
WebString& WebString::operator=(const WebString& str)
{
if (&str == this)
diff --git a/Source/WebKit/blackberry/Api/WebString.h b/Source/WebKit/blackberry/Api/WebString.h
index fe43c247f..c2af16b79 100644
--- a/Source/WebKit/blackberry/Api/WebString.h
+++ b/Source/WebKit/blackberry/Api/WebString.h
@@ -41,6 +41,7 @@ public:
WebString& operator=(const WebString&);
std::string utf8() const;
static WebString fromUtf8(const char* utf8);
+ static WebString fromUtf8(const char* utf8, size_t length);
const unsigned short* characters() const;
unsigned length() const;
bool isEmpty() const;