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
3 // found in the LICENSE file.
5 #include "content/renderer/renderer_webcookiejar_impl.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/common/frame_messages.h"
9 #include "content/public/renderer/content_renderer_client.h"
10 #include "content/renderer/render_frame_impl.h"
12 using blink::WebString
;
17 void RendererWebCookieJarImpl::setCookie(
18 const WebURL
& url
, const WebURL
& first_party_for_cookies
,
19 const WebString
& value
) {
20 std::string value_utf8
= base::UTF16ToUTF8(base::StringPiece16(value
));
21 sender_
->Send(new FrameHostMsg_SetCookie(
22 sender_
->GetRoutingID(), url
, first_party_for_cookies
, value_utf8
));
25 WebString
RendererWebCookieJarImpl::cookies(
26 const WebURL
& url
, const WebURL
& first_party_for_cookies
) {
27 std::string value_utf8
;
28 sender_
->Send(new FrameHostMsg_GetCookies(
29 sender_
->GetRoutingID(), url
, first_party_for_cookies
, &value_utf8
));
30 return WebString::fromUTF8(value_utf8
);
33 WebString
RendererWebCookieJarImpl::cookieRequestHeaderFieldValue(
34 const WebURL
& url
, const WebURL
& first_party_for_cookies
) {
35 return cookies(url
, first_party_for_cookies
);
38 bool RendererWebCookieJarImpl::cookiesEnabled(
39 const WebURL
& url
, const WebURL
& first_party_for_cookies
) {
40 bool cookies_enabled
= false;
41 sender_
->Send(new FrameHostMsg_CookiesEnabled(
42 sender_
->GetRoutingID(), url
, first_party_for_cookies
, &cookies_enabled
));
43 return cookies_enabled
;
46 } // namespace content