void MediaPlayer::load(const String& url, const ContentType& contentType) { String type = contentType.type().lower(); String typeCodecs = contentType.parameter(codecs()); // If the MIME type is missing or is not meaningful, try to figure it out from the URL. if (type.isEmpty() || type == applicationOctetStream() || type == textPlain()) { if (protocolIs(url, "data")) type = mimeTypeFromDataURL(url); else { size_t pos = url.reverseFind('.'); if (pos != notFound) { String extension = url.substring(pos + 1); String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension); if (!mediaType.isEmpty()) type = mediaType; } } } m_url = url; m_contentMIMEType = type; m_contentTypeCodecs = typeCodecs; loadWithNextMediaEngine(0); }
bool MediaPlayer::load(const URL& url, const ContentType& contentType, const String& keySystem) { m_contentMIMEType = contentType.type().lower(); m_contentTypeCodecs = contentType.parameter(codecs()); m_url = url; m_keySystem = keySystem.lower(); m_contentMIMETypeWasInferredFromExtension = false; #if ENABLE(MEDIA_SOURCE) m_mediaSource = 0; #endif // If the MIME type is missing or is not meaningful, try to figure it out from the URL. if (m_contentMIMEType.isEmpty() || m_contentMIMEType == applicationOctetStream() || m_contentMIMEType == textPlain()) { if (m_url.protocolIsData()) m_contentMIMEType = mimeTypeFromDataURL(m_url.string()); else { String lastPathComponent = url.lastPathComponent(); size_t pos = lastPathComponent.reverseFind('.'); if (pos != notFound) { String extension = lastPathComponent.substring(pos + 1); String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension); if (!mediaType.isEmpty()) { m_contentMIMEType = mediaType; m_contentMIMETypeWasInferredFromExtension = true; } } } } loadWithNextMediaEngine(0); return m_currentMediaEngine; }
bool HTMLPlugInImageElement::isImageType() { if (m_serviceType.isEmpty() && protocolIs(m_url, "data")) m_serviceType = mimeTypeFromDataURL(m_url); if (Frame* frame = document()->frame()) { KURL completedURL = frame->loader()->completeURL(m_url); return frame->loader()->client()->objectContentType(completedURL, m_serviceType) == ObjectContentImage; } return Image::supportsType(m_serviceType); }
bool HTMLPlugInElement::isImageType() { if (m_serviceType.isEmpty() && protocolIs(m_url, "data")) m_serviceType = mimeTypeFromDataURL(m_url); if (LocalFrame* frame = document().frame()) { KURL completedURL = document().completeURL(m_url); return frame->loader().client()->objectContentType(completedURL, m_serviceType, shouldPreferPlugInsForImages()) == ObjectContentImage; } return Image::supportsType(m_serviceType); }
PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const URL& url, ApplicationCacheResource* newestCachedResource) { ResourceRequest request(url); m_frame->loader().applyUserAgent(request); request.setHTTPHeaderField("Cache-Control", "max-age=0"); if (newestCachedResource) { const String& lastModified = newestCachedResource->response().httpHeaderField("Last-Modified"); const String& eTag = newestCachedResource->response().httpHeaderField("ETag"); if (!lastModified.isEmpty() || !eTag.isEmpty()) { if (!lastModified.isEmpty()) request.setHTTPHeaderField("If-Modified-Since", lastModified); if (!eTag.isEmpty()) request.setHTTPHeaderField("If-None-Match", eTag); } } #if PLATFORM(BLACKBERRY) ResourceRequest::TargetType target = ResourceRequest::TargetIsUnspecified; if (newestCachedResource) { const String& mimeType = newestCachedResource->response().mimeType(); if (!mimeType.isEmpty()) target = ResourceRequest::targetTypeFromMimeType(mimeType); } if (target == ResourceRequest::TargetIsUnspecified) { String mimeType; if (url.protocolIsData()) mimeType = mimeTypeFromDataURL(url); if (!mimeType.isEmpty()) target = ResourceRequest::targetTypeFromMimeType(mimeType); } request.setTargetType(target); #endif RefPtr<ResourceHandle> handle = ResourceHandle::create(m_frame->loader().networkingContext(), request, this, false, true); #if ENABLE(INSPECTOR) // Because willSendRequest only gets called during redirects, we initialize // the identifier and the first willSendRequest here. m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier(); ResourceResponse redirectResponse = ResourceResponse(); InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, redirectResponse); #endif return handle; }