void PluginView::cancelManualStreamLoad() { if (!frame()) return; DocumentLoader* documentLoader = frame()->loader()->activeDocumentLoader(); ASSERT(documentLoader); if (documentLoader->isLoadingMainResource()) documentLoader->cancelMainResourceLoad(frame()->loader()->cancelledError(m_parameters.url)); }
void ApplicationCacheGroup::deliverDelayedMainResources() { // Need to copy loaders, because the cache group may be destroyed at the end of iteration. Vector<DocumentLoader*> loaders; copyToVector(m_pendingMasterResourceLoaders, loaders); size_t count = loaders.size(); for (size_t i = 0; i != count; ++i) { DocumentLoader* loader = loaders[i]; if (loader->isLoadingMainResource()) continue; const ResourceError& error = loader->mainDocumentError(); if (error.isNull()) finishedLoadingMainResource(loader); else failedLoadingMainResource(loader); } if (!count) checkIfLoadIsComplete(); }
void PluginStream::stop() { m_streamState = StreamStopped; if (m_loadManually) { ASSERT(!m_loader); DocumentLoader* documentLoader = m_frame->loader()->activeDocumentLoader(); ASSERT(documentLoader); if (documentLoader->isLoadingMainResource()) documentLoader->cancelMainResourceLoad(m_frame->loader()->cancelledError(m_resourceRequest)); return; } if (m_loader) { m_loader->cancel(); m_loader = 0; } }
//+ 11/23/09 CSidhall - added bool WebFrame::isDocLoading() { const bool loading = false; Frame* coreFrame = core(this); if( (!coreFrame) && (!coreFrame->loader()) ) return loading; DocumentLoader* pDocLoader = coreFrame->loader()->documentLoader(); if(!pDocLoader) return loading; if( (pDocLoader->isLoading()) || (pDocLoader->isLoadingSubresources()) || (pDocLoader->isLoadingMainResource()) || (pDocLoader->isLoadingPlugIns()) ) { return true; } return loading; }
BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForLoad(const URL& url, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader) { if (m_contentExtensions.isEmpty()) return { }; Document* currentDocument = nullptr; URL mainDocumentURL; if (Frame* frame = initiatingDocumentLoader.frame()) { currentDocument = frame->document(); if (initiatingDocumentLoader.isLoadingMainResource() && frame->isMainFrame() && resourceType == ResourceType::Document) mainDocumentURL = url; else if (Document* mainDocument = frame->mainFrame().document()) mainDocumentURL = mainDocument->url(); } ResourceLoadInfo resourceLoadInfo = { url, mainDocumentURL, resourceType }; Vector<ContentExtensions::Action> actions = actionsForResourceLoad(resourceLoadInfo); bool willBlockLoad = false; bool willBlockCookies = false; bool willMakeHTTPS = false; for (const auto& action : actions) { switch (action.type()) { case ContentExtensions::ActionType::BlockLoad: willBlockLoad = true; break; case ContentExtensions::ActionType::BlockCookies: willBlockCookies = true; break; case ContentExtensions::ActionType::CSSDisplayNoneSelector: if (resourceType == ResourceType::Document) initiatingDocumentLoader.addPendingContentExtensionDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID()); else if (currentDocument) currentDocument->extensionStyleSheets().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID()); break; case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: { StyleSheetContents* styleSheetContents = globalDisplayNoneStyleSheet(action.stringArgument()); if (styleSheetContents) { if (resourceType == ResourceType::Document) initiatingDocumentLoader.addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents); else if (currentDocument) currentDocument->extensionStyleSheets().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents); } break; } case ContentExtensions::ActionType::MakeHTTPS: { if ((url.protocolIs("http") || url.protocolIs("ws")) && (!url.port() || isDefaultPortForProtocol(url.port().value(), url.protocol()))) willMakeHTTPS = true; break; } case ContentExtensions::ActionType::IgnorePreviousRules: case ContentExtensions::ActionType::InvalidAction: RELEASE_ASSERT_NOT_REACHED(); } } if (currentDocument) { if (willMakeHTTPS) { ASSERT(url.protocolIs("http") || url.protocolIs("ws")); String newProtocol = url.protocolIs("http") ? ASCIILiteral("https") : ASCIILiteral("wss"); currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker promoted URL from ", url.string(), " to ", newProtocol)); } if (willBlockLoad) currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", mainDocumentURL.string(), " from loading a resource from ", url.string())); } return { willBlockLoad, willBlockCookies, willMakeHTTPS }; }
BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForLoad(ResourceRequest& request, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader) { Document* currentDocument = nullptr; URL mainDocumentURL; if (Frame* frame = initiatingDocumentLoader.frame()) { currentDocument = frame->document(); if (initiatingDocumentLoader.isLoadingMainResource() && frame->isMainFrame() && resourceType == ResourceType::Document) mainDocumentURL = request.url(); else if (Document* mainDocument = frame->mainFrame().document()) mainDocumentURL = mainDocument->url(); } ResourceLoadInfo resourceLoadInfo = { request.url(), mainDocumentURL, resourceType }; Vector<ContentExtensions::Action> actions = actionsForResourceLoad(resourceLoadInfo); bool willBlockLoad = false; for (const auto& action : actions) { switch (action.type()) { case ContentExtensions::ActionType::BlockLoad: willBlockLoad = true; break; case ContentExtensions::ActionType::BlockCookies: request.setAllowCookies(false); break; case ContentExtensions::ActionType::CSSDisplayNoneSelector: if (resourceType == ResourceType::Document) initiatingDocumentLoader.addPendingContentExtensionDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID()); else if (currentDocument) currentDocument->extensionStyleSheets().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID()); break; case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: { StyleSheetContents* styleSheetContents = globalDisplayNoneStyleSheet(action.stringArgument()); if (styleSheetContents) { if (resourceType == ResourceType::Document) initiatingDocumentLoader.addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents); else if (currentDocument) currentDocument->extensionStyleSheets().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents); } break; } case ContentExtensions::ActionType::MakeHTTPS: { const URL originalURL = request.url(); if (originalURL.protocolIs("http") && (!originalURL.hasPort() || isDefaultPortForProtocol(originalURL.port(), originalURL.protocol()))) { URL newURL = originalURL; newURL.setProtocol("https"); if (originalURL.hasPort()) newURL.setPort(defaultPortForProtocol("https")); request.setURL(newURL); if (resourceType == ResourceType::Document && initiatingDocumentLoader.isLoadingMainResource()) { // This is to make sure the correct 'new' URL shows in the location bar. initiatingDocumentLoader.request().setURL(newURL); initiatingDocumentLoader.frameLoader()->client().dispatchDidChangeProvisionalURL(); } if (currentDocument) currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker promoted URL from ", originalURL.string(), " to ", newURL.string())); } break; } case ContentExtensions::ActionType::IgnorePreviousRules: case ContentExtensions::ActionType::InvalidAction: RELEASE_ASSERT_NOT_REACHED(); } } if (willBlockLoad) { if (currentDocument) currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", mainDocumentURL.string(), " from loading a resource from ", request.url().string())); return BlockedStatus::Blocked; } return BlockedStatus::NotBlocked; }