⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176108 in webkit


Ignore:
Timestamp:
Nov 13, 2014, 4:46:53 PM (12 years ago)
Author:
Beth Dakin
Message:

Context menus should not offer the "Download video" option for videos that cannot
be downloaded
https://bugs.webkit.org/show_bug.cgi?id=138530
-and corresponding-
rdar://problem/18919130

Patch by Eric Carlson <eric.carlson@apple.com> on 2014-11-13
Reviewed by Tim Horton.

Source/WebCore:

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute):

  • html/HTMLMediaElement.h:
  • page/ContextMenuController.cpp:

(WebCore::ContextMenuController::populate):

  • platform/graphics/MediaPlayer.cpp:

(WebCore::MediaPlayer::canSaveMediaData):
(WebCore::MediaPlayer::supportsSave): Deleted.

  • platform/graphics/MediaPlayer.h:
  • platform/graphics/MediaPlayerPrivate.h:

(WebCore::MediaPlayerPrivateInterface::supportsFullscreen):
(WebCore::MediaPlayerPrivateInterface::canSaveMediaData):
(WebCore::MediaPlayerPrivateInterface::supportsSave): Deleted.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::resolvedURL):
(WebCore::MediaPlayerPrivateAVFoundation::canSaveMediaData):

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::resolvedURL):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::canSaveMediaData):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
  • platform/graphics/mac/MediaPlayerPrivateQTKit.h:
  • platform/graphics/mac/MediaPlayerPrivateQTKit.mm:

(WebCore::MediaPlayerPrivateQTKit::canSaveMediaData):

  • rendering/HitTestResult.cpp:

(WebCore::HitTestResult::isDownloadableMedia):

Source/WebKit2:

Expose isDownloadableMedia() to the InjectedBundleHitTestResult.

  • WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp:

(WKBundleHitTestResultIsDownloadableMedia):

  • WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
  • WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:

(WebKit::InjectedBundleHitTestResult::isDownloadableMedia):

  • WebProcess/InjectedBundle/InjectedBundleHitTestResult.h:
Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176106 r176108  
     12014-11-13  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Context menus should not offer the "Download video" option for videos that cannot
     4        be downloaded
     5        https://bugs.webkit.org/show_bug.cgi?id=138530
     6        -and corresponding-
     7        rdar://problem/18919130
     8
     9        Reviewed by Tim Horton.
     10
     11        * html/HTMLMediaElement.cpp:
     12        (WebCore::HTMLMediaElement::parseAttribute):
     13        * html/HTMLMediaElement.h:
     14        * page/ContextMenuController.cpp:
     15        (WebCore::ContextMenuController::populate):
     16        * platform/graphics/MediaPlayer.cpp:
     17        (WebCore::MediaPlayer::canSaveMediaData):
     18        (WebCore::MediaPlayer::supportsSave): Deleted.
     19        * platform/graphics/MediaPlayer.h:
     20        * platform/graphics/MediaPlayerPrivate.h:
     21        (WebCore::MediaPlayerPrivateInterface::supportsFullscreen):
     22        (WebCore::MediaPlayerPrivateInterface::canSaveMediaData):
     23        (WebCore::MediaPlayerPrivateInterface::supportsSave): Deleted.
     24        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     25        (WebCore::MediaPlayerPrivateAVFoundation::resolvedURL):
     26        (WebCore::MediaPlayerPrivateAVFoundation::canSaveMediaData):
     27        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
     28        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     29        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     30        (WebCore::MediaPlayerPrivateAVFoundationObjC::resolvedURL):
     31        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     32        (WebCore::MediaPlayerPrivateGStreamer::canSaveMediaData):
     33        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
     34        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
     35        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
     36        (WebCore::MediaPlayerPrivateQTKit::canSaveMediaData):
     37        * rendering/HitTestResult.cpp:
     38        (WebCore::HitTestResult::isDownloadableMedia):
     39
    1402014-11-02  Tim Horton  <timothy_horton@apple.com>
    241
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r176002 r176108  
    22702270
    22712271
    2272 bool HTMLMediaElement::supportsSave() const
    2273 {
    2274     return m_player ? m_player->supportsSave() : false;
    2275 }
    2276 
    22772272bool HTMLMediaElement::supportsScanning() const
    22782273{
     
    61186113{
    61196114    if (m_player)
    6120         return m_player->setShouldBufferData(shouldBuffer);
    6121 }
    6122    
    6123 }
    6124 
    6125 #endif
     6115        m_player->setShouldBufferData(shouldBuffer);
     6116}
     6117
     6118bool HTMLMediaElement::canSaveMediaData() const
     6119{
     6120    if (m_player)
     6121        return m_player->canSaveMediaData();
     6122
     6123    return false;
     6124}
     6125
     6126}
     6127
     6128#endif
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r176002 r176108  
    119119    virtual bool supportsFullscreen() const override { return false; };
    120120
    121     virtual bool supportsSave() const;
    122121    virtual bool supportsScanning() const override;
    123    
     122
     123    bool canSaveMediaData() const;
     124
    124125    virtual bool doesHaveAttribute(const AtomicString&, AtomicString* value = nullptr) const override;
    125126
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r175435 r176108  
    891891            appendItem(CopyMediaLinkItem, m_contextMenu.get());
    892892            appendItem(OpenMediaInNewWindowItem, m_contextMenu.get());
    893             if (loader.client().canHandleRequest(ResourceRequest(mediaURL)))
     893            if (m_context.hitTestResult().isDownloadableMedia() && loader.client().canHandleRequest(ResourceRequest(mediaURL)))
    894894                appendItem(DownloadMediaItem, m_contextMenu.get());
    895895        }
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r176002 r176108  
    553553}
    554554
    555 bool MediaPlayer::supportsSave() const
    556 {
    557     return m_private->supportsSave();
     555bool MediaPlayer::canSaveMediaData() const
     556{
     557    return m_private->canSaveMediaData();
    558558}
    559559
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r176002 r176108  
    294294
    295295    bool supportsFullscreen() const;
    296     bool supportsSave() const;
    297296    bool supportsScanning() const;
     297    bool canSaveMediaData() const;
    298298    bool requiresImmediateCompositing() const;
    299299    bool doesHaveAttribute(const AtomicString&, AtomicString* value = nullptr) const;
  • trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r176002 r176108  
    7171
    7272    virtual bool supportsFullscreen() const { return false; }
    73     virtual bool supportsSave() const { return false; }
    7473    virtual bool supportsScanning() const { return false; }
    7574    virtual bool requiresImmediateCompositing() const { return false; }
     75
     76    virtual bool canSaveMediaData() const { return false; }
    7677
    7778    virtual IntSize naturalSize() const = 0;
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r175526 r176108  
    10481048#endif
    10491049
     1050URL MediaPlayerPrivateAVFoundation::resolvedURL() const
     1051{
     1052    if (!m_assetURL.length())
     1053        return URL();
     1054
     1055    return URL(ParsedURLString, m_assetURL);
     1056}
     1057
     1058bool MediaPlayerPrivateAVFoundation::canSaveMediaData() const
     1059{
     1060    URL url = resolvedURL();
     1061
     1062    if (url.isLocalFile())
     1063        return true;
     1064
     1065    if (!url.protocolIsInHTTPFamily())
     1066        return false;
     1067
     1068    if (isLiveStream())
     1069        return false;
     1070
     1071    return true;
     1072}
     1073
    10501074} // namespace WebCore
    10511075
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

    r176002 r176108  
    192192    virtual bool shouldMaintainAspectRatio() const override { return m_shouldMaintainAspectRatio; }
    193193    virtual void setShouldMaintainAspectRatio(bool) override;
     194    virtual bool canSaveMediaData() const override;
    194195
    195196    virtual MediaPlayer::MovieLoadType movieLoadType() const;
     
    303304    void clearTextTracks();
    304305    Vector<RefPtr<InbandTextTrackPrivateAVF>> m_textTracks;
     306
     307virtual URL resolvedURL() const;
    305308
    306309private:
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r176002 r176108  
    282282    virtual double minFastReverseRate() const override { return m_cachedCanPlayFastReverse ? -std::numeric_limits<double>::infinity() : 0.0; }
    283283
     284    virtual URL resolvedURL() const override;
     285
    284286    WeakPtrFactory<MediaPlayerPrivateAVFoundationObjC> m_weakPtrFactory;
    285287
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r176105 r176108  
    28462846}
    28472847
     2848URL MediaPlayerPrivateAVFoundationObjC::resolvedURL() const
     2849{
     2850    if (!m_avAsset)
     2851        return MediaPlayerPrivateAVFoundation::resolvedURL();
     2852
     2853    return URL([m_avAsset resolvedURL]);
     2854}
     2855
    28482856NSArray* assetMetadataKeyNames()
    28492857{
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r175719 r176108  
    19211921}
    19221922
     1923bool MediaPlayerPrivateGStreamer::canSaveMediaData() const
     1924{
     1925    if (isLiveStream())
     1926        return false;
     1927
     1928    if (m_url.isLocalFile())
     1929        return true;
     1930
     1931    if (m_url.protocolIsInHTTPFamily())
     1932        return true;
     1933   
     1934    return false;
     1935}
     1936
    19231937}
    19241938
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r175719 r176108  
    165165    virtual bool isLiveStream() const { return m_isStreaming; }
    166166    virtual bool didPassCORSAccessCheck() const;
     167    virtual bool canSaveMediaData() const override;
    167168
    168169private:
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h

    r176002 r176108  
    135135    bool hasSingleSecurityOrigin() const;
    136136    MediaPlayer::MovieLoadType movieLoadType() const;
     137
     138    virtual bool canSaveMediaData() const override;
    137139
    138140    void createQTMovie(const String& url);
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

    r176002 r176108  
    15181518}
    15191519
     1520bool MediaPlayerPrivateQTKit::canSaveMediaData() const
     1521{
     1522    URL url;
     1523
     1524    if (durationMediaTime().isPositiveInfinite())
     1525        return false;
     1526
     1527    if (m_qtMovie)
     1528        url = URL(wkQTMovieResolvedURL(m_qtMovie.get()));
     1529    else
     1530        url = URL(ParsedURLString, m_movieURL);
     1531
     1532    if (url.isLocalFile())
     1533        return true;
     1534
     1535    if (url.protocolIsInHTTPFamily())
     1536        return true;
     1537   
     1538    return false;
     1539}
     1540
    15201541} // namespace WebCore
    15211542
  • trunk/Source/WebCore/rendering/HitTestResult.cpp

    r175779 r176108  
    508508bool HitTestResult::isDownloadableMedia() const
    509509{
    510     // FIXME: We should actually answer instead of always returning true for media elements.
    511     // https://bugs.webkit.org/show_bug.cgi?id=138530
    512     return mediaElement() ? true : false;
     510#if ENABLE(VIDEO)
     511    if (HTMLMediaElement* mediaElt = mediaElement())
     512        return mediaElt->canSaveMediaData();
     513#endif
     514
     515    return false;
    513516}
    514517
  • trunk/Source/WebKit2/ChangeLog

    r176105 r176108  
     12014-11-13  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Context menus should not offer the "Download video" option for videos that cannot
     4        be downloaded
     5        https://bugs.webkit.org/show_bug.cgi?id=138530
     6        -and corresponding-
     7        rdar://problem/18919130
     8
     9        Reviewed by Tim Horton.
     10
     11        Expose isDownloadableMedia() to the InjectedBundleHitTestResult.
     12        * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp:
     13        (WKBundleHitTestResultIsDownloadableMedia):
     14        * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
     15        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
     16        (WebKit::InjectedBundleHitTestResult::isDownloadableMedia):
     17        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.h:
     18
    1192014-11-13  Daniel Bates  <dabates@apple.com>
    220
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp

    r172780 r176108  
    9191}
    9292
     93bool WKBundleHitTestResultIsDownloadableMedia(WKBundleHitTestResultRef hitTestResultRef)
     94{
     95    return toImpl(hitTestResultRef)->isDownloadableMedia();
     96}
     97
    9398WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResultRef)
    9499{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h

    r172780 r176108  
    5555WK_EXPORT bool WKBundleHitTestResultMediaIsInFullscreen(WKBundleHitTestResultRef hitTestResult);
    5656WK_EXPORT bool WKBundleHitTestResultMediaHasAudio(WKBundleHitTestResultRef hitTestResult);
     57WK_EXPORT bool WKBundleHitTestResultIsDownloadableMedia(WKBundleHitTestResultRef hitTestResultRef);
    5758WK_EXPORT WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResult);
    5859
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp

    r174225 r176108  
    109109}
    110110
     111bool InjectedBundleHitTestResult::isDownloadableMedia() const
     112{
     113    return m_hitTestResult.isDownloadableMedia();
     114}
     115
    111116BundleHitTestResultMediaType InjectedBundleHitTestResult::mediaType() const
    112117{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h

    r172780 r176108  
    5656    bool mediaIsInFullscreen() const;
    5757    bool mediaHasAudio() const;
     58    bool isDownloadableMedia() const;
    5859    BundleHitTestResultMediaType mediaType() const;
    5960
Note: See TracChangeset for help on using the changeset viewer.