summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/jni/WebSettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/android/jni/WebSettings.cpp')
-rw-r--r--Source/WebKit/android/jni/WebSettings.cpp131
1 files changed, 73 insertions, 58 deletions
diff --git a/Source/WebKit/android/jni/WebSettings.cpp b/Source/WebKit/android/jni/WebSettings.cpp
index 589615d..65ac360 100644
--- a/Source/WebKit/android/jni/WebSettings.cpp
+++ b/Source/WebKit/android/jni/WebSettings.cpp
@@ -49,9 +49,7 @@
#include "Settings.h"
#include "WebCoreFrameBridge.h"
#include "WebCoreJni.h"
-#if USE(V8)
#include "WorkerContextExecutionProxy.h"
-#endif
#include "WebRequestContext.h"
#include "WebViewCore.h"
@@ -132,8 +130,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/WebSettings$AutoFillProfile;");
- jclass autoFillProfileClass = env->FindClass("android/webkit/WebSettings$AutoFillProfile");
+ mAutoFillProfile = env->GetFieldID(clazz, "mAutoFillProfile", "Landroid/webkit/WebSettingsClassic$AutoFillProfile;");
+ jclass autoFillProfileClass = env->FindClass("android/webkit/WebSettingsClassic$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;");
@@ -146,53 +144,51 @@ 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");
-#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(mUserAgent, "Could not find field mUserAgent");
- LOG_ASSERT(mAcceptLanguage, "Could not find field mAcceptLanguage");
- 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");
+ 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(mUserAgent, "Could not find field mUserAgent");
+ ALOG_ASSERT(mAcceptLanguage, "Could not find field mAcceptLanguage");
+ 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");
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
- LOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage");
+ ALOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage");
#endif
- LOG_ASSERT(mBlockNetworkLoads, "Could not find field mBlockNetworkLoads");
- LOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled");
- LOG_ASSERT(mPluginState, "Could not find field mPluginState");
+ ALOG_ASSERT(mBlockNetworkLoads, "Could not find field mBlockNetworkLoads");
+ ALOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled");
+ ALOG_ASSERT(mPluginState, "Could not find field mPluginState");
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- LOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled");
- LOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath");
- LOG_ASSERT(mAppCacheMaxSize, "Could not find field mAppCacheMaxSize");
+ ALOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled");
+ ALOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath");
+ ALOG_ASSERT(mAppCacheMaxSize, "Could not find field mAppCacheMaxSize");
#endif
#if ENABLE(WORKERS)
- LOG_ASSERT(mWorkersEnabled, "Could not find field mWorkersEnabled");
+ ALOG_ASSERT(mWorkersEnabled, "Could not find field mWorkersEnabled");
#endif
- LOG_ASSERT(mJavaScriptCanOpenWindowsAutomatically,
+ ALOG_ASSERT(mJavaScriptCanOpenWindowsAutomatically,
"Could not find field mJavaScriptCanOpenWindowsAutomatically");
- 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");
+ 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");
jclass enumClass = env->FindClass("java/lang/Enum");
- LOG_ASSERT(enumClass, "Could not find Enum class!");
+ ALOG_ASSERT(enumClass, "Could not find Enum class!");
mOrdinal = env->GetMethodID(enumClass, "ordinal", "()I");
- LOG_ASSERT(mOrdinal, "Could not find method ordinal");
+ ALOG_ASSERT(mOrdinal, "Could not find method ordinal");
env->DeleteLocalRef(enumClass);
}
@@ -267,9 +263,7 @@ struct FieldIds {
jfieldID mAutoFillProfileCountry;
jfieldID mAutoFillProfilePhoneNumber;
#endif
-#if USE(CHROME_NETWORK_STACK)
jfieldID mOverrideCacheMode;
-#endif
};
static struct FieldIds* gFieldIds;
@@ -315,7 +309,7 @@ public:
static void Sync(JNIEnv* env, jobject obj, jint frame)
{
WebCore::Frame* pFrame = (WebCore::Frame*)frame;
- LOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__);
+ ALOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__);
WebCore::Settings* s = pFrame->settings();
if (!s)
return;
@@ -331,7 +325,7 @@ public:
pFrame->document()->styleSelectorChanged(WebCore::RecalcStyleImmediately);
if (pFrame->document()->renderer()) {
recursiveCleanupForFullLayout(pFrame->document()->renderer());
- LOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout");
+ 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
@@ -369,7 +363,6 @@ public:
str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgent);
WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str));
-#if USE(CHROME_NETWORK_STACK)
WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent();
jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode);
@@ -377,7 +370,6 @@ public:
str = (jstring)env->GetObjectField(obj, gFieldIds->mAcceptLanguage);
WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str));
-#endif
jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize);
s->setMinimumFontSize(size);
@@ -408,6 +400,10 @@ public:
flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled);
s->setJavaScriptEnabled(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
@@ -420,22 +416,38 @@ public:
#endif
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- 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);
+ // 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 | O_EXCL, permissionFlags660);
- if (fd >= 0)
+ 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
@@ -571,6 +583,9 @@ 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);
+
+ s->setPasswordEchoEnabled(true);
}
};
@@ -586,11 +601,11 @@ static JNINativeMethod gWebSettingsMethods[] = {
int registerWebSettings(JNIEnv* env)
{
- jclass clazz = env->FindClass("android/webkit/WebSettings");
- LOG_ASSERT(clazz, "Unable to find class WebSettings!");
+ jclass clazz = env->FindClass("android/webkit/WebSettingsClassic");
+ ALOG_ASSERT(clazz, "Unable to find class WebSettingsClassic!");
gFieldIds = new FieldIds(env, clazz);
env->DeleteLocalRef(clazz);
- return jniRegisterNativeMethods(env, "android/webkit/WebSettings",
+ return jniRegisterNativeMethods(env, "android/webkit/WebSettingsClassic",
gWebSettingsMethods, NELEM(gWebSettingsMethods));
}