Changeset 54261 in webkit


Ignore:
Timestamp:
Feb 2, 2010 4:03:27 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-02 Philippe Normand <pnormand@igalia.com>

Reviewed by Gustavo Noronha Silva.

[Gtk] libsoup critical warning in media player http cookies injection code
https://bugs.webkit.org/show_bug.cgi?id=34435

Fixed the critical warning and refactored the
User-Agent/Referer/cookies injection code, in that order. Previous
order (cookies first) was wrong because if cookies injection could
not be done neither the User-Agent not Referer were injected. Also
started a non-JSC-specific, gtk-specific GOwnPtr module.

  • GNUmakefile.am:
  • platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: (WebCore::mediaPlayerPrivateSourceChangedCallback):
  • platform/gtk/GOwnPtrGtk.cpp: Added. (WTF::SoupURI): (WTF::GstElement):
  • platform/gtk/GOwnPtrGtk.h: Added.
Location:
trunk/WebCore
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54259 r54261  
     12010-02-02  Philippe Normand  <pnormand@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [Gtk] libsoup critical warning in media player http cookies injection code
     6        https://bugs.webkit.org/show_bug.cgi?id=34435
     7
     8        Fixed the critical warning and refactored the
     9        User-Agent/Referer/cookies injection code, in that order. Previous
     10        order (cookies first) was wrong because if cookies injection could
     11        not be done neither the User-Agent not Referer were injected. Also
     12        started a non-JSC-specific, gtk-specific GOwnPtr module.
     13
     14        * GNUmakefile.am:
     15        * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
     16        (WebCore::mediaPlayerPrivateSourceChangedCallback):
     17        * platform/gtk/GOwnPtrGtk.cpp: Added.
     18        (WTF::SoupURI):
     19        (WTF::GstElement):
     20        * platform/gtk/GOwnPtrGtk.h: Added.
     21
    1222010-02-02  Nate Chapin  <japhet@chromium.org>
    223
  • trunk/WebCore/GNUmakefile.am

    r54137 r54261  
    20072007        WebCore/platform/gtk/GRefPtrGtk.cpp \
    20082008        WebCore/platform/gtk/GRefPtrGtk.h \
     2009        WebCore/platform/gtk/GOwnPtrGtk.cpp \
     2010        WebCore/platform/gtk/GOwnPtrGtk.h \
    20092011        WebCore/platform/gtk/GtkPluginWidget.cpp \
    20102012        WebCore/platform/gtk/GtkPluginWidget.h \
  • trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp

    r54136 r54261  
    132132{
    133133    MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data);
    134     GstElement* element;
    135 
    136     g_object_get(mp->m_playBin, "source", &element, NULL);
    137     gst_object_replace((GstObject**) &mp->m_source, (GstObject*) element);
    138 
    139     if (element) {
    140         GParamSpec* pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(element), "cookies");
    141 
    142         // First check if the source element has a cookies property
    143         // of the format we expect
    144         if (!pspec || pspec->value_type != G_TYPE_STRV)
    145             return;
    146 
    147         // Then get the cookies for the URI and set them
    148         SoupSession* session = webkit_get_default_session();
    149         SoupCookieJar* cookieJar = SOUP_COOKIE_JAR(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR));
    150 
    151         char* location;
    152         g_object_get(element, "location", &location, NULL);
    153 
    154         SoupURI* uri = soup_uri_new(location);
    155         g_free(location);
    156 
    157         // Let Apple web servers know we want to access their nice movie trailers.
    158         if (g_str_equal(uri->host, "movies.apple.com"))
    159             g_object_set(element, "user-agent", "Quicktime/7.2.0", NULL);
    160 
    161         char* cookies = soup_cookie_jar_get_cookies(cookieJar, uri, FALSE);
    162         soup_uri_free(uri);
    163 
    164         char* cookiesStrv[] = {cookies, NULL};
    165         g_object_set(element, "cookies", cookiesStrv, NULL);
    166         g_free(cookies);
    167 
    168         Frame* frame = mp->m_player->frameView() ? mp->m_player->frameView()->frame() : 0;
    169         Document* document = frame ? frame->document() : 0;
    170         if (document) {
    171             GstStructure* extraHeaders = gst_structure_new("extra-headers",
    172                                                            "Referer", G_TYPE_STRING,
    173                                                            document->documentURI().utf8().data(), 0);
    174             g_object_set(element, "extra-headers", extraHeaders, NULL);
    175             gst_structure_free(extraHeaders);
    176         }
    177     }
    178 
    179     gst_object_unref(element);
     134    GOwnPtr<GstElement> element;
     135
     136    g_object_get(mp->m_playBin, "source", &element.outPtr(), NULL);
     137    gst_object_replace((GstObject**) &mp->m_source, (GstObject*) element.get());
     138
     139    if (!element)
     140        return;
     141
     142    GOwnPtr<char> location;
     143    g_object_get(element.get(), "location", &location.outPtr(), NULL);
     144
     145    GOwnPtr<SoupURI> uri(soup_uri_new(location.get()));
     146
     147    // Let Apple web servers know we want to access their nice movie trailers.
     148    if (g_str_equal(uri->host, "movies.apple.com"))
     149        g_object_set(element.get(), "user-agent", "Quicktime/7.2.0", NULL);
     150
     151    // Set the HTTP referer.
     152    Frame* frame = mp->m_player->frameView() ? mp->m_player->frameView()->frame() : 0;
     153    Document* document = frame ? frame->document() : 0;
     154    if (document) {
     155        GstStructure* extraHeaders = gst_structure_new("extra-headers",
     156                                                       "Referer", G_TYPE_STRING,
     157                                                       document->documentURI().utf8().data(), 0);
     158        g_object_set(element.get(), "extra-headers", extraHeaders, NULL);
     159        gst_structure_free(extraHeaders);
     160    }
     161
     162    // Deal with the cookies from now on.
     163    GParamSpec* cookiesParamSpec = g_object_class_find_property(G_OBJECT_GET_CLASS(element.get()), "cookies");
     164
     165    // First check if the source element has a cookies property
     166    // of the format we expect
     167    if (!cookiesParamSpec || cookiesParamSpec->value_type != G_TYPE_STRV)
     168        return;
     169
     170    // Then get the cookies for the URI and set them
     171    SoupSession* session = webkit_get_default_session();
     172    SoupSessionFeature* cookieJarFeature = soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR);
     173    if (!cookieJarFeature)
     174        return;
     175
     176    SoupCookieJar* cookieJar = SOUP_COOKIE_JAR(cookieJarFeature);
     177    GOwnPtr<char> cookies(soup_cookie_jar_get_cookies(cookieJar, uri.get(), FALSE));
     178    char* cookiesStrv[] = {cookies.get(), 0};
     179    g_object_set(element.get(), "cookies", cookiesStrv, NULL);
    180180}
    181181
Note: See TracChangeset for help on using the changeset viewer.