// static void InspectorPageAgent::resourceContent(ErrorString* errorString, Frame* frame, const KURL& url, String* result, bool* base64Encoded) { if (!frame) { *errorString = "No frame to get resource content for"; return; } FrameLoader* frameLoader = frame->loader(); DocumentLoader* loader = frameLoader->documentLoader(); if (!loader) { *errorString = "No documentLoader for frame to get resource content for"; return; } RefPtr<SharedBuffer> buffer; bool success = false; if (equalIgnoringFragmentIdentifier(url, loader->url())) { *base64Encoded = false; success = mainResourceContent(frame, *base64Encoded, result); } if (!success) success = cachedResourceContent(cachedResource(frame, url), result, base64Encoded); if (!success) *errorString = "No resource with given URL found"; }
// static void InspectorPageAgent::resourceContent(ErrorString* errorString, LocalFrame* frame, const KURL& url, String* result, bool* base64Encoded) { DocumentLoader* loader = assertDocumentLoader(errorString, frame); if (!loader) return; if (!cachedResourceContent(cachedResource(frame, url), result, base64Encoded)) *errorString = "No resource with given URL found"; }
void InspectorPageAgent::searchInResources(ErrorString*, const String& text, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<InspectorArray>* object) { RefPtr<InspectorArray> result = InspectorArray::create(); bool isRegex = optionalIsRegex ? *optionalIsRegex : false; String regexSource = isRegex ? text : createSearchRegexSource(text); bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; RegularExpression regex(regexSource, caseSensitive ? TextCaseSensitive : TextCaseInsensitive); for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) { String content; bool base64Encoded; Vector<CachedResource*> allResources = cachedResourcesForFrame(frame); for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) { CachedResource* cachedResource = *it; switch (InspectorPageAgent::cachedResourceType(*cachedResource)) { case InspectorPageAgent::StylesheetResource: case InspectorPageAgent::ScriptResource: if (cachedResourceContent(cachedResource, &content, &base64Encoded)) { ASSERT(!base64Encoded); int matchesCount = countRegularExpressionMatches(regex, content); if (matchesCount) result->pushValue(buildObjectForSearchMatch(frameId(frame), cachedResource->url(), matchesCount)); } break; default: break; } } if (mainResourceContent(frame, false, &content)) { int matchesCount = countRegularExpressionMatches(regex, content); if (matchesCount) result->pushValue(buildObjectForSearchMatch(frameId(frame), frame->document()->url(), matchesCount)); } } *object = result; }