1/* 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19#include "config.h" 20 21#include "WebCookieJar.h" 22 23#include "CookieManager.h" 24#include "KURL.h" 25#include <BlackBerryPlatformString.h> 26 27using namespace WebCore; 28 29namespace BlackBerry { 30namespace WebKit { 31 32WebCookieJar::WebCookieJar() 33{ 34} 35 36std::vector<BlackBerry::Platform::String> WebCookieJar::cookies(const BlackBerry::Platform::String& url) 37{ 38 KURL kurl = KURL(KURL(), url); 39 40 Vector<RefPtr<ParsedCookie> > rawCookies; 41 cookieManager().getRawCookies(rawCookies, kurl, WithHttpOnlyCookies); 42 43 std::vector<BlackBerry::Platform::String> result; 44 for (size_t i = 0; i < rawCookies.size(); ++i) 45 result.push_back(rawCookies[i]->toNameValuePair()); 46 47 return result; 48} 49 50void WebCookieJar::setCookies(const BlackBerry::Platform::String& url, const std::vector<BlackBerry::Platform::String>& cookies) 51{ 52 KURL kurl = KURL(KURL(), url); 53 Vector<String> coreCookies; 54 for (size_t i = 0; i < cookies.size(); ++i) 55 coreCookies.append(cookies[i]); 56 cookieManager().setCookies(kurl, coreCookies, WithHttpOnlyCookies); 57} 58 59} 60} 61