void ResourceHandle::setClientCertificateInfo(const String& host, const String& certificate, const String& key) { if (fileExists(certificate)) addAllowedClientCertificate(host, certificate, key); else LOG(Network, "Invalid client certificate file: %s!\n", certificate.latin1().data()); }
// 'region' is in contents coordinates relative to the frame containing 'node' // 'remainingFingerRegion' and 'intersectingRegions' will always be in main frame contents // coordinates. // Thus, before comparing, we need to map the former to main frame contents coordinates. bool FatFingers::checkFingerIntersection(const IntRectRegion& region, const IntRectRegion& remainingFingerRegion, Node* node, Vector<IntersectingRegion>& intersectingRegions) { ASSERT(node); IntRectRegion regionCopy(region); WebCore::IntPoint framePos(m_webPage->frameOffset(node->document()->frame())); regionCopy.move(framePos.x(), framePos.y()); IntRectRegion intersection = intersectRegions(regionCopy, remainingFingerRegion); if (intersection.isEmpty()) return false; #if DEBUG_FAT_FINGERS String nodeName; if (node->isTextNode()) nodeName = "text node"; else if (node->isElementNode()) nodeName = String::format("%s node", toElement(node)->tagName().latin1().data()); else nodeName = "unknown node"; if (node->isInShadowTree()) { nodeName = nodeName + "(in shadow tree"; if (node->isElementNode() && !toElement(node)->shadowPseudoId().isEmpty()) nodeName = nodeName + ", pseudo id " + toElement(node)->shadowPseudoId(); nodeName = nodeName + ")"; } Platform::logAlways(Platform::LogLevelInfo, "%s has region %s, intersecting at %s (area %d)", nodeName.latin1().data(), regionCopy.toString().c_str(), intersection.toString().c_str(), intersection.area()); #endif intersectingRegions.append(std::make_pair(node, intersection)); return true; }
bool CurlCacheEntry::saveResponseHeaders(const ResourceResponse& response) { PlatformFileHandle headerFile = openFile(m_headerFilename, OpenForWrite); if (!isHandleValid(headerFile)) { LOG(Network, "Cache Error: Could not open %s for write\n", m_headerFilename.latin1().data()); return false; } // Headers HTTPHeaderMap::const_iterator it = response.httpHeaderFields().begin(); HTTPHeaderMap::const_iterator end = response.httpHeaderFields().end(); while (it != end) { String headerField = it->key; headerField.append(": "); headerField.append(it->value); headerField.append("\n"); CString headerFieldLatin1 = headerField.latin1(); writeToFile(headerFile, headerFieldLatin1.data(), headerFieldLatin1.length()); m_cachedResponse.setHTTPHeaderField(it->key, it->value); ++it; } closeFile(headerFile); return true; }
void CurlDownload::init(CurlDownloadListener* listener, const URL& url) { if (!listener) return; MutexLocker locker(m_mutex); m_curlHandle = curl_easy_init(); String urlStr = url.string(); m_url = fastStrDup(urlStr.latin1().data()); curl_easy_setopt(m_curlHandle, CURLOPT_URL, m_url); curl_easy_setopt(m_curlHandle, CURLOPT_PRIVATE, this); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEFUNCTION, writeCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEDATA, this); curl_easy_setopt(m_curlHandle, CURLOPT_HEADERFUNCTION, headerCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEHEADER, this); curl_easy_setopt(m_curlHandle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curlHandle, CURLOPT_MAXREDIRS, 10); curl_easy_setopt(m_curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); const char* certPath = getenv("CURL_CA_BUNDLE_PATH"); if (certPath) curl_easy_setopt(m_curlHandle, CURLOPT_CAINFO, certPath); CURLSH* curlsh = ResourceHandleManager::sharedInstance()->getCurlShareHandle(); if (curlsh) curl_easy_setopt(m_curlHandle, CURLOPT_SHARE, curlsh); m_listener = listener; }
bool Frame::canNavigate(const Frame& targetFrame) { String errorReason; bool isAllowedNavigation = canNavigateWithoutFramebusting(targetFrame, errorReason); if (targetFrame != this && !securityContext()->isSandboxed(SandboxTopNavigation) && targetFrame == tree().top()) { DEFINE_STATIC_LOCAL(EnumerationHistogram, framebustHistogram, ("WebCore.Framebust", 4)); const unsigned userGestureBit = 0x1; const unsigned allowedBit = 0x2; unsigned framebustParams = 0; UseCounter::count(&targetFrame, UseCounter::TopNavigationFromSubFrame); bool hasUserGesture = isLocalFrame() ? toLocalFrame(this)->document()->hasReceivedUserGesture() : false; if (hasUserGesture) framebustParams |= userGestureBit; if (isAllowedNavigation) framebustParams |= allowedBit; framebustHistogram.count(framebustParams); // Frame-busting used to be generally allowed in most situations, but may // now blocked if there is no user gesture. if (!RuntimeEnabledFeatures:: framebustingNeedsSameOriginOrUserGestureEnabled()) return true; if (hasUserGesture || isAllowedNavigation) return true; errorReason = "The frame attempting navigation is targeting its top-level window, " "but is neither same-origin with its target nor is it processing a " "user gesture. See " "https://www.chromestatus.com/features/5851021045661696."; printNavigationErrorMessage(targetFrame, errorReason.latin1().data()); if (isLocalFrame()) { toLocalFrame(this)->navigationScheduler().schedulePageBlock( toLocalFrame(this)->document(), ResourceError::ACCESS_DENIED); } return false; } if (!isAllowedNavigation && !errorReason.isNull()) printNavigationErrorMessage(targetFrame, errorReason.latin1().data()); return isAllowedNavigation; }
void HTMLDocument::determineParseMode() { // FIXME: It's terrible that this code runs separately and isn't just built in to the // HTML tokenizer/parser. // This code more or less mimics Mozilla's implementation (specifically the // doctype parsing implemented by David Baron in Mozilla's nsParser.cpp). // // There are three possible parse modes: // COMPAT - quirks mode emulates WinIE and NS4. CSS parsing is also relaxed in this mode, e.g., unit types can // be omitted from numbers. // ALMOST STRICT - This mode is identical to strict mode except for its treatment of line-height in the inline box model. For // now (until the inline box model is re-written), this mode is identical to STANDARDS mode. // STRICT - no quirks apply. Web pages will obey the specifications to the letter. bool wasInCompatMode = inCompatMode(); DocumentType* docType = doctype(); if (!docType || !equalIgnoringCase(docType->name(), "html")) // No doctype found at all or the doctype is not HTML. Default to quirks mode and Html4. setParseMode(Compat); else if (!doctype()->systemId().isEmpty() && equalIgnoringCase(docType->systemId(), "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd")) // Assume quirks mode for this particular system ID. In the HTML5 spec, this is the only // system identifier that is examined. setParseMode(Compat); else if (docType->publicId().isEmpty()) // A doctype without a public ID means use strict mode. setParseMode(Strict); else { // We have to check a list of public IDs to see what we // should do. String lowerPubID = docType->publicId().lower(); CString pubIDStr = lowerPubID.latin1(); // Look up the entry in our gperf-generated table. const PubIDInfo* doctypeEntry = findDoctypeEntry(pubIDStr.data(), pubIDStr.length()); if (!doctypeEntry) // The DOCTYPE is not in the list. Assume strict mode. setParseMode(Strict); else { switch (docType->systemId().isEmpty() ? doctypeEntry->mode_if_no_sysid : doctypeEntry->mode_if_sysid) { case PubIDInfo::eQuirks3: case PubIDInfo::eQuirks: setParseMode(Compat); break; case PubIDInfo::eAlmostStandards: setParseMode(AlmostStrict); break; default: ASSERT(false); } } } if (inCompatMode() != wasInCompatMode) updateStyleSelector(); }
void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstance* targetInstance) { SVGElement* element = targetInstance->correspondingElement(); ASSERT(element); SVGElement* shadowTreeElement = targetInstance->shadowTreeElement(); ASSERT(shadowTreeElement); String elementId = element->getIDAttribute(); String elementNodeName = element->nodeName(); String shadowTreeElementNodeName = shadowTreeElement->nodeName(); String parentNodeName = element->parentNode() ? element->parentNode()->nodeName() : "null"; String firstChildNodeName = element->firstChild() ? element->firstChild()->nodeName() : "null"; for (unsigned int i = 0; i < depth; ++i) text += " "; text += String::format("SVGElementInstance this=%p, (parentNode=%s (%p), firstChild=%s (%p), correspondingElement=%s (%p), shadowTreeElement=%s (%p), id=%s)\n", targetInstance, parentNodeName.latin1().data(), element->parentNode(), firstChildNodeName.latin1().data(), element->firstChild(), elementNodeName.latin1().data(), element, shadowTreeElementNodeName.latin1().data(), shadowTreeElement, elementId.latin1().data()); for (unsigned int i = 0; i < depth; ++i) text += " "; const HashSet<SVGElementInstance*>& elementInstances = element->instancesForElement(); text += String::format("Corresponding element is associated with %i instance(s):\n", elementInstances.size()); const HashSet<SVGElementInstance*>::const_iterator end = elementInstances.end(); for (HashSet<SVGElementInstance*>::const_iterator it = elementInstances.begin(); it != end; ++it) { for (unsigned int i = 0; i < depth; ++i) text += " "; text += String::format(" -> SVGElementInstance this=%p, (refCount: %i, shadowTreeElement in document? %i)\n", *it, (*it)->refCount(), (*it)->shadowTreeElement()->inDocument()); } ++depth; for (SVGElementInstance* instance = targetInstance->firstChild(); instance; instance = instance->nextSibling()) dumpInstanceTree(depth, text, instance); --depth; }
String btoa(void*, const String& stringToEncode, ExceptionState& es) { if (stringToEncode.isNull()) return String(); if (!stringToEncode.containsOnlyLatin1()) { es.throwDOMException(InvalidCharacterError, "'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); return String(); } return base64Encode(stringToEncode.latin1()); }
String DOMWindowBase64::btoa(const String& stringToEncode, ExceptionState& exceptionState) { if (stringToEncode.isNull()) return String(); if (!stringToEncode.containsOnlyLatin1()) { exceptionState.throwDOMException(InvalidCharacterError, "The string to be encoded contains characters outside of the Latin1 range."); return String(); } return base64Encode(stringToEncode.latin1()); }
TextCodecBrew::TextCodecBrew(const TextEncoding& encoding) : m_charsetConverter(0) , m_encoding(encoding) , m_numBufferedBytes(0) { String format = String::format("%s>%s", encoding.name(), m_internalEncodingName); IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; AEECLSID classID = ISHELL_GetHandler(shell, AEEIID_ICharsetConv, format.latin1().data()); ISHELL_CreateInstance(shell, classID, reinterpret_cast<void**>(&m_charsetConverter)); ASSERT(m_charsetConverter); }
void GraphicsLayerBlackBerry::removeAnimation(const String& animationName) { // WebCore might have added several animations with the same name, but for different properties #if DEBUG_LAYER_ANIMATION fprintf(stderr, "LayerAnimation: Removing animation %s\n", animationName.latin1().data()); #endif while (removeAnimationByName(animationName, m_runningAnimations)) { } while (removeAnimationByName(animationName, m_suspendedAnimations)) { } updateAnimations(); }
CurlCacheEntry::CurlCacheEntry(const String& url, const String& cacheDir) : m_headerFilename(cacheDir) , m_contentFilename(cacheDir) , m_expireDate(-1) , m_headerInMemory(false) { generateBaseFilename(url.latin1()); m_headerFilename.append(m_basename); m_headerFilename.append(".header"); m_contentFilename.append(m_basename); m_contentFilename.append(".content"); }
void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstance* targetInstance) { SVGElement* element = targetInstance->correspondingElement(); ASSERT(element); String elementId = element->getIDAttribute(); String elementNodeName = element->nodeName(); String parentNodeName = element->parentNode() ? element->parentNode()->nodeName() : "null"; String firstChildNodeName = element->firstChild() ? element->firstChild()->nodeName() : "null"; for (unsigned int i = 0; i < depth; ++i) text += " "; text += String::format("SVGElementInstance (parentNode=%s, firstChild=%s, correspondingElement=%s, id=%s)\n", parentNodeName.latin1().data(), firstChildNodeName.latin1().data(), elementNodeName.latin1().data(), elementId.latin1().data()); depth++; for (SVGElementInstance* instance = targetInstance->firstChild(); instance; instance = instance->nextSibling()) dumpInstanceTree(depth, text, instance); depth--; }
bool CurlCacheEntry::loadFileToBuffer(const String& filepath, Vector<char>& buffer) { // open the file PlatformFileHandle inputFile = openFile(filepath, OpenForRead); if (!isHandleValid(inputFile)) { LOG(Network, "Cache Error: Could not open %s for read\n", filepath.latin1().data()); return false; } long long filesize = -1; if (!getFileSize(filepath, filesize)) { LOG(Network, "Cache Error: Could not get file size of %s\n", filepath.latin1().data()); closeFile(inputFile); return false; } // load the file content into buffer buffer.resize(filesize); int bufferPosition = 0; int bufferReadSize = 4096; int bytesRead = 0; while (filesize > bufferPosition) { if (filesize - bufferPosition < bufferReadSize) bufferReadSize = filesize - bufferPosition; bytesRead = readFromFile(inputFile, buffer.data() + bufferPosition, bufferReadSize); if (bytesRead != bufferReadSize) { LOG(Network, "Cache Error: Could not read from %s\n", filepath.latin1().data()); closeFile(inputFile); return false; } bufferPosition += bufferReadSize; } closeFile(inputFile); return true; }
void MyResourceLoader::loadFile(const String& file) { LOGD("Loading file (%s) ...", file.latin1().data()); FILE* f = fopen(file.latin1().data(), "r"); ResourceHandleClient* client = m_handle->client(); if (!f) { client->didFail(m_handle, ResourceError("", -14, file, "Could not open file")); } else { ResourceResponse response; response.setTextEncodingName("utf-8"); response.setMimeType(mimeTypeForExtension(file)); client->didReceiveResponse(m_handle, response); char buf[512]; while (true) { int res = fread(buf, 1, sizeof(buf), f); if (res <= 0) break; client->didReceiveData(m_handle, buf, res, 0); } fclose(f); client->didFinishLoading(m_handle, 0); } }
void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) { String fileName = String("PROGDIR:Searches"); if (!name.isEmpty()) fileName = fileName + "_" + name; FILE *file = fopen(fileName.latin1().data(), "w"); if (file) { Vector<String>::iterator end = (Vector<String>::iterator)searchItems.end(); for (Vector<String>::iterator it = (Vector<String>::iterator)searchItems.begin(); it < end; it++) fprintf(file, "%s\n", (*it).utf8().data()); fclose(file); } }
String defaultLanguage() { static String computedDefaultLanguage; if (!computedDefaultLanguage.isEmpty()) return computedDefaultLanguage; String languageName = localeInfo(LOCALE_SISO639LANGNAME, "en"); String countryName = localeInfo(LOCALE_SISO3166CTRYNAME, String()); if (countryName.isEmpty()) computedDefaultLanguage = languageName; else computedDefaultLanguage = String::format("%s-%s", languageName.latin1().data(), countryName.latin1().data()); return computedDefaultLanguage; }
CurlCacheEntry::CurlCacheEntry(const String& url, ResourceHandle* job, const String& cacheDir) : m_headerFilename(cacheDir) , m_contentFilename(cacheDir) , m_contentFile(invalidPlatformFileHandle) , m_entrySize(0) , m_expireDate(-1) , m_headerParsed(false) , m_job(job) { generateBaseFilename(url.latin1()); m_headerFilename.append(m_basename); m_headerFilename.append(".header"); m_contentFilename.append(m_basename); m_contentFilename.append(".content"); }
CString openTemporaryFile(const char*, PlatformFileHandle& handle) { handle = INVALID_HANDLE_VALUE; wchar_t tempPath[MAX_PATH]; int tempPathLength = ::GetTempPath(_countof(tempPath), tempPath); if (tempPathLength <= 0 || tempPathLength > _countof(tempPath)) return CString(); HCRYPTPROV hCryptProv = 0; if (!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) return CString(); String proposedPath; while (1) { wchar_t tempFile[] = L"XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names) const int randomPartLength = 8; if (!CryptGenRandom(hCryptProv, randomPartLength * 2, reinterpret_cast<BYTE*>(tempFile))) break; // Limit to valid filesystem characters, also excluding others that could be problematic, like punctuation. // don't include both upper and lowercase since Windows file systems are typically not case sensitive. const char validChars[] = "0123456789abcdefghijklmnopqrstuvwxyz"; for (int i = 0; i < randomPartLength; ++i) tempFile[i] = validChars[tempFile[i] % (sizeof(validChars) - 1)]; ASSERT(wcslen(tempFile) * 2 == sizeof(tempFile) - 2); proposedPath = pathByAppendingComponent(String(tempPath), String(tempFile)); // use CREATE_NEW to avoid overwriting an existing file with the same name handle = CreateFile(proposedPath.charactersWithNullTermination(), GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS) continue; break; } CryptReleaseContext(hCryptProv, 0); if (!isHandleValid(handle)) return CString(); return proposedPath.latin1(); }
void WebChromeClient::setStatusbarText(const String& statusText) { #if PLATFORM(AMIGAOS4) BalWidget *widget = m_webView->viewWindow(); if (widget && widget->gad_status) { CString statusLatin1 = statusText.latin1(); snprintf(widget->statusBarText, sizeof(widget->statusBarText), "%s", statusLatin1.data()); if (widget->statusBarText[0] && widget->toolTipText[0]) snprintf(widget->statusToolTipText, sizeof(widget->statusToolTipText), "%s | %s", widget->statusBarText, widget->toolTipText); else snprintf(widget->statusToolTipText, sizeof(widget->statusToolTipText), "%s", widget->statusBarText[0] ? widget->statusBarText : widget->toolTipText); IIntuition->RefreshSetGadgetAttrs(widget->gad_status, widget->window, NULL, GA_Text, widget->statusToolTipText, TAG_DONE); } #endif }
void CurlDownload::init(CurlDownloadListener* listener, const URL& url) { if (!listener) return; MutexLocker locker(m_mutex); m_curlHandle = curl_easy_init(); String urlStr = url.string(); m_url = fastStrDup(urlStr.latin1().data()); #ifndef NDEBUG if (getenv("DEBUG_CURL")) curl_easy_setopt(m_curlHandle, CURLOPT_VERBOSE, 1); #endif // Fifth handles certs differently; ignore CA checks. curl_easy_setopt(m_curlHandle, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(m_curlHandle, CURLOPT_SSL_VERIFYHOST, 2L); curl_easy_setopt(m_curlHandle, CURLOPT_URL, m_url); curl_easy_setopt(m_curlHandle, CURLOPT_PRIVATE, this); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEFUNCTION, writeCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEDATA, this); curl_easy_setopt(m_curlHandle, CURLOPT_HEADERFUNCTION, headerCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEHEADER, this); curl_easy_setopt(m_curlHandle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curlHandle, CURLOPT_MAXREDIRS, 10); curl_easy_setopt(m_curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // Youtube requires an insecure SSL cipher that curl disables by default. // Enable it only for those sites to stay secure. if (url.host().endsWith("googlevideo.com") || url.host().endsWith("youtube.com")) curl_easy_setopt(m_curlHandle, CURLOPT_SSL_CIPHER_LIST, "DEFAULT"); // TODO warning: download certs *aren't* currently checked! Requires SSLHandle reorg. CURLSH* curlsh = ResourceHandleManager::sharedInstance()->getCurlShareHandle(); if (curlsh) curl_easy_setopt(m_curlHandle, CURLOPT_SHARE, curlsh); m_listener = listener; }
void WebFrameLoaderClient::setTitle(const String& title, const KURL& url) { #if PLATFORM(AMIGAOS4) if (!m_webFrame->parentFrame()) { BalWidget* viewWindow = m_webFrame->webView()->viewWindow(); if (viewWindow && viewWindow->window) { CString titleLatin1 = title.latin1(); const char *titlestr = titleLatin1.data(); if (titlestr && titlestr[0]) snprintf(viewWindow->title, sizeof(viewWindow->title), "OWB: %s", titlestr); else strcpy(viewWindow->title, "Origyn Web Browser"); IIntuition->SetWindowTitles(viewWindow->window, viewWindow->title, (STRPTR)~0UL); CString urlLatin1 = url.prettyURL().latin1(); const char *urlstr = urlLatin1.data(); if (urlstr && urlstr[0] && viewWindow->gad_url) { snprintf(viewWindow->url, sizeof(viewWindow->url), "%s", urlstr); IIntuition->RefreshSetGadgetAttrs(viewWindow->gad_url, viewWindow->window, NULL, STRINGA_TextVal, viewWindow->url, TAG_DONE); } } } #endif bool privateBrowsingEnabled = false; WebPreferences* preferences = m_webFrame->webView()->preferences(); if (preferences) privateBrowsingEnabled = preferences->privateBrowsingEnabled(); if (privateBrowsingEnabled) return; // update title in global history WebHistory* history = webHistory(); if (!history) return; WebHistoryItem* item = history->itemForURL(url.string()); if (!item) return; item->setTitle(title); }
// We can't use String::format for two reasons: // 1) It doesn't handle non-ASCII characters in the format string. // 2) It doesn't handle the %2$d syntax. // Note that because |format| is used as the second parameter to va_start, it cannot be a reference // type according to section 18.7/3 of the C++ N1905 standard. static String formatLocalizedString(String format, ...) { #if USE(CF) va_list arguments; va_start(arguments, format); RetainPtr<CFStringRef> formatCFString(AdoptCF, format.createCFString()); RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments)); va_end(arguments); return result.get(); #elif PLATFORM(QT) va_list arguments; va_start(arguments, format); QString result; result.vsprintf(format.latin1().data(), arguments); va_end(arguments); return result; #else notImplemented(); return format; #endif }
LanguageManager::LanguageManager() { COMPtr<IMultiLanguage> multiLanguage; if (FAILED(::CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_INPROC_SERVER, IID_IMultiLanguage, reinterpret_cast<LPVOID*>(&multiLanguage)))) return; COMPtr<IEnumCodePage> enumInterface; if (FAILED(multiLanguage->EnumCodePages(MIMECONTF_BROWSER, &enumInterface))) return; MIMECPINFO cpInfo; ULONG ccpInfo; while (SUCCEEDED(enumInterface->Next(1, &cpInfo, &ccpInfo)) && ccpInfo) { if (!IsValidCodePage(cpInfo.uiCodePage)) continue; HashMap<UINT, CString>::iterator i = codePageCharsets().find(cpInfo.uiCodePage); CString name(String(cpInfo.wszWebCharset).latin1()); if (i == codePageCharsets().end()) { CharsetInfo info; info.m_codePage = cpInfo.uiCodePage; knownCharsets().set(name.data(), info); i = codePageCharsets().set(cpInfo.uiCodePage, name).iterator; } if (i != codePageCharsets().end()) { HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(String(i->value.data(), i->value.length())); ASSERT(j != knownCharsets().end()); CharsetInfo& info = j->value; info.m_name = i->value.data(); info.m_friendlyName = cpInfo.wszDescription; info.m_aliases.append(name); info.m_aliases.append(String(cpInfo.wszHeaderCharset).latin1()); info.m_aliases.append(String(cpInfo.wszBodyCharset).latin1()); String cpName = "cp" + String::number(cpInfo.uiCodePage); info.m_aliases.append(cpName.latin1()); supportedCharsets().add(i->value.data()); } } }
bool Frame::canNavigate(const Frame& targetFrame) { String errorReason; bool isAllowedNavigation = canNavigateWithoutFramebusting(targetFrame, errorReason); // Frame-busting is generally allowed, but blocked for sandboxed frames lacking the 'allow-top-navigation' flag. if (targetFrame != this && !securityContext()->isSandboxed(SandboxTopNavigation) && targetFrame == tree().top()) { DEFINE_STATIC_LOCAL(EnumerationHistogram, framebustHistogram, ("WebCore.Framebust", 4)); const unsigned userGestureBit = 0x1; const unsigned allowedBit = 0x2; unsigned framebustParams = 0; if (UserGestureIndicator::processingUserGesture()) framebustParams |= userGestureBit; if (isAllowedNavigation) framebustParams |= allowedBit; framebustHistogram.count(framebustParams); return true; } if (!isAllowedNavigation && !errorReason.isNull()) printNavigationErrorMessage(targetFrame, errorReason.latin1().data()); return isAllowedNavigation; }
void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems) { String fileName = String("PROGDIR:Searches"); if (!name.isEmpty()) fileName = fileName + "_" + name; searchItems.clear(); FILE *file = fopen(fileName.latin1().data(), "r"); if (file) { char item[4096]; while (fgets(item, 4096, file)) { size_t len = strlen(item); if (len) item[len-1] = 0; searchItems.append(String(item)); } fclose(file); } }
bool GraphicsLayerAndroid::createAnimationFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& keyframesName, double beginTime) { bool isKeyframe = valueList.size() > 2; TLOG("createAnimationFromKeyframes(%d), name(%s) beginTime(%.2f)", isKeyframe, keyframesName.latin1().data(), beginTime); switch (valueList.property()) { case AnimatedPropertyInvalid: break; case AnimatedPropertyWebkitTransform: break; case AnimatedPropertyBackgroundColor: break; case AnimatedPropertyOpacity: { MLOG("ANIMATEDPROPERTYOPACITY"); KeyframeValueList* operationsList = new KeyframeValueList(AnimatedPropertyOpacity); for (unsigned int i = 0; i < valueList.size(); i++) { FloatAnimationValue* originalValue = (FloatAnimationValue*)valueList.at(i); PassRefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction())); FloatAnimationValue* value = new FloatAnimationValue(originalValue->keyTime(), originalValue->value(), timingFunction); operationsList->insert(value); } RefPtr<AndroidOpacityAnimation> anim = AndroidOpacityAnimation::create(animation, operationsList, beginTime); if (keyframesName.isEmpty()) anim->setName(propertyIdToString(valueList.property())); else anim->setName(keyframesName); m_contentLayer->addAnimation(anim.release()); needsNotifyClient(); return true; } break; } return false; }
void FTPDirectoryTokenizer::parseAndAppendOneLine(const String& inputLine) { ListResult result; FTPEntryType typeResult = parseOneFTPLine(inputLine.latin1().data(), m_listState, result); // FTPMiscEntry is a comment or usage statistic which we don't care about, and junk is invalid data - bail in these 2 cases if (typeResult == FTPMiscEntry || typeResult == FTPJunkEntry) return; String filename(result.filename, result.filenameLength); if (result.type == FTPDirectoryEntry) { filename.append("/"); // We have no interest in linking to "current directory" if (filename == "./") return; } LOG(FTP, "Appending entry - %s, %s", filename.ascii().data(), result.fileSize.ascii().data()); appendEntry(filename, processFilesizeString(result.fileSize, result.type == FTPDirectoryEntry), processFileDateString(result.modifiedTime), result.type == FTPDirectoryEntry); }
LanguageManager::LanguageManager() { IEnumCodePage* enumInterface; IMultiLanguage* mli = FontCache::getMultiLanguageInterface(); if (mli && S_OK == mli->EnumCodePages(MIMECONTF_BROWSER, &enumInterface)) { MIMECPINFO cpInfo; ULONG ccpInfo; while (S_OK == enumInterface->Next(1, &cpInfo, &ccpInfo) && ccpInfo) { if (!IsValidCodePage(cpInfo.uiCodePage)) continue; HashMap<UINT, CString>::iterator i = codePageCharsets().find(cpInfo.uiCodePage); CString name(String(cpInfo.wszWebCharset).latin1()); if (i == codePageCharsets().end()) { CharsetInfo info; info.m_codePage = cpInfo.uiCodePage; knownCharsets().set(name.data(), info); i = codePageCharsets().set(cpInfo.uiCodePage, name).iterator; } if (i != codePageCharsets().end()) { HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(String(i->second.data(), i->second.length())); ASSERT(j != knownCharsets().end()); CharsetInfo& info = j->second; info.m_name = i->second.data(); info.m_friendlyName = cpInfo.wszDescription; info.m_aliases.append(name); info.m_aliases.append(String(cpInfo.wszHeaderCharset).latin1()); info.m_aliases.append(String(cpInfo.wszBodyCharset).latin1()); String cpName = "cp" + String::number(cpInfo.uiCodePage); info.m_aliases.append(cpName.latin1()); supportedCharsets().add(i->second.data()); } } enumInterface->Release(); } }
// This is the app path on the device to install app specific files // node modules will be installed in a sub directory under this // so each app gets its own set of node modules void NodeProxy::setAppDataPath(const String& dataPath) { NODE_LOGI("%s, module path: %s", __FUNCTION__, dataPath.latin1().data()); s_moduleRootPath = new String(dataPath); }