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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/common/cookie_data.h" | 8 #include "content/common/cookie_data.h" |
9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "content/public/renderer/content_renderer_client.h" | 10 #include "content/public/renderer/content_renderer_client.h" |
11 #include "content/renderer/render_view_impl.h" | 11 #include "content/renderer/render_view_impl.h" |
12 #include "third_party/WebKit/public/platform/WebCookie.h" | 12 #include "third_party/WebKit/public/platform/WebCookie.h" |
13 | 13 |
14 using blink::WebCookie; | 14 using blink::WebCookie; |
15 using blink::WebString; | 15 using blink::WebString; |
16 using blink::WebURL; | 16 using blink::WebURL; |
17 using blink::WebVector; | 17 using blink::WebVector; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 void RendererWebCookieJarImpl::setCookie( | 21 void RendererWebCookieJarImpl::setCookie( |
22 const WebURL& url, const WebURL& first_party_for_cookies, | 22 const WebURL& url, const WebURL& first_party_for_cookies, |
23 const WebString& value) { | 23 const WebString& value) { |
24 std::string value_utf8 = UTF16ToUTF8(value); | 24 std::string value_utf8 = UTF16ToUTF8(value); |
25 if (!GetContentClient()->renderer()->HandleSetCookieRequest( | 25 sender_->Send(new ViewHostMsg_SetCookie( |
26 sender_, url, first_party_for_cookies, value_utf8)) { | 26 MSG_ROUTING_NONE, 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 } | |
30 } | 27 } |
31 | 28 |
32 WebString RendererWebCookieJarImpl::cookies( | 29 WebString RendererWebCookieJarImpl::cookies( |
33 const WebURL& url, const WebURL& first_party_for_cookies) { | 30 const WebURL& url, const WebURL& first_party_for_cookies) { |
34 std::string value_utf8; | 31 std::string value_utf8; |
35 | 32 sender_->Send(new ViewHostMsg_GetCookies( |
36 if (!GetContentClient()->renderer()->HandleGetCookieRequest( | 33 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 } | |
42 return WebString::fromUTF8(value_utf8); | 34 return WebString::fromUTF8(value_utf8); |
43 } | 35 } |
44 | 36 |
45 WebString RendererWebCookieJarImpl::cookieRequestHeaderFieldValue( | 37 WebString RendererWebCookieJarImpl::cookieRequestHeaderFieldValue( |
46 const WebURL& url, const WebURL& first_party_for_cookies) { | 38 const WebURL& url, const WebURL& first_party_for_cookies) { |
47 return cookies(url, first_party_for_cookies); | 39 return cookies(url, first_party_for_cookies); |
48 } | 40 } |
49 | 41 |
50 void RendererWebCookieJarImpl::rawCookies( | 42 void RendererWebCookieJarImpl::rawCookies( |
51 const WebURL& url, const WebURL& first_party_for_cookies, | 43 const WebURL& url, const WebURL& first_party_for_cookies, |
(...skipping 27 matching lines...) Expand all Loading... |
79 bool RendererWebCookieJarImpl::cookiesEnabled( | 71 bool RendererWebCookieJarImpl::cookiesEnabled( |
80 const WebURL& url, const WebURL& first_party_for_cookies) { | 72 const WebURL& url, const WebURL& first_party_for_cookies) { |
81 bool cookies_enabled; | 73 bool cookies_enabled; |
82 // NOTE: This may pump events (see RenderThread::Send). | 74 // NOTE: This may pump events (see RenderThread::Send). |
83 sender_->Send(new ViewHostMsg_CookiesEnabled( | 75 sender_->Send(new ViewHostMsg_CookiesEnabled( |
84 url, first_party_for_cookies, &cookies_enabled)); | 76 url, first_party_for_cookies, &cookies_enabled)); |
85 return cookies_enabled; | 77 return cookies_enabled; |
86 } | 78 } |
87 | 79 |
88 } // namespace content | 80 } // namespace content |
OLD | NEW |