Commit eaca9067 authored by jer.noble@apple.com's avatar jer.noble@apple.com

2011-02-03 Jer Noble <jer.noble@apple.com>

        Reviewed by Maciej Stachowiak.

        MediaPlayerPrivateQTKit should use the Application Cache during load.
        https://bugs.webkit.org/show_bug.cgi?id=53818

        No new tests.

        When loading a URL, check to see if the Application Cache has a version of that URL
        stored; if so, use that data instead of the remote URL.

        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivateQTKit::commonMovieAttributes):
        (WebCore::MediaPlayerPrivateQTKit::createQTMovie):
        (WebCore::MediaPlayerPrivateQTKit::loadInternal):

git-svn-id: svn://svn.chromium.org/blink/trunk@82009 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bbc0bc9f
2011-02-03 Jer Noble <jer.noble@apple.com>
Reviewed by Maciej Stachowiak.
MediaPlayerPrivateQTKit should use the Application Cache during load.
https://bugs.webkit.org/show_bug.cgi?id=53818
No new tests.
When loading a URL, check to see if the Application Cache has a version of that URL
stored; if so, use that data instead of the remote URL.
* platform/graphics/mac/MediaPlayerPrivateQTKit.h:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::commonMovieAttributes):
(WebCore::MediaPlayerPrivateQTKit::createQTMovie):
(WebCore::MediaPlayerPrivateQTKit::loadInternal):
2011-03-25 James Robinson <jamesr@chromium.org> 2011-03-25 James Robinson <jamesr@chromium.org>
Reviewed by Kenneth Russell. Reviewed by Kenneth Russell.
...@@ -55,6 +55,8 @@ class WebCoreMovieObserver; ...@@ -55,6 +55,8 @@ class WebCoreMovieObserver;
namespace WebCore { namespace WebCore {
class ApplicationCacheResource;
class MediaPlayerPrivateQTKit : public MediaPlayerPrivateInterface { class MediaPlayerPrivateQTKit : public MediaPlayerPrivateInterface {
public: public:
static void registerMediaEngine(MediaEngineRegistrar); static void registerMediaEngine(MediaEngineRegistrar);
...@@ -139,6 +141,7 @@ private: ...@@ -139,6 +141,7 @@ private:
void createQTMovie(const String& url); void createQTMovie(const String& url);
void createQTMovie(NSURL *, NSDictionary *movieAttributes); void createQTMovie(NSURL *, NSDictionary *movieAttributes);
void createQTMovie(ApplicationCacheResource*);
enum MediaRenderingMode { MediaRenderingNone, MediaRenderingMovieView, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer }; enum MediaRenderingMode { MediaRenderingNone, MediaRenderingMovieView, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer };
MediaRenderingMode currentRenderingMode() const; MediaRenderingMode currentRenderingMode() const;
...@@ -179,6 +182,8 @@ private: ...@@ -179,6 +182,8 @@ private:
virtual void setPrivateBrowsingMode(bool); virtual void setPrivateBrowsingMode(bool);
NSMutableDictionary* commonMovieAttributes();
MediaPlayer* m_player; MediaPlayer* m_player;
RetainPtr<QTMovie> m_qtMovie; RetainPtr<QTMovie> m_qtMovie;
RetainPtr<QTMovieView> m_qtMovieView; RetainPtr<QTMovieView> m_qtMovieView;
......
...@@ -29,11 +29,18 @@ ...@@ -29,11 +29,18 @@
#import "MediaPlayerPrivateQTKit.h" #import "MediaPlayerPrivateQTKit.h"
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
#include "ApplicationCacheHost.h"
#include "ApplicationCacheResource.h"
#include "DocumentLoader.h"
#endif
#ifdef BUILDING_ON_TIGER #ifdef BUILDING_ON_TIGER
#import "AutodrainedPool.h" #import "AutodrainedPool.h"
#endif #endif
#import "BlockExceptions.h" #import "BlockExceptions.h"
#import "DocumentLoader.h"
#import "FrameView.h" #import "FrameView.h"
#import "GraphicsContext.h" #import "GraphicsContext.h"
#import "KURL.h" #import "KURL.h"
...@@ -83,6 +90,7 @@ SOFT_LINK_POINTER(QTKit, QTMediaTypeText, NSString *) ...@@ -83,6 +90,7 @@ SOFT_LINK_POINTER(QTKit, QTMediaTypeText, NSString *)
SOFT_LINK_POINTER(QTKit, QTMediaTypeVideo, NSString *) SOFT_LINK_POINTER(QTKit, QTMediaTypeVideo, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieAskUnresolvedDataRefsAttribute, NSString *) SOFT_LINK_POINTER(QTKit, QTMovieAskUnresolvedDataRefsAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieLoopsAttribute, NSString *) SOFT_LINK_POINTER(QTKit, QTMovieLoopsAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieDataAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieDataSizeAttribute, NSString *) SOFT_LINK_POINTER(QTKit, QTMovieDataSizeAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieDidEndNotification, NSString *) SOFT_LINK_POINTER(QTKit, QTMovieDidEndNotification, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieHasVideoAttribute, NSString *) SOFT_LINK_POINTER(QTKit, QTMovieHasVideoAttribute, NSString *)
...@@ -120,6 +128,7 @@ SOFT_LINK_POINTER(QTKit, QTMovieApertureModeAttribute, NSString *) ...@@ -120,6 +128,7 @@ SOFT_LINK_POINTER(QTKit, QTMovieApertureModeAttribute, NSString *)
#define QTMediaTypeVideo getQTMediaTypeVideo() #define QTMediaTypeVideo getQTMediaTypeVideo()
#define QTMovieAskUnresolvedDataRefsAttribute getQTMovieAskUnresolvedDataRefsAttribute() #define QTMovieAskUnresolvedDataRefsAttribute getQTMovieAskUnresolvedDataRefsAttribute()
#define QTMovieLoopsAttribute getQTMovieLoopsAttribute() #define QTMovieLoopsAttribute getQTMovieLoopsAttribute()
#define QTMovieDataAttribute getQTMovieDataAttribute()
#define QTMovieDataSizeAttribute getQTMovieDataSizeAttribute() #define QTMovieDataSizeAttribute getQTMovieDataSizeAttribute()
#define QTMovieDidEndNotification getQTMovieDidEndNotification() #define QTMovieDidEndNotification getQTMovieDidEndNotification()
#define QTMovieHasVideoAttribute getQTMovieHasVideoAttribute() #define QTMovieHasVideoAttribute getQTMovieHasVideoAttribute()
...@@ -241,11 +250,9 @@ MediaPlayerPrivateQTKit::~MediaPlayerPrivateQTKit() ...@@ -241,11 +250,9 @@ MediaPlayerPrivateQTKit::~MediaPlayerPrivateQTKit()
[m_objcObserver.get() disconnect]; [m_objcObserver.get() disconnect];
} }
void MediaPlayerPrivateQTKit::createQTMovie(const String& url) NSMutableDictionary* MediaPlayerPrivateQTKit::commonMovieAttributes()
{ {
NSURL *cocoaURL = KURL(ParsedURLString, url); return [NSMutableDictionary dictionaryWithObjectsAndKeys:
NSMutableDictionary *movieAttributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:
cocoaURL, QTMovieURLAttribute,
[NSNumber numberWithBool:m_player->preservesPitch()], QTMovieRateChangesPreservePitchAttribute, [NSNumber numberWithBool:m_player->preservesPitch()], QTMovieRateChangesPreservePitchAttribute,
[NSNumber numberWithBool:YES], QTMoviePreventExternalURLLinksAttribute, [NSNumber numberWithBool:YES], QTMoviePreventExternalURLLinksAttribute,
[NSNumber numberWithBool:YES], QTSecurityPolicyNoCrossSiteAttribute, [NSNumber numberWithBool:YES], QTSecurityPolicyNoCrossSiteAttribute,
...@@ -256,6 +263,13 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url) ...@@ -256,6 +263,13 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
QTMovieApertureModeClean, QTMovieApertureModeAttribute, QTMovieApertureModeClean, QTMovieApertureModeAttribute,
#endif #endif
nil]; nil];
}
void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
{
NSURL *cocoaURL = KURL(ParsedURLString, url);
NSMutableDictionary *movieAttributes = commonMovieAttributes();
[movieAttributes setValue:cocoaURL forKey:QTMovieURLAttribute];
#if !defined(BUILDING_ON_LEOPARD) #if !defined(BUILDING_ON_LEOPARD)
CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings(); CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings();
...@@ -291,6 +305,33 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url) ...@@ -291,6 +305,33 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
createQTMovie(cocoaURL, movieAttributes); createQTMovie(cocoaURL, movieAttributes);
} }
void MediaPlayerPrivateQTKit::createQTMovie(ApplicationCacheResource* resource)
{
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
ASSERT(resource);
NSMutableDictionary *movieAttributes = commonMovieAttributes();
[movieAttributes setObject:[NSNumber numberWithBool:YES] forKey:@"QTMovieOpenForPlaybackAttribute"];
// ApplicationCacheResources can supply either a data pointer, or a path to a locally cached
// flat file. We would prefer the path over the data, but QTKit can handle either:
String localPath = resource->path();
NSURL* cocoaURL = !localPath.isEmpty() ? [NSURL fileURLWithPath:localPath isDirectory:NO] : nil;
if (cocoaURL)
[movieAttributes setValue:cocoaURL forKey:QTMovieURLAttribute];
else {
NSData* movieData = resource->data()->createNSData();
[movieAttributes setValue:movieData forKey:QTMovieDataAttribute];
[movieData release];
}
createQTMovie(cocoaURL, movieAttributes);
#else
ASSERT_NOT_REACHED();
#endif
}
static void disableComponentsOnce() static void disableComponentsOnce()
{ {
static bool sComponentsDisabled = false; static bool sComponentsDisabled = false;
...@@ -658,6 +699,14 @@ void MediaPlayerPrivateQTKit::loadInternal(const String& url) ...@@ -658,6 +699,14 @@ void MediaPlayerPrivateQTKit::loadInternal(const String& url)
[m_objcObserver.get() setDelayCallbacks:YES]; [m_objcObserver.get() setDelayCallbacks:YES];
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : NULL;
ApplicationCacheHost* cacheHost = frame ? frame->loader()->documentLoader()->applicationCacheHost() : NULL;
ApplicationCacheResource* resource = NULL;
if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceRequest(url), resource) && resource)
createQTMovie(resource);
else
#endif
createQTMovie(url); createQTMovie(url);
[m_objcObserver.get() loadStateChanged:nil]; [m_objcObserver.get() loadStateChanged:nil];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment