OSDN Git Service

Set 660 permissions on HTML5 Database API meta database
authorSteve Block <steveblock@google.com>
Tue, 21 Dec 2010 11:55:38 +0000 (11:55 +0000)
committerSteve Block <steveblock@google.com>
Tue, 21 Dec 2010 12:40:14 +0000 (12:40 +0000)
Bug: 3244281
Change-Id: I7af7c47c92fc180435cff2416922916a1114c88f

WebKit/android/jni/WebSettings.cpp

index 05c92e5..d293942 100644 (file)
@@ -462,8 +462,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(jstringToWtfString(env, str));
+            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, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+                if (fd >= 0)
+                    close(fd);
+            }
         }
 #endif
 #if ENABLE(DOM_STORAGE)