diff options
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 2136f67..62a9cc8 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -33,6 +33,8 @@ #include "DatabaseTracker.h" #include "DocLoader.h" #include "Document.h" +#include "EditorClientAndroid.h" +#include "FileSystem.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameView.h" @@ -54,6 +56,8 @@ namespace android { +static const int permissionFlags660 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; + struct FieldIds { FieldIds(JNIEnv* env, jclass clazz) { mLayoutAlgorithm = env->GetFieldID(clazz, "mLayoutAlgorithm", @@ -334,6 +338,13 @@ public: WebCore::String path = to_string(env, str); if (path.length() && WebCore::cacheStorage().cacheDirectory().isNull()) { WebCore::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 | O_EXCL, permissionFlags660); + if (fd >= 0) + close(fd); } } jlong maxsize = env->GetIntField(obj, gFieldIds->mAppCacheMaxSize); @@ -362,8 +373,18 @@ public: if (flag) { // If the user has set the database path, sync it to the DatabaseTracker. str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); - if (str) - WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(to_string(env, str)); + if (str) { + String path = to_string(env, str); + WebCore::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) @@ -391,7 +412,7 @@ public: // GeolocationPositionCache.cpp. WebCore::String filename = WebCore::SQLiteFileSystem::appendDatabaseFileNameToPath( path, "CachedGeoposition.db"); - int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); if (fd >= 0) close(fd); } |