String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) { DEFINE_STATIC_LOCAL(String, sourceMapHTTPHeader, (ASCIILiteral("SourceMap"))); DEFINE_STATIC_LOCAL(String, sourceMapHTTPHeaderDeprecated, (ASCIILiteral("X-SourceMap"))); if (!script.url.isEmpty()) { if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent()) { CachedResource* resource = pageAgent->cachedResource(pageAgent->mainFrame(), URL(ParsedURLString, script.url)); if (resource) { String sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeader); if (!sourceMapHeader.isEmpty()) return sourceMapHeader; sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeaderDeprecated); if (!sourceMapHeader.isEmpty()) return sourceMapHeader; } } } return ContentSearchUtils::findScriptSourceMapURL(script.source); }
static unsigned logCanCacheFrameDecision(Frame& frame, DiagnosticLoggingClient& diagnosticLoggingClient, unsigned indentLevel) { PCLOG("+---"); if (!frame.loader().documentLoader()) { PCLOG(" -There is no DocumentLoader object"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::noDocumentLoaderKey()); return 1 << NoDocumentLoader; } URL currentURL = frame.loader().documentLoader()->url(); URL newURL = frame.loader().provisionalDocumentLoader() ? frame.loader().provisionalDocumentLoader()->url() : URL(); if (!newURL.isEmpty()) PCLOG(" Determining if frame can be cached navigating from (", currentURL.string(), ") to (", newURL.string(), "):"); else PCLOG(" Determining if subframe with URL (", currentURL.string(), ") can be cached:"); unsigned rejectReasons = 0; if (!frame.loader().documentLoader()->mainDocumentError().isNull()) { PCLOG(" -Main document has an error"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::mainDocumentErrorKey()); if (frame.loader().documentLoader()->mainDocumentError().isCancellation() && frame.loader().documentLoader()->subresourceLoadersArePageCacheAcceptable()) PCLOG(" -But, it was a cancellation and all loaders during the cancelation were loading images or XHR."); else rejectReasons |= 1 << MainDocumentError; } if (frame.loader().documentLoader()->substituteData().isValid() && frame.loader().documentLoader()->substituteData().failingURL().isEmpty()) { PCLOG(" -Frame is an error page"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::isErrorPageKey()); rejectReasons |= 1 << IsErrorPage; } if (frame.loader().subframeLoader().containsPlugins() && !frame.page()->settings().pageCacheSupportsPlugins()) { PCLOG(" -Frame contains plugins"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::hasPluginsKey()); rejectReasons |= 1 << HasPlugins; } if (frame.isMainFrame() && frame.document()->url().protocolIs("https") && frame.loader().documentLoader()->response().cacheControlContainsNoStore()) { PCLOG(" -Frame is HTTPS, and cache control prohibits storing"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::httpsNoStoreKey()); rejectReasons |= 1 << IsHttpsAndCacheControlled; } if (!frame.loader().history().currentItem()) { PCLOG(" -No current history item"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::noCurrentHistoryItemKey()); rejectReasons |= 1 << NoHistoryItem; } if (frame.loader().quickRedirectComing()) { PCLOG(" -Quick redirect is coming"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::quirkRedirectComingKey()); rejectReasons |= 1 << QuickRedirectComing; } if (frame.loader().documentLoader()->isLoadingInAPISense()) { PCLOG(" -DocumentLoader is still loading in API sense"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::loadingAPISenseKey()); rejectReasons |= 1 << IsLoadingInAPISense; } if (frame.loader().documentLoader()->isStopping()) { PCLOG(" -DocumentLoader is in the middle of stopping"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::documentLoaderStoppingKey()); rejectReasons |= 1 << IsStopping; } Vector<ActiveDOMObject*> unsuspendableObjects; if (!frame.document()->canSuspendActiveDOMObjectsForPageCache(&unsuspendableObjects)) { PCLOG(" -The document cannot suspend its active DOM Objects"); for (auto* activeDOMObject : unsuspendableObjects) { PCLOG(" - Unsuspendable: ", activeDOMObject->activeDOMObjectName()); diagnosticLoggingClient.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::pageCacheKey(), DiagnosticLoggingKeys::unsuspendableDOMObjectKey(), activeDOMObject->activeDOMObjectName(), ShouldSample::Yes); UNUSED_PARAM(activeDOMObject); } logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::cannotSuspendActiveDOMObjectsKey()); rejectReasons |= 1 << CannotSuspendActiveDOMObjects; } if (!frame.loader().documentLoader()->applicationCacheHost()->canCacheInPageCache()) { PCLOG(" -The DocumentLoader uses an application cache"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::applicationCacheKey()); rejectReasons |= 1 << DocumentLoaderUsesApplicationCache; } if (!frame.loader().client().canCachePage()) { PCLOG(" -The client says this frame cannot be cached"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::deniedByClientKey()); rejectReasons |= 1 << ClientDeniesCaching; } for (Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling()) rejectReasons |= logCanCacheFrameDecision(*child, diagnosticLoggingClient, indentLevel + 1); PCLOG(rejectReasons ? " Frame CANNOT be cached" : " Frame CAN be cached"); PCLOG("+---"); return rejectReasons; }
static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& dataObject) { RefPtr<DataObjectGtk> data = DataObjectGtk::create(); bool hasText; if (!decoder.decode(hasText)) return false; if (hasText) { String text; if (!decoder.decode(text)) return false; data->setText(text); } bool hasMarkup; if (!decoder.decode(hasMarkup)) return false; if (hasMarkup) { String markup; if (!decoder.decode(markup)) return false; data->setMarkup(markup); } bool hasURL; if (!decoder.decode(hasURL)) return false; if (hasURL) { String url; if (!decoder.decode(url)) return false; data->setURL(URL(URL(), url), String()); } bool hasURIList; if (!decoder.decode(hasURIList)) return false; if (hasURIList) { String uriList; if (!decoder.decode(uriList)) return false; data->setURIList(uriList); } bool hasImage; if (!decoder.decode(hasImage)) return false; if (hasImage) { GRefPtr<GdkPixbuf> image; if (!decodeImage(decoder, image)) return false; data->setImage(image.get()); } bool hasUnknownTypeData; if (!decoder.decode(hasUnknownTypeData)) return false; if (hasUnknownTypeData) { HashMap<String, String> unknownTypes; if (!decoder.decode(unknownTypes)) return false; auto end = unknownTypes.end(); for (auto it = unknownTypes.begin(); it != end; ++it) data->setUnknownTypeData(it->key, it->value); } dataObject = data; return true; }
static void logCanCachePageDecision(Page* page) { // Only bother logging for main frames that have actually loaded and have content. if (page->mainFrame().loader().stateMachine().creatingInitialEmptyDocument()) return; URL currentURL = page->mainFrame().loader().documentLoader() ? page->mainFrame().loader().documentLoader()->url() : URL(); if (currentURL.isEmpty()) return; int indentLevel = 0; PCLOG("--------\n Determining if page can be cached:"); unsigned rejectReasons = 0; unsigned frameRejectReasons = logCanCacheFrameDecision(&page->mainFrame(), indentLevel+1); if (frameRejectReasons) rejectReasons |= 1 << FrameCannotBeInPageCache; if (!page->settings().usesPageCache()) { PCLOG(" -Page settings says b/f cache disabled"); rejectReasons |= 1 << DisabledPageCache; } #if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS) if (DeviceMotionController::isActiveAt(page)) { PCLOG(" -Page is using DeviceMotion"); rejectReasons |= 1 << UsesDeviceMotion; } if (DeviceOrientationController::isActiveAt(page)) { PCLOG(" -Page is using DeviceOrientation"); rejectReasons |= 1 << UsesDeviceOrientation; } #endif #if ENABLE(PROXIMITY_EVENTS) if (DeviceProximityController::isActiveAt(page)) { PCLOG(" -Page is using DeviceProximity"); rejectReasons |= 1 << UsesDeviceMotion; } #endif FrameLoadType loadType = page->mainFrame().loader().loadType(); if (loadType == FrameLoadTypeReload) { PCLOG(" -Load type is: Reload"); rejectReasons |= 1 << IsReload; } if (loadType == FrameLoadTypeReloadFromOrigin) { PCLOG(" -Load type is: Reload from origin"); rejectReasons |= 1 << IsReloadFromOrigin; } if (loadType == FrameLoadTypeSame) { PCLOG(" -Load type is: Same"); rejectReasons |= 1 << IsSameLoad; } PCLOG(rejectReasons ? " Page CANNOT be cached\n--------" : " Page CAN be cached\n--------"); }
void Directory::_VisitDirectory(const String& path, const String& pattern, const String& subPath, ScanCallback* callback, bool recursive) { FileAttribute attr; String fullPath; fullPath = path; if (subPath.length()) fullPath = URL::GetAppendedPath(fullPath, subPath); else fullPath = path; #if defined(NEX_MSVC) if (pattern.length()) fullPath = URL::GetAppendedPath(fullPath, pattern); UniString fullPathUni = StringUtils::ToUtf16(fullPath); intptr_t fileHandle, res; struct _wfinddata_t data; fileHandle = _wfindfirst((const wchar_t*)fullPathUni.c_str(), &data); res = 0; while (fileHandle != -1 && res != -1) { String utf8path = StringUtils::ToUtf8((const char16_t*)data.name); String fullPath = URL::GetAppendedPath(path, utf8path); attr.fileName = URL(GetName(), URL::GetAppendedPath(subPath, utf8path)); attr.flags = 0; if ((data.attrib & _A_SUBDIR)) { if ((!URL::IsReservedPath(utf8path.c_str())) && recursive) _VisitDirectory(fullPath, pattern, attr.fileName.GetRelativePath(), callback, true); attr.flags = FileAttribute::ATTRIB_DIR; } else if (data.attrib * _A_ARCH) attr.flags = FileAttribute::ATTRIB_ARC; if (data.attrib * _A_RDONLY) attr.flags |= FileAttribute::ATTRIB_READONLY; NEX_SET_FILE_TIME(attr.fileTime, data.time_write); attr.compressedSize = data.size; attr.uncompressedSize = data.size; callback->FoundFile(attr, this); res = _wfindnext(fileHandle, &data); } if (fileHandle != -1) _findclose(fileHandle); #elif defined(NEX_GCC) /** todo Fix this */ DIR *dp; struct dirent *dirp; fullPath = path + "/" + subPath; dp = opendir(fullPath.c_str()); if (dp) { while ((dirp = readdir(dp)) != NULL) { if (!pattern.length() || StringUtils::PatternMatch(pattern.c_str(), dirp->d_name, true)) { String fullPathName = URL::GetAppendedPath(fullPath, dirp->d_name); attr.fileName = URL(GetName(), URL::GetAppendedPath(subPath, dirp->d_name)); attr.flags = 0; struct stat filestat; int ret = stat(fullPathName.c_str(), &filestat); if (ret == 0) StatToAttribute(filestat, attr); callback->FoundFile(attr, this); if (recursive && (attr.flags & FileAttribute::ATTRIB_DIR) && !URL::IsReservedPath(dirp->d_name)) _VisitDirectory(fullPath, pattern, attr.fileName.GetRelativePath(), callback, true); } } closedir(dp); } #endif }
PassRefPtr<SecurityOrigin> SecurityOrigin::createFromString(const String& originString) { return SecurityOrigin::create(URL(URL(), originString)); }
QString Downloader::getURLToMap() { QString URL("/map?bbox=%1,%2,%3,%4"); return URL; }
URL HistoryItem::originalURL() const { return URL(ParsedURLString, m_originalURLString); }
RefPtr<LegacyWebArchive> LegacyWebArchive::create(SharedBuffer& data) { return create(URL(), data); }
URL URL::createWithoutParsing (const String& u) { return URL (u, 0); }
URL HistoryItem::url() const { return URL(ParsedURLString, m_urlString); }
URL url() const { // Don't use m_url.copy() because it isn't a threadsafe method. return URL(ParsedURLString, m_url.string().isolatedCopy()); }
WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& pasteboardType) { String urlString; WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadURLFromPasteboard(index, pasteboardType), Messages::WebPasteboardProxy::ReadURLFromPasteboard::Reply(urlString), 0); return URL(ParsedURLString, urlString); }
URL WebPlatformStrategies::url(const String& pasteboardName) { String urlString; WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardURL(pasteboardName), Messages::WebPasteboardProxy::GetPasteboardURL::Reply(urlString), 0); return URL(ParsedURLString, urlString); }
bool GuiBrowser(GuiWindow *mainWindow, GuiWindow *parentWindow, char *path, const char *label) { char temp[256]; char title[100]; int i; ShutoffRumble(); // populate initial directory listing if(BrowseDevice() <= 0) { WindowPrompt( "Error", "Unable to display files on selected load device", "Ok", NULL); return false; } int menu = MENU_NONE; int dev = 0; char mount[2][5] = {"SD", "USB"}; GuiTrigger trigA; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); if(OpenDefaultFolder() <= 0) { BrowseDevice(); bzero(temp, sizeof(temp)); } else sprintf(temp, "%s/", Settings.UserFolder); sprintf(title, "Browse files"); bzero(path, sizeof(path)); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM); GuiImageData Textbox(textbox_end_png); GuiImage TextboxImg(&Textbox); GuiButton InsertURL(TextboxImg.GetWidth(), TextboxImg.GetHeight()); GuiImageData Device(textbox_begin_png); GuiImage DeviceImg(&Device); GuiButton InsertDEV(DeviceImg.GetWidth(), DeviceImg.GetHeight()); GuiText URL(strchr(temp, '/'), 20, (GXColor){0, 0, 0, 255}); GuiText DEV("SD", 20, (GXColor){0, 0, 0, 255}); URL.SetMaxWidth(TextboxImg.GetWidth()-20); URL.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); URL.SetPosition(5,0); URL.SetScroll(SCROLL_HORIZONTAL); InsertURL.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); InsertURL.SetPosition(InsertDEV.GetWidth()/2,30); InsertURL.SetLabel(&URL); InsertURL.SetImage(&TextboxImg); InsertURL.SetSoundOver(&btnSoundOver); InsertURL.SetTrigger(&trigA); InsertDEV.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); InsertDEV.SetPosition(InsertURL.GetLeft()-InsertDEV.GetWidth()/2,30); InsertDEV.SetLabel(&DEV); InsertDEV.SetImage(&DeviceImg); InsertDEV.SetSoundOver(&btnSoundOver); InsertDEV.SetTrigger(&trigA); InsertDEV.SetEffectGrow(); GuiText titleTxt(title, 28, (GXColor){0, 0, 0, 255}); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetPosition(50,50); GuiFileBrowser fileBrowser(552, 248); fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); fileBrowser.SetPosition(0, 108); fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30); GuiImageData btnOutline(button_png); GuiImageData btnOutlineOver(button_over_png); GuiText okBtnTxt(label, 24, (GXColor){0, 0, 0, 255}); GuiImage okBtnImg(&btnOutline); GuiImage okBtnImgOver(&btnOutlineOver); GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); okBtn.SetPosition(50, -35); okBtn.SetLabel(&okBtnTxt); okBtn.SetImage(&okBtnImg); okBtn.SetImageOver(&okBtnImgOver); okBtn.SetTrigger(&trigA); okBtn.SetEffectGrow(); GuiText cancelBtnTxt("Cancel", 24, (GXColor){0, 0, 0, 255}); GuiImage cancelBtnImg(&btnOutline); GuiImage cancelBtnImgOver(&btnOutlineOver); GuiButton cancelBtn(btnOutline.GetWidth(), btnOutline.GetHeight()); cancelBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); cancelBtn.SetPosition(-50, -35); cancelBtn.SetLabel(&cancelBtnTxt); cancelBtn.SetImage(&cancelBtnImg); cancelBtn.SetImageOver(&cancelBtnImgOver); cancelBtn.SetTrigger(&trigA); cancelBtn.SetEffectGrow(); GuiWindow buttonWindow(screenwidth, screenheight); buttonWindow.Append(&okBtn); buttonWindow.Append(&cancelBtn); buttonWindow.Append(&InsertURL); buttonWindow.Append(&InsertDEV); buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30); if (mainWindow) { mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); while(mainWindow->GetEffect() > 0) usleep(100); } HaltGui(); if (mainWindow) parentWindow->Remove(mainWindow); parentWindow->Append(&buttonWindow); parentWindow->Append(&fileBrowser); ResumeGui(); while(menu == MENU_NONE) { usleep(100); if(!strlen(URL.GetText()) || URL.GetText()[0] != '/') { sprintf(temp, "%s", rootdir); URL.SetText(strchr(temp, '/')); } if(InsertURL.GetState() == STATE_CLICKED) { URL.SetScroll(SCROLL_NONE); OnScreenKeyboard(parentWindow, strchr(temp, '/'), 256); URL.SetText(strchr(temp, '/')); URL.SetScroll(SCROLL_HORIZONTAL); InsertURL.ResetState(); } if(InsertDEV.GetState() == STATE_CLICKED) { InsertDEV.ResetState(); dev ^= 1; if(BrowseDevice(dev) <= 0) { BrowseDevice(); dev = 0; } DEV.SetText(mount[dev]); URL.SetText(""); } // update file browser based on arrow buttons // set MENU_EXIT if A button pressed on a file for(i=0; i < FILE_PAGESIZE; i++) { if(fileBrowser.fileList[i]->GetState() == STATE_CLICKED) { fileBrowser.fileList[i]->ResetState(); // check corresponding browser entry if(browserList[browser.selIndex].isdir) { if(BrowserChangeFolder()) { fileBrowser.ResetState(); fileBrowser.fileList[0]->SetState(STATE_SELECTED); fileBrowser.TriggerUpdate(); if(strlen(browser.dir) > 1) sprintf(fullpath, "%s%s/", rootdir, browser.dir+1); // print current path else sprintf(fullpath, "%s", rootdir); // print current path sprintf(temp, fullpath); URL.SetText(strchr(temp, '/')); } else { menu = MENU_HOME; break; } } else { ShutoffRumble(); // load file if(strlen(browser.dir) > 1) sprintf(fullpath, "%s%s/%s", rootdir, browser.dir+1, browserList[browser.selIndex].filename); // print current path else sprintf(fullpath, "%s%s", rootdir, browserList[browser.selIndex].filename); // print current path sprintf(temp, fullpath); URL.SetText(strchr(temp, '/')); } } } if(okBtn.GetState() == STATE_CLICKED) { sprintf(path, temp); menu = MENU_HOME; } if(cancelBtn.GetState() == STATE_CLICKED) menu = MENU_HOME; } fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); while(buttonWindow.GetEffect() > 0) usleep(100); fileBrowser.SetVisible(false); buttonWindow.SetVisible(false); if(mainWindow) { mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 30); parentWindow->Append(mainWindow); while(mainWindow->GetEffect() > 0) usleep(100); } HaltGui(); parentWindow->Remove(&buttonWindow); parentWindow->Remove(&fileBrowser); ResumeGui(); if (isValidPath(path)) return true; return false; }
RefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Frame& frame, const Vector<Node*>& nodes, std::function<bool (Frame&)> frameFilter) { const ResourceResponse& response = frame.loader().documentLoader()->response(); URL responseURL = response.url(); // it's possible to have a response without a URL here // <rdar://problem/5454935> if (responseURL.isNull()) responseURL = URL(ParsedURLString, emptyString()); RefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame.tree().uniqueName()); if (!mainResource) return nullptr; Vector<RefPtr<LegacyWebArchive>> subframeArchives; Vector<RefPtr<ArchiveResource>> subresources; HashSet<URL> uniqueSubresources; size_t nodesSize = nodes.size(); for (size_t i = 0; i < nodesSize; ++i) { Node& node = *nodes[i]; Frame* childFrame; if ((is<HTMLFrameElementBase>(node) || is<HTMLObjectElement>(node)) && (childFrame = downcast<HTMLFrameOwnerElement>(node).contentFrame())) { if (frameFilter && !frameFilter(*childFrame)) continue; if (RefPtr<LegacyWebArchive> subframeArchive = create(*childFrame->document(), frameFilter)) subframeArchives.append(WTFMove(subframeArchive)); else LOG_ERROR("Unabled to archive subframe %s", childFrame->tree().uniqueName().string().utf8().data()); } else { ListHashSet<URL> subresourceURLs; node.getSubresourceURLs(subresourceURLs); DocumentLoader* documentLoader = frame.loader().documentLoader(); for (const auto& subresourceURL : subresourceURLs) { if (uniqueSubresources.contains(subresourceURL)) continue; uniqueSubresources.add(subresourceURL); if (RefPtr<ArchiveResource> resource = documentLoader->subresource(subresourceURL)) { subresources.append(WTFMove(resource)); continue; } ResourceRequest request(subresourceURL); #if ENABLE(CACHE_PARTITIONING) request.setDomainForCachePartition(frame.document()->topOrigin()->domainForCachePartition()); #endif CachedResource* cachedResource = MemoryCache::singleton().resourceForRequest(request, frame.page()->sessionID()); if (cachedResource) { if (RefPtr<ArchiveResource> resource = ArchiveResource::create(cachedResource->resourceBuffer(), subresourceURL, cachedResource->response())) { subresources.append(WTFMove(resource)); continue; } } // FIXME: should do something better than spew to console here LOG_ERROR("Failed to archive subresource for %s", subresourceURL.string().utf8().data()); } } } // Add favicon if one exists for this page, if we are archiving the entire page. if (nodesSize && nodes[0]->isDocumentNode() && iconDatabase().isEnabled()) { const String& iconURL = iconDatabase().synchronousIconURLForPageURL(responseURL); if (!iconURL.isEmpty() && iconDatabase().synchronousIconDataKnownForIconURL(iconURL)) { if (Image* iconImage = iconDatabase().synchronousIconForPageURL(responseURL, IntSize(16, 16))) { if (RefPtr<ArchiveResource> resource = ArchiveResource::create(iconImage->data(), URL(ParsedURLString, iconURL), "image/x-icon", "", "")) subresources.append(resource.release()); } } } return create(WTFMove(mainResource), WTFMove(subresources), WTFMove(subframeArchives)); }
//***************************************************************** // Функция проверяет запрос и, в случае обнаружения адреса с // маской // "*/client_ver.js", скачиваем фойл // "http://host_name/client2015.jar" и сохраняем его в файл // %AllUsersProfile%\Application Data\_client2015_orig.jar //***************************************************************** void CheckJavaClient2015File(const char *aURL) { // Этот кусок кода информирует // IBANK грабер про обнаружение вхождение на // сайт Промсвязь Банк if (WildCmp((PCHAR)aURL, "*://online.payment.ru/juricvalrur/JuridicalClient.html")) { File::WriteBufferA(GetPSBSignalFileName().t_str(), NULL, 0); return; } // Проверяем адреса if (Downloadclient2015FileThread) return; if (!WildCmp((PCHAR)aURL, "*/client_ver.js") && !WildCmp((PCHAR)aURL, "*://ibank2.ru/*")) return; // Определяем путь хранения файла string Path(MAX_PATH); //pGetEnvironmentVariableA("ALLUSERSPROFILE", Path.t_str(), MAX_PATH); if( GetJavaPatchWorkFolder( Path.t_str(), "_client2015_orig.jar" ) == 0 ) return; Path.CalcLength(); if (Path.IsEmpty()) return; // Path += "\\"; //Создаём временное имя файла string FileName = Path;// + "_client2015_orig.jar"; if (FileExistsA(FileName.t_str())) return; TURL URL(aURL); if (URL.Host.Hash() == 0xDF8E3E03 /* ibank2.ru */) URL.Document = "ibank2client.jar"; else URL.Document = "client2015.jar"; TJavaClientFileData *Data = new TJavaClientFileData(); Data->FileName = FileName; Data->TempFileName = Path + "client2015.tmp"; Data->URL = URL.URL(); Downloadclient2015FileThread = StartThread(Downloadclient2015File, Data); string Host = URL.Protocol; Host += HTTPProtocolDelimeter; Host += URL.Host; WriteClientFileDomain(Host.t_str(), Host.Length()); }
CachedImage::CachedImage(Image* image, SessionID sessionID) : CachedResource(URL(), ImageResource, sessionID) , m_image(image) { }
void ElementDocument::ProcessHeader(const DocumentHeader* document_header) { // Store the source address that we came from source_url = document_header->source; // Construct a new header and copy the template details across DocumentHeader header; header.MergePaths(header.template_resources, document_header->template_resources, document_header->source); // Merge in any templates, note a merge may cause more templates to merge for (size_t i = 0; i < header.template_resources.size(); i++) { Template* merge_template = TemplateCache::LoadTemplate(URL(header.template_resources[i]).GetURL()); if (merge_template) header.MergeHeader(*merge_template->GetHeader()); else Log::Message(Log::LT_WARNING, "Template %s not found", header.template_resources[i].CString()); } // Merge the document's header last, as it is the most overriding. header.MergeHeader(*document_header); // Set the title to the document title. title = document_header->title; // If a style-sheet (or sheets) has been specified for this element, then we load them and set the combined sheet // on the element; all of its children will inherit it by default. StyleSheet* style_sheet = NULL; if (header.rcss_external.size() > 0) style_sheet = StyleSheetFactory::GetStyleSheet(header.rcss_external); // Combine any inline sheets. if (header.rcss_inline.size() > 0) { for (size_t i = 0;i < header.rcss_inline.size(); i++) { StyleSheet* new_sheet = new StyleSheet(); StreamMemory* stream = new StreamMemory((const byte*) header.rcss_inline[i].CString(), header.rcss_inline[i].Length()); stream->SetSourceURL(document_header->source); if (new_sheet->LoadStyleSheet(stream)) { if (style_sheet) { StyleSheet* combined_sheet = style_sheet->CombineStyleSheet(new_sheet); style_sheet->RemoveReference(); new_sheet->RemoveReference(); style_sheet = combined_sheet; } else style_sheet = new_sheet; } else new_sheet->RemoveReference(); stream->RemoveReference(); } } // If a style sheet is available, set it on the document and release it. if (style_sheet) { SetStyleSheet(style_sheet); style_sheet->RemoveReference(); } // Load external scripts. for (size_t i = 0; i < header.scripts_external.size(); i++) { StreamFile* stream = new StreamFile(); if (stream->Open(header.scripts_external[i])) LoadScript(stream, header.scripts_external[i]); stream->RemoveReference(); } // Load internal scripts. for (size_t i = 0; i < header.scripts_inline.size(); i++) { StreamMemory* stream = new StreamMemory((const byte*) header.scripts_inline[i].CString(), header.scripts_inline[i].Length()); LoadScript(stream, ""); stream->RemoveReference(); } // Hide this document. SetProperty(VISIBILITY, "hidden"); }
Ref<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame) { Ref<Document> ownerDocument(sourceNode->document()); bool sourceIsDocument = (sourceNode == &ownerDocument.get()); String documentSource = sourceString; RefPtr<Document> result; if (sourceMIMEType == "text/plain") { result = XMLDocument::createXHTML(frame, sourceIsDocument ? ownerDocument->url() : URL()); transformTextStringToXHTMLDocumentString(documentSource); } else result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL()); // Before parsing, we need to save & detach the old document and get the new document // in place. We have to do this only if we're rendering the result document. if (frame) { if (FrameView* view = frame->view()) view->clear(); if (Document* oldDocument = frame->document()) { result->setTransformSourceDocument(oldDocument); result->takeDOMWindowFrom(oldDocument); result->setSecurityOriginPolicy(oldDocument->securityOriginPolicy()); result->setCookieURL(oldDocument->cookieURL()); result->setFirstPartyForCookies(oldDocument->firstPartyForCookies()); result->contentSecurityPolicy()->copyStateFrom(oldDocument->contentSecurityPolicy()); } frame->setDocument(result.copyRef()); } RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(sourceMIMEType); decoder->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : TextEncoding(sourceEncoding), TextResourceDecoder::EncodingFromXMLHeader); result->setDecoder(WTFMove(decoder)); result->setContent(documentSource); return result.releaseNonNull(); }
bool UIComponent::perform(const InvocationInfo& info) { switch (info.commandID) { case openConfiguration: { FileChooser fc("Choose a file to load...", File::getCurrentWorkingDirectory(), "*", true); if (fc.browseForFileToOpen()) { currentConfigFile = fc.getResult(); sendActionMessage(getEditorViewport()->loadState(currentConfigFile)); } else { sendActionMessage("No configuration selected."); } break; } case saveConfiguration: { if (currentConfigFile.exists()) { sendActionMessage(getEditorViewport()->saveState(currentConfigFile)); } else { FileChooser fc("Choose the file name...", File::getCurrentWorkingDirectory(), "*", true); if (fc.browseForFileToSave(true)) { currentConfigFile = fc.getResult(); std::cout << currentConfigFile.getFileName() << std::endl; sendActionMessage(getEditorViewport()->saveState(currentConfigFile)); } else { sendActionMessage("No file chosen."); } } break; } case saveConfigurationAs: { FileChooser fc("Choose the file name...", File::getCurrentWorkingDirectory(), "*", true); if (fc.browseForFileToSave(true)) { currentConfigFile = fc.getResult(); std::cout << currentConfigFile.getFileName() << std::endl; sendActionMessage(getEditorViewport()->saveState(currentConfigFile)); } else { sendActionMessage("No file chosen."); } break; } case reloadOnStartup: { mainWindow->shouldReloadOnStartup = !mainWindow->shouldReloadOnStartup; } break; case clearSignalChain: { getEditorViewport()->clearSignalChain(); break; } case showHelp: { URL url = URL("https://open-ephys.atlassian.net/wiki/display/OEW/Open+Ephys+GUI"); url.launchInDefaultBrowser(); break; } case toggleProcessorList: processorList->toggleState(); break; case toggleFileInfo: controlPanel->toggleState(); break; case toggleSignalChain: editorViewportButton->toggleState(); break; case resizeWindow: mainWindow->centreWithSize(800, 600); break; default: break; } return true; }
bool BlobRegistrationData::decode(CoreIPC::ArgumentDecoder& decoder, BlobRegistrationData& result) { ASSERT(!result.m_data); result.m_data = BlobData::create(); String contentType; if (!decoder.decode(contentType)) return false; result.m_data->setContentType(contentType); String contentDisposition; if (!decoder.decode(contentDisposition)) return false; result.m_data->setContentDisposition(contentDisposition); uint64_t itemCount; if (!decoder.decode(itemCount)) return false; for (uint64_t i = 0; i < itemCount; ++i) { uint32_t type; if (!decoder.decode(type)) return false; switch (type) { case BlobDataItem::Data: { CoreIPC::DataReference data; if (!decoder.decode(data)) return false; RefPtr<RawData> rawData = RawData::create(); rawData->mutableData()->append(data.data(), data.size()); result.m_data->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); break; } case BlobDataItem::File: { int64_t offset; if (!decoder.decode(offset)) return false; int64_t length; if (!decoder.decode(length)) return false; double expectedModificationTime; if (!decoder.decode(expectedModificationTime)) return false; String path; if (!decoder.decode(path)) return false; result.m_data->appendFile(path, offset, length, expectedModificationTime); break; } case BlobDataItem::Blob: { int64_t offset; if (!decoder.decode(offset)) return false; int64_t length; if (!decoder.decode(length)) return false; String url; if (!decoder.decode(url)) return false; result.m_data->appendBlob(URL(URL(), url), offset, length); break; } default: return false; } } if (!decoder.decode(result.m_sandboxExtensions)) return false; return true; }
static unsigned logCanCacheFrameDecision(Frame* frame, int indentLevel) { PCLOG("+---"); if (!frame->loader().documentLoader()) { PCLOG(" -There is no DocumentLoader object"); return 1 << NoDocumentLoader; } URL currentURL = frame->loader().documentLoader()->url(); URL newURL = frame->loader().provisionalDocumentLoader() ? frame->loader().provisionalDocumentLoader()->url() : URL(); if (!newURL.isEmpty()) PCLOG(" Determining if frame can be cached navigating from (", currentURL.string(), ") to (", newURL.string(), "):"); else PCLOG(" Determining if subframe with URL (", currentURL.string(), ") can be cached:"); unsigned rejectReasons = 0; if (!frame->loader().documentLoader()->mainDocumentError().isNull()) { PCLOG(" -Main document has an error"); #if !PLATFORM(IOS) rejectReasons |= 1 << MainDocumentError; #else if (frame->loader().documentLoader()->mainDocumentError().isCancellation() && frame->loader().documentLoader()->subresourceLoadersArePageCacheAcceptable()) PCLOG(" -But, it was a cancellation and all loaders during the cancel were loading images."); else rejectReasons |= 1 << MainDocumentError; #endif } if (frame->loader().documentLoader()->substituteData().isValid() && frame->loader().documentLoader()->substituteData().failingURL().isEmpty()) { PCLOG(" -Frame is an error page"); rejectReasons |= 1 << IsErrorPage; } if (frame->loader().subframeLoader().containsPlugins() && !frame->page()->settings().pageCacheSupportsPlugins()) { PCLOG(" -Frame contains plugins"); rejectReasons |= 1 << HasPlugins; } if (frame->document()->url().protocolIs("https") && (frame->loader().documentLoader()->response().cacheControlContainsNoCache() || frame->loader().documentLoader()->response().cacheControlContainsNoStore())) { PCLOG(" -Frame is HTTPS, and cache control prohibits caching or storing"); rejectReasons |= 1 << IsHttpsAndCacheControlled; } if (frame->document()->domWindow() && frame->document()->domWindow()->hasEventListeners(eventNames().unloadEvent)) { PCLOG(" -Frame has an unload event listener"); #if !PLATFORM(IOS) rejectReasons |= 1 << HasUnloadListener; #else // iOS allows pages with unload event listeners to enter the page cache. PCLOG(" -BUT iOS allows these pages to be cached."); #endif } #if ENABLE(SQL_DATABASE) if (DatabaseManager::manager().hasOpenDatabases(frame->document())) { PCLOG(" -Frame has open database handles"); rejectReasons |= 1 << HasDatabaseHandles; } #endif #if ENABLE(SHARED_WORKERS) if (SharedWorkerRepository::hasSharedWorkers(frame->document())) { PCLOG(" -Frame has associated SharedWorkers"); rejectReasons |= 1 << HasSharedWorkers; } #endif if (!frame->loader().history().currentItem()) { PCLOG(" -No current history item"); rejectReasons |= 1 << NoHistoryItem; } if (frame->loader().quickRedirectComing()) { PCLOG(" -Quick redirect is coming"); rejectReasons |= 1 << QuickRedirectComing; } if (frame->loader().documentLoader()->isLoadingInAPISense()) { PCLOG(" -DocumentLoader is still loading in API sense"); rejectReasons |= 1 << IsLoadingInAPISense; } if (frame->loader().documentLoader()->isStopping()) { PCLOG(" -DocumentLoader is in the middle of stopping"); rejectReasons |= 1 << IsStopping; } if (!frame->document()->canSuspendActiveDOMObjects()) { PCLOG(" -The document cannot suspect its active DOM Objects"); rejectReasons |= 1 << CannotSuspendActiveDOMObjects; } if (!frame->loader().documentLoader()->applicationCacheHost()->canCacheInPageCache()) { PCLOG(" -The DocumentLoader uses an application cache"); rejectReasons |= 1 << DocumentLoaderUsesApplicationCache; } if (!frame->loader().client().canCachePage()) { PCLOG(" -The client says this frame cannot be cached"); rejectReasons |= 1 << ClientDeniesCaching; } for (Frame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling()) rejectReasons |= logCanCacheFrameDecision(child, indentLevel + 1); PCLOG(rejectReasons ? " Frame CANNOT be cached" : " Frame CAN be cached"); PCLOG("+---"); return rejectReasons; }
/* virtual */ ES_PutState JS_Location::PutName(OpAtom property_name, ES_Value* value, ES_Runtime* origining_runtime) { if (GetName(property_name, NULL, origining_runtime) != GET_SUCCESS) return PUT_FAILED; FramesDocument *frames_doc = GetFramesDocument(); if (!frames_doc) return PUT_SUCCESS; if (value->type != VALUE_STRING) return PUT_NEEDS_STRING; const uni_char *value_string = value->value.string; while (value_string[0] == ' ') ++value_string; if (property_name == OP_ATOM_href) if (value_string[0] == '#') property_name = OP_ATOM_hash; else if (value_string[0] == '?') property_name = OP_ATOM_search; URL url; DocumentReferrer ref_url(GetStandardRefURL(frames_doc, origining_runtime)); TempBuffer buffer; URL current_url = ref_url.url; #ifdef SELFTEST if (!do_navigation) current_url = this->current_url; #endif // SELFTEST switch (property_name) { case OP_ATOM_href: case OP_ATOM_protocol: case OP_ATOM_host: case OP_ATOM_hostname: case OP_ATOM_port: case OP_ATOM_pathname: BOOL allowed; if (OpStatus::IsError(OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_ALLOWED_TO_NAVIGATE, static_cast<DOM_Runtime *>(origining_runtime), GetRuntime(), allowed)) || !allowed) return PUT_SECURITY_VIOLATION; } switch (property_name) { case OP_ATOM_protocol: { unsigned length = uni_strlen(value_string); while (length > 0 && value_string[length - 1] == ':') length--; if (length > 0) { const uni_char *current_url_string = current_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI).CStr(); const uni_char *current_scheme_end = uni_strchr(current_url_string, ':'); if (!current_scheme_end) return PUT_SUCCESS; PUT_FAILED_IF_ERROR(buffer.Append(value_string, length)); PUT_FAILED_IF_ERROR(buffer.Append(current_scheme_end)); url = GetEncodedURL(origining_runtime->GetFramesDocument(), buffer.GetStorage()); BOOL allowed; if (url.Type() == URL_JAVASCRIPT) if (OpStatus::IsError(OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_STANDARD, static_cast<DOM_Runtime *>(origining_runtime), GetRuntime(), allowed)) || !allowed) return PUT_SUCCESS; } break; } case OP_ATOM_host: { const uni_char *current_url_string = current_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI).CStr(); const uni_char *current_scheme_end = uni_strchr(current_url_string, ':'); // URL must be an "authority-based URL" if (current_scheme_end && current_scheme_end[1] == '/' && current_scheme_end[2] == '/') { OpString hostname; PUT_FAILED_IF_ERROR(current_url.GetAttribute(URL::KUniHostName, hostname)); /* Just bail if the URL doesn't have a hostname after all. */ if (!hostname.CStr()) return PUT_SUCCESS; uni_char *hostname_start = uni_strstr(current_url_string, hostname.CStr()); OP_ASSERT(hostname_start); uni_char *hostname_end = hostname_start + hostname.Length(); unsigned short port = current_url.GetAttribute(URL::KServerPort); if (port > 0 && *hostname_end == ':') { hostname_end++; while (uni_isdigit(*hostname_end)) hostname_end++; } PUT_FAILED_IF_ERROR(buffer.Append(current_url_string, hostname_start - current_url_string)); PUT_FAILED_IF_ERROR(buffer.Append(value_string)); PUT_FAILED_IF_ERROR(buffer.Append(hostname_end)); url = GetEncodedURL(origining_runtime->GetFramesDocument(), buffer.GetStorage()); } break; } case OP_ATOM_hostname: { while (*value_string == '/') value_string++; const uni_char *current_url_string = current_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI).CStr(); const uni_char *current_scheme_end = uni_strchr(current_url_string, ':'); // URL must be an "authority-based URL" if (*value_string && current_scheme_end && current_scheme_end[1] == '/' && current_scheme_end[2] == '/') { OpString hostname; PUT_FAILED_IF_ERROR(current_url.GetAttribute(URL::KUniHostName, hostname)); /* Just bail if the URL doesn't have a hostname after all. */ if (!hostname.CStr()) return PUT_SUCCESS; uni_char *hostname_start = uni_strstr(current_url_string, hostname.CStr()); OP_ASSERT(hostname_start); uni_char *hostname_end = hostname_start + hostname.Length(); PUT_FAILED_IF_ERROR(buffer.Append(current_url_string, hostname_start - current_url_string)); PUT_FAILED_IF_ERROR(buffer.Append(value_string)); PUT_FAILED_IF_ERROR(buffer.Append(hostname_end)); url = GetEncodedURL(origining_runtime->GetFramesDocument(), buffer.GetStorage()); } break; } case OP_ATOM_port: { const uni_char *current_url_string = current_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI).CStr(); const uni_char *current_scheme_end = uni_strchr(current_url_string, ':'); // URL must be an "authority-based URL" if (current_scheme_end && current_scheme_end[1] == '/' && current_scheme_end[2] == '/') { while (*value_string == '0') value_string++; int port = 0; if (uni_isdigit(*value_string)) port = uni_atoi(value_string); if (port <= 0 || port > 65535) break; OpString hostname; PUT_FAILED_IF_ERROR(current_url.GetAttribute(URL::KUniHostName, hostname)); /* Just bail if the URL doesn't have a hostname after all. */ if (!hostname.CStr()) return PUT_SUCCESS; uni_char *hostname_start = uni_strstr(current_scheme_end, hostname.CStr()); OP_ASSERT(hostname_start); uni_char *hostname_end = hostname_start + hostname.Length(); PUT_FAILED_IF_ERROR(buffer.Append(current_url_string, hostname_end - current_url_string)); PUT_FAILED_IF_ERROR(buffer.Append(":")); if (*hostname_end == ':') { hostname_end++; while (uni_isdigit(*hostname_end)) hostname_end++; } PUT_FAILED_IF_ERROR(buffer.AppendLong(port)); PUT_FAILED_IF_ERROR(buffer.Append(hostname_end)); url = GetEncodedURL(origining_runtime->GetFramesDocument(), buffer.GetStorage()); } break; } case OP_ATOM_href: case OP_ATOM_pathname: { url = GetEncodedURL(origining_runtime->GetFramesDocument(), value_string); BOOL allowed; // Stricter security for javascript urls. It's possible this check should move into DocumentManager in the future. if (url.Type() == URL_JAVASCRIPT) if (OpStatus::IsError(OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_STANDARD, static_cast<DOM_Runtime *>(origining_runtime), GetRuntime(), allowed)) || !allowed) return PUT_SUCCESS; break; } case OP_ATOM_search: { const uni_char *current_url_string = current_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI).CStr(); int current_len; const uni_char *current_search_start = uni_strchr(current_url_string, '?'); if (current_search_start) current_len = current_search_start - current_url_string; else current_len = uni_strlen(current_url_string); if (value_string[0] == '?') ++value_string; PUT_FAILED_IF_ERROR(buffer.Expand(current_len + uni_strlen(value_string) + 2)); OpStatus::Ignore(buffer.Append(current_url_string, current_len)); // buffer is successfully expanded above OpStatus::Ignore(buffer.Append("?")); OpStatus::Ignore(buffer.Append(value_string)); url = GetEncodedURL(origining_runtime->GetFramesDocument(), buffer.GetStorage()); break; } case OP_ATOM_hash: if (value_string[0] == '#') ++value_string; // Strip trailing whitespace if (unsigned length = uni_strlen(value_string)) { if (value_string[length - 1] == ' ') { PUT_FAILED_IF_ERROR(buffer.Append(value_string)); uni_char *string = buffer.GetStorage(); while (length > 0 && string[length - 1] == ' ') --length; string[length] = 0; value_string = string; } } #ifdef SELFTEST url = URL(!do_navigation ? current_url : frames_doc->GetURL(), value_string); #else url = URL(frames_doc->GetURL(), value_string); #endif // SELFTEST break; } if (url.Type() != URL_NULL_TYPE) { #ifdef GADGET_SUPPORT switch (property_name) { case OP_ATOM_href: case OP_ATOM_protocol: case OP_ATOM_host: case OP_ATOM_hostname: case OP_ATOM_port: case OP_ATOM_pathname: { BOOL allowed; if (frames_doc->GetWindow()->GetGadget()) if (OpStatus::IsError(OpSecurityManager::CheckSecurity(OpSecurityManager::GADGET_ALLOWED_TO_NAVIGATE, OpSecurityContext(frames_doc), url, allowed)) || !allowed) return PUT_SECURITY_VIOLATION; } } #endif // GADGET_SUPPORT return SetTheURL(frames_doc, ref_url, url, GetCurrentThread(origining_runtime), property_name == OP_ATOM_hash); } else return PUT_SUCCESS; }
bool Directory::GetAttribute(const String& fileName, nextar::FileAttribute & attr) { String path; MultiStringHelper pathsL(paths); MultiStringHelper::Iterator it = pathsL.Iterate(); while (it.HasNext(path)) { String fullPath = URL::GetAppendedPath(path, fileName); #if NEX_WINDOWS==1 if (StringUtils::IsAscii(fullPath)) { struct stat filestat; int ret = stat(fullPath.c_str(), &filestat); if (ret == 0) { attr.fileName = URL(GetName(), fileName); attr.flags = 0; StatToAttribute(filestat, attr); } else return false; } else { UniString fullPathUni = StringUtils::ToUtf16(fullPath); DWORD flags = GetFileAttributesW((const wchar_t*)fullPathUni.c_str()); if (flags == INVALID_FILE_ATTRIBUTES) return false; else attr.fileName = URL(GetName(), fileName); if (flags & FILE_ATTRIBUTE_DIRECTORY) attr.flags = FileAttribute::ATTRIB_DIR; if ((flags & FILE_ATTRIBUTE_READONLY)) attr.flags |= FileAttribute::ATTRIB_READONLY; if ((flags & FILE_ATTRIBUTE_ARCHIVE)) attr.flags |= FileAttribute::ATTRIB_ARC; if ((flags & FILE_ATTRIBUTE_COMPRESSED)) attr.flags |= FileAttribute::ATTRIB_COMPRESSED; HANDLE hFile = CreateFileW((const wchar_t*)fullPathUni.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile != INVALID_HANDLE_VALUE) { FILETIME lastWriteTime; if (GetFileTime(hFile, NULL, NULL, &lastWriteTime)) WriteFileTime(attr.fileTime, lastWriteTime); } attr.uncompressedSize = GetFileSize(hFile, NULL); if ((flags & FILE_ATTRIBUTE_COMPRESSED)) attr.compressedSize = GetCompressedFileSizeW((const wchar_t*)fullPathUni.c_str(), NULL); } #elif NEX_LINUX==1 struct stat filestat; int ret = stat(fullPath.c_str(), &filestat); if (ret == 0) { attr.fileName = URL(GetName(), fileName); attr.flags = 0; StatToAttribute(filestat, attr); } else return false; #else //problem # error Platform error #endif return true; } return false;
URL IconController::url() { IconURLs iconURLs = urlsForTypes(Favicon); return iconURLs.isEmpty() ? URL() : iconURLs[0].m_iconURL; }
static void logCanCachePageDecision(Page& page) { // Only bother logging for main frames that have actually loaded and have content. if (page.mainFrame().loader().stateMachine().creatingInitialEmptyDocument()) return; URL currentURL = page.mainFrame().loader().documentLoader() ? page.mainFrame().loader().documentLoader()->url() : URL(); if (currentURL.isEmpty()) return; unsigned indentLevel = 0; PCLOG("--------\n Determining if page can be cached:"); unsigned rejectReasons = 0; MainFrame& mainFrame = page.mainFrame(); DiagnosticLoggingClient& diagnosticLoggingClient = mainFrame.diagnosticLoggingClient(); unsigned frameRejectReasons = logCanCacheFrameDecision(mainFrame, diagnosticLoggingClient, indentLevel + 1); if (frameRejectReasons) rejectReasons |= 1 << FrameCannotBeInPageCache; if (!page.settings().usesPageCache()) { PCLOG(" -Page settings says b/f cache disabled"); rejectReasons |= 1 << DisabledPageCache; } #if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS) if (DeviceMotionController::isActiveAt(page)) { PCLOG(" -Page is using DeviceMotion"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::deviceMotionKey()); rejectReasons |= 1 << UsesDeviceMotion; } if (DeviceOrientationController::isActiveAt(page)) { PCLOG(" -Page is using DeviceOrientation"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::deviceOrientationKey()); rejectReasons |= 1 << UsesDeviceOrientation; } #endif #if ENABLE(PROXIMITY_EVENTS) if (DeviceProximityController::isActiveAt(page)) { PCLOG(" -Page is using DeviceProximity"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, deviceProximityKey); rejectReasons |= 1 << UsesDeviceMotion; } #endif FrameLoadType loadType = page.mainFrame().loader().loadType(); if (loadType == FrameLoadType::Reload) { PCLOG(" -Load type is: Reload"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::reloadKey()); rejectReasons |= 1 << IsReload; } if (loadType == FrameLoadType::ReloadFromOrigin) { PCLOG(" -Load type is: Reload from origin"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::reloadFromOriginKey()); rejectReasons |= 1 << IsReloadFromOrigin; } if (loadType == FrameLoadType::Same) { PCLOG(" -Load type is: Same"); logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::sameLoadKey()); rejectReasons |= 1 << IsSameLoad; } if (rejectReasons) PCLOG(" Page CANNOT be cached\n--------"); else PCLOG(" Page CAN be cached\n--------"); diagnosticLoggingClient.logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageCacheKey(), emptyString(), rejectReasons ? DiagnosticLoggingResultFail : DiagnosticLoggingResultPass, ShouldSample::Yes); }
void PluginControllerProxy::streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers) { m_plugin->streamDidReceiveResponse(streamID, URL(ParsedURLString, responseURLString), streamLength, lastModifiedTime, mimeType, headers, String()); }
BOOL HEListElm::UpdateImageUrl(URL* img_url) { BOOL replace_url = FALSE; BOOL is_visible = GetImageVisible(); old_url = URL(); if (url_imagecontent_provider && url_imagecontent_provider->GetUrl()->Id(TRUE) != img_url->Id(TRUE)) event_sent = FALSE; if (url_imagecontent_provider) { // We are replacing an imageurl. Make sure it is not syncronized. syncronize_animation = FALSE; if (animation_handler) { animation_handler->DecRef(this); animation_handler = NULL; } if (is_visible) { url_imagecontent_provider->GetImage().DecVisible(this); } url_imagecontent_provider->DecRef(this); url_imagecontent_provider = NULL; replace_url = TRUE; event_sent = FALSE; } switch (inline_type) { case IMAGE_INLINE: case BGIMAGE_INLINE: case EXTRA_BGIMAGE_INLINE: case BORDER_IMAGE_INLINE: case VIDEO_POSTER_INLINE: OP_ASSERT(img_url); #ifdef HAS_ATVEF_SUPPORT if (img_url->Type() == URL_TV) { is_atvef_image = TRUE; return TRUE; } #endif url_imagecontent_provider = UrlImageContentProvider::FindImageContentProvider(*img_url); if (url_imagecontent_provider == NULL) { url_imagecontent_provider = OP_NEW(UrlImageContentProvider, (*img_url)); if (url_imagecontent_provider == NULL) return FALSE; } if (LoadInlineElm *lie = GetLoadInlineElm()) lie->SetUrlImageContentProvider(url_imagecontent_provider); url_imagecontent_provider->IncRef(this); Image img = url_imagecontent_provider->GetImage(); if (replace_url) { if (is_visible) { if (OpStatus::IsMemoryError(img.IncVisible(this))) return FALSE; } // FIXME: This won't have any effect if is_visible was false since // the image has no listener then. // The current fix for this is to call LoadAll() after SetImagePosition() // in ImageContent::Paint(). if (OpStatus::IsMemoryError(img.OnLoadAll(url_imagecontent_provider))) return FALSE; } break; } return TRUE; }
static URL processAndCreateYouTubeURL(const URL& url, bool& isYouTubeShortenedURL) { if (!url.protocolIs("http") && !url.protocolIs("https")) return URL(); // Bail out early if we aren't even on www.youtube.com or youtube.com. if (!isYouTubeURL(url)) return URL(); const String& hostName = url.host().lower(); bool isYouTubeMobileWebAppURL = hostName == "m.youtube.com"; isYouTubeShortenedURL = hostName == "youtu.be"; // Short URL of the form: http://youtu.be/v1d301D if (isYouTubeShortenedURL) { const String& videoID = url.lastPathComponent(); if (videoID.isEmpty() || videoID == "/") return URL(); return createYouTubeURL(videoID, emptyString()); } String path = url.path(); String query = url.query(); String fragment = url.fragmentIdentifier(); // On the YouTube mobile web app, the path and query string are put into the // fragment so that one web page is only ever loaded (see <rdar://problem/9550639>). if (isYouTubeMobileWebAppURL) { size_t location = fragment.find('?'); if (location == notFound) { path = fragment; query = emptyString(); } else { path = fragment.substring(0, location); query = fragment.substring(location + 1); } fragment = emptyString(); } if (path.lower() == "/watch") { if (!query.isEmpty()) { const auto& queryDictionary = queryKeysAndValues(query); String videoID = valueForKey(queryDictionary, "v"); if (!videoID.isEmpty()) { const auto& fragmentDictionary = queryKeysAndValues(url.fragmentIdentifier()); String timeID = valueForKey(fragmentDictionary, "t"); return createYouTubeURL(videoID, timeID); } } // May be a new-style link (see <rdar://problem/7733692>). if (fragment.startsWith('!')) { query = fragment.substring(1); if (!query.isEmpty()) { const auto& queryDictionary = queryKeysAndValues(query); String videoID = valueForKey(queryDictionary, "v"); if (!videoID.isEmpty()) { String timeID = valueForKey(queryDictionary, "t"); return createYouTubeURL(videoID, timeID); } } } } else if (hasCaseInsensitivePrefix(path, "/v/") || hasCaseInsensitivePrefix(path, "/e/")) { String videoID = url.lastPathComponent(); // These URLs are funny - they don't have a ? for the first query parameter. // Strip all characters after and including '&' to remove extraneous parameters after the video ID. size_t ampersand = videoID.find('&'); if (ampersand != notFound) videoID = videoID.substring(0, ampersand); if (!videoID.isEmpty()) return createYouTubeURL(videoID, emptyString()); } return URL(); }