void QNetworkReplyHandler::sendResponseIfNeeded() { m_shouldSendResponse = (m_loadMode != LoadNormal); if (m_shouldSendResponse) return; if (m_reply->error()) return; if (m_responseSent || !m_resourceHandle) return; m_responseSent = true; ResourceHandleClient* client = m_resourceHandle->client(); if (!client) return; WebCore::String contentType = m_reply->header(QNetworkRequest::ContentTypeHeader).toString(); WebCore::String encoding = extractCharsetFromMediaType(contentType); WebCore::String mimeType = extractMIMETypeFromMediaType(contentType); if (mimeType.isEmpty()) { // let's try to guess from the extension QString extension = m_reply->url().path(); int index = extension.lastIndexOf(QLatin1Char('.')); if (index > 0) { extension = extension.mid(index + 1); mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension); } } KURL url(m_reply->url()); ResourceResponse response(url, mimeType, m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), encoding, String()); if (url.isLocalFile()) { client->didReceiveResponse(m_resourceHandle, response); return; } // The status code is equal to 0 for protocols not in the HTTP family. int statusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (url.protocolInHTTPFamily()) { String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromAscii(m_reply->rawHeader("Content-Disposition"))); if (!suggestedFilename.isEmpty()) response.setSuggestedFilename(suggestedFilename); else response.setSuggestedFilename(url.lastPathComponent()); response.setHTTPStatusCode(statusCode); response.setHTTPStatusText(m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData()); // Add remaining headers. foreach (const QByteArray& headerName, m_reply->rawHeaderList()) { response.setHTTPHeaderField(QString::fromAscii(headerName), QString::fromAscii(m_reply->rawHeader(headerName))); } }
static inline void addAdobeAcrobatPluginDirectory(Vector<String>& directories) { WebCore::String path; char readerPathBase[MAX_PATH]; if(FindAcrobatInUserPath(readerPathBase)) { path = FindAcrobat(readerPathBase); if(!path.isEmpty()) directories.append(path); } path = FindAcrobat("/opt/Adobe"); if(!path.isEmpty()) directories.append(path); }
/** * Return directory path where icon database is stored. * * @return newly allocated string with database path or @c NULL if * none is set or database is closed. Note that return must be * freed with free() as it's a strdup()ed copy of the string * due reference counting. */ char* ewk_settings_icon_database_path_get(void) { if (!WebCore::iconDatabase()->isEnabled()) return 0; if (!WebCore::iconDatabase()->isOpen()) return 0; WebCore::String path = WebCore::iconDatabase()->databasePath(); if (path.isEmpty()) return 0; return strdup(path.utf8().data()); }
static bool isValidProtocolString(const WebCore::String& protocol) { if (protocol.isNull()) return true; if (protocol.isEmpty()) return false; const UChar* characters = protocol.characters(); for (size_t i = 0; i < protocol.length(); i++) { if (characters[i] < 0x21 || characters[i] > 0x7E) return false; } return true; }
/** * webkit_get_web_database_directory_path: * * Returns the current path to the directory WebKit will write Web * Database databases. By default this path will be in the user data * directory. * * Returns: the current database directory path * * Since: 1.1.14 **/ G_CONST_RETURN gchar* webkit_get_web_database_directory_path() { #if ENABLE(DATABASE) WebCore::String path = WebCore::DatabaseTracker::tracker().databaseDirectoryPath(); if (path.isEmpty()) return ""; g_free(webkit_database_directory_path); webkit_database_directory_path = g_strdup(path.utf8().data()); return webkit_database_directory_path; #else return ""; #endif }
// ---------------------------------------------------------------------------- void WebCoreResourceLoader::SetResponseHeader(JNIEnv* env, jobject obj, jint nativeResponse, jstring key, jstring val) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse; LOG_ASSERT(response, "nativeSetResponseHeader must take a valid response pointer!"); LOG_ASSERT(key, "How did a null value become a key?"); if (val) { WebCore::String valStr = to_string(env, val); if (!valStr.isEmpty()) response->setHTTPHeaderField(to_string(env, key), valStr); } }
/** * webkit_web_database_get_display_name: * @web_database: a #WebKitWebDatabase * * Returns the name of the #WebKitWebDatabase as seen by the user. * * Returns: the name of the database as seen by the user. * * Since: 1.1.14 **/ G_CONST_RETURN gchar* webkit_web_database_get_display_name(WebKitWebDatabase* webDatabase) { g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL); #if ENABLE(DATABASE) WebKitWebDatabasePrivate* priv = webDatabase->priv; WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(priv->name, core(priv->origin)); WebCore::String displayName = details.displayName(); if (displayName.isEmpty()) return ""; g_free(priv->displayName); priv->displayName = g_strdup(displayName.utf8().data()); return priv->displayName; #else return ""; #endif }
/** * webkit_web_database_get_filename: * @web_database: a #WebKitWebDatabase * * Returns the absolute filename to the #WebKitWebDatabase file on disk. * * Returns: the absolute filename of the database * * Since: 1.1.14 **/ G_CONST_RETURN gchar* webkit_web_database_get_filename(WebKitWebDatabase* webDatabase) { g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL); #if ENABLE(DATABASE) WebKitWebDatabasePrivate* priv = webDatabase->priv; WebCore::String coreName = WebCore::String::fromUTF8(priv->name); WebCore::String corePath = WebCore::DatabaseTracker::tracker().fullPathForDatabase(core(priv->origin), coreName); if (corePath.isEmpty()) return""; g_free(priv->filename); priv->filename = g_strdup(corePath.utf8().data()); return priv->filename; #else return ""; #endif }
void WebDebugListenerImpl::sourceParsed(ExecState* execState, const SourceCode& source, int errorLine, const UString& errorMsg) { if (m_listener && !m_inDebug) { m_inDebug = true; WebCore::String coreSourceURL = WebCore::ustringToString(source.provider()->url()); WebCore::Frame *frame = static_cast<WebCore::JSDOMWindow*>(execState->lexicalGlobalObject())->impl()->frame(); if (!(coreSourceURL.isNull() || coreSourceURL.isEmpty())) { WebCore::KURL sourceURL(WebCore::ParsedURLString, coreSourceURL); WebCore::KURL mappedURL; if(WebCore::FrameLoaderClientApollo::mapFrameUrl(frame, sourceURL, &mappedURL)) { coreSourceURL = mappedURL.string(); } } WebCore::String coreErrorMsg = WebCore::ustringToString(errorMsg); WebCore::String coreSource(source.data(), source.length()); m_listener->m_pVTable->sourceParsed(m_listener, source.provider()->asID(), coreSourceURL.webString(), coreSource.webString(), source.firstLine(), errorLine, coreErrorMsg.webString()); m_inDebug = false; } }