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>
Reviewed by Kenneth Russell.
......@@ -54,6 +54,8 @@ class WebCoreMovieObserver;
#endif
namespace WebCore {
class ApplicationCacheResource;
class MediaPlayerPrivateQTKit : public MediaPlayerPrivateInterface {
public:
......@@ -139,6 +141,7 @@ private:
void createQTMovie(const String& url);
void createQTMovie(NSURL *, NSDictionary *movieAttributes);
void createQTMovie(ApplicationCacheResource*);
enum MediaRenderingMode { MediaRenderingNone, MediaRenderingMovieView, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer };
MediaRenderingMode currentRenderingMode() const;
......@@ -178,6 +181,8 @@ private:
virtual double maximumDurationToCacheMediaTime() const { return 5; }
virtual void setPrivateBrowsingMode(bool);
NSMutableDictionary* commonMovieAttributes();
MediaPlayer* m_player;
RetainPtr<QTMovie> m_qtMovie;
......
......@@ -29,11 +29,18 @@
#import "MediaPlayerPrivateQTKit.h"
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
#include "ApplicationCacheHost.h"
#include "ApplicationCacheResource.h"
#include "DocumentLoader.h"
#endif
#ifdef BUILDING_ON_TIGER
#import "AutodrainedPool.h"
#endif
#import "BlockExceptions.h"
#import "DocumentLoader.h"
#import "FrameView.h"
#import "GraphicsContext.h"
#import "KURL.h"
......@@ -83,6 +90,7 @@ SOFT_LINK_POINTER(QTKit, QTMediaTypeText, NSString *)
SOFT_LINK_POINTER(QTKit, QTMediaTypeVideo, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieAskUnresolvedDataRefsAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieLoopsAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieDataAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieDataSizeAttribute, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieDidEndNotification, NSString *)
SOFT_LINK_POINTER(QTKit, QTMovieHasVideoAttribute, NSString *)
......@@ -120,6 +128,7 @@ SOFT_LINK_POINTER(QTKit, QTMovieApertureModeAttribute, NSString *)
#define QTMediaTypeVideo getQTMediaTypeVideo()
#define QTMovieAskUnresolvedDataRefsAttribute getQTMovieAskUnresolvedDataRefsAttribute()
#define QTMovieLoopsAttribute getQTMovieLoopsAttribute()
#define QTMovieDataAttribute getQTMovieDataAttribute()
#define QTMovieDataSizeAttribute getQTMovieDataSizeAttribute()
#define QTMovieDidEndNotification getQTMovieDidEndNotification()
#define QTMovieHasVideoAttribute getQTMovieHasVideoAttribute()
......@@ -241,21 +250,26 @@ MediaPlayerPrivateQTKit::~MediaPlayerPrivateQTKit()
[m_objcObserver.get() disconnect];
}
void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
NSMutableDictionary* MediaPlayerPrivateQTKit::commonMovieAttributes()
{
NSURL *cocoaURL = KURL(ParsedURLString, url);
NSMutableDictionary *movieAttributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:
cocoaURL, QTMovieURLAttribute,
[NSNumber numberWithBool:m_player->preservesPitch()], QTMovieRateChangesPreservePitchAttribute,
[NSNumber numberWithBool:YES], QTMoviePreventExternalURLLinksAttribute,
[NSNumber numberWithBool:YES], QTSecurityPolicyNoCrossSiteAttribute,
[NSNumber numberWithBool:NO], QTMovieAskUnresolvedDataRefsAttribute,
[NSNumber numberWithBool:NO], QTMovieLoopsAttribute,
[NSNumber numberWithBool:!m_privateBrowsing], @"QTMovieAllowPersistentCacheAttribute",
return [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:m_player->preservesPitch()], QTMovieRateChangesPreservePitchAttribute,
[NSNumber numberWithBool:YES], QTMoviePreventExternalURLLinksAttribute,
[NSNumber numberWithBool:YES], QTSecurityPolicyNoCrossSiteAttribute,
[NSNumber numberWithBool:NO], QTMovieAskUnresolvedDataRefsAttribute,
[NSNumber numberWithBool:NO], QTMovieLoopsAttribute,
[NSNumber numberWithBool:!m_privateBrowsing], @"QTMovieAllowPersistentCacheAttribute",
#ifndef BUILDING_ON_TIGER
QTMovieApertureModeClean, QTMovieApertureModeAttribute,
QTMovieApertureModeClean, QTMovieApertureModeAttribute,
#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)
CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings();
......@@ -291,6 +305,33 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
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 bool sComponentsDisabled = false;
......@@ -658,6 +699,14 @@ void MediaPlayerPrivateQTKit::loadInternal(const String& url)
[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);
[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