Changeset 200159 in webkit


Ignore:
Timestamp:
Apr 27, 2016 4:32:13 PM (8 years ago)
Author:
Michael Catanzaro
Message:

[SOUP] Implement PlatformCookieJar::addCookie
https://bugs.webkit.org/show_bug.cgi?id=156295

Reviewed by Carlos Garcia Campos.

  • platform/network/soup/CookieJarSoup.cpp:

(WebCore::msToSoupDate):
(WebCore::toSoupCookie):
(WebCore::addCookie):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r200158 r200159  
     12016-04-27  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [SOUP] Implement PlatformCookieJar::addCookie
     4        https://bugs.webkit.org/show_bug.cgi?id=156295
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * platform/network/soup/CookieJarSoup.cpp:
     9        (WebCore::msToSoupDate):
     10        (WebCore::toSoupCookie):
     11        (WebCore::addCookie):
     12
    1132016-04-27  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp

    r199167 r200159  
    2929#include "URL.h"
    3030#include "NetworkingContext.h"
    31 #include "NotImplemented.h"
    3231#include "PlatformCookieJar.h"
    3332#include "SoupNetworkSession.h"
     33#include <wtf/DateMath.h>
    3434#include <wtf/glib/GRefPtr.h>
    3535#include <wtf/text/CString.h>
     
    193193}
    194194
    195 void addCookie(const NetworkStorageSession&, const URL&, const Cookie&)
    196 {
    197     // FIXME: implement this command. <https://webkit.org/b/156295>
    198     notImplemented();
     195static SoupDate* msToSoupDate(double ms)
     196{
     197    int year = msToYear(ms);
     198    int dayOfYear = dayInYear(ms, year);
     199    bool leapYear = isLeapYear(year);
     200    return soup_date_new(year, monthFromDayInYear(dayOfYear, leapYear), dayInMonthFromDayInYear(dayOfYear, leapYear), msToHours(ms), msToMinutes(ms), static_cast<int>(ms / 1000) % 60);
     201}
     202
     203static SoupCookie* toSoupCookie(const Cookie& cookie)
     204{
     205    SoupCookie* soupCookie = soup_cookie_new(cookie.name.utf8().data(), cookie.value.utf8().data(),
     206        cookie.domain.utf8().data(), cookie.path.utf8().data(), -1);
     207    soup_cookie_set_http_only(soupCookie, cookie.httpOnly);
     208    soup_cookie_set_secure(soupCookie, cookie.secure);
     209    if (!cookie.session) {
     210        SoupDate* date = msToSoupDate(cookie.expires);
     211        soup_cookie_set_expires(soupCookie, date);
     212        soup_date_free(date);
     213    }
     214    return soupCookie;
     215}
     216
     217void addCookie(const NetworkStorageSession& session, const URL&, const Cookie& cookie)
     218{
     219    soup_cookie_jar_add_cookie(cookieJarForSession(session), toSoupCookie(cookie));
    199220}
    200221
Note: See TracChangeset for help on using the changeset viewer.