summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 16:57:51 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 16:57:51 +0000
commitb921cfd2c37845a0663570ddd3a6a9ec9c49a093 (patch)
treed3a3e1d52ede9bcc1639dcd18635b9df9a152acb
parent520dc79d6c0262b48da86e72c34a89a937486ed7 (diff)
downloadchromium_src-b921cfd2c37845a0663570ddd3a6a9ec9c49a093.zip
chromium_src-b921cfd2c37845a0663570ddd3a6a9ec9c49a093.tar.gz
chromium_src-b921cfd2c37845a0663570ddd3a6a9ec9c49a093.tar.bz2
Implement WebCookieJar.
Moves the implementation of cookie methods in RendererWebKitClientImpl into RendererWebCookieJarImpl. Moves the implementation of cookie methods in TestShellWebKitInit into SimpleWebCookieJarImpl. This leaves us with no longer implementing the cookie methods on WebKitClient. That'll allow us to delete those. WebPluginImpl needs to access the WebCookieJar used by either the renderer or test_shell. To enable that, I added a GetCookieJar method on WebPluginPageDelegate. This interface is used whenever the WebPluginImpl needs to talk to the RenderView or TestWebViewDelegate. R=jorlow BUG=35589 Review URL: http://codereview.chromium.org/661070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40023 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/chrome_renderer.gypi2
-rw-r--r--chrome/renderer/render_view.cc26
-rw-r--r--chrome/renderer/render_view.h5
-rw-r--r--chrome/renderer/renderer_webcookiejar_impl.cc92
-rw-r--r--chrome/renderer/renderer_webcookiejar_impl.h45
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc104
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h15
-rw-r--r--webkit/glue/webplugin_impl.cc25
-rw-r--r--webkit/glue/webplugin_page_delegate.h7
-rw-r--r--webkit/tools/test_shell/simple_webcookiejar_impl.cc25
-rw-r--r--webkit/tools/test_shell/simple_webcookiejar_impl.h22
-rw-r--r--webkit/tools/test_shell/test_shell.gypi2
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h26
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc14
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h1
15 files changed, 267 insertions, 144 deletions
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 484653a..4c22c42 100755
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -121,6 +121,8 @@
'renderer/renderer_main_platform_delegate_win.cc',
'renderer/renderer_sandbox_support_linux.cc',
'renderer/renderer_sandbox_support_linux.h',
+ 'renderer/renderer_webcookiejar_impl.cc',
+ 'renderer/renderer_webcookiejar_impl.h',
'renderer/renderer_webkitclient_impl.cc',
'renderer/renderer_webkitclient_impl.h',
'renderer/renderer_webstoragearea_impl.cc',
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 831ab1f..a35f97b 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -138,6 +138,7 @@ using WebKit::WebColor;
using WebKit::WebColorName;
using WebKit::WebConsoleMessage;
using WebKit::WebContextMenuData;
+using WebKit::WebCookieJar;
using WebKit::WebCString;
using WebKit::WebData;
using WebKit::WebDataSource;
@@ -319,7 +320,8 @@ RenderView::RenderView(RenderThreadBase* render_thread,
document_tag_(0),
webkit_preferences_(webkit_preferences),
session_storage_namespace_id_(session_storage_namespace_id),
- ALLOW_THIS_IN_INITIALIZER_LIST(text_translator_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(text_translator_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)) {
ClearBlockedContentSettings();
page_translator_.reset(new PageTranslator(&text_translator_, this));
}
@@ -2139,6 +2141,10 @@ WebMediaPlayer* RenderView::createMediaPlayer(
return new webkit_glue::WebMediaPlayerImpl(client, factory);
}
+WebCookieJar* RenderView::cookieJar() {
+ return &cookie_jar_;
+}
+
void RenderView::willClose(WebFrame* frame) {
if (!frame->parent()) {
const GURL& url = frame->url();
@@ -3044,13 +3050,6 @@ void RenderView::DidStopLoadingForPlugin() {
didStopLoading();
}
-void RenderView::PageTranslated(int page_id,
- const std::string& original_lang,
- const std::string& target_lang) {
- Send(new ViewHostMsg_PageTranslated(routing_id_, page_id_,
- original_lang, target_lang));
-}
-
void RenderView::ShowModalHTMLDialogForPlugin(
const GURL& url,
const gfx::Size& size,
@@ -3061,6 +3060,17 @@ void RenderView::ShowModalHTMLDialogForPlugin(
json_retval));
}
+WebCookieJar* RenderView::GetCookieJar() {
+ return &cookie_jar_;
+}
+
+void RenderView::PageTranslated(int page_id,
+ const std::string& original_lang,
+ const std::string& target_lang) {
+ Send(new ViewHostMsg_PageTranslated(routing_id_, page_id_,
+ original_lang, target_lang));
+}
+
void RenderView::SyncNavigationState() {
if (!webview())
return;
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 173404f..34069e9 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -39,6 +39,7 @@
#include "chrome/renderer/notification_provider.h"
#include "chrome/renderer/render_widget.h"
#include "chrome/renderer/render_view_visitor.h"
+#include "chrome/renderer/renderer_webcookiejar_impl.h"
#include "chrome/renderer/translate/page_translator.h"
#include "chrome/renderer/translate/text_translator_impl.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -292,6 +293,7 @@ class RenderView : public RenderWidget,
const WebKit::WebString& name, unsigned long long documentId);
virtual WebKit::WebMediaPlayer* createMediaPlayer(
WebKit::WebFrame* frame, WebKit::WebMediaPlayerClient* client);
+ virtual WebKit::WebCookieJar* cookieJar();
virtual void willClose(WebKit::WebFrame* frame);
virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
@@ -397,6 +399,7 @@ class RenderView : public RenderWidget,
const gfx::Size& size,
const std::string& json_arguments,
std::string* json_retval);
+ virtual WebKit::WebCookieJar* GetCookieJar();
// PageTranslator::PageTranslatorDelegate implementation:
virtual void PageTranslated(int page_id,
@@ -1133,6 +1136,8 @@ class RenderView : public RenderWidget,
// The geolocation dispatcher attached to this view, lazily initialized.
scoped_ptr<GeolocationDispatcher> geolocation_dispatcher_;
+ RendererWebCookieJarImpl cookie_jar_;
+
DISALLOW_COPY_AND_ASSIGN(RenderView);
};
diff --git a/chrome/renderer/renderer_webcookiejar_impl.cc b/chrome/renderer/renderer_webcookiejar_impl.cc
new file mode 100644
index 0000000..9e9263a
--- /dev/null
+++ b/chrome/renderer/renderer_webcookiejar_impl.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/renderer_webcookiejar_impl.h"
+
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/cookie_message_filter.h"
+#include "chrome/renderer/render_thread.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCookie.h"
+
+using WebKit::WebCookie;
+using WebKit::WebString;
+using WebKit::WebURL;
+using WebKit::WebVector;
+
+void RendererWebCookieJarImpl::SendSynchronousMessage(
+ IPC::SyncMessage* message) {
+ CookieMessageFilter* filter =
+ RenderThread::current()->cookie_message_filter();
+
+ message->set_pump_messages_event(filter->pump_messages_event());
+ sender_->Send(message);
+
+ // We may end up nesting calls to SendCookieMessage, so we defer the reset
+ // until we return to the top-most message loop.
+ if (filter->pump_messages_event()->IsSignaled()) {
+ MessageLoop::current()->PostNonNestableTask(FROM_HERE,
+ NewRunnableMethod(filter,
+ &CookieMessageFilter::ResetPumpMessagesEvent));
+ }
+}
+
+void RendererWebCookieJarImpl::setCookie(
+ const WebURL& url, const WebURL& first_party_for_cookies,
+ const WebString& value) {
+ std::string value_utf8;
+ UTF16ToUTF8(value.data(), value.length(), &value_utf8);
+ sender_->Send(new ViewHostMsg_SetCookie(
+ MSG_ROUTING_NONE, url, first_party_for_cookies, value_utf8));
+}
+
+WebString RendererWebCookieJarImpl::cookies(
+ const WebURL& url, const WebURL& first_party_for_cookies) {
+ std::string value_utf8;
+ SendSynchronousMessage(new ViewHostMsg_GetCookies(
+ MSG_ROUTING_NONE, url, first_party_for_cookies, &value_utf8));
+ return WebString::fromUTF8(value_utf8);
+}
+
+WebString RendererWebCookieJarImpl::cookieRequestHeaderFieldValue(
+ const WebURL& url, const WebURL& first_party_for_cookies) {
+ return cookies(url, first_party_for_cookies);
+}
+
+void RendererWebCookieJarImpl::rawCookies(
+ const WebURL& url, const WebURL& first_party_for_cookies,
+ WebVector<WebCookie>& raw_cookies) {
+ std::vector<webkit_glue::WebCookie> cookies;
+ SendSynchronousMessage(new ViewHostMsg_GetRawCookies(
+ MSG_ROUTING_NONE, url, first_party_for_cookies, &cookies));
+
+ WebVector<WebCookie> result(cookies.size());
+ int i = 0;
+ for (std::vector<webkit_glue::WebCookie>::iterator it = cookies.begin();
+ it != cookies.end(); ++it) {
+ result[i++] = WebCookie(WebString::fromUTF8(it->name),
+ WebString::fromUTF8(it->value),
+ WebString::fromUTF8(it->domain),
+ WebString::fromUTF8(it->path),
+ it->expires,
+ it->http_only,
+ it->secure,
+ it->session);
+ }
+ raw_cookies.swap(result);
+}
+
+void RendererWebCookieJarImpl::deleteCookie(
+ const WebURL& url, const WebString& cookie_name) {
+ std::string cookie_name_utf8;
+ UTF16ToUTF8(cookie_name.data(), cookie_name.length(), &cookie_name_utf8);
+ sender_->Send(new ViewHostMsg_DeleteCookie(url, cookie_name_utf8));
+}
+
+bool RendererWebCookieJarImpl::cookiesEnabled(
+ const WebURL& url, const WebURL& first_party_for_cookies) {
+ bool enabled;
+ sender_->Send(new ViewHostMsg_GetCookiesEnabled(
+ url, first_party_for_cookies, &enabled));
+ return enabled;
+}
diff --git a/chrome/renderer/renderer_webcookiejar_impl.h b/chrome/renderer/renderer_webcookiejar_impl.h
new file mode 100644
index 0000000..e4f113a
--- /dev/null
+++ b/chrome/renderer/renderer_webcookiejar_impl.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
+#define CHROME_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
+
+#include "ipc/ipc_message.h"
+// TODO(darin): WebCookieJar.h is missing a WebString.h include!
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCookieJar.h"
+
+namespace IPC {
+class SyncMessage;
+}
+
+class RendererWebCookieJarImpl : public WebKit::WebCookieJar {
+ public:
+ explicit RendererWebCookieJarImpl(IPC::Message::Sender* sender)
+ : sender_(sender) {
+ }
+
+ private:
+ void SendSynchronousMessage(IPC::SyncMessage* message);
+
+ // WebKit::WebCookieJar methods:
+ virtual void setCookie(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies,
+ const WebKit::WebString& value);
+ virtual WebKit::WebString cookies(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
+ virtual WebKit::WebString cookieRequestHeaderFieldValue(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
+ virtual void rawCookies(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies,
+ WebKit::WebVector<WebKit::WebCookie>& cookies);
+ virtual void deleteCookie(
+ const WebKit::WebURL& url, const WebKit::WebString& cookie_name);
+ virtual bool cookiesEnabled(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
+
+ IPC::Message::Sender* sender_;
+};
+
+#endif // CHROME_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 68bfe06..534cd75 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -19,14 +19,12 @@
#include "chrome/common/render_messages.h"
#include "chrome/common/webmessageportchannel_impl.h"
#include "chrome/plugin/npobject_util.h"
-#include "chrome/renderer/cookie_message_filter.h"
#include "chrome/renderer/net/render_dns_master.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h"
#include "chrome/renderer/renderer_webstoragenamespace_impl.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "googleurl/src/gurl.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebCookie.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
@@ -45,7 +43,6 @@
using WebKit::WebApplicationCacheHost;
using WebKit::WebApplicationCacheHostClient;
-using WebKit::WebCookie;
using WebKit::WebFrame;
using WebKit::WebKitClient;
using WebKit::WebStorageArea;
@@ -73,6 +70,11 @@ WebKit::WebSandboxSupport* RendererWebKitClientImpl::sandboxSupport() {
#endif
}
+WebKit::WebCookieJar* RendererWebKitClientImpl::cookieJar() {
+ NOTREACHED() << "Use WebFrameClient::cookieJar() instead!";
+ return NULL;
+}
+
bool RendererWebKitClientImpl::sandboxEnabled() {
// As explained in WebKitClient.h, this function is used to decide whether to
// allow file system operations to come out of WebKit or not. Even if the
@@ -112,84 +114,6 @@ RendererWebKitClientImpl::createMessagePortChannel() {
return new WebMessagePortChannelImpl();
}
-void RendererWebKitClientImpl::setCookies(const WebURL& url,
- const WebURL& first_party_for_cookies,
- const WebString& value) {
- // TODO(darin): Modify WebKit to pass the WebFrame. This code may be reached
- // when there is no active script context.
- int32 routing_id = RenderThread::RoutingIDForCurrentContext();
-
- std::string value_utf8;
- UTF16ToUTF8(value.data(), value.length(), &value_utf8);
- RenderThread::current()->Send(
- new ViewHostMsg_SetCookie(routing_id, url, first_party_for_cookies,
- value_utf8));
-}
-
-WebString RendererWebKitClientImpl::cookies(
- const WebURL& url, const WebURL& first_party_for_cookies) {
- // TODO(darin): Modify WebKit to pass the WebFrame. This code may be reached
- // when there is no active script context.
- int32 routing_id = RenderThread::RoutingIDForCurrentContext();
-
- // TODO(darin): We should use SendAndRunNestedMessageLoop here to avoid dead-
- // locking the browser, but this causes a performance regression. Switching
- // back to Send to verify. See http://crbug.com/36310.
-
- std::string value_utf8;
- SendCookieMessage(
- new ViewHostMsg_GetCookies(routing_id, url, first_party_for_cookies,
- &value_utf8));
-
- return WebString::fromUTF8(value_utf8);
-}
-
-bool RendererWebKitClientImpl::rawCookies(
- const WebURL& url,
- const WebURL& first_party_for_cookies,
- WebVector<WebKit::WebCookie>* raw_cookies) {
- // TODO(darin): Modify WebKit to pass the WebFrame. This code may be reached
- // when there is no active script context.
- int32 routing_id = RenderThread::RoutingIDForCurrentContext();
-
- std::vector<webkit_glue::WebCookie> cookies;
- SendCookieMessage(
- new ViewHostMsg_GetRawCookies(routing_id, url, first_party_for_cookies,
- &cookies));
-
- WebVector<WebKit::WebCookie> result(cookies.size());
- int i = 0;
- for (std::vector<webkit_glue::WebCookie>::iterator it = cookies.begin();
- it != cookies.end(); ++it)
- result[i++] = WebKit::WebCookie(WebString::fromUTF8(it->name),
- WebString::fromUTF8(it->value),
- WebString::fromUTF8(it->domain),
- WebString::fromUTF8(it->path),
- it->expires,
- it->http_only,
- it->secure,
- it->session);
- raw_cookies->assign(result);
- return true;
-}
-
-void RendererWebKitClientImpl::deleteCookie(const WebURL& url,
- const WebString& cookie_name) {
- std::string cookie_name_utf8;
- UTF16ToUTF8(cookie_name.data(), cookie_name.length(), &cookie_name_utf8);
- RenderThread::current()->Send(
- new ViewHostMsg_DeleteCookie(url, cookie_name_utf8));
-}
-
-bool RendererWebKitClientImpl::cookiesEnabled(
- const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies) {
- bool enabled;
- RenderThread::current()->Send(
- new ViewHostMsg_GetCookiesEnabled(
- url, first_party_for_cookies, &enabled));
- return enabled;
-}
-
void RendererWebKitClientImpl::prefetchHostName(const WebString& hostname) {
if (!hostname.isEmpty()) {
std::string hostname_utf8;
@@ -414,21 +338,3 @@ WebKit::WebString RendererWebKitClientImpl::signedPublicKeyAndChallengeString(
&signed_public_key));
return WebString::fromUTF8(signed_public_key);
}
-
-//------------------------------------------------------------------------------
-
-void RendererWebKitClientImpl::SendCookieMessage(IPC::SyncMessage* message) {
- RenderThread* render_thread = RenderThread::current();
-
- CookieMessageFilter* filter = render_thread->cookie_message_filter();
- message->set_pump_messages_event(filter->pump_messages_event());
- render_thread->Send(message);
-
- // We may end up nesting calls to SendCookieMessage, so we defer the reset
- // until we return to the top-most message loop.
- if (filter->pump_messages_event()->IsSignaled()) {
- MessageLoop::current()->PostNonNestableTask(FROM_HERE,
- NewRunnableMethod(filter,
- &CookieMessageFilter::ResetPumpMessagesEvent));
- }
-}
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index b3a446c..71154c8 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -32,24 +32,13 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebClipboard* clipboard();
virtual WebKit::WebMimeRegistry* mimeRegistry();
virtual WebKit::WebSandboxSupport* sandboxSupport();
+ virtual WebKit::WebCookieJar* cookieJar();
virtual bool sandboxEnabled();
virtual bool getFileSize(const WebKit::WebString& path, long long& result);
virtual unsigned long long visitedLinkHash(
const char* canonicalURL, size_t length);
virtual bool isLinkVisited(unsigned long long linkHash);
virtual WebKit::WebMessagePortChannel* createMessagePortChannel();
- virtual void setCookies(const WebKit::WebURL& url,
- const WebKit::WebURL& first_party_for_cookies,
- const WebKit::WebString&);
- virtual WebKit::WebString cookies(
- const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
- virtual bool rawCookies(const WebKit::WebURL& url,
- const WebKit::WebURL& first_party_for_cookies,
- WebKit::WebVector<WebKit::WebCookie>* raw_cookies);
- virtual void deleteCookie(const WebKit::WebURL& url,
- const WebKit::WebString& cookie_name);
- virtual bool cookiesEnabled(const WebKit::WebURL& url,
- const WebKit::WebURL& first_party_for_cookies);
virtual void prefetchHostName(const WebKit::WebString&);
virtual WebKit::WebString defaultLocale();
virtual void suddenTerminationChanged(bool enabled);
@@ -110,8 +99,6 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
};
#endif
- void SendCookieMessage(IPC::SyncMessage* message);
-
webkit_glue::WebClipboardImpl clipboard_;
MimeRegistry mime_registry_;
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index 20b86b4..adf5f64 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -11,6 +11,7 @@
#include "net/base/net_errors.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCookieJar.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h"
@@ -40,6 +41,7 @@
using WebKit::WebCanvas;
using WebKit::WebConsoleMessage;
+using WebKit::WebCookieJar;
using WebKit::WebCString;
using WebKit::WebCursorInfo;
using WebKit::WebData;
@@ -584,14 +586,31 @@ NPObject* WebPluginImpl::GetPluginElement() {
void WebPluginImpl::SetCookie(const GURL& url,
const GURL& first_party_for_cookies,
const std::string& cookie) {
- WebKit::webKitClient()->setCookies(
+ if (!page_delegate_)
+ return;
+
+ WebCookieJar* cookie_jar = page_delegate_->GetCookieJar();
+ if (!cookie_jar) {
+ DLOG(WARNING) << "No cookie jar!";
+ return;
+ }
+
+ cookie_jar->setCookie(
url, first_party_for_cookies, WebString::fromUTF8(cookie));
}
std::string WebPluginImpl::GetCookies(const GURL& url,
const GURL& first_party_for_cookies) {
- return UTF16ToUTF8(WebKit::webKitClient()->cookies(url,
- first_party_for_cookies));
+ if (!page_delegate_)
+ return std::string();
+
+ WebCookieJar* cookie_jar = page_delegate_->GetCookieJar();
+ if (!cookie_jar) {
+ DLOG(WARNING) << "No cookie jar!";
+ return std::string();
+ }
+
+ return UTF16ToUTF8(cookie_jar->cookies(url, first_party_for_cookies));
}
void WebPluginImpl::ShowModalHTMLDialog(const GURL& url, int width, int height,
diff --git a/webkit/glue/webplugin_page_delegate.h b/webkit/glue/webplugin_page_delegate.h
index 25be5ec..58f6da6 100644
--- a/webkit/glue/webplugin_page_delegate.h
+++ b/webkit/glue/webplugin_page_delegate.h
@@ -9,6 +9,10 @@
class GURL;
+namespace WebKit {
+class WebCookieJar;
+}
+
namespace webkit_glue {
class WebPluginDelegate;
@@ -55,6 +59,9 @@ class WebPluginPageDelegate {
const gfx::Size& size,
const std::string& json_arguments,
std::string* json_retval) = 0;
+
+ // The WebCookieJar to use for this plugin.
+ virtual WebKit::WebCookieJar* GetCookieJar() = 0;
};
} // namespace webkit_glue
diff --git a/webkit/tools/test_shell/simple_webcookiejar_impl.cc b/webkit/tools/test_shell/simple_webcookiejar_impl.cc
new file mode 100644
index 0000000..e534beb
--- /dev/null
+++ b/webkit/tools/test_shell/simple_webcookiejar_impl.cc
@@ -0,0 +1,25 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/tools/test_shell/simple_webcookiejar_impl.h"
+
+#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
+#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
+
+using WebKit::WebString;
+using WebKit::WebURL;
+
+void SimpleWebCookieJarImpl::setCookie(const WebURL& url,
+ const WebURL& first_party_for_cookies,
+ const WebString& value) {
+ SimpleResourceLoaderBridge::SetCookie(
+ url, first_party_for_cookies, value.utf8());
+}
+
+WebString SimpleWebCookieJarImpl::cookies(
+ const WebURL& url,
+ const WebURL& first_party_for_cookies) {
+ return WebString::fromUTF8(
+ SimpleResourceLoaderBridge::GetCookies(url, first_party_for_cookies));
+}
diff --git a/webkit/tools/test_shell/simple_webcookiejar_impl.h b/webkit/tools/test_shell/simple_webcookiejar_impl.h
new file mode 100644
index 0000000..fe53561
--- /dev/null
+++ b/webkit/tools/test_shell/simple_webcookiejar_impl.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_WEBCOOKIEJAR_IMPL_H_
+#define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_WEBCOOKIEJAR_IMPL_H_
+
+// TODO(darin): WebCookieJar.h is missing a WebString.h include!
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCookieJar.h"
+
+class SimpleWebCookieJarImpl : public WebKit::WebCookieJar {
+ public:
+ // WebKit::WebCookieJar methods:
+ virtual void setCookie(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies,
+ const WebKit::WebString& cookie);
+ virtual WebKit::WebString cookies(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
+};
+
+#endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_WEBCOOKIEJAR_IMPL_H_
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index 4ad72ca..67bb736 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -83,6 +83,8 @@
'simple_resource_loader_bridge.h',
'simple_socket_stream_bridge.cc',
'simple_socket_stream_bridge.h',
+ 'simple_webcookiejar_impl.h',
+ 'simple_webcookiejar_impl.cc',
'test_navigation_controller.cc',
'test_navigation_controller.h',
'test_shell.cc',
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index 4c59551..95608ae 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -1,6 +1,6 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
@@ -34,6 +34,7 @@
#include "webkit/tools/test_shell/simple_appcache_system.h"
#include "webkit/tools/test_shell/simple_database_system.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
+#include "webkit/tools/test_shell/simple_webcookiejar_impl.h"
#include "v8/include/v8.h"
#if defined(OS_WIN)
@@ -111,6 +112,10 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
return NULL;
}
+ virtual WebKit::WebCookieJar* cookieJar() {
+ return &cookie_jar_;
+ }
+
virtual bool sandboxEnabled() {
return true;
}
@@ -158,20 +163,6 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
return NULL;
}
- virtual void setCookies(const WebKit::WebURL& url,
- const WebKit::WebURL& first_party_for_cookies,
- const WebKit::WebString& value) {
- SimpleResourceLoaderBridge::SetCookie(
- url, first_party_for_cookies, value.utf8());
- }
-
- virtual WebKit::WebString cookies(
- const WebKit::WebURL& url,
- const WebKit::WebURL& first_party_for_cookies) {
- return WebKit::WebString::fromUTF8(SimpleResourceLoaderBridge::GetCookies(
- url, first_party_for_cookies));
- }
-
virtual void prefetchHostName(const WebKit::WebString&) {
}
@@ -238,6 +229,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
ScopedTempDir appcache_dir_;
SimpleAppCacheSystem appcache_system_;
SimpleDatabaseSystem database_system_;
+ SimpleWebCookieJarImpl cookie_jar_;
#if defined(OS_WIN)
WebKit::WebThemeEngine* active_theme_engine_;
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 4f0ed93..4c5db40 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -26,6 +26,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h"
@@ -67,6 +68,7 @@ using appcache::WebApplicationCacheHostImpl;
using WebKit::WebAccessibilityObject;
using WebKit::WebConsoleMessage;
using WebKit::WebContextMenuData;
+using WebKit::WebCookieJar;
using WebKit::WebData;
using WebKit::WebDataSource;
using WebKit::WebDragData;
@@ -590,6 +592,11 @@ int TestWebViewDelegate::historyForwardListCount() {
return shell_->navigation_controller()->GetEntryCount() - current_index - 1;
}
+void TestWebViewDelegate::focusAccessibilityObject(
+ const WebAccessibilityObject& object) {
+ shell_->accessibility_controller()->SetFocusedElement(object);
+}
+
// WebWidgetClient -----------------------------------------------------------
void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) {
@@ -1013,9 +1020,10 @@ bool TestWebViewDelegate::allowScript(WebFrame* frame,
return enabled_per_settings && shell_->allow_scripts();
}
-void TestWebViewDelegate::focusAccessibilityObject(
- const WebAccessibilityObject& object) {
- shell_->accessibility_controller()->SetFocusedElement(object);
+// WebPluginPageDelegate -----------------------------------------------------
+
+WebCookieJar* TestWebViewDelegate::GetCookieJar() {
+ return WebKit::webKitClient()->cookieJar();
}
// Public methods ------------------------------------------------------------
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 305b2fa..4bd36f5 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -225,6 +225,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
const gfx::Size& size,
const std::string& json_arguments,
std::string* json_retval) {}
+ virtual WebKit::WebCookieJar* GetCookieJar();
TestWebViewDelegate(TestShell* shell);
~TestWebViewDelegate();