New CORS option in ResourceLoader.

This patch is a partial cherry-pick of:

[CSS Shapes] CORS-enabled fetch for shape image values
https://bugs.webkit.org/show_bug.cgi?id=123114

Reviewed by Andreas Kling.

Source/WebCore:

Access to shape images is now controlled by CORS CSS shape per
http://dev.w3.org/csswg/css-shapes/#shape-outside-property.
Previously shape images had to be same-origin.

Shape image URL access is defined by the same logic that defines
canvas tainting: same-origin and data URLs are allowed and images
with a "Access-Control-Allow-Origin:" header that's either "*" or
that matches the document's origin.

A PotentiallyCrossOriginEnabled RequestOriginPolicy was added to
ResourceLoaderOptions, to indicate that a "potentially CORS-enabled fetch"
was to be undertaken. The CSSImageValue::cachedImage() method handles this
option by effectively setting the "Origin:" request header (see
updateRequestForAccessControl() in CrossOriginAccessControl.cpp).
StyleResolver::loadPendingShapeImage() uses the new ResourceLoaderOption.

The static ShapeInsideInfo and ShapeOutsideInfo isEnabledFor() method
now performs the CORS check for image valued shapes. The private
isOriginClean() method from CanvasRenderingContext2D has been moved to
the CachedImage class so that it can be shared by the Canvas and Shape
implementations. It checks the response headers per the CORS spec.

Test: http/tests/security/shape-image-cors.html

* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage): Handle the new ResourceLoaderOption.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::loadPendingShapeImage): Set the new ResourceLoaderOption.
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::createPattern): Use the CachedImage::isOriginClean().
* loader/ResourceLoaderOptions.h: Added PotentiallyCrossOriginEnabled to RequestOriginPolicy.
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::isOriginClean): Migrated from CanvasRenderingContext2D.
* loader/cache/CachedImage.h:
* rendering/shapes/ShapeInfo.cpp:
(WebCore::::checkImageOrigin): Do the CORS check and log an error message if neccessary.
* rendering/shapes/ShapeInfo.h:
* rendering/shapes/ShapeInsideInfo.cpp:
(WebCore::ShapeInsideInfo::isEnabledFor): Call checkImageOrigin() for images.
* rendering/shapes/ShapeOutsideInfo.cpp:
(WebCore::ShapeOutsideInfo::isEnabledFor): Ditto.

LayoutTests:

Verify that images not allowed by CORS don't affect the layout
and that same-origin images, data URLs, and images with a
"Access-Control-Allow-Origin: *" header do define the layout.
Added a simple PHP script that optionally adds the allow origin header.

Replaced and renamed the original shape same-origin-only test.

* http/tests/security/resources/image-access-control.php: Added.
* http/tests/security/shape-image-cors-expected.html: Added.
* http/tests/security/shape-image-cors.html: Added.
* http/tests/security/shape-inside-image-origin-expected.txt: Removed.
* http/tests/security/shape-inside-image-origin.html: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GStreamer] Seeking fails on media content provided by servers not supporting Range requests
https://bugs.webkit.org/show_bug.cgi?id=85994

Patch by Andres Gomez <agomez@igalia.com> on 2013-11-25
Reviewed by Philippe Normand.

Source/WebCore:

Based on the patch written by Andre Moreira Magalhaes.

When the GStreamer web source was doing a "Range" request we were
expecting to receive a 206 status reply with the "Content-Range"
header and just the requested data. Supporting "Range" requests is
not mandatory so, for the servers not supporting it they will be
replying with a 200 status and the whole content of the media
element. Now, we are properly handling these replies too.

Test: http/tests/media/media-seeking-no-ranges-server.html

* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(StreamingClient::handleResponseReceived): Do not fail when
receiving 200 as response for HTTP range requests.
(StreamingClient::handleDataReceived): Manually seek on stream
when receiving the full data after a seek.

LayoutTests:

Added test to check that seeking media files on http servers not
supporting "Range" requests doesn't trigger an error.

* http/tests/media/media-seeking-no-ranges-server-expected.txt: Added.
* http/tests/media/media-seeking-no-ranges-server.html: Added.
* http/tests/media/resources/load-video.php: Added support for new
"ranges" paramenter.
* http/tests/media/resources/serve-video.php: Added support for
new "ranges" paramenter. When "ranges" is "no" we always answer
the HTTP status "200 OK" and send the whole file.
* platform/mac/TestExpectations: New test skipped in Mac port as
media playback download control is passed to AVFoundation that
doesn't like fancy PHP URLs like the one used in the test and, in
addition, they won't care about HTTP servers not supporting
"Range" requests.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159746 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	LayoutTests/ChangeLog
	LayoutTests/http/tests/media/resources/load-video.php
	LayoutTests/http/tests/media/resources/serve-video.php
	LayoutTests/platform/mac/TestExpectations
	Source/WebCore/ChangeLog
[GStreamer] Invalid command line error when visiting www.chessbase.com
https://bugs.webkit.org/show_bug.cgi?id=124715

Reviewed by Philippe Normand.

Source/WebCore:

We were not handling the HTTP errors in the WebKit GStreamer
source and therefore the 404 error page was being 'decoded'. As no
decoder could be found (for obvious reasons), playback failed, but
it should be failing for the source not being found instead of the
decoding problem.

Test: http/tests/media/video-error-does-not-exist.html

* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(StreamingClient::handleResponseReceived): Handle HTTP errors in
the source and raise a GStreamer error to the pipeline.

LayoutTests:

Copied and adapted for HTTP from
media/video-error-does-not-exist.html.

* http/tests/media/video-error-does-not-exist-expected.txt: Added.
* http/tests/media/video-error-does-not-exist.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159810 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	LayoutTests/ChangeLog
	Source/WebCore/ChangeLog
[GStreamer] Lockup when playing Icecast radio
https://bugs.webkit.org/show_bug.cgi?id=127452

Reviewed by Philippe Normand.

No new tests. This bug can only be demonstrated with an Icecast stream, and it's
not clear how to do that in our testing framework.

* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(StreamingClient::handleResponseReceived): Wait until we unlock to send notifications.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162842 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
[GStreamer] No CORS support for media elements
https://bugs.webkit.org/show_bug.cgi?id=99037

Patch by Youenn Fablet <youenn.fablet@crf.canon.fr> on 2014-04-13
Reviewed by Philippe Normand.

Source/WebCore:

Added CORS access control check to media sources when crossorigin attribute is set.

Added getter to CORS access control check status (used to compute whether the stream is tainted or not).
Related test is http/tests/security/video-cross-origin-readback.html.

Disabled access to cross-origin streams that fail CORS check when crossorigin attribute is set.
Related test is http/tests/security/video-cross-origin-accessfailure.html.

Tests: http/tests/security/video-cross-origin-accessfailure.html
       http/tests/security/video-cross-origin-accesssameorigin.html

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::didPassCORSAccessCheck): Return whether media is cross-origin (tainted) or not by querying the gstreamer source layer.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Added MediaPlayerPrivateGStreamer::didPassCORSAccessCheck declaration.
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webKitWebSrcStart): Passed CORS mode parameter to the streaming client. In case of CORS check failure, stop the resource loading.
(webKitSrcPassedCORSAccessCheck): Return whether CORS access control check was done and successful.
(StreamingClient::handleResponseReceived): Take a parameter to assign the CORS access control check result.
(CachedResourceStreamingClient::CachedResourceStreamingClient): Updated setting of the ResourceLoaderOptions according CORS mode.
(CachedResourceStreamingClient::responseReceived): Check CORS and pass result to handleResponseReceived.
(ResourceHandleStreamingClient::didReceiveResponse): No CORS check.
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.h: Added webKitSrcPassedCORSAccessCheck declaration.

LayoutTests:

http/tests/security/video-cross-origin-accessfailure.html verifies that cross-origin streams that fail CORS check
are not played when crossorigin attribute is set.
 http/tests/security/video-cross-origin-accesssameorigin.html verifies that access to same-origin streams
are played when crossorigin attribute is set.

* http/tests/security/video-cross-origin-accessfailure-expected.txt: Added.
* http/tests/security/video-cross-origin-accessfailure.html: Added.
* http/tests/security/video-cross-origin-accesssameorigin-expected.txt: Added.
* http/tests/security/video-cross-origin-accesssameorigin.html: Added.
* platform/efl/TestExpectations: Enabled http/tests/security/video-cross-origin-readback.html.
* platform/gtk/TestExpectations: Ditto.
* platform/mac/TestExpectations: Disabled http/tests/security/video-cross-origin-accessfailure.html.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167193 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	LayoutTests/ChangeLog
	LayoutTests/platform/efl/TestExpectations
	LayoutTests/platform/gtk/TestExpectations
	LayoutTests/platform/mac/TestExpectations
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
[GStreamer] http/tests/media/video-auth.html is failing
https://bugs.webkit.org/show_bug.cgi?id=126619

Patch by Youenn Fablet <youenn.fablet@crf.canon.fr> on 2014-09-16
Reviewed by Philippe Normand.

Source/WebCore:

Test: http/tests/media/video-auth-cors.html

Use stored credentials when retrieving videos following image loading behavior
(i.e. stored credentials are always used except when in cors anonymous mode),
except that requesting credentials from user remains disabled for cross-origin requests.

Patch is covered by http/tests/media/video-auth.html.

* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(CachedResourceStreamingClient::CachedResourceStreamingClient): Enable using stored credentials except when using cors anonymous mode.

LayoutTests:

* platform/efl/TestExpectations: Removed failure expectation for http/tests/media/video-auth.html.
* platform/efl/http/tests/media/video-auth-expected.txt: Added.
* platform/gtk/TestExpectations: Removed failure expectation for http/tests/media/video-auth.html.
* platform/gtk/http/tests/media/video-auth-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173654 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	LayoutTests/ChangeLog
	LayoutTests/platform/efl/TestExpectations
	LayoutTests/platform/gtk/TestExpectations
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
Source/WebCore: Seek for video doesn't work when playback rate is negative
https://bugs.webkit.org/show_bug.cgi?id=123791

In MediaPlayerPrivateGStreamer::seek negative playback rate was not taken to account.

Patch by Piotr Grad <p.grad@samsung.com> on 2013-11-06
Reviewed by Philippe Normand.

Test: media/video-seek-with-negative-playback.html

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::seek):

LayoutTests: Test for seek not working properly with negative playback rate.
https://bugs.webkit.org/show_bug.cgi?id=123791

Seek method should work properly with negative playback rate.

Patch by Piotr Grad <p.grad@samsung.com> on 2013-11-06
Reviewed by Philippe Normand.

* media/video-seek-with-negative-playback.html: Added.
* media/video-seek-with-negative-playback-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158734 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	LayoutTests/ChangeLog
	Source/WebCore/ChangeLog
[GStreamer] Playback rate is not set when pipeline is not ready.
https://bugs.webkit.org/show_bug.cgi?id=126692

Patch by Piotr Grad <p.grad@samsung.com> on 2014-01-14
Reviewed by Philippe Normand.

No new tests. Covered by existing tests.

Added new method updatePlaybackRate which is called when playback rate change is possible.
Added m_lastPlaybackRate in order to retrieve last correct playback rate and notify upper
layers about that setting playback rate failed.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::updatePlaybackRate):
(WebCore::MediaPlayerPrivateGStreamer::setRate):
(WebCore::MediaPlayerPrivateGStreamer::updateStates):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161984 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
[GStreamer] the GstPlayFlags enum diverged from upstream
https://bugs.webkit.org/show_bug.cgi?id=128957

Reviewed by Philippe Normand.

Removed the GstPlayFlags from the GStreamer implementation and
replaced by the use of the GFlags.

* platform/graphics/gstreamer/GStreamerUtilities.h:
* platform/graphics/gstreamer/GStreamerUtilities.cpp:
(WebCore::getGstPlaysFlag): Created to get the flags by using the
GFlags infrastructure.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::setDownloadBuffering):
Replaced GST_PLAY_FLAG_DOWNLOAD with getGstPlaysFlag.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164362 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h
	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
[GStreamer] Corrected typo
https://bugs.webkit.org/show_bug.cgi?id=132609

Reviewed by Martin Robinson.

Corrected m_canFallBackToLastFinishedSeekPositon typo and
initialized in the constructor to prevent problems in the future.

No test needed.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
Initialized m_canFallBackToLastFinishedSeekPosition as false.
(WebCore::MediaPlayerPrivateGStreamer::playbackPosition):
(WebCore::MediaPlayerPrivateGStreamer::handleMessage):
(WebCore::MediaPlayerPrivateGStreamer::asyncStateChangeDone):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
m_canFallBackToLastFinishedSeekPositon ->
m_canFallBackToLastFinishedSeekPosition

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	Source/WebCore/ChangeLog
Video is resumed with old playback rate.
https://bugs.webkit.org/show_bug.cgi?id=132905

Patch by Piotr Grad <p.grad@samsung.com> on 2014-05-22
Reviewed by Philippe Normand.

Source/WebCore:
Setting '0' playback rate is causing pipeline to pause.
GStreamer player impl. exposed this information to upper layers but it should not.
Solution is to hidden such situation behind m_playbackRatePause flag.

Test: media/video-paused-0-rate.html

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::play):
(WebCore::MediaPlayerPrivateGStreamer::pause):
(WebCore::MediaPlayerPrivateGStreamer::doSeek):
(WebCore::MediaPlayerPrivateGStreamer::updatePlaybackRate):
(WebCore::MediaPlayerPrivateGStreamer::paused):
(WebCore::MediaPlayerPrivateGStreamer::setRate):
(WebCore::MediaPlayerPrivateGStreamer::updateStates):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

LayoutTests:
* media/video-paused-0-rate-expected.txt: Added.
* media/video-paused-0-rate.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@169200 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	LayoutTests/ChangeLog
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Cache the gst_query_get_n_buffering_ranges() return value for the for-loop conditional
https://bugs.webkit.org/show_bug.cgi?id=133953

Reviewed by Philippe Normand.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::buffered): Avoid the extra call in the for-loop
conditional expression by caching the return value of gst_query_get_n_buffering_ranges().

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170051 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	Source/WebCore/ChangeLog
[GTK] 8tracks.com triggers annoying pop-up window/installation of "About protocol source plugin" (GStreamer?)
https://bugs.webkit.org/show_bug.cgi?id=133605

Reviewed by Carlos Garcia Campos.

Don't attempt to load blank URLs with the GStreamer media
player. Those URLs trigger the codec installer which is useless in
this scenario. This patch also renames some of the variables of
the ::load method, as suggested by Carlos.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
Check video-sink validity before disconnecting its signal handlers.
(WebCore::MediaPlayerPrivateGStreamer::load): Don't load blank
URLs (about:blank).
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
Disconnect repaint handler only if it's valid.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170526 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
[GStreamer] playback rate is rounded to integer
https://bugs.webkit.org/show_bug.cgi?id=135802

Patch by Fabien Vallée <fvallee@connected-labs.com> on 2014-08-12
Reviewed by Philippe Normand.

Source/WebCore:

Test: media/video-ended-event-slow-motion-playback.html

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::setRate):

LayoutTests:

add test to ensure playback is actually working
in slow motion (playback rate = 0.5): Player
should reach EOS and dispatch ended event.

* media/video-ended-event-slow-motion-playback-expected.txt: Added.
* media/video-ended-event-slow-motion-playback.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@172472 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
	LayoutTests/ChangeLog
	Source/WebCore/ChangeLog
	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp