コード例 #1
0
ファイル: DOMTokenList.cpp プロジェクト: rhythmkay/webkit
void DOMTokenList::setValueInternal(const WTF::String& value)
{
    // Clear tokens but not capacity.
    m_tokens.shrink(0);

    HashSet<AtomicString> addedTokens;
    // https://dom.spec.whatwg.org/#ordered%20sets
    for (unsigned start = 0; ; ) {
        while (start < value.length() && isHTMLSpace(value[start]))
            ++start;
        if (start >= value.length())
            break;
        unsigned end = start + 1;
        while (end < value.length() && !isHTMLSpace(value[end]))
            ++end;

        AtomicString token = value.substring(start, end - start);
        if (!addedTokens.contains(token)) {
            m_tokens.append(token);
            addedTokens.add(token);
        }

        start = end + 1;
    }

    m_tokens.shrinkToFit();
    m_cachedValue = nullAtom;
}
コード例 #2
0
ファイル: DOMSupport.cpp プロジェクト: Moondee/Artemis
bool elementPatternMatches(const char* pattern, const HTMLInputElement* inputElement)
{
    WTF::String patternString(pattern);
    if (!inputElement || patternString.isEmpty())
        return false;

    if (inputElement->fastHasAttribute(HTMLNames::patternAttr)) {
        WTF::String patternAttribute = inputElement->fastGetAttribute(HTMLNames::patternAttr);
        if (patternAttribute.startsWith(patternString)) {
            // The pattern is for hexadecimal, make sure nothing else is permitted.

            // Check if it was an exact match.
            if (patternAttribute.length() == patternString.length())
                return true;

            // Check for *
            if (patternAttribute.length() == patternString.length() + 1 && patternAttribute[patternString.length()] == '*')
                return true;

            // Is the regex specifying a character count?
            if (patternAttribute[patternString.length()] != '{' || !patternAttribute.endsWith('}'))
                return false;

            // Make sure the number in the regex is actually a number.
            unsigned count = 0;
            patternString = patternString + "{%d}";
            return (sscanf(patternAttribute.latin1().data(), patternString.latin1().data() + '\0', &count) == 1) && count > 0;
        }
    }
    return false;
}
void setDataToClipBoard(WTF::String& format , WTF::String& data){

    LOGD("   setDataToClipBoard :  Enter");	
	
    JNIEnv* env = JSC::Bindings::getJNIEnv();
    if(env == NULL || format.isEmpty() || data.isEmpty())
    	return;


    jstring jFormat = env->NewString((jchar*) format.characters(), format.length());	
    jstring jData = env->NewString((jchar*) data.characters(), data.length());

    if((m_javaGlueForPasteBoard.object(env).get() == NULL )||(m_javaGlueForPasteBoard.m_setDataToClipBoard  ==  0 ))
    {
       LOGD("   setDataToClipBoard :  return with out copy");	
	return;
    }
    env->CallVoidMethod(m_javaGlueForPasteBoard.object(env).get(),
        	 m_javaGlueForPasteBoard.m_setDataToClipBoard , jFormat , jData);


    env->DeleteLocalRef(jFormat); 
    env->DeleteLocalRef(jData);
    checkException(env);
}
コード例 #4
0
HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyValue( 
    /* [in] */ BSTR propertyName,
    /* [retval][out] */ BSTR* result)
{
    WTF::String propertyNameString(propertyName);
    WTF::String value = m_style->getPropertyValue(propertyNameString);
    *result = SysAllocStringLen(value.characters(), value.length());
    if (value.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #5
0
HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::value( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && isHTMLInputElement(m_element));
    HTMLInputElement* inputElement = toHTMLInputElement(m_element);
    WTF::String valueString = inputElement->value();
    *result = BString(valueString.characters(), valueString.length()).release();
    if (valueString.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #6
0
HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::value( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && m_element->hasTagName(textareaTag));
    HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
    WTF::String valueString = textareaElement->value();
    *result = BString(valueString.characters(), valueString.length()).release();
    if (valueString.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #7
0
HRESULT STDMETHODCALLTYPE DOMNode::nodeValue( 
    /* [retval][out] */ BSTR* result)
{
    if (!m_node)
        return E_FAIL;
    WTF::String nodeValueStr = m_node->nodeValue();
    *result = SysAllocStringLen(nodeValueStr.characters(), nodeValueStr.length());
    if (nodeValueStr.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #8
0
static void writeString(WTF::Vector<char>& vector, const WTF::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 = vector.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.
        vector.grow(length);
        // Grab the position to write to.
        char* data = vector.begin() + vectorLen;
        // Write the actual string
        int l = SkUTF16_ToUTF8(str.characters(), strLen, data);
        ALOGV("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.
        vector.shrink(vectorLen + l);
    } else
        vector.append((char*)&strLen, sizeof(unsigned));
}
コード例 #9
0
HRESULT AccessibleText::get_textAtOffset(long offset, enum IA2TextBoundaryType boundaryType, long* startOffset, long* endOffset, BSTR* text)
{
    if (initialCheck() == E_POINTER)
        return E_POINTER;

    if (!startOffset || !endOffset || !text)
        return E_POINTER;

    int textLength = m_object->stringValue().length();

    offset = convertSpecialOffset(offset);

    if (offset < 0 || offset > textLength)
        return E_INVALIDARG;

    // Obtain the desired text range
    VisiblePosition currentPosition = m_object->visiblePositionForIndex(offset);
    VisiblePositionRange textRange;
    switch (boundaryType) {
    case IA2_TEXT_BOUNDARY_CHAR:
        textRange = m_object->visiblePositionRangeForRange(PlainTextRange(offset, 1));
        break;
    case IA2_TEXT_BOUNDARY_WORD:
        textRange = m_object->positionOfRightWord(leftWordPosition(currentPosition.next(), true));
        break;
    case IA2_TEXT_BOUNDARY_SENTENCE:
        textRange = m_object->sentenceForPosition(currentPosition);
        break;
    case IA2_TEXT_BOUNDARY_PARAGRAPH:
        textRange = m_object->paragraphForPosition(currentPosition);
        break;
    case IA2_TEXT_BOUNDARY_LINE:
        textRange = m_object->leftLineVisiblePositionRange(currentPosition);
        break;
    case IA2_TEXT_BOUNDARY_ALL:
        textRange = m_object->visiblePositionRangeForRange(PlainTextRange(0, m_object->text().length()));
        break;
    default:
        return E_INVALIDARG;
        break;
    }

    // Obtain string and offsets associated with text range
    *startOffset = textRange.start.deepEquivalent().offsetInContainerNode();
    *endOffset = textRange.end.deepEquivalent().offsetInContainerNode();

    if (*startOffset == *endOffset)
        return S_FALSE;

    WTF::String substringText = m_object->text().substring(*startOffset, *endOffset - *startOffset);
    *text = BString(substringText).release();

    if (substringText.length() && !*text)
        return E_OUTOFMEMORY;

    if (!*text)
        return S_FALSE;

    return S_OK;
}
コード例 #10
0
HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && m_element->hasTagName(formTag));
    WTF::String methodString = static_cast<HTMLFormElement*>(m_element)->method();
    *result = BString(methodString.characters(), methodString.length()).release();
    return S_OK;
}
コード例 #11
0
HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && isHTMLFormElement(m_element));
    WTF::String methodString = toHTMLFormElement(m_element)->method();
    *result = BString(methodString.characters(), methodString.length()).release();
    return S_OK;
}
コード例 #12
0
HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && m_element->isHTMLElement());
    WTF::String innerTextString = static_cast<HTMLElement*>(m_element)->innerText();
    *result = BString(innerTextString.characters(), innerTextString.length()).release();
    return S_OK;
}
コード例 #13
0
ファイル: SquirrelThread.cpp プロジェクト: eriser/kdguigl
static PBEcode SquirrelPrecompil(WTF::String& code, Vector<UChar>& codeCache) {
    PBEcode	 rt = EnumPBSuccess;
    Vector<UChar> codeFake;

    wcsncpy((wchar_t *)&codeCache[0], (const wchar_t *)code.characters(), code.length());

    int x1 = wcslen((const wchar_t *)&codeCache[0]);

    rt = StrReplaceCase_0((wchar_t *)&codeCache[0], code.length()); // 去掉注释
    if ( rt != EnumPBSuccess )
        goto Exit0;
    
    codeFake = codeCache;
    OutputDebugStringW((wchar_t *)&codeCache[0]);

    int xx = wcslen((const wchar_t *)&codeFake[0]);
    

    rt = StrReplaceCase_1((const wchar_t *)codeFake.data(), code.length(), (wchar_t *)codeCache.data(), codeCache.size()); // 识别class
    if ( rt != EnumPBSuccess )
        goto Exit0;

    OutputDebugStringW((wchar_t *)&codeCache[0]);

    rt = StrReplaceCase_2((wchar_t *)&codeCache[0], codeCache.size()); // 识别.prototype.
    if ( rt != EnumPBSuccess )
        goto Exit0;

    OutputDebugStringW((wchar_t *)&codeCache[0]);

    rt = StrReplaceCase_3((wchar_t *)&codeCache[0], codeCache.size()); // 去掉new 
    if ( rt != EnumPBSuccess )
        goto Exit0;

    rt = StrReplaceCase_4((wchar_t *)&codeCache[0], codeCache.size()); // for in
    if ( rt != EnumPBSuccess )
        goto Exit0;

    OutputDebugStringW((wchar_t *)&codeCache[0]);

Exit0:
    return rt;
}
コード例 #14
0
bool ChromeClientBlackBerry::runJavaScriptConfirm(Frame* frame, const WTF::String& message)
{
    if (m_webPage->d->m_dumpRenderTree)
        return m_webPage->d->m_dumpRenderTree->runJavaScriptConfirm(message);
    TimerBase::fireTimersInNestedEventLoop();

    CString latinOrigin = frameOrigin(frame);
    return m_webPage->client()->runJavaScriptConfirm(message.characters(), message.length(), latinOrigin.data(), latinOrigin.length());

}
コード例 #15
0
HRESULT STDMETHODCALLTYPE DOMHTMLInputElement::value( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(is<HTMLInputElement>(m_element));
    HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element);
    WTF::String valueString = inputElement.value();
    *result = BString(valueString).release();
    if (valueString.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #16
0
ファイル: DOMCSSClasses.cpp プロジェクト: clbr/webkitfltk
HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyValue( 
    /* [in] */ BSTR propertyName,
    /* [retval][out] */ BSTR* result)
{
    WTF::String propertyNameString(propertyName);
    WTF::String value = m_style->getPropertyValue(propertyNameString);
    *result = WebCore::BString(value).release();
    if (value.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #17
0
ファイル: DOMCoreClasses.cpp プロジェクト: clbr/webkitfltk
HRESULT STDMETHODCALLTYPE DOMNode::nodeValue( 
    /* [retval][out] */ BSTR* result)
{
    if (!m_node)
        return E_FAIL;
    WTF::String nodeValueStr = m_node->nodeValue();
    *result = BString(nodeValueStr).release();
    if (nodeValueStr.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #18
0
ファイル: DOMHTMLClasses.cpp プロジェクト: PTaylour/webkit
HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::value( 
        /* [retval][out] */ BSTR* result)
{
    ASSERT(m_element && isHTMLTextAreaElement(m_element));
    HTMLTextAreaElement* textareaElement = toHTMLTextAreaElement(m_element);
    WTF::String valueString = textareaElement->value();
    *result = BString(valueString).release();
    if (valueString.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #19
0
ファイル: DOMHTMLClasses.cpp プロジェクト: eocanha/webkit
HRESULT DOMHTMLTextAreaElement::value(__deref_opt_out BSTR* result)
{
    if (!result)
        return E_POINTER;

    ASSERT(is<HTMLTextAreaElement>(m_element));
    HTMLTextAreaElement& textareaElement = downcast<HTMLTextAreaElement>(*m_element);
    WTF::String valueString = textareaElement.value();
    *result = BString(valueString).release();
    if (valueString.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #20
0
HRESULT DOMNode::nodeValue(__deref_opt_out BSTR* result)
{
    if (!result)
        return E_POINTER;
    *result = nullptr;
    if (!m_node)
        return E_FAIL;
    WTF::String nodeValueStr = m_node->nodeValue();
    *result = BString(nodeValueStr).release();
    if (nodeValueStr.length() && !*result)
        return E_OUTOFMEMORY;
    return S_OK;
}
コード例 #21
0
HRESULT AccessibleText::get_text(long startOffset, long endOffset, BSTR* text)
{
    if (initialCheck() == E_POINTER)
        return E_POINTER;

    startOffset = convertSpecialOffset(startOffset);
    endOffset = convertSpecialOffset(endOffset);
    WTF::String substringText = m_object->stringValue().substring(startOffset, endOffset - startOffset);

    *text = BString(substringText).release();
    if (substringText.length() && !*text)
        return E_OUTOFMEMORY;

    return S_OK;
}
コード例 #22
0
bool MockSpellCheck::spellCheckWord(const WebString& text, int* misspelledOffset, int* misspelledLength)
{
    ASSERT(misspelledOffset);
    ASSERT(misspelledLength);

    // Initialize this spellchecker.
    initializeIfNeeded();

    // Reset the result values as our spellchecker does.
    *misspelledOffset = 0;
    *misspelledLength = 0;

    // Convert to a String because we store String instances in
    // m_misspelledWords and WebString has no find().
    const WTF::String stringText(text.data(), text.length());

    // Extract the first possible English word from the given string.
    // The given string may include non-ASCII characters or numbers. So, we
    // should filter out such characters before start looking up our
    // misspelled-word table.
    // (This is a simple version of our SpellCheckWordIterator class.)
    // If the given string doesn't include any ASCII characters, we can treat the
    // string as valid one.
    // Unfortunately, This implementation splits a contraction, i.e. "isn't" is
    // split into two pieces "isn" and "t". This is OK because webkit tests
    // don't have misspelled contractions.
    int wordOffset = stringText.find(isASCIIAlpha);
    if (wordOffset == -1)
        return true;
    int wordEnd = stringText.find(isNotASCIIAlpha, wordOffset);
    int wordLength = wordEnd == -1 ? stringText.length() - wordOffset : wordEnd - wordOffset;

    // Look up our misspelled-word table to check if the extracted word is a
    // known misspelled word, and return the offset and the length of the
    // extracted word if this word is a known misspelled word.
    // (See the comment in MockSpellCheck::initializeIfNeeded() why we use a
    // misspelled-word table.)
    WTF::String word = stringText.substring(wordOffset, wordLength);
    if (!m_misspelledWords.contains(word))
        return true;

    *misspelledOffset = wordOffset;
    *misspelledLength = wordLength;
    return false;
}
コード例 #23
0
bool ChromeClientBlackBerry::runJavaScriptPrompt(Frame* frame, const WTF::String& message, const WTF::String& defaultValue, WTF::String& result)
{
    WebString clientResult;

    if (m_webPage->d->m_dumpRenderTree) {
        result = m_webPage->d->m_dumpRenderTree->runJavaScriptPrompt(message, defaultValue);
        return true;
    }

    TimerBase::fireTimersInNestedEventLoop();

    CString latinOrigin = frameOrigin(frame);
    if (m_webPage->client()->runJavaScriptPrompt(message.characters(), message.length(), defaultValue.characters(), defaultValue.length(), latinOrigin.data(), latinOrigin.length(), clientResult)) {
        result = clientResult;
        return true;
    }
    return false;
}
コード例 #24
0
const string WebResponse::resolveMimeType(const string& url, const string& old_mime)
{
    // Use "text/html" as a default (matching the behaviour of the Apache
    // HTTP stack -- see guessMimeType() in LoadListener.java).
    string mimeType = old_mime.length() ? old_mime : "text/html";
    // Try to guess a better MIME type from the URL. We call
    // getMIMETypeForExtension rather than getMIMETypeForPath because the
    // latter defaults to "application/octet-stream" on failure.
    WebCore::KURL kurl(WebCore::ParsedURLString, url.c_str());
    WTF::String path = kurl.path();
    size_t extensionPos = path.reverseFind('.');
    if (extensionPos != WTF::notFound) {
        // We found a file extension.
        path.remove(0, extensionPos + 1);
        // TODO: Should use content-disposition instead of url if it is there
        WTF::String mime = WebCore::MIMETypeRegistry::getMIMETypeForExtension(path);
        if (!mime.isEmpty()) {
            // Great, we found a MIME type.
            mimeType = std::string(mime.utf8().data(), mime.length());
        }
    }
    return mimeType;
}
コード例 #25
0
void DebuggerAgentManager::sendCommandToV8(const WTF::String& cmd, v8::Debug::ClientData* data)
{
    v8::Debug::SendCommand(reinterpret_cast<const uint16_t*>(cmd.characters()), cmd.length(), data);
}
コード例 #26
0
void ChromeClientBlackBerry::exceededDatabaseQuota(Frame* frame, const WTF::String& name)
{
#if ENABLE(DATABASE)
    Document* document = frame->document();
    if (!document)
        return;

    SecurityOrigin* origin = document->securityOrigin();
    if (m_webPage->d->m_dumpRenderTree) {
        m_webPage->d->m_dumpRenderTree->exceededDatabaseQuota(origin, name);
        return;
    }

    DatabaseTracker& tracker = DatabaseTracker::tracker(document->groupName());

    unsigned long long totalUsage = tracker.totalDatabaseUsage();
    unsigned long long originUsage = tracker.usageForOrigin(origin);

    DatabaseDetails details = tracker.detailsForNameAndOrigin(name, origin);
    unsigned long long estimatedSize = details.expectedUsage();
    const WTF::String& nameStr = details.displayName();

    WTF::String originStr = origin->databaseIdentifier();

    unsigned long long quota = m_webPage->client()->databaseQuota(originStr.characters(), originStr.length(),
        nameStr.characters(), nameStr.length(), totalUsage, originUsage, estimatedSize);

    tracker.setQuota(origin, quota);
#endif
}
コード例 #27
0
void ChromeClientBlackBerry::addMessageToConsole(MessageSource, MessageType, MessageLevel, const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceID)
{
    if (m_webPage->d->m_dumpRenderTree)
        m_webPage->d->m_dumpRenderTree->addMessageToConsole(message, lineNumber, sourceID);
    m_webPage->client()->addMessageToConsole(message.characters(), message.length(), sourceID.characters(), sourceID.length(), lineNumber);
}
コード例 #28
0
    static void Sync(JNIEnv* env, jobject obj, jint frame)
    {
        WebCore::Frame* pFrame = (WebCore::Frame*)frame;
        ALOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__);
        WebCore::Settings* s = pFrame->settings();
        if (!s)
            return;
        WebCore::CachedResourceLoader* cachedResourceLoader = pFrame->document()->cachedResourceLoader();

#ifdef ANDROID_LAYOUT
        jobject layout = env->GetObjectField(obj, gFieldIds->mLayoutAlgorithm);
        WebCore::Settings::LayoutAlgorithm l = (WebCore::Settings::LayoutAlgorithm)
                env->CallIntMethod(layout, gFieldIds->mOrdinal);
        if (s->layoutAlgorithm() != l) {
            s->setLayoutAlgorithm(l);
            if (pFrame->document()) {
                pFrame->document()->styleSelectorChanged(WebCore::RecalcStyleImmediately);
                if (pFrame->document()->renderer()) {
                    recursiveCleanupForFullLayout(pFrame->document()->renderer());
                    ALOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout");
                    pFrame->view()->layout();
                    // FIXME: This call used to scroll the page to put the focus into view.
                    // It worked on the WebViewCore, but now scrolling is done outside of the
                    // WebViewCore, on the UI side, so there needs to be a new way to do this.
                    //pFrame->makeFocusVisible();
                }
            }
        }
#endif
        jint textSize = env->GetIntField(obj, gFieldIds->mTextSize);
        float zoomFactor = textSize / 100.0f;
        if (pFrame->textZoomFactor() != zoomFactor)
            pFrame->setTextZoomFactor(zoomFactor);

        jstring str = (jstring)env->GetObjectField(obj, gFieldIds->mStandardFontFamily);
        s->setStandardFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mFixedFontFamily);
        s->setFixedFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mSansSerifFontFamily);
        s->setSansSerifFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mSerifFontFamily);
        s->setSerifFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mCursiveFontFamily);
        s->setCursiveFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mFantasyFontFamily);
        s->setFantasyFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mDefaultTextEncoding);
//SAMSUNG Change >>
        String defaultEncoding = jstringToWtfString(env, str);
        if (defaultEncoding == "AutoDetect") {
            s->setUsesEncodingDetector(true);
        } else {
            s->setUsesEncodingDetector(false);
            s->setDefaultTextEncodingName(defaultEncoding);
        }
//SAMSUNG Change <<
        //s->setDefaultTextEncodingName(jstringToWtfString(env, str));

        str = (jstring)env->CallObjectMethod(obj, gFieldIds->mGetUserAgentString);//4.2 Merge
        WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str));
        WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent();

        jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode);
        WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextCacheMode(cacheMode);

        str = (jstring)env->CallObjectMethod(obj, gFieldIds->mGetAcceptLanguage);//4.2 Merge
        WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str));

        jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize);
        s->setMinimumFontSize(size);

        size = env->GetIntField(obj, gFieldIds->mMinimumLogicalFontSize);
        s->setMinimumLogicalFontSize(size);

        size = env->GetIntField(obj, gFieldIds->mDefaultFontSize);
        s->setDefaultFontSize(size);

        size = env->GetIntField(obj, gFieldIds->mDefaultFixedFontSize);
        s->setDefaultFixedFontSize(size);

        jboolean flag = env->GetBooleanField(obj, gFieldIds->mLoadsImagesAutomatically);
        s->setLoadsImagesAutomatically(flag);
        if (flag)
            cachedResourceLoader->setAutoLoadImages(true);

#ifdef ANDROID_BLOCK_NETWORK_IMAGE
        flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkImage);
        s->setBlockNetworkImage(flag);
        if(!flag)
            cachedResourceLoader->setBlockNetworkImage(false);
#endif
        flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkLoads);
        WebFrame* webFrame = WebFrame::getWebFrame(pFrame);
        webFrame->setBlockNetworkLoads(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled);
        s->setJavaScriptEnabled(flag);

// SERI - WebGL >>
#if ENABLE(WEBGL)
        flag = env->GetBooleanField(obj, gFieldIds->mWebGLEnabled);
        s->setWebGLEnabled(flag);
#endif
// SERI - WebGL <<

        flag = env->GetBooleanField(obj, gFieldIds->mAllowUniversalAccessFromFileURLs);
        s->setAllowUniversalAccessFromFileURLs(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mAllowFileAccessFromFileURLs);
        s->setAllowFileAccessFromFileURLs(flag);

        // Hyperlink auditing (the ping attribute) has similar privacy
        // considerations as does the running of JavaScript, so to keep the UI
        // simpler, we leverage the same setting.
        s->setHyperlinkAuditingEnabled(flag);

        // ON = 0
        // ON_DEMAND = 1
        // OFF = 2
        jobject pluginState = env->GetObjectField(obj, gFieldIds->mPluginState);
        int state = env->CallIntMethod(pluginState, gFieldIds->mOrdinal);
        s->setPluginsEnabled(state < 2);
#ifdef ANDROID_PLUGINS
        s->setPluginsOnDemand(state == 1);
#endif

#if ENABLE(OFFLINE_WEB_APPLICATIONS)
        // We only enable AppCache if it's been enabled with a call to
        // setAppCacheEnabled() and if a valid path has been supplied to
        // setAppCachePath(). Note that the path is applied to all WebViews
        // whereas enabling is applied per WebView.

        // WebCore asserts that the path is only set once. Since the path is
        // shared between WebViews, we can't do the required checks to guard
        // against this in the Java WebSettings.
        bool isPathValid = false;
        if (cacheStorage().cacheDirectory().isNull()) {
            str = static_cast<jstring>(env->GetObjectField(obj, gFieldIds->mAppCachePath));
            // Check for non-null string as an optimization, as this is the common case.
            if (str) {
                String path = jstringToWtfString(env, str);
                ALOG_ASSERT(!path.empty(), "Java side should never send empty string for AppCache path");
                // This database is created on the first load. If the file
                // doesn't exist, we create it and set its permissions. The
                // filename must match that in ApplicationCacheStorage.cpp.
                String filename = pathByAppendingComponent(path, "ApplicationCache.db");
                int fd = open(filename.utf8().data(), O_CREAT, permissionFlags660);
                if (fd >= 0) {
                    close(fd);
                    cacheStorage().setCacheDirectory(path);
                    isPathValid = true;
              }
            }
        } else
            isPathValid = true;

        flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled);
        s->setOfflineWebApplicationCacheEnabled(flag && isPathValid);

        jlong maxsize = env->GetLongField(obj, gFieldIds->mAppCacheMaxSize);
        cacheStorage().setMaximumSize(maxsize);
#endif

        flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptCanOpenWindowsAutomatically);
        s->setJavaScriptCanOpenWindowsAutomatically(flag);

#ifdef ANDROID_LAYOUT
        flag = env->GetBooleanField(obj, gFieldIds->mUseWideViewport);
        s->setUseWideViewport(flag);
#endif

#ifdef ANDROID_MULTIPLE_WINDOWS
        flag = env->GetBooleanField(obj, gFieldIds->mSupportMultipleWindows);
        s->setSupportMultipleWindows(flag);
#endif
        flag = env->GetBooleanField(obj, gFieldIds->mShrinksStandaloneImagesToFit);
        s->setShrinksStandaloneImagesToFit(flag);
        jlong maxImage = env->GetLongField(obj, gFieldIds->mMaximumDecodedImageSize);
        // Since in ImageSourceAndroid.cpp, the image will always not exceed
        // MAX_SIZE_BEFORE_SUBSAMPLE, there's no need to pass the max value to
        // WebCore, which checks (image_width * image_height * 4) as an
        // estimation against the max value, which is done in CachedImage.cpp.
        // And there're cases where the decoded image size will not
        // exceed the max, but the WebCore estimation will.  So the following
        // code is commented out to fix those cases.
        // if (maxImage == 0)
        //    maxImage = computeMaxBitmapSizeForCache();
        s->setMaximumDecodedImageSize(maxImage);

        flag = env->GetBooleanField(obj, gFieldIds->mPrivateBrowsingEnabled);
        s->setPrivateBrowsingEnabled(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mSyntheticLinksEnabled);
        s->setDefaultFormatDetection(flag);
        s->setFormatDetectionAddress(flag);
        s->setFormatDetectionEmail(flag);
        s->setFormatDetectionTelephone(flag);
#if ENABLE(DATABASE)
        flag = env->GetBooleanField(obj, gFieldIds->mDatabaseEnabled);
        WebCore::Database::setIsAvailable(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mDatabasePathHasBeenSet);
        if (flag) {
            // If the user has set the database path, sync it to the DatabaseTracker.
            str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath);
            if (str) {
                String path = jstringToWtfString(env, str);
                DatabaseTracker::tracker().setDatabaseDirectoryPath(path);
                // This database is created when the first HTML5 Database object is
                // instantiated. If the file doesn't exist, we create it and set its
                // permissions. The filename must match that in
                // DatabaseTracker.cpp.
                String filename = SQLiteFileSystem::appendDatabaseFileNameToPath(path, "Databases.db");
                int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660);
                if (fd >= 0)
                    close(fd);
            }
        }
#endif
#if ENABLE(FILE_SYSTEM)
        flag = env->GetBooleanField(obj, gFieldIds->mFilesystemEnabled);
        flag = env->GetBooleanField(obj, gFieldIds->mFileSystemPathHasBeenSet);
        if (flag) {
            // If the user has set the filesystem path, sync it to the LocalFileSystem.
            str = (jstring)env->GetObjectField(obj, gFieldIds->mFileSystemPath);
            if (str) {
                String path = jstringToWtfString(env, str);
                LocalFileSystem::localFileSystem().initializeLocalFileSystem(path);
            }
        }
#endif

// Samsung Change - HTML5 Web Notification	>>
#if ENABLE(NOTIFICATIONS)
	flag = env->GetBooleanField(obj, gFieldIds->mWebnotificationEnabled);
	//flag = env->GetBooleanField(obj, gFieldIds->mFileSystemPathHasBeenSet);
	//if (flag) {
	// If the user has set the Web notification path, sync it to the NotificationPresenterImpl.
	str = (jstring)env->GetObjectField(obj, gFieldIds->mWebnotificationDatabasePath);
	if (str) {
		String path = jstringToWtfString(env, str);
		NotificationPresenterImpl::setDatabasePath(path);
	}

	// ALWAYS ON = 0
        // ON_DEMAND = 1
        // OFF = 2
        jobject notificationState = env->GetObjectField(obj, gFieldIds->mNotificationState);
        int notifystate = env->CallIntMethod(notificationState, gFieldIds->mOrdinal);
	NotificationPresenterImpl::setSettingsValue(notifystate);
        //s->setPluginsEnabled(state < 2);

	   
        //}
#endif
// Samsung Change - HTML5 Web Notification	<<

#if ENABLE(DOM_STORAGE)
        flag = env->GetBooleanField(obj, gFieldIds->mDomStorageEnabled);
        s->setLocalStorageEnabled(flag);
        str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath);
        if (str) {
            WTF::String localStorageDatabasePath = jstringToWtfString(env,str);
            if (localStorageDatabasePath.length()) {
                localStorageDatabasePath = WebCore::pathByAppendingComponent(
                        localStorageDatabasePath, "localstorage");
                // We need 770 for folders
                mkdir(localStorageDatabasePath.utf8().data(),
                        permissionFlags660 | S_IXUSR | S_IXGRP);
                s->setLocalStorageDatabasePath(localStorageDatabasePath);
            }
        }
#endif
//SISO_HTMLComposer Start
	flag = env->GetBooleanField(obj, gFieldIds->mEditableSupport);
	if(flag)        
		s->setEditableLinkBehavior(WebCore::EditableLinkNeverLive);
		
	s->setEditableSupportEnabled(flag);		

    flag = env->GetBooleanField(obj, gFieldIds->mDisableAnimation);	
    s->setDisableAnimation(flag);

    flag = env->GetBooleanField(obj, gFieldIds->mHighResolutionDevice);
    s->setHighResolutionDevice(flag);
//SISO_HTMLComposer End	

//SAMSUNG ADVANCED TEXT SELECTION - BEGIN
        flag = env->GetBooleanField(obj, gFieldIds->mAdvanceTextSelection);
        s->setAdvancedSelectionEnabled(flag);
        jlong color = env->GetLongField(obj, gFieldIds->mAdvanceSelectionBgColor);
        if (-1 != color) {
            int r = ((color & 0x00FF0000) >> 16);
            int g = ((color & 0x0000FF00) >> 8);
            int b = (color & 0x000000FF);
            s->setAdvancedSelectionBgColor(r, g, b);
        }
コード例 #29
0
v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singleShot)
{
    int argumentCount = args.Length();

    if (argumentCount < 1)
        return v8::Undefined();

    DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
    ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document());

    if (!scriptContext) {
        V8Proxy::setDOMException(INVALID_ACCESS_ERR);
        return v8::Undefined();
    }

    v8::Handle<v8::Value> function = args[0];
    WTF::String functionString;
    if (!function->IsFunction()) {
        if (function->IsString())
            functionString = toWebCoreString(function);
        else {
            v8::Handle<v8::Value> v8String = function->ToString();

            // Bail out if string conversion failed.
            if (v8String.IsEmpty())
                return v8::Undefined();

            functionString = toWebCoreString(v8String);
        }

        // Don't allow setting timeouts to run empty functions!
        // (Bug 1009597)
        if (functionString.length() == 0)
            return v8::Undefined();
    }

    int32_t timeout = 0;
    if (argumentCount >= 2)
        timeout = args[1]->Int32Value();

    if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true))
        return v8::Undefined();

    int id;
    if (function->IsFunction()) {
        int paramCount = argumentCount >= 2 ? argumentCount - 2 : 0;
        v8::Local<v8::Value>* params = 0;
        if (paramCount > 0) {
            params = new v8::Local<v8::Value>[paramCount];
            for (int i = 0; i < paramCount; i++)
                // parameters must be globalized
                params[i] = args[i+2];
        }

        // params is passed to action, and released in action's destructor
        OwnPtr<ScheduledAction> action = adoptPtr(new ScheduledAction(V8Proxy::context(imp->frame()), v8::Handle<v8::Function>::Cast(function), paramCount, params));

        // FIXME: We should use OwnArrayPtr for params.
        delete[] params;

        id = DOMTimer::install(scriptContext, action.release(), timeout, singleShot);
    } else {
        if (imp->document() && !imp->document()->contentSecurityPolicy()->allowEval())
            return v8::Integer::New(0);
        id = DOMTimer::install(scriptContext, adoptPtr(new ScheduledAction(V8Proxy::context(imp->frame()), functionString)), timeout, singleShot);
    }

    // Try to do the idle notification before the timeout expires to get better
    // use of any idle time. Aim for the middle of the interval for simplicity.
    if (timeout > 0) {
        double maximumFireInterval = static_cast<double>(timeout) / 1000 / 2;
        V8GCForContextDispose::instance().notifyIdleSooner(maximumFireInterval);
    }

    return v8::Integer::New(id);
}
コード例 #30
0
    static void Sync(JNIEnv* env, jobject obj, jint frame)
    {
        WebCore::Frame* pFrame = (WebCore::Frame*)frame;
        ALOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__);
        WebCore::Settings* s = pFrame->settings();
        if (!s)
            return;
        WebCore::CachedResourceLoader* cachedResourceLoader = pFrame->document()->cachedResourceLoader();

#ifdef ANDROID_LAYOUT
        jobject layout = env->GetObjectField(obj, gFieldIds->mLayoutAlgorithm);
        WebCore::Settings::LayoutAlgorithm l = (WebCore::Settings::LayoutAlgorithm)
                env->CallIntMethod(layout, gFieldIds->mOrdinal);
        if (s->layoutAlgorithm() != l) {
            s->setLayoutAlgorithm(l);
            if (pFrame->document()) {
                pFrame->document()->styleSelectorChanged(WebCore::RecalcStyleImmediately);
                if (pFrame->document()->renderer()) {
                    recursiveCleanupForFullLayout(pFrame->document()->renderer());
                    ALOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout");
                    pFrame->view()->layout();
                    // FIXME: This call used to scroll the page to put the focus into view.
                    // It worked on the WebViewCore, but now scrolling is done outside of the
                    // WebViewCore, on the UI side, so there needs to be a new way to do this.
                    //pFrame->makeFocusVisible();
                }
            }
        }
#endif
        jint textSize = env->GetIntField(obj, gFieldIds->mTextSize);
        float zoomFactor = textSize / 100.0f;
        if (pFrame->textZoomFactor() != zoomFactor)
            pFrame->setTextZoomFactor(zoomFactor);

        jstring str = (jstring)env->GetObjectField(obj, gFieldIds->mStandardFontFamily);
        s->setStandardFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mFixedFontFamily);
        s->setFixedFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mSansSerifFontFamily);
        s->setSansSerifFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mSerifFontFamily);
        s->setSerifFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mCursiveFontFamily);
        s->setCursiveFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mFantasyFontFamily);
        s->setFantasyFontFamily(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mDefaultTextEncoding);
        s->setDefaultTextEncodingName(jstringToWtfString(env, str));

        str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgent);
        WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str));
        WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent();

        jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode);
        WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextCacheMode(cacheMode);

        str = (jstring)env->GetObjectField(obj, gFieldIds->mAcceptLanguage);
        WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str));

        jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize);
        s->setMinimumFontSize(size);

        size = env->GetIntField(obj, gFieldIds->mMinimumLogicalFontSize);
        s->setMinimumLogicalFontSize(size);

        size = env->GetIntField(obj, gFieldIds->mDefaultFontSize);
        s->setDefaultFontSize(size);

        size = env->GetIntField(obj, gFieldIds->mDefaultFixedFontSize);
        s->setDefaultFixedFontSize(size);

        jboolean flag = env->GetBooleanField(obj, gFieldIds->mLoadsImagesAutomatically);
        s->setLoadsImagesAutomatically(flag);
        if (flag)
            cachedResourceLoader->setAutoLoadImages(true);

        flag = env->GetBooleanField(obj, gFieldIds->mMediaPreloadEnabled);
        s->setMediaPreloadEnabled(flag);

#ifdef ANDROID_BLOCK_NETWORK_IMAGE
        flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkImage);
        s->setBlockNetworkImage(flag);
        if(!flag)
            cachedResourceLoader->setBlockNetworkImage(false);
#endif
        flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkLoads);
        WebFrame* webFrame = WebFrame::getWebFrame(pFrame);
        webFrame->setBlockNetworkLoads(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled);
        s->setJavaScriptEnabled(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mAllowUniversalAccessFromFileURLs);
        s->setAllowUniversalAccessFromFileURLs(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mAllowFileAccessFromFileURLs);
        s->setAllowFileAccessFromFileURLs(flag);

        // Hyperlink auditing (the ping attribute) has similar privacy
        // considerations as does the running of JavaScript, so to keep the UI
        // simpler, we leverage the same setting.
        s->setHyperlinkAuditingEnabled(flag);

        // ON = 0
        // ON_DEMAND = 1
        // OFF = 2
        jobject pluginState = env->GetObjectField(obj, gFieldIds->mPluginState);
        int state = env->CallIntMethod(pluginState, gFieldIds->mOrdinal);
        s->setPluginsEnabled(state < 2);
#ifdef ANDROID_PLUGINS
        s->setPluginsOnDemand(state == 1);
#endif

#if ENABLE(OFFLINE_WEB_APPLICATIONS)
        // We only enable AppCache if it's been enabled with a call to
        // setAppCacheEnabled() and if a valid path has been supplied to
        // setAppCachePath(). Note that the path is applied to all WebViews
        // whereas enabling is applied per WebView.

        // WebCore asserts that the path is only set once. Since the path is
        // shared between WebViews, we can't do the required checks to guard
        // against this in the Java WebSettings.
        bool isPathValid = false;
        if (cacheStorage().cacheDirectory().isNull()) {
            str = static_cast<jstring>(env->GetObjectField(obj, gFieldIds->mAppCachePath));
            // Check for non-null string as an optimization, as this is the common case.
            if (str) {
                String path = jstringToWtfString(env, str);
                ALOG_ASSERT(!path.empty(), "Java side should never send empty string for AppCache path");
                // This database is created on the first load. If the file
                // doesn't exist, we create it and set its permissions. The
                // filename must match that in ApplicationCacheStorage.cpp.
                String filename = pathByAppendingComponent(path, "ApplicationCache.db");
                int fd = open(filename.utf8().data(), O_CREAT, permissionFlags660);
                if (fd >= 0) {
                    close(fd);
                    cacheStorage().setCacheDirectory(path);
                    isPathValid = true;
              }
            }
        } else
            isPathValid = true;

        flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled);
        s->setOfflineWebApplicationCacheEnabled(flag && isPathValid);

        jlong maxsize = env->GetLongField(obj, gFieldIds->mAppCacheMaxSize);
        cacheStorage().setMaximumSize(maxsize);
#endif

        flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptCanOpenWindowsAutomatically);
        s->setJavaScriptCanOpenWindowsAutomatically(flag);

#ifdef ANDROID_LAYOUT
        flag = env->GetBooleanField(obj, gFieldIds->mUseWideViewport);
        s->setUseWideViewport(flag);
#endif

#ifdef ANDROID_MULTIPLE_WINDOWS
        flag = env->GetBooleanField(obj, gFieldIds->mSupportMultipleWindows);
        s->setSupportMultipleWindows(flag);
#endif
        flag = env->GetBooleanField(obj, gFieldIds->mShrinksStandaloneImagesToFit);
        s->setShrinksStandaloneImagesToFit(flag);
        jlong maxImage = env->GetLongField(obj, gFieldIds->mMaximumDecodedImageSize);
        // Since in ImageSourceAndroid.cpp, the image will always not exceed
        // MAX_SIZE_BEFORE_SUBSAMPLE, there's no need to pass the max value to
        // WebCore, which checks (image_width * image_height * 4) as an
        // estimation against the max value, which is done in CachedImage.cpp.
        // And there're cases where the decoded image size will not
        // exceed the max, but the WebCore estimation will.  So the following
        // code is commented out to fix those cases.
        // if (maxImage == 0)
        //    maxImage = computeMaxBitmapSizeForCache();
        s->setMaximumDecodedImageSize(maxImage);

        flag = env->GetBooleanField(obj, gFieldIds->mPrivateBrowsingEnabled);
        s->setPrivateBrowsingEnabled(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mSyntheticLinksEnabled);
        s->setDefaultFormatDetection(flag);
        s->setFormatDetectionAddress(flag);
        s->setFormatDetectionEmail(flag);
        s->setFormatDetectionTelephone(flag);
#if ENABLE(DATABASE)
        flag = env->GetBooleanField(obj, gFieldIds->mDatabaseEnabled);
        WebCore::Database::setIsAvailable(flag);

        flag = env->GetBooleanField(obj, gFieldIds->mDatabasePathHasBeenSet);
        if (flag) {
            // If the user has set the database path, sync it to the DatabaseTracker.
            str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath);
            if (str) {
                String path = jstringToWtfString(env, str);
                DatabaseTracker::tracker().setDatabaseDirectoryPath(path);
                // This database is created when the first HTML5 Database object is
                // instantiated. If the file doesn't exist, we create it and set its
                // permissions. The filename must match that in
                // DatabaseTracker.cpp.
                String filename = SQLiteFileSystem::appendDatabaseFileNameToPath(path, "Databases.db");
                int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660);
                if (fd >= 0)
                    close(fd);
            }
        }
#endif
#if ENABLE(DOM_STORAGE)
        flag = env->GetBooleanField(obj, gFieldIds->mDomStorageEnabled);
        s->setLocalStorageEnabled(flag);
        str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath);
        if (str) {
            WTF::String localStorageDatabasePath = jstringToWtfString(env,str);
            if (localStorageDatabasePath.length()) {
                localStorageDatabasePath = WebCore::pathByAppendingComponent(
                        localStorageDatabasePath, "localstorage");
                // We need 770 for folders
                mkdir(localStorageDatabasePath.utf8().data(),
                        permissionFlags660 | S_IXUSR | S_IXGRP);
                s->setLocalStorageDatabasePath(localStorageDatabasePath);
            }
        }
#endif

        flag = env->GetBooleanField(obj, gFieldIds->mGeolocationEnabled);
        GeolocationPermissions::setAlwaysDeny(!flag);
        str = (jstring)env->GetObjectField(obj, gFieldIds->mGeolocationDatabasePath);
        if (str) {
            String path = jstringToWtfString(env, str);
            GeolocationPermissions::setDatabasePath(path);
            GeolocationPositionCache::instance()->setDatabasePath(path);
            // This database is created when the first Geolocation object is
            // instantiated. If the file doesn't exist, we create it and set its
            // permissions. The filename must match that in
            // GeolocationPositionCache.cpp.
            String filename = SQLiteFileSystem::appendDatabaseFileNameToPath(path, "CachedGeoposition.db");
            int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660);
            if (fd >= 0)
                close(fd);
        }

        flag = env->GetBooleanField(obj, gFieldIds->mXSSAuditorEnabled);
        s->setXSSAuditorEnabled(flag);

#if ENABLE(LINK_PREFETCH)
        flag = env->GetBooleanField(obj, gFieldIds->mLinkPrefetchEnabled);
        s->setLinkPrefetchEnabled(flag);
#endif

        size = env->GetIntField(obj, gFieldIds->mPageCacheCapacity);
        if (size > 0) {
            s->setUsesPageCache(true);
            WebCore::pageCache()->setCapacity(size);
        } else
            s->setUsesPageCache(false);

#if ENABLE(WEB_AUTOFILL)
        flag = env->GetBooleanField(obj, gFieldIds->mAutoFillEnabled);
        // TODO: This updates the Settings WebCore side with the user's
        // preference for autofill and will stop WebCore making requests
        // into the chromium autofill code. That code in Chromium also has
        // a notion of being enabled/disabled that gets read from the users
        // preferences. At the moment, it's hardcoded to true on Android
        // (see chrome/browser/autofill/autofill_manager.cc:405). This
        // setting should probably be synced into Chromium also.

        s->setAutoFillEnabled(flag);

        if (flag) {
            EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(pFrame->page()->editorClient());
            WebAutofill* webAutofill = editorC->getAutofill();
            // Set the active AutofillProfile data.
            jobject autoFillProfile = env->GetObjectField(obj, gFieldIds->mAutoFillProfile);
            if (autoFillProfile)
                syncAutoFillProfile(env, autoFillProfile, webAutofill);
            else {
                // The autofill profile is null. We need to tell Chromium about this because
                // this may be because the user just deleted their profile but left the
                // autofill feature setting enabled.
                webAutofill->clearProfiles();
            }
        }
#endif

        // This is required to enable the XMLTreeViewer when loading an XML document that
        // has no style attached to it. http://trac.webkit.org/changeset/79799
        s->setDeveloperExtrasEnabled(true);
        s->setSpatialNavigationEnabled(true);
        bool echoPassword = env->GetBooleanField(obj,
                gFieldIds->mPasswordEchoEnabled);
        s->setPasswordEchoEnabled(echoPassword);
    }