本文整理汇总了C++中FrameLoader::networkingContext方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameLoader::networkingContext方法的具体用法?C++ FrameLoader::networkingContext怎么用?C++ FrameLoader::networkingContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrameLoader
的用法示例。
在下文中一共展示了FrameLoader::networkingContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: webKitWebSrcStart
static bool webKitWebSrcStart(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
if (!priv->uri) {
GST_ERROR_OBJECT(src, "No URI provided");
return false;
}
KURL url = KURL(KURL(), priv->uri);
ResourceRequest request(url);
request.setTargetType(ResourceRequestBase::TargetIsMedia);
request.setAllowCookies(true);
NetworkingContext* context = 0;
if (priv->frame) {
Document* document = priv->frame->document();
if (document)
request.setHTTPReferrer(document->documentURI());
FrameLoader* loader = priv->frame->loader();
if (loader) {
loader->addExtraFieldsToSubresourceRequest(request);
context = loader->networkingContext();
}
}
// Let Apple web servers know we want to access their nice movie trailers.
if (!g_ascii_strcasecmp("movies.apple.com", url.host().utf8().data())
|| !g_ascii_strcasecmp("trailers.apple.com", url.host().utf8().data()))
request.setHTTPUserAgent("Quicktime/7.6.6");
if (priv->requestedOffset) {
GOwnPtr<gchar> val;
val.set(g_strdup_printf("bytes=%" G_GUINT64_FORMAT "-", priv->requestedOffset));
request.setHTTPHeaderField("Range", val.get());
}
if (priv->iradioMode)
request.setHTTPHeaderField("icy-metadata", "1");
// Needed to use DLNA streaming servers
request.setHTTPHeaderField("transferMode.dlna", "Streaming");
priv->resourceHandle = ResourceHandle::create(context, request, priv->client, false, false);
if (!priv->resourceHandle) {
GST_ERROR_OBJECT(src, "Failed to create ResourceHandle");
return false;
}
GST_DEBUG_OBJECT(src, "Started request");
return true;
}
示例2:
QList<QObject*> QWebFrameAdapter::childFrames() const
{
QList<QObject*> originatingObjects;
if (frame) {
FrameTree* tree = frame->tree();
for (Frame* child = tree->firstChild(); child; child = child->tree()->nextSibling()) {
FrameLoader* loader = child->loader();
originatingObjects.append(loader->networkingContext()->originatingObject());
}
}
return originatingObjects;
}
示例3: commitLoad
void MediaPlayerPrivateQt::commitLoad(const String& url)
{
// We are now loading
if (m_networkState != MediaPlayer::Loading) {
m_networkState = MediaPlayer::Loading;
m_webCorePlayer->networkStateChanged();
}
// And we don't have any data yet
if (m_readyState != MediaPlayer::HaveNothing) {
m_readyState = MediaPlayer::HaveNothing;
m_webCorePlayer->readyStateChanged();
}
KURL kUrl(ParsedURLString, url);
const QUrl rUrl = kUrl;
const QString scheme = rUrl.scheme().toLower();
// Grab the client media element
HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
// Construct the media content with a network request if the resource is http[s]
if (scheme == QString::fromLatin1("http") || scheme == QString::fromLatin1("https")) {
QNetworkRequest request = QNetworkRequest(rUrl);
// Grab the current document
Document* document = element->document();
if (!document)
document = element->ownerDocument();
// Grab the frame and network manager
Frame* frame = document ? document->frame() : 0;
FrameLoader* frameLoader = frame ? frame->loader() : 0;
QNetworkAccessManager* manager = frameLoader ? frameLoader->networkingContext()->networkAccessManager() : 0;
if (manager) {
// Set the cookies
QNetworkCookieJar* jar = manager->cookieJar();
QList<QNetworkCookie> cookies = jar->cookiesForUrl(rUrl);
// Don't set the header if there are no cookies.
// This prevents a warning from being emitted.
if (!cookies.isEmpty())
request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies));
// Set the refferer, but not when requesting insecure content from a secure page
QUrl documentUrl = QUrl(QString(document->documentURI()));
if (documentUrl.scheme().toLower() == QString::fromLatin1("http") || scheme == QString::fromLatin1("https"))
request.setRawHeader("Referer", documentUrl.toEncoded());
// Set the user agent
request.setRawHeader("User-Agent", frameLoader->userAgent(rUrl).utf8().data());
}
m_mediaPlayer->setMedia(QMediaContent(request));
} else {
// Otherwise, just use the URL
m_mediaPlayer->setMedia(QMediaContent(rUrl));
}
// Set the current volume and mute status
// We get these from the element, rather than the player, in case we have
// transitioned from a media engine which doesn't support muting, to a media
// engine which does.
m_mediaPlayer->setMuted(element->muted());
m_mediaPlayer->setVolume(static_cast<int>(element->volume() * 100.0));
// Don't send PlaybackChanged notification for pre-roll.
m_suppressNextPlaybackChanged = true;
// Setting a media source will start loading the media, but we need
// to pre-roll as well to get video size-hints and buffer-status
if (element->paused())
m_mediaPlayer->pause();
else
m_mediaPlayer->play();
}