diff options
Diffstat (limited to 'Source/WebKit/android/jni/WebSettings.cpp')
-rw-r--r-- | Source/WebKit/android/jni/WebSettings.cpp | 153 |
1 files changed, 61 insertions, 92 deletions
diff --git a/Source/WebKit/android/jni/WebSettings.cpp b/Source/WebKit/android/jni/WebSettings.cpp index 467da3d..dd847e8 100644 --- a/Source/WebKit/android/jni/WebSettings.cpp +++ b/Source/WebKit/android/jni/WebSettings.cpp @@ -49,7 +49,9 @@ #include "Settings.h" #include "WebCoreFrameBridge.h" #include "WebCoreJni.h" +#if USE(V8) #include "WorkerContextExecutionProxy.h" +#endif #include "WebRequestContext.h" #include "WebViewCore.h" @@ -120,9 +122,6 @@ struct FieldIds { mGeolocationEnabled = env->GetFieldID(clazz, "mGeolocationEnabled", "Z"); mGeolocationDatabasePath = env->GetFieldID(clazz, "mGeolocationDatabasePath", "Ljava/lang/String;"); mXSSAuditorEnabled = env->GetFieldID(clazz, "mXSSAuditorEnabled", "Z"); -#if ENABLE(LINK_PREFETCH) - mLinkPrefetchEnabled = env->GetFieldID(clazz, "mLinkPrefetchEnabled", "Z"); -#endif mJavaScriptCanOpenWindowsAutomatically = env->GetFieldID(clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); mUseWideViewport = env->GetFieldID(clazz, "mUseWideViewport", "Z"); @@ -135,8 +134,8 @@ struct FieldIds { mPageCacheCapacity = env->GetFieldID(clazz, "mPageCacheCapacity", "I"); #if ENABLE(WEB_AUTOFILL) mAutoFillEnabled = env->GetFieldID(clazz, "mAutoFillEnabled", "Z"); - mAutoFillProfile = env->GetFieldID(clazz, "mAutoFillProfile", "Landroid/webkit/WebSettingsClassic$AutoFillProfile;"); - jclass autoFillProfileClass = env->FindClass("android/webkit/WebSettingsClassic$AutoFillProfile"); + mAutoFillProfile = env->GetFieldID(clazz, "mAutoFillProfile", "Landroid/webkit/WebSettings$AutoFillProfile;"); + jclass autoFillProfileClass = env->FindClass("android/webkit/WebSettings$AutoFillProfile"); mAutoFillProfileFullName = env->GetFieldID(autoFillProfileClass, "mFullName", "Ljava/lang/String;"); mAutoFillProfileEmailAddress = env->GetFieldID(autoFillProfileClass, "mEmailAddress", "Ljava/lang/String;"); mAutoFillProfileCompanyName = env->GetFieldID(autoFillProfileClass, "mCompanyName", "Ljava/lang/String;"); @@ -149,57 +148,57 @@ struct FieldIds { mAutoFillProfilePhoneNumber = env->GetFieldID(autoFillProfileClass, "mPhoneNumber", "Ljava/lang/String;"); env->DeleteLocalRef(autoFillProfileClass); #endif +#if USE(CHROME_NETWORK_STACK) mOverrideCacheMode = env->GetFieldID(clazz, "mOverrideCacheMode", "I"); - mPasswordEchoEnabled = env->GetFieldID(clazz, "mPasswordEchoEnabled", "Z"); - - ALOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); - ALOG_ASSERT(mTextSize, "Could not find field mTextSize"); - ALOG_ASSERT(mStandardFontFamily, "Could not find field mStandardFontFamily"); - ALOG_ASSERT(mFixedFontFamily, "Could not find field mFixedFontFamily"); - ALOG_ASSERT(mSansSerifFontFamily, "Could not find field mSansSerifFontFamily"); - ALOG_ASSERT(mSerifFontFamily, "Could not find field mSerifFontFamily"); - ALOG_ASSERT(mCursiveFontFamily, "Could not find field mCursiveFontFamily"); - ALOG_ASSERT(mFantasyFontFamily, "Could not find field mFantasyFontFamily"); - ALOG_ASSERT(mDefaultTextEncoding, "Could not find field mDefaultTextEncoding"); - ALOG_ASSERT(mGetUserAgentString, "Could not find method getUserAgentString"); - ALOG_ASSERT(mGetAcceptLanguage, "Could not find method getAcceptLanguage"); - ALOG_ASSERT(mMinimumFontSize, "Could not find field mMinimumFontSize"); - ALOG_ASSERT(mMinimumLogicalFontSize, "Could not find field mMinimumLogicalFontSize"); - ALOG_ASSERT(mDefaultFontSize, "Could not find field mDefaultFontSize"); - ALOG_ASSERT(mDefaultFixedFontSize, "Could not find field mDefaultFixedFontSize"); - ALOG_ASSERT(mLoadsImagesAutomatically, "Could not find field mLoadsImagesAutomatically"); +#endif + + LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); + LOG_ASSERT(mTextSize, "Could not find field mTextSize"); + LOG_ASSERT(mStandardFontFamily, "Could not find field mStandardFontFamily"); + LOG_ASSERT(mFixedFontFamily, "Could not find field mFixedFontFamily"); + LOG_ASSERT(mSansSerifFontFamily, "Could not find field mSansSerifFontFamily"); + LOG_ASSERT(mSerifFontFamily, "Could not find field mSerifFontFamily"); + LOG_ASSERT(mCursiveFontFamily, "Could not find field mCursiveFontFamily"); + LOG_ASSERT(mFantasyFontFamily, "Could not find field mFantasyFontFamily"); + LOG_ASSERT(mDefaultTextEncoding, "Could not find field mDefaultTextEncoding"); + LOG_ASSERT(mGetUserAgentString, "Could not find method getUserAgentString"); + LOG_ASSERT(mGetAcceptLanguage, "Could not find method getAcceptLanguage"); + LOG_ASSERT(mMinimumFontSize, "Could not find field mMinimumFontSize"); + LOG_ASSERT(mMinimumLogicalFontSize, "Could not find field mMinimumLogicalFontSize"); + LOG_ASSERT(mDefaultFontSize, "Could not find field mDefaultFontSize"); + LOG_ASSERT(mDefaultFixedFontSize, "Could not find field mDefaultFixedFontSize"); + LOG_ASSERT(mLoadsImagesAutomatically, "Could not find field mLoadsImagesAutomatically"); #ifdef ANDROID_BLOCK_NETWORK_IMAGE - ALOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage"); + LOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage"); #endif - ALOG_ASSERT(mBlockNetworkLoads, "Could not find field mBlockNetworkLoads"); - ALOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled"); - ALOG_ASSERT(mAllowUniversalAccessFromFileURLs, + LOG_ASSERT(mBlockNetworkLoads, "Could not find field mBlockNetworkLoads"); + LOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled"); + LOG_ASSERT(mAllowUniversalAccessFromFileURLs, "Could not find field mAllowUniversalAccessFromFileURLs"); - ALOG_ASSERT(mAllowFileAccessFromFileURLs, + LOG_ASSERT(mAllowFileAccessFromFileURLs, "Could not find field mAllowFileAccessFromFileURLs"); - ALOG_ASSERT(mPluginState, "Could not find field mPluginState"); + LOG_ASSERT(mPluginState, "Could not find field mPluginState"); #if ENABLE(OFFLINE_WEB_APPLICATIONS) - ALOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled"); - ALOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath"); - ALOG_ASSERT(mAppCacheMaxSize, "Could not find field mAppCacheMaxSize"); + LOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled"); + LOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath"); + LOG_ASSERT(mAppCacheMaxSize, "Could not find field mAppCacheMaxSize"); #endif #if ENABLE(WORKERS) - ALOG_ASSERT(mWorkersEnabled, "Could not find field mWorkersEnabled"); + LOG_ASSERT(mWorkersEnabled, "Could not find field mWorkersEnabled"); #endif - ALOG_ASSERT(mJavaScriptCanOpenWindowsAutomatically, + LOG_ASSERT(mJavaScriptCanOpenWindowsAutomatically, "Could not find field mJavaScriptCanOpenWindowsAutomatically"); - ALOG_ASSERT(mUseWideViewport, "Could not find field mUseWideViewport"); - ALOG_ASSERT(mSupportMultipleWindows, "Could not find field mSupportMultipleWindows"); - ALOG_ASSERT(mShrinksStandaloneImagesToFit, "Could not find field mShrinksStandaloneImagesToFit"); - ALOG_ASSERT(mMaximumDecodedImageSize, "Could not find field mMaximumDecodedImageSize"); - ALOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree"); - ALOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity"); - ALOG_ASSERT(mPasswordEchoEnabled, "Could not find field mPasswordEchoEnabled"); + LOG_ASSERT(mUseWideViewport, "Could not find field mUseWideViewport"); + LOG_ASSERT(mSupportMultipleWindows, "Could not find field mSupportMultipleWindows"); + LOG_ASSERT(mShrinksStandaloneImagesToFit, "Could not find field mShrinksStandaloneImagesToFit"); + LOG_ASSERT(mMaximumDecodedImageSize, "Could not find field mMaximumDecodedImageSize"); + LOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree"); + LOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity"); jclass enumClass = env->FindClass("java/lang/Enum"); - ALOG_ASSERT(enumClass, "Could not find Enum class!"); + LOG_ASSERT(enumClass, "Could not find Enum class!"); mOrdinal = env->GetMethodID(enumClass, "ordinal", "()I"); - ALOG_ASSERT(mOrdinal, "Could not find method ordinal"); + LOG_ASSERT(mOrdinal, "Could not find method ordinal"); env->DeleteLocalRef(enumClass); } @@ -258,9 +257,6 @@ struct FieldIds { jfieldID mGeolocationEnabled; jfieldID mGeolocationDatabasePath; jfieldID mXSSAuditorEnabled; -#if ENABLE(LINK_PREFETCH) - jfieldID mLinkPrefetchEnabled; -#endif #if ENABLE(DATABASE) || ENABLE(DOM_STORAGE) jfieldID mDatabasePath; jfieldID mDatabasePathHasBeenSet; @@ -279,8 +275,9 @@ struct FieldIds { jfieldID mAutoFillProfileCountry; jfieldID mAutoFillProfilePhoneNumber; #endif +#if USE(CHROME_NETWORK_STACK) jfieldID mOverrideCacheMode; - jfieldID mPasswordEchoEnabled; +#endif }; static struct FieldIds* gFieldIds; @@ -326,7 +323,7 @@ public: 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__); + LOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__); WebCore::Settings* s = pFrame->settings(); if (!s) return; @@ -342,7 +339,7 @@ public: 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"); + LOG_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 @@ -380,6 +377,7 @@ public: str = (jstring)env->CallObjectMethod(obj, gFieldIds->mGetUserAgentString); WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str)); +#if USE(CHROME_NETWORK_STACK) WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent(); jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode); @@ -387,6 +385,7 @@ public: str = (jstring)env->CallObjectMethod(obj, gFieldIds->mGetAcceptLanguage); WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str)); +#endif jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize); s->setMinimumFontSize(size); @@ -424,11 +423,6 @@ public: 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 @@ -440,38 +434,22 @@ public: #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"); + flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled); + s->setOfflineWebApplicationCacheEnabled(flag); + str = (jstring)env->GetObjectField(obj, gFieldIds->mAppCachePath); + if (str) { + String path = jstringToWtfString(env, str); + if (path.length() && cacheStorage().cacheDirectory().isNull()) { + cacheStorage().setCacheDirectory(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) { + int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, 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 @@ -569,11 +547,6 @@ public: 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); @@ -612,10 +585,6 @@ public: // 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); } }; @@ -631,11 +600,11 @@ static JNINativeMethod gWebSettingsMethods[] = { int registerWebSettings(JNIEnv* env) { - jclass clazz = env->FindClass("android/webkit/WebSettingsClassic"); - ALOG_ASSERT(clazz, "Unable to find class WebSettingsClassic!"); + jclass clazz = env->FindClass("android/webkit/WebSettings"); + LOG_ASSERT(clazz, "Unable to find class WebSettings!"); gFieldIds = new FieldIds(env, clazz); env->DeleteLocalRef(clazz); - return jniRegisterNativeMethods(env, "android/webkit/WebSettingsClassic", + return jniRegisterNativeMethods(env, "android/webkit/WebSettings", gWebSettingsMethods, NELEM(gWebSettingsMethods)); } |