Chromium Code Reviews| Index: chrome/browser/renderer_host/resource_message_filter.cc |
| =================================================================== |
| --- chrome/browser/renderer_host/resource_message_filter.cc (revision 30453) |
| +++ chrome/browser/renderer_host/resource_message_filter.cc (working copy) |
| @@ -47,6 +47,7 @@ |
| #include "chrome/common/render_messages.h" |
| #include "chrome/common/url_constants.h" |
| #include "chrome/common/worker_messages.h" |
| +#include "net/base/cookie_monster.h" |
| #include "net/base/keygen_handler.h" |
| #include "net/base/mime_util.h" |
| #include "net/base/load_flags.h" |
| @@ -295,6 +296,8 @@ |
| IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_GetCookies, OnGetCookies) |
| + IPC_MESSAGE_HANDLER(ViewHostMsg_GetRawCookies, OnGetRawCookies) |
| + IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie) |
| #if defined(OS_WIN) // This hack is Windows-specific. |
| IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont) |
| #endif |
| @@ -502,6 +505,54 @@ |
| *cookies = context->cookie_store()->GetCookies(url); |
| } |
| +void ResourceMessageFilter::OnGetRawCookies( |
| + const GURL& url, |
| + const GURL& first_party_for_cookies, |
| + std::vector<webkit_glue::WebCookie>* raw_cookies) { |
| + raw_cookies->clear(); |
| + |
| + URLRequestContext* context = GetRequestContextForURL(url); |
| + net::CookieMonster* cookie_monster = context->cookie_store()-> |
| + GetCookieMonster(); |
| + DCHECK(cookie_monster); |
|
yurys
2009/10/29 16:00:49
remove this line
pfeldman
2009/10/29 16:08:28
Done.
|
| + if (!cookie_monster) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + if (!context->cookie_policy()->CanGetCookies(url, first_party_for_cookies)) |
| + return; |
| + |
| + typedef std::vector<net::CookieMonster::CanonicalCookie> CanonicalCookieList; |
| + CanonicalCookieList cookies; |
| + cookie_monster->GetRawCookies(url, &cookies); |
| + for (CanonicalCookieList::iterator it = cookies.begin(); |
| + it != cookies.end(); ++it) { |
| + raw_cookies->push_back( |
| + webkit_glue::WebCookie(it->Name(), |
| + it->Value(), |
|
yurys
2009/10/29 16:00:49
wrong parameters indnentation
pfeldman
2009/10/29 16:08:28
Done.
|
| + url.host(), |
| + it->Path(), |
| + it->ExpiryDate().ToDoubleT() * 1000, |
| + it->IsHttpOnly(), |
| + it->IsSecure(), |
| + !it->IsPersistent())); |
| + } |
| +} |
| + |
| +void ResourceMessageFilter::OnDeleteCookie(const GURL& url, |
| + const std::string& cookie_name) |
| +{ |
| + URLRequestContext* context = GetRequestContextForURL(url); |
| + net::CookieMonster* cookie_monster = context->cookie_store()-> |
| + GetCookieMonster(); |
| + DCHECK(cookie_monster); |
| + if (!cookie_monster) |
|
yurys
2009/10/29 16:00:49
be consistent:
if (!cookie_monster) {
NOTREACHE
pfeldman
2009/10/29 16:08:28
Done.
|
| + return; |
| + |
| + cookie_monster->DeleteCookie(url, cookie_name); |
| +} |
| + |
| #if defined(OS_WIN) // This hack is Windows-specific. |
| void ResourceMessageFilter::OnLoadFont(LOGFONT font) { |
| // If renderer is running in a sandbox, GetTextMetrics |