Exemplo n.º 1
0
bool TextTrackLoader::load(const URL& url, const String& crossOriginMode, bool isInitiatingElementInUserAgentShadowTree)
{
    cancelLoad();

    ASSERT(is<Document>(m_scriptExecutionContext));
    Document* document = downcast<Document>(m_scriptExecutionContext);

    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
    options.setContentSecurityPolicyImposition(isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);

    CachedResourceRequest cueRequest(ResourceRequest(document->completeURL(url)), options);

    if (!crossOriginMode.isNull()) {
        m_crossOriginMode = crossOriginMode;
        StoredCredentials allowCredentials = equalLettersIgnoringASCIICase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
        updateRequestForAccessControl(cueRequest.mutableResourceRequest(), document->securityOrigin(), allowCredentials);
    } else {
        // Cross-origin resources that are not suitably CORS-enabled may not load.
        if (!document->securityOrigin()->canRequest(url)) {
            corsPolicyPreventedLoad();
            return false;
        }
    }

    m_resource = document->cachedResourceLoader().requestTextTrack(cueRequest);
    if (!m_resource)
        return false;

    m_resource->addClient(this);
    
    return true;
}
Exemplo n.º 2
0
bool TextTrackLoader::load(const KURL& url, const String& crossOriginMode)
{
    cancelLoad();

    if (!m_client->shouldLoadCues(this))
        return false;

    ASSERT(m_scriptExecutionContext->isDocument());
    Document* document = static_cast<Document*>(m_scriptExecutionContext);
    ResourceRequest cueRequest(document->completeURL(url));

    if (!crossOriginMode.isNull()) {
        m_crossOriginMode = crossOriginMode;
        StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
        updateRequestForAccessControl(cueRequest, document->securityOrigin(), allowCredentials);
    } else {
        // Cross-origin resources that are not suitably CORS-enabled may not load.
        if (!document->securityOrigin()->canRequest(url)) {
            corsPolicyPreventedLoad();
            return false;
        }
    }

    CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
    m_cachedCueData = cachedResourceLoader->requestTextTrack(cueRequest);
    if (m_cachedCueData)
        m_cachedCueData->addClient(this);
    
    m_client->cueLoadingStarted(this);
    
    return true;
}
bool TextTrackLoader::load(const KURL& url, const AtomicString& crossOriginMode)
{
    cancelLoad();

    FetchRequest cueRequest(ResourceRequest(m_document.completeURL(url)), FetchInitiatorTypeNames::texttrack);

    if (!crossOriginMode.isNull()) {
        cueRequest.setCrossOriginAccessControl(m_document.securityOrigin(), crossOriginMode);
    } else if (!m_document.securityOrigin()->canRequest(url)) {
        // Text track elements without 'crossorigin' set on the parent are "No CORS"; report error if not same-origin.
        corsPolicyPreventedLoad(m_document.securityOrigin(), url);
        return false;
    }

    ResourceFetcher* fetcher = m_document.fetcher();
    setResource(fetcher->fetchRawResource(cueRequest));
    return resource();
}
Exemplo n.º 4
0
bool TextTrackLoader::load(const KURL& url, CrossOriginAttributeValue crossOrigin)
{
    cancelLoad();

    FetchRequest cueRequest(ResourceRequest(document().completeURL(url)), FetchInitiatorTypeNames::texttrack);

    if (crossOrigin != CrossOriginAttributeNotSet) {
        cueRequest.setCrossOriginAccessControl(document().securityOrigin(), crossOrigin);
    } else if (!document().securityOrigin()->canRequestNoSuborigin(url)) {
        // Text track elements without 'crossorigin' set on the parent are "No CORS"; report error if not same-origin.
        corsPolicyPreventedLoad(document().securityOrigin(), url);
        return false;
    }

    ResourceFetcher* fetcher = document().fetcher();
    setResource(RawResource::fetchTextTrack(cueRequest, fetcher));
    return resource();
}
Exemplo n.º 5
0
bool TextTrackLoader::load(const KURL& url)
{
    if (!m_client->shouldLoadCues(this))
        return false;
    
    cancelLoad();
    
    ASSERT(m_scriptExecutionContext->isDocument());
    Document* document = static_cast<Document*>(m_scriptExecutionContext);
    
    ResourceRequest cueRequest(document->completeURL(url));
    CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
    m_cachedCueData = static_cast<CachedTextTrack*>(cachedResourceLoader->requestTextTrack(cueRequest));
    if (m_cachedCueData)
        m_cachedCueData->addClient(this);
    
    m_client->cueLoadingStarted(this);
    
    return true;
}