本文整理汇总了C++中ResourceRequest函数的典型用法代码示例。如果您正苦于以下问题:C++ ResourceRequest函数的具体用法?C++ ResourceRequest怎么用?C++ ResourceRequest使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ResourceRequest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request
void WebInspector::openInNewTab(const String& urlString)
{
Page* inspectedPage = m_page->corePage();
if (!inspectedPage)
return;
Frame& inspectedMainFrame = inspectedPage->mainFrame();
FrameLoadRequest request(inspectedMainFrame.document()->securityOrigin(), ResourceRequest(urlString), "_blank", LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Allow, ReplaceDocumentIfJavaScriptURL, ShouldOpenExternalURLsPolicy::ShouldNotAllow);
Page* newPage = inspectedPage->chrome().createWindow(&inspectedMainFrame, request, WindowFeatures(), NavigationAction(request.resourceRequest(), NavigationType::LinkClicked));
if (!newPage)
return;
newPage->mainFrame().loader().load(request);
}
示例2: expectHeader
void expectHeader(const char* input, const char* headerName, bool isPresent, const char* headerValue, float width = 0)
{
KURL inputURL(ParsedURLString, input);
FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), FetchInitiatorInfo());
if (width > 0) {
FetchRequest::ResourceWidth resourceWidth;
resourceWidth.width = width;
resourceWidth.isSet = true;
fetchRequest.setResourceWidth(resourceWidth);
}
fetchContext->addClientHintsIfNecessary(fetchRequest);
EXPECT_STREQ(isPresent ? headerValue : "",
fetchRequest.resourceRequest().httpHeaderField(headerName).utf8().data());
}
示例3: docLoaderFunc
static xmlDocPtr docLoaderFunc(const xmlChar* uri,
xmlDictPtr,
int options,
void* ctxt,
xsltLoadType type)
{
if (!globalProcessor)
return 0;
switch (type) {
case XSLT_LOAD_DOCUMENT: {
xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt;
xmlChar* base = xmlNodeGetBase(context->document->doc, context->node);
KURL url(KURL(ParsedURLString, reinterpret_cast<const char*>(base)), reinterpret_cast<const char*>(uri));
xmlFree(base);
ResourceLoaderOptions fetchOptions(ResourceFetcher::defaultResourceOptions());
FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml, fetchOptions);
request.setOriginRestriction(FetchRequest::RestrictToSameOrigin);
ResourcePtr<Resource> resource = globalResourceFetcher->fetchSynchronously(request);
if (!resource || !globalProcessor)
return 0;
PageConsole* console = 0;
Frame* frame = globalProcessor->xslStylesheet()->ownerDocument()->frame();
if (frame && frame->page())
console = &frame->page()->console();
xmlSetStructuredErrorFunc(console, XSLTProcessor::parseErrorFunc);
xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc);
// We don't specify an encoding here. Neither Gecko nor WinIE respects
// the encoding specified in the HTTP headers.
SharedBuffer* data = resource->resourceBuffer();
xmlDocPtr doc = data ? xmlReadMemory(data->data(), data->size(), (const char*)uri, 0, options) : 0;
xmlSetStructuredErrorFunc(0, 0);
xmlSetGenericErrorFunc(0, 0);
return doc;
}
case XSLT_LOAD_STYLESHEET:
return globalProcessor->xslStylesheet()->locateStylesheetSubResource(((xsltStylesheetPtr)ctxt)->doc, uri);
default:
break;
}
return 0;
}
示例4: fire
virtual void fire(Frame* frame)
{
OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicator();
if (!m_historySteps) {
FrameLoadRequest frameRequest(frame->document()->securityOrigin(), ResourceRequest(frame->document()->url()));
frameRequest.setLockBackForwardList(lockBackForwardList());
// Special case for go(0) from a frame -> reload only the frame
// To follow Firefox and IE's behavior, history reload can only navigate the self frame.
frame->loader().load(frameRequest);
return;
}
// go(i!=0) from a frame navigates into the history of the frame only,
// in both IE and NS (but not in Mozilla). We can't easily do that.
frame->page()->mainFrame()->loader().client()->navigateBackForward(m_historySteps);
}
示例5: ASSERT
StyleFetchedImage* CSSImageValue::cachedImage(ResourceFetcher* fetcher, const ResourceLoaderOptions& options)
{
ASSERT(fetcher);
if (!m_accessedImage) {
m_accessedImage = true;
FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isEmpty() ? FetchInitiatorTypeNames::css : m_initiatorName, options);
request.mutableResourceRequest().setHTTPReferrer(m_referrer);
if (ResourcePtr<ImageResource> cachedImage = fetcher->fetchImage(request))
m_image = StyleFetchedImage::create(cachedImage.get());
}
return (m_image && m_image->isImageResource()) ? toStyleFetchedImage(m_image) : 0;
}
示例6: TEST_F
TEST_F(CachingCorrectnessTest, PostToSameURLTwice)
{
ResourceRequest request1(KURL(ParsedURLString, kResourceURL));
request1.setHTTPMethod(HTTPNames::POST);
ResourcePtr<Resource> resource1 = new Resource(ResourceRequest(request1.url()), Resource::Raw);
resource1->setLoading(true);
memoryCache()->add(resource1.get());
ResourceRequest request2(KURL(ParsedURLString, kResourceURL));
request2.setHTTPMethod(HTTPNames::POST);
FetchRequest fetch2(request2, FetchInitiatorInfo());
ResourcePtr<Resource> resource2 = RawResource::fetchSynchronously(fetch2, fetcher());
EXPECT_EQ(resource2, memoryCache()->resourceForURL(request2.url()));
EXPECT_NE(resource1, resource2);
}
示例7: ASSERT
void DocumentThreadableLoader::willSendRequest(SubresourceLoader* loader, ResourceRequest& request, const ResourceResponse&)
{
ASSERT(m_client);
ASSERT_UNUSED(loader, loader == m_loader);
// apollo integrate
//#if PLATFORM(APOLLO)
// if (!m_document->securityOrigin()->canRequestExt(request.url(), m_document)) {
//#endif
// end apollo integrate
if (!isAllowedRedirect(request.url())) {
RefPtr<DocumentThreadableLoader> protect(this);
m_client->didFailRedirectCheck();
request = ResourceRequest();
}
}
示例8: TEST_F
TEST_F(FrameFetchContextTest, ModifyPriorityForLowPriorityIframes)
{
Settings* settings = document->frame()->settings();
settings->setLowPriorityIframes(false);
FetchRequest request(ResourceRequest("http://www.example.com"), FetchInitiatorInfo());
FrameFetchContext* childFetchContext = createChildFrame();
// No low priority iframes, expect default values.
EXPECT_EQ(ResourceLoadPriorityVeryHigh, childFetchContext->modifyPriorityForExperiments(ResourceLoadPriorityVeryHigh));
EXPECT_EQ(ResourceLoadPriorityMedium, childFetchContext->modifyPriorityForExperiments(ResourceLoadPriorityMedium));
// Low priority iframes enabled, everything should be low priority
settings->setLowPriorityIframes(true);
EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForExperiments(ResourceLoadPriorityVeryHigh));
EXPECT_EQ(ResourceLoadPriorityVeryLow, childFetchContext->modifyPriorityForExperiments(ResourceLoadPriorityMedium));
}
示例9: LOG
void ContentFilter::willSendRequest(ResourceRequest& request, const ResourceResponse& redirectResponse)
{
LOG(ContentFiltering, "ContentFilter received request for <%s> with redirect response from <%s>.\n", request.url().string().ascii().data(), redirectResponse.url().string().ascii().data());
ResourceRequest requestCopy { request };
ASSERT(m_state == State::Initialized || m_state == State::Filtering);
forEachContentFilterUntilBlocked([&requestCopy, &redirectResponse](PlatformContentFilter& contentFilter) {
contentFilter.willSendRequest(requestCopy, redirectResponse);
if (contentFilter.didBlockData())
requestCopy = ResourceRequest();
});
#if !LOG_DISABLED
if (request != requestCopy)
LOG(ContentFiltering, "ContentFilter changed request url to <%s>.\n", requestCopy.url().string().ascii().data());
#endif
request = requestCopy;
}
示例10: ResourceRequest
void Resource::error(Resource::Status status)
{
if (!m_revalidatingRequest.isNull())
m_revalidatingRequest = ResourceRequest();
if (!m_error.isNull() && (m_error.isCancellation() || !isPreloaded()))
memoryCache()->remove(this);
setStatus(status);
ASSERT(errorOccurred());
m_data.clear();
setLoading(false);
checkNotify();
markClientsFinished();
}
示例11: request
void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const
{
if (m_isCachePending || !m_cachedImage || !document.fetcher())
return;
if (document.fetcher()->cachedResource(KURL(ParsedURLString, m_absoluteURL)))
return;
ImageResource* resource = m_cachedImage->cachedImage();
if (!resource)
return;
FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isEmpty() ? FetchInitiatorTypeNames::css : m_initiatorName, resource->options());
MixedContentChecker::shouldBlockFetch(document.frame(), resource->lastResourceRequest(),
resource->lastResourceRequest().url(), MixedContentChecker::SendReport);
document.fetcher()->requestLoadStarted(resource, request, ResourceFetcher::ResourceLoadingFromCache);
}
示例12: SetUp
void SetUp() override
{
url = KURL(KURL(), "https://example.test/foo");
securityInfo = "security info";
mainResourceUrl = KURL(KURL(), "https://www.example.test");
MockFrameLoaderClient* client = new MockFrameLoaderClient;
EXPECT_CALL(*client, didDisplayContentWithCertificateErrors(url, securityInfo));
dummyPageHolder = DummyPageHolder::create(IntSize(500, 500), nullptr, client);
dummyPageHolder->page().setDeviceScaleFactor(1.0);
documentLoader = DocumentLoader::create(&dummyPageHolder->frame(), ResourceRequest(mainResourceUrl), SubstituteData());
document = toHTMLDocument(&dummyPageHolder->document());
document->setURL(mainResourceUrl);
fetchContext = static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context());
owner = DummyFrameOwner::create();
FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
}
示例13: ResourceRequest
void ResourceLoader::setDefersLoading(bool defers)
{
if (m_options.defersLoadingPolicy() == DefersLoadingPolicy::DisallowDefersLoading)
return;
m_defersLoading = defers;
if (m_handle)
m_handle->setDefersLoading(defers);
if (!defers && !m_deferredRequest.isNull()) {
m_request = m_deferredRequest;
m_deferredRequest = ResourceRequest();
start();
}
platformStrategies()->loaderStrategy()->resourceLoadScheduler()->setDefersLoading(this, defers);
}
示例14: request
void IconLoader::startLoading()
{
if (m_resource || !m_frame.document())
return;
CachedResourceRequest request(ResourceRequest(m_frame.loader().icon().url()), ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForAnyCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo));
request.mutableResourceRequest().setPriority(ResourceLoadPriorityLow);
request.setInitiator(cachedResourceRequestInitiators().icon);
m_resource = m_frame.document()->cachedResourceLoader().requestRawResource(request);
if (m_resource)
m_resource->addClient(this);
else
LOG_ERROR("Failed to start load for icon at url %s", m_frame.loader().icon().url().string().ascii().data());
}
示例15: URL
void StyleRuleImport::requestStyleSheet()
{
if (!m_parentStyleSheet)
return;
Document* document = m_parentStyleSheet->singleOwnerDocument();
if (!document)
return;
CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
if (!cachedResourceLoader)
return;
URL absURL;
if (!m_parentStyleSheet->baseURL().isNull())
// use parent styleheet's URL as the base URL
absURL = URL(m_parentStyleSheet->baseURL(), m_strHref);
else
absURL = document->completeURL(m_strHref);
// Check for a cycle in our import chain. If we encounter a stylesheet
// in our parent chain with the same URL, then just bail.
StyleSheetContents* rootSheet = m_parentStyleSheet;
for (StyleSheetContents* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
if (equalIgnoringFragmentIdentifier(absURL, sheet->baseURL())
|| equalIgnoringFragmentIdentifier(absURL, document->completeURL(sheet->originalURL())))
return;
rootSheet = sheet;
}
CachedResourceRequest request(ResourceRequest(absURL), m_parentStyleSheet->charset());
request.setInitiator(cachedResourceRequestInitiators().css);
if (m_cachedSheet)
m_cachedSheet->removeClient(&m_styleSheetClient);
if (m_parentStyleSheet->isUserStyleSheet())
m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request);
else
m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request);
if (m_cachedSheet) {
// if the import rule is issued dynamically, the sheet may be
// removed from the pending sheet count, so let the doc know
// the sheet being imported is pending.
if (m_parentStyleSheet && m_parentStyleSheet->loadCompleted() && rootSheet == m_parentStyleSheet)
m_parentStyleSheet->startLoadingDynamicSheet();
m_loading = true;
m_cachedSheet->addClient(&m_styleSheetClient);
}
}