jstring WebCoreResourceLoader::RedirectedToUrl(JNIEnv* env, jobject obj,
        jstring baseUrl, jstring redirectTo, jint nativeResponse)
{
#ifdef ANDROID_INSTRUMENT
    TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
    LOGV("webcore_resourceloader redirectedToUrl");
    WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
    LOG_ASSERT(handle, "nativeRedirectedToUrl must take a valid handle!");
    // ResourceLoader::didFail() can set handle to be NULL, we need to check
    if (!handle)
        return NULL;

    LOG_ASSERT(handle->client(), "Why do we not have a client?");
    WebCore::ResourceRequest r = handle->request();
    WebCore::KURL url(WebCore::KURL(WebCore::ParsedURLString, to_string(env, baseUrl)),
            to_string(env, redirectTo));
    r.setURL(url);
    if (r.httpMethod() == "POST") {
        r.setHTTPMethod("GET");
        r.clearHTTPReferrer();
        r.setHTTPBody(0);
        r.setHTTPContentType("");
    }
    WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse;
    // If the url fails to resolve the relative path, return null.
    if (url.protocol().isEmpty()) {
        delete response;
        return NULL;
    }
    handle->client()->willSendRequest(handle, r, *response);
    delete response;
    WebCore::String s = url.string();
    return env->NewString((unsigned short*)s.characters(), s.length());
}
static const char* anp_getApplicationDataDirectory() {
    if (NULL == gApplicationDataDir) {
        PluginClient* client = JavaSharedClient::GetPluginClient();
        if (!client)
            return NULL;

        WebCore::String path = client->getPluginSharedDataDirectory();
        int length = path.length();
        if (length == 0)
            return NULL;

        char* storage = (char*) malloc(length + 1);
        if (NULL == storage)
            return NULL;

        memcpy(storage, path.utf8().data(), length);
        storage[length] = '\0';

        // save this assignment for last, so that if multiple threads call us
        // (which should never happen), we never return an incomplete global.
        // At worst, we would allocate storage for the path twice.
        gApplicationDataDir = storage;
    }
    return gApplicationDataDir;
}
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)));
        }
    }
// Keep this in sync with the other platform event constructors
// TODO: m_balEventKey should be refcounted
PlatformKeyboardEvent::PlatformKeyboardEvent(BalEventKey* event)
    : m_type((event->state == SDL_RELEASED) ? KeyUp : KeyDown)
    , m_autoRepeat(false)
    , m_windowsVirtualKeyCode(ConvertSDLKeyToVirtualKey(event->keysym.sym, event->keysym.mod))
    , m_isKeypad(event->keysym.sym >= SDLK_KP0 && event->keysym.sym <= SDLK_KP_EQUALS)
    , m_shiftKey(event->keysym.mod & KMOD_SHIFT)
    , m_ctrlKey(event->keysym.mod & KMOD_CTRL)
    , m_altKey(event->keysym.mod & KMOD_ALT)
    , m_metaKey(event->keysym.mod & KMOD_META)
    , m_balEventKey(event)
{
    UChar aSrc[2];
    aSrc[0] = event->keysym.unicode;
    aSrc[1] = 0;

    WebCore::String aText(aSrc);
    WebCore::String aUnmodifiedText(aSrc);
    WebCore::String aKeyIdentifier = keyIdentifierForSDLKeyCode(event->keysym.sym);

    m_text = aText;
    m_unmodifiedText = aUnmodifiedText;
    m_keyIdentifier = aKeyIdentifier;

#if ENABLE(CEHTML)
    bool isVKKey = event->keysym.scancode == 0xFF && event->keysym.sym == event->keysym.unicode;
    if (UNLIKELY(isVKKey)) {
        WebCore::String vkKey = convertVKKeyToString(event->keysym.sym);
        ASSERT(!vkKey.isNull());
        m_keyIdentifier = vkKey;
        m_unmodifiedText = vkKey;
        m_windowsVirtualKeyCode = event->keysym.sym;
    }
#endif
}
static void write_string(WTF::Vector<char>& v, const WebCore::String& str)
{
    unsigned strLen = str.length();
    // Only do work if the string has data.
    if (strLen) {
        // Determine how much to grow the vector. Use the worst case for utf8 to
        // avoid reading the string twice. Add sizeof(unsigned) to hold the
        // string length in utf8.
        unsigned vectorLen = v.size() + sizeof(unsigned);
        unsigned length = (strLen << 2) + vectorLen;
        // Grow the vector. This will change the value of v.size() but we
        // remember the original size above.
        v.grow(length);
        // Grab the position to write to.
        char* data = v.begin() + vectorLen;
        // Write the actual string
        int l = SkUTF16_ToUTF8(str.characters(), strLen, data);
        LOGV("Writing string       %d %.*s", l, l, data);
        // Go back and write the utf8 length. Subtract sizeof(unsigned) from
        // data to get the position to write the length.
        memcpy(data - sizeof(unsigned), (char*)&l, sizeof(unsigned));
        // Shrink the internal state of the vector so we match what was
        // actually written.
        v.shrink(vectorLen + l);
    } else
        v.append((char*)&strLen, sizeof(unsigned));
}
static jobject GetOrigins(JNIEnv* env, jobject obj)
{
    Vector<RefPtr<WebCore::SecurityOrigin> > coreOrigins;
    WebCore::DatabaseTracker::tracker().origins(coreOrigins);
    Vector<WebCore::KURL> manifestUrls;
    if (WebCore::cacheStorage().manifestURLs(&manifestUrls)) {
        int size = manifestUrls.size();
        for (int i = 0; i < size; ++i) {
            RefPtr<WebCore::SecurityOrigin> manifestOrigin = WebCore::SecurityOrigin::create(manifestUrls[i]);
            if (manifestOrigin.get() == 0)
                continue;
            coreOrigins.append(manifestOrigin);
        }
    }

    jclass setClass = env->FindClass("java/util/HashSet");
    jmethodID cid = env->GetMethodID(setClass, "<init>", "()V");
    jmethodID mid = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z");
    jobject set = env->NewObject(setClass, cid);

    for (unsigned i = 0; i < coreOrigins.size(); ++i) {
        WebCore::SecurityOrigin* origin = coreOrigins[i].get();
        WebCore::String url = origin->toString();
        jstring jUrl = env->NewString(url.characters(), url.length());
        env->CallBooleanMethod(set, mid, jUrl);
        env->DeleteLocalRef(jUrl);
    }

    return set;
}
HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && m_element->hasTagName(formTag));
    WebCore::String methodString = static_cast<HTMLFormElement*>(m_element)->method();
    *result = BString(methodString.characters(), methodString.length()).release();
    return S_OK;
}
HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && m_element->isHTMLElement());
    WebCore::String innerTextString = static_cast<HTMLElement*>(m_element)->innerText();
    *result = BString(innerTextString.characters(), innerTextString.length()).release();
    return S_OK;
}
Beispiel #9
0
/**
 * Return directory path where web database is stored.
 *
 * @return newly allocated string with database path. Note that return must be
 * freed with free() as it's a strdup()ed copy of the string due reference
 * counting.
 */
const char *ewk_settings_web_database_path_get()
{
#if ENABLE(DATABASE)
    WebCore::String path = WebCore::DatabaseTracker::tracker().databaseDirectoryPath();
    return strdup(path.utf8().data());
#else
    return 0;
#endif
}
Beispiel #10
0
/**
 * webkit_set_web_database_directory_path:
 * @path: the new database directory path
 *
 * Sets the current path to the directory WebKit will write Web 
 * Database databases. 
 *
 * Since: 1.1.14
 **/
void webkit_set_web_database_directory_path(const gchar* path)
{
#if ENABLE(DATABASE)
    WebCore::String corePath = WebCore::String::fromUTF8(path);
    WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(corePath);

    g_free(webkit_database_directory_path);
    webkit_database_directory_path = g_strdup(corePath.utf8().data());
#endif
}
HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyValue( 
    /* [in] */ BSTR propertyName,
    /* [retval][out] */ BSTR* result)
{
    WebCore::String propertyNameString(propertyName);
    WebCore::String value = m_style->getPropertyValue(propertyNameString);
    *result = SysAllocStringLen(value.characters(), value.length());
    if (value.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::value( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && m_element->hasTagName(textareaTag));
    HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
    WebCore::String valueString = textareaElement->value();
    *result = BString(valueString.characters(), valueString.length()).release();
    if (valueString.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
Beispiel #13
0
/**
 * 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());
}
/**
 * webkit_security_origin_get_host:
 * @security_origin: a #WebKitSecurityOrigin
 *
 * Returns the hostname for the security origin.
 *
 * Returns: the hostname for the security origin
 *
 * Since: 1.1.14
 **/
G_CONST_RETURN gchar* webkit_security_origin_get_host(WebKitSecurityOrigin* securityOrigin)
{
    g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);

    WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
    WebCore::String host =  priv->coreOrigin->host();

    if (!priv->host)
        priv->host = g_strdup(host.utf8().data());

    return priv->host;
}
Beispiel #15
0
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;
}
bool PlugInInfoStore::supportsMIMEType(WebCore::String const& mimetype)
{
    logm(MODULE_FACILITIES, mimetype.deprecatedString().ascii());
    if (mimetype == "application/x-origyn-mediaplayer") {
        logm(MODULE_FACILITIES, make_message("mime-type '%s' is supported",
             mimetype.deprecatedString().ascii()));
        return true;
    } else {
        logm(MODULE_FACILITIES, make_message("mime-type '%s' is not supported",
             mimetype.deprecatedString().ascii()));
        return false;
    }
}
Beispiel #17
0
void
JavaBridge::setCookies(WebCore::KURL const& url, WebCore::String const& value)
{
    JNIEnv* env = JSC::Bindings::getJNIEnv();
    const WebCore::String& urlStr = url.string();
    jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length());
    jstring jValueStr = env->NewString(value.characters(), value.length());

    AutoJObject obj = getRealObject(env, mJavaObject);
    env->CallVoidMethod(obj.get(), mSetCookies, jUrlStr, jValueStr);
    env->DeleteLocalRef(jUrlStr);
    env->DeleteLocalRef(jValueStr);
}
/*
* This static method is called to check to see if a POST response is in
* the cache. This may be slow, but is only used during a navigation to
* a POST response.
*/
bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t identifier)
{
    JNIEnv* env = JSC::Bindings::getJNIEnv();
    WebCore::String urlStr = url.string();
    jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length());
    jclass resourceLoader = env->FindClass("android/webkit/LoadListener");
    bool val = env->CallStaticBooleanMethod(resourceLoader, 
            gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier);
    checkException(env);
    env->DeleteLocalRef(jUrlStr);

    return val;
}
Beispiel #19
0
/**
 * 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
}
/**
 * webkit_web_history_item_get_original_uri:
 * @webHistoryItem: a #WebKitWebHistoryItem
 *
 * Returns the original URI of @webHistoryItem.
 *
 * Return value: the original URI of @webHistoryITem
 */
G_CONST_RETURN gchar* webkit_web_history_item_get_original_uri(WebKitWebHistoryItem* webHistoryItem)
{
    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);

    WebCore::HistoryItem* item = core(WEBKIT_WEB_HISTORY_ITEM(webHistoryItem));

    g_return_val_if_fail(item != NULL, NULL);

    WebCore::String originalUri = item->originalURLString();
    WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
    g_free(priv->originalUri);
    priv->originalUri = g_strdup(originalUri.utf8().data());

    return webHistoryItem->priv->originalUri;
}
/**
 * webkit_web_history_item_get_alternate_title:
 * @webHistoryItem: a #WebKitWebHistoryItem
 *
 * Returns the alternate title of @webHistoryItem
 *
 * Return value: the alternate title of @webHistoryItem
 */
G_CONST_RETURN gchar* webkit_web_history_item_get_alternate_title(WebKitWebHistoryItem* webHistoryItem)
{
    g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);

    WebCore::HistoryItem* item = core(webHistoryItem);

    g_return_val_if_fail(item != NULL, NULL);

    WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
    WebCore::String alternateTitle = item->alternateTitle();
    g_free(priv->alternateTitle);
    priv->alternateTitle = g_strdup(alternateTitle.utf8().data());

    return priv->alternateTitle;
}
Beispiel #22
0
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);
}
// ----------------------------------------------------------------------------
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);
    }
}
Beispiel #24
0
WebCore::String JavaBridge::getSignedPublicKeyAndChallengeString(unsigned index,
        const WebCore::String& challenge, const WebCore::KURL& url) {
    JNIEnv* env = JSC::Bindings::getJNIEnv();
    jstring jChallenge = env->NewString(challenge.characters(),
                                        challenge.length());
    const WebCore::String& urlStr = url.string();
    jstring jUrl = env->NewString(urlStr.characters(), urlStr.length());
    AutoJObject obj = getRealObject(env, mJavaObject);
    jstring key = (jstring) env->CallObjectMethod(obj.get(),
                  mGetSignedPublicKey, index, jChallenge, jUrl);
    WebCore::String ret = to_string(env, key);
    env->DeleteLocalRef(jChallenge);
    env->DeleteLocalRef(jUrl);
    env->DeleteLocalRef(key);
    return ret;
}
Beispiel #25
0
/**
 * 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
}
Beispiel #26
0
/**
 * 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
}
jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url, jint statusCode,
                                                    jstring statusText, jstring mimeType, jlong expectedLength,
                                                    jstring encoding)
{
#ifdef ANDROID_INSTRUMENT
    TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
    LOG_ASSERT(url, "Must have a url in the response!");
    WebCore::KURL kurl(WebCore::ParsedURLString, to_string(env, url));
    WebCore::String encodingStr;
    WebCore::String mimeTypeStr;
    if (mimeType) {
        mimeTypeStr = to_string(env, mimeType);
        LOGV("Response setMIMEType: %s", mimeTypeStr.latin1().data());
    }
    if (encoding) {
        encodingStr = to_string(env, encoding);
        LOGV("Response setTextEncodingName: %s", encodingStr.latin1().data());
    }
    WebCore::ResourceResponse* response = new WebCore::ResourceResponse(
            kurl, mimeTypeStr, (long long)expectedLength,
            encodingStr, WebCore::String());
    response->setHTTPStatusCode(statusCode);
    if (statusText) {
        WebCore::String status = to_string(env, statusText);
        response->setHTTPStatusText(status);
        LOGV("Response setStatusText: %s", status.latin1().data());
    }
    return (int)response;
}
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;
    }
}
void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) {
    // Do not want to update during inflation.
    if (!m_active)
        return;
    WebHistoryItem* webItem = this;
    // Now we need to update the top-most WebHistoryItem based on the top-most
    // HistoryItem.
    if (m_parent) {
        webItem = m_parent.get();
        if (webItem->hasOneRef()) {
            // if the parent only has one ref, it is from this WebHistoryItem.
            // This means that the matching WebCore::HistoryItem has been freed.
            // This can happen during clear().
            LOGW("Can't updateHistoryItem as the top HistoryItem is gone");
            return;
        }
        while (webItem->parent())
            webItem = webItem->parent();
        item = webItem->historyItem();
        if (!item) {
            // If a HistoryItem only exists for page cache, it is possible that
            // the parent HistoryItem destroyed before the child HistoryItem. If
            // it happens, skip updating.
            LOGW("Can't updateHistoryItem as the top HistoryItem is gone");
            return;
        }
    }
    JNIEnv* env = JSC::Bindings::getJNIEnv();
    if (!env)
        return;

    // Don't do anything if the item has been gc'd already
    AutoJObject realItem = getRealObject(env, webItem->m_object);
    if (!realItem.get())
        return;

    const WebCore::String& urlString = item->urlString();
    jstring urlStr = NULL;
    if (!urlString.isNull())
        urlStr = env->NewString((unsigned short*)urlString.characters(), urlString.length());
    const WebCore::String& originalUrlString = item->originalURLString();
    jstring originalUrlStr = NULL;
    if (!originalUrlString.isNull()) {
    	originalUrlStr = env->NewString(
                (unsigned short*) originalUrlString.characters(), 
                originalUrlString.length());
    }
    const WebCore::String& titleString = item->title();
    jstring titleStr = NULL;
    if (!titleString.isNull())
        titleStr = env->NewString((unsigned short*)titleString.characters(), titleString.length());

    // Try to get the favicon from the history item. For some pages like Grand
    // Prix, there are history items with anchors. If the icon fails for the
    // item, try to get the icon using the url without the ref.
    jobject favicon = NULL;
    WebCore::String url = item->urlString();
    if (item->url().hasFragmentIdentifier()) {
        int refIndex = url.reverseFind('#');
        url = url.substring(0, refIndex);
    }
    WebCore::Image* icon = WebCore::iconDatabase()->iconForPageURL(url,
            WebCore::IntSize(16, 16));

    if (icon)
        favicon = webcoreImageToJavaBitmap(env, icon);

    WTF::Vector<char> data;
    jbyteArray array = WebHistory::Flatten(env, data, item);
    env->CallVoidMethod(realItem.get(), gWebHistoryItem.mUpdate, urlStr,
            originalUrlStr, titleStr, favicon, array);
    env->DeleteLocalRef(urlStr);
    env->DeleteLocalRef(originalUrlStr);
    env->DeleteLocalRef(titleStr);
    if (favicon)
        env->DeleteLocalRef(favicon);
    env->DeleteLocalRef(array);
}
Beispiel #30
0
void ChromeClient::addMessageToConsole(WebCore::MessageSource source, WebCore::MessageType type, WebCore::MessageLevel level, const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceId)
{
    gboolean retval;
    g_signal_emit_by_name(m_webView, "console-message", message.utf8().data(), lineNumber, sourceId.utf8().data(), &retval);
}