| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/renderer_webcookiejar_impl.h" | 5 #include "content/renderer/renderer_webcookiejar_impl.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
| 9 #include "content/renderer/content_renderer_client.h" |
| 9 #include "content/renderer/render_thread.h" | 10 #include "content/renderer/render_thread.h" |
| 11 #include "content/renderer/render_view.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCookie.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCookie.h" |
| 11 #include "webkit/glue/webcookie.h" | 13 #include "webkit/glue/webcookie.h" |
| 12 | 14 |
| 13 using WebKit::WebCookie; | 15 using WebKit::WebCookie; |
| 14 using WebKit::WebString; | 16 using WebKit::WebString; |
| 15 using WebKit::WebURL; | 17 using WebKit::WebURL; |
| 16 using WebKit::WebVector; | 18 using WebKit::WebVector; |
| 17 | 19 |
| 18 void RendererWebCookieJarImpl::setCookie( | 20 void RendererWebCookieJarImpl::setCookie( |
| 19 const WebURL& url, const WebURL& first_party_for_cookies, | 21 const WebURL& url, const WebURL& first_party_for_cookies, |
| 20 const WebString& value) { | 22 const WebString& value) { |
| 21 std::string value_utf8; | 23 std::string value_utf8; |
| 22 UTF16ToUTF8(value.data(), value.length(), &value_utf8); | 24 UTF16ToUTF8(value.data(), value.length(), &value_utf8); |
| 23 sender_->Send(new ViewHostMsg_SetCookie( | 25 if (!content::GetContentClient()->renderer()->HandleSetCookieRequest( |
| 24 MSG_ROUTING_NONE, url, first_party_for_cookies, value_utf8)); | 26 sender_, url, first_party_for_cookies, value_utf8)) { |
| 27 sender_->Send(new ViewHostMsg_SetCookie( |
| 28 MSG_ROUTING_NONE, url, first_party_for_cookies, value_utf8)); |
| 29 } |
| 25 } | 30 } |
| 26 | 31 |
| 27 WebString RendererWebCookieJarImpl::cookies( | 32 WebString RendererWebCookieJarImpl::cookies( |
| 28 const WebURL& url, const WebURL& first_party_for_cookies) { | 33 const WebURL& url, const WebURL& first_party_for_cookies) { |
| 29 std::string value_utf8; | 34 std::string value_utf8; |
| 30 // NOTE: This may pump events (see RenderThread::Send). | 35 |
| 31 sender_->Send(new ViewHostMsg_GetCookies( | 36 if (!content::GetContentClient()->renderer()->HandleGetCookieRequest( |
| 32 MSG_ROUTING_NONE, url, first_party_for_cookies, &value_utf8)); | 37 sender_, url, first_party_for_cookies, &value_utf8)) { |
| 38 // NOTE: This may pump events (see RenderThread::Send). |
| 39 sender_->Send(new ViewHostMsg_GetCookies( |
| 40 MSG_ROUTING_NONE, url, first_party_for_cookies, &value_utf8)); |
| 41 } |
| 33 return WebString::fromUTF8(value_utf8); | 42 return WebString::fromUTF8(value_utf8); |
| 34 } | 43 } |
| 35 | 44 |
| 36 WebString RendererWebCookieJarImpl::cookieRequestHeaderFieldValue( | 45 WebString RendererWebCookieJarImpl::cookieRequestHeaderFieldValue( |
| 37 const WebURL& url, const WebURL& first_party_for_cookies) { | 46 const WebURL& url, const WebURL& first_party_for_cookies) { |
| 38 return cookies(url, first_party_for_cookies); | 47 return cookies(url, first_party_for_cookies); |
| 39 } | 48 } |
| 40 | 49 |
| 41 void RendererWebCookieJarImpl::rawCookies( | 50 void RendererWebCookieJarImpl::rawCookies( |
| 42 const WebURL& url, const WebURL& first_party_for_cookies, | 51 const WebURL& url, const WebURL& first_party_for_cookies, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 70 } | 79 } |
| 71 | 80 |
| 72 bool RendererWebCookieJarImpl::cookiesEnabled( | 81 bool RendererWebCookieJarImpl::cookiesEnabled( |
| 73 const WebURL& url, const WebURL& first_party_for_cookies) { | 82 const WebURL& url, const WebURL& first_party_for_cookies) { |
| 74 bool cookies_enabled; | 83 bool cookies_enabled; |
| 75 // NOTE: This may pump events (see RenderThread::Send). | 84 // NOTE: This may pump events (see RenderThread::Send). |
| 76 sender_->Send(new ViewHostMsg_CookiesEnabled( | 85 sender_->Send(new ViewHostMsg_CookiesEnabled( |
| 77 url, first_party_for_cookies, &cookies_enabled)); | 86 url, first_party_for_cookies, &cookies_enabled)); |
| 78 return cookies_enabled; | 87 return cookies_enabled; |
| 79 } | 88 } |
| OLD | NEW |