[WK2] Apply quota policy for LocalFileSystem
authorJihye Kang <jye.kang@samsung.com>
Fri, 29 Mar 2013 00:56:46 +0000 (09:56 +0900)
committerGerrit Code Review <gerrit2@kim11>
Mon, 8 Apr 2013 06:51:13 +0000 (15:51 +0900)
[Title] Apply quota policy for LocalFileSystem
[Issue#] N/A
[Problem] Quota is not limited for LocalFileSystem
[Cause]
[Solution] apply quota policy for LocalFileSystem
- Default quota per origin: 100*1024*1024
- Maximum quota per origin: 2*1024*1024*1024
- Request quota for UA when quota is about to exceed from default
- ewk_view_exceeded_local_file_system_quota_callback_set() is added for calling the callback when request quota for UA
- ewk_view_exceeded_local_file_system_quota_reply() is added to allow/deny quota

Change-Id: I6262bedbf76db651dc50df905d2896edb6738fc3

25 files changed:
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/GroupSettings.cpp
Source/WebCore/page/GroupSettings.h
Source/WebCore/platform/FileSystem.h
Source/WebCore/platform/efl/tizen/AsyncFileSystemTizen.cpp
Source/WebCore/platform/efl/tizen/AsyncFileSystemTizen.h
Source/WebCore/platform/efl/tizen/AsyncFileWriterTizen.cpp
Source/WebCore/platform/efl/tizen/FileSystemTizen.cpp
Source/WebCore/workers/WorkerThread.cpp
Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.cpp
Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.h
Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.h
Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
Source/WebKit2/UIProcess/API/efl/ewk_view_tizen_client.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
Source/WebKit2/UIProcess/tizen/WebTizenClient.cpp
Source/WebKit2/UIProcess/tizen/WebTizenClient.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 90cb2b3..6fcde13 100755 (executable)
@@ -237,6 +237,10 @@ public:
     virtual bool exceededIndexedDatabaseQuota(Frame*, int64_t) { }
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    virtual bool exceededLocalFileSystemQuota(Frame* frame, int64_t currentUsage) { }
+#endif
+
 };
 
 class EmptyFrameLoaderClient : public FrameLoaderClient {
index 2f9f7eb..55dcd35 100755 (executable)
@@ -406,6 +406,10 @@ namespace WebCore {
         virtual bool exceededIndexedDatabaseQuota(Frame*, int64_t) = 0;
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+        virtual bool exceededLocalFileSystemQuota(Frame*, int64_t currentUsage) = 0;
+#endif
+
     protected:
         virtual ~ChromeClient() { }
     };
index 0762861..7801cfd 100644 (file)
@@ -31,6 +31,9 @@ namespace WebCore {
 GroupSettings::GroupSettings()
     : m_localStorageQuotaBytes(5 * 1024 * 1024) // Suggested by the HTML5 spec.
     , m_indexedDBQuotaBytes(5 * 1024 * 1024)
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    , m_localFileSystemQuotaBytes(0x6400000) // 100M
+#endif
 {
 }
 
@@ -49,5 +52,11 @@ void GroupSettings::setIndexedDBQuotaBytes(int64_t quota)
     m_indexedDBQuotaBytes = quota;
 }
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+void GroupSettings::setLocalFileSystemQuotaBytes(int64_t quota)
+{
+    m_localFileSystemQuotaBytes = quota;
+}
+#endif
 
 } // namespace WebCore
index 1bbad2b..2f1bcd7 100644 (file)
@@ -50,12 +50,20 @@ public:
     void setIndexedDBDatabasePath(const String&);
     const String& indexedDBDatabasePath() const { return m_indexedDBDatabasePath; }
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    void setLocalFileSystemQuotaBytes(int64_t quota);
+    int64_t localFileSystemQuotaBytes() const { return m_localFileSystemQuotaBytes; }
+#endif
+
 private:
     GroupSettings();
 
     unsigned m_localStorageQuotaBytes;
     String m_indexedDBDatabasePath;
     int64_t m_indexedDBQuotaBytes;
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    int64_t m_localFileSystemQuotaBytes;
+#endif
 };
 
 } // namespace WebCore
index 35d70b9..7529d20 100644 (file)
@@ -228,10 +228,11 @@ bool safeCreateFile(const String&, CFDataRef);
 #endif
 
 #if ENABLE(TIZEN_FILE_SYSTEM)
-bool copyFile(const String&, const String&);
-bool linkFile(const String&, const String&);
+bool copyFile(const String& sourcePath, const String& destinationPath);
+bool getDirectorySize(const String& path, long long& size);
+bool linkFile(const String& sourcePath, const String& destinationPath);
 bool removeDirectory(const String& path);
-bool renameFile(const String&, const String&);
+bool renameFile(const String& sourcePath, const String& destinationPath);
 #endif
 
 } // namespace WebCore
index 17bb48e..8f85f9f 100644 (file)
 #include "FileMetadata.h"
 #include "FileSystem.h"
 #include "GOwnPtr.h"
+#include "GroupSettings.h"
 #include "LocalFileSystem.h"
 #include "NotImplemented.h"
 #include "Page.h"
+#include "PageGroup.h"
 #include "SecurityOrigin.h"
 #include "WorkerContext.h"
 #include "WorkerRunLoop.h"
 
 namespace WebCore {
 
-/*
-// Defined but not used.
-static void openFileSystemNotAllowed(ScriptExecutionContext*, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
-{
-    callbacks->didFail(FileError::SECURITY_ERR);
-}
-*/
-
 static void openFileSystem(ScriptExecutionContext* context, const String& basePath, const String& identifier, FileSystemType type, bool create, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType synchronousType)
 {
     String typeString = (type == FileSystemTypePersistent) ? "Persistent" : "Temporary";
@@ -172,7 +166,7 @@ void AsyncFileSystemTizen::move(const KURL& srcPath, const KURL& destPath, PassO
     m_taskController->postTaskToMainThread(createCallbackTask(&moveAsync, AsyncFileSystemCallbacksTizen::create(m_taskController.get(), callbacks, mode), sourceFileSystemPath, destinationFileSystemPath));
 }
 
-static void copyAsync(ScriptExecutionContext*, PassOwnPtr<AsyncFileSystemCallbacksTizen> helperCallbacks, const String& sourcePath, const String& destinationPath)
+static void copyAsync(ScriptExecutionContext* context, PassOwnPtr<AsyncFileSystemCallbacksTizen> helperCallbacks, const String& sourcePath, const String& destinationPath)
 {
     if (!fileExists(sourcePath)) {
         helperCallbacks->didFail(FileError::NOT_FOUND_ERR);
@@ -184,6 +178,12 @@ static void copyAsync(ScriptExecutionContext*, PassOwnPtr<AsyncFileSystemCallbac
         return;
     }
 
+    int errorCode = 0;
+    if (!AsyncFileSystemTizen::checkQuota(context, sourcePath, errorCode)) {
+        helperCallbacks->didFail(errorCode);
+        return;
+    }
+
     if (copyFile(sourcePath, destinationPath))
         helperCallbacks->didSucceed();
     else
@@ -251,13 +251,19 @@ void AsyncFileSystemTizen::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSy
     m_taskController->postTaskToMainThread(createCallbackTask(&readMetadataAsync, AsyncFileSystemCallbacksTizen::create(m_taskController.get(), callbacks, mode), fileSystemPath));
 }
 
-static void createFileAsync(ScriptExecutionContext*, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacksTizen> helperCallbacks, const String& path)
+static void createFileAsync(ScriptExecutionContext* context, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacksTizen> helperCallbacks, const String& path)
 {
     if (exclusive && fileExists(path)) {
         helperCallbacks->didFail(FileError::PATH_EXISTS_ERR);
         return;
     }
 
+    int errorCode = 0;
+    if (!AsyncFileSystemTizen::checkQuota(context, path, errorCode)) {
+        helperCallbacks->didFail(errorCode);
+        return;
+    }
+
     PlatformFileHandle handle;
     handle = openFile(path, OpenForWrite);
 
@@ -275,13 +281,19 @@ void AsyncFileSystemTizen::createFile(const KURL& path, bool exclusive, PassOwnP
     m_taskController->postTaskToMainThread(createCallbackTask(&createFileAsync, exclusive, AsyncFileSystemCallbacksTizen::create(m_taskController.get(), callbacks, mode), fileSystemPath));
 }
 
-static void createDirectoryAsync(ScriptExecutionContext*, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacksTizen> helperCallbacks, const String& path)
+static void createDirectoryAsync(ScriptExecutionContext* context, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacksTizen> helperCallbacks, const String& path)
 {
     if (exclusive && fileExists(path)) {
         helperCallbacks->didFail(FileError::PATH_EXISTS_ERR);
         return;
     }
 
+    int errorCode = 0;
+    if (!AsyncFileSystemTizen::checkQuota(context, path, errorCode)) {
+        helperCallbacks->didFail(errorCode);
+        return;
+    }
+
     if (makeAllDirectories(path))
         helperCallbacks->didSucceed();
     else
@@ -418,9 +430,66 @@ String AsyncFileSystemTizen::virtualPathToFileSystemPath(const KURL& virtualPath
     fileSystemPath.append(origin->databaseIdentifier());
     fileSystemPath.append(innerURL.path());
 
-    return String(fileSystemRepresentation(fileSystemPath.toString()).data());
+    return fileSystemPath.toString();
+}
+
+bool AsyncFileSystemTizen::checkQuota(ScriptExecutionContext* context, const String& sourcePath, int& errorCode)
+{
+    if (!sourcePath.startsWith(LocalFileSystem::localFileSystem().fileSystemBasePath())) {
+        errorCode = FileError::NOT_FOUND_ERR;
+        return false;
+    }
+
+    String subPath = sourcePath.substring(LocalFileSystem::localFileSystem().fileSystemBasePath().length());
+    Vector<String> components;
+    subPath.split('/', components);
+    size_t componentsSize = components.size();
+    if (!componentsSize) {
+        errorCode = FileError::NOT_FOUND_ERR;
+        return false;
+    }
+
+    StringBuilder fileSystemPath;
+    fileSystemPath.append(LocalFileSystem::localFileSystem().fileSystemBasePath());
+    if (subPath.startsWith('/'))
+        fileSystemPath.append('/');
+    fileSystemPath.append(components[0]);
+    String originRootPath = String(fileSystemRepresentation(fileSystemPath.toString()).data());
+
+    int64_t usage = 0;
+    if (!getDirectorySize(originRootPath, usage)) {
+        errorCode = FileError::NOT_READABLE_ERR;
+        return false;
+    }
+
+    if (context->isDocument()) {
+        Document* document = static_cast<Document*>(context);
+        int64_t defaultQuota = document->page()->group().groupSettings()->localFileSystemQuotaBytes();
+        int64_t maxQuota = 0x80000000; // 2GB
+        if (usage > maxQuota) {
+            errorCode = FileError::QUOTA_EXCEEDED_ERR;
+            return false;
+        }
+
+        if (usage >= defaultQuota && defaultQuota != maxQuota) {
+            if (document->page()->chrome()->client()->exceededLocalFileSystemQuota(document->frame(), usage))
+                document->page()->group().groupSettings()->setLocalFileSystemQuotaBytes(maxQuota);
+            else {
+                errorCode = FileError::QUOTA_EXCEEDED_ERR;
+                return false;
+            }
+        }
+    } else {
+        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+        if (usage >= workerContext->groupSettings()->localFileSystemQuotaBytes()) {
+            errorCode = FileError::QUOTA_EXCEEDED_ERR;
+            return false;
+        }
+    }
+
+    return true;
 }
 
 } // namespace WebCore
 
-#endif // ENABLE(FILE_SYSTEM)
+#endif// ENABLE(FILE_SYSTEM)
index bf7a656..1dd95e1 100644 (file)
@@ -56,6 +56,7 @@ public:
     void setTaskController(PassRefPtr<AsyncFileSystemTaskControllerTizen>);
 
     static String virtualPathToFileSystemPath(const KURL&);
+    static bool checkQuota(ScriptExecutionContext*, const String& path, int& errorCode);
 
 private:
     String m_localFileSystemBasePath;
index f31fab7..2925e1f 100644 (file)
@@ -25,6 +25,7 @@
 
 #if ENABLE(TIZEN_FILE_SYSTEM)
 
+#include "AsyncFileSystemTizen.h"
 #include "AsyncFileWriterClientTizen.h"
 #include "Blob.h"
 #include "BlobRegistryImpl.h"
@@ -42,14 +43,23 @@ AsyncFileWriterTizen::AsyncFileWriterTizen(AsyncFileWriterClient* client, const
 {
 }
 
-static void writeAsync(ScriptExecutionContext*, PassOwnPtr<AsyncFileWriterClientTizen> helperClient, const String& path, long long position, Blob* data)
+static void writeAsync(ScriptExecutionContext* context, PassOwnPtr<AsyncFileWriterClientTizen> helperClient, const String& path, long long position, Blob* data)
 {
     int bytesWritten;
     PlatformFileHandle handle;
     handle = openFile(path, OpenForWrite);
 
-    if (!isHandleValid(handle))
+    if (!isHandleValid(handle)) {
+        helperClient->didFail(FileError::NOT_FOUND_ERR);
+        return;
+    }
+
+    int errorCode = 0;
+    if (!AsyncFileSystemTizen::checkQuota(context, path, errorCode)) {
+        closeFile(handle);
+        helperClient->didFail(static_cast<FileError::ErrorCode>(errorCode));
         return;
+    }
 
     RefPtr<BlobStorageData> blobStorage = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(data->url());
     if (blobStorage) {
index 83053cf..a0d6f9c 100644 (file)
@@ -31,6 +31,7 @@
 
 #if ENABLE(TIZEN_FILE_SYSTEM)
 #include "FileMetadata.h"
+#include <dirent.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
 namespace WebCore {
 
+bool getDirectorySize(const String& path, long long& size)
+{
+    if(!fileExists(path))
+        return false;
+
+    DIR* directory = opendir(fileSystemRepresentation(path).data());
+    if(!directory)
+        return false;
+
+    struct dirent* directoryEntry;
+    struct stat buf;
+
+    while (directoryEntry = readdir(directory)) {
+        if (!strcmp(directoryEntry->d_name, ".") || !strcmp(directoryEntry->d_name, ".."))
+            continue;
+
+        String absolutePath = pathByAppendingComponent(path, String(directoryEntry->d_name));
+
+        if (lstat(absolutePath.utf8().data(), &buf) == -1) {
+            closedir(directory);
+            return false;
+        }
+
+        bool result;
+        if (S_ISDIR(buf.st_mode)) {
+            if (!getDirectorySize(absolutePath, size)) {
+                closedir(directory);
+                return false;
+            }
+        } else
+            size += buf.st_size;
+    }
+
+    closedir(directory);
+    return true;
+}
+
 bool getFileMetadata(const String& path, FileMetadata& metadata)
 {
     CString fsRep = fileSystemRepresentation(path);
index bd0355c..3b90ea2 100644 (file)
@@ -102,6 +102,10 @@ WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const St
     m_groupSettings->setLocalStorageQuotaBytes(settings->localStorageQuotaBytes());
     m_groupSettings->setIndexedDBQuotaBytes(settings->indexedDBQuotaBytes());
     m_groupSettings->setIndexedDBDatabasePath(settings->indexedDBDatabasePath().isolatedCopy());
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    m_groupSettings->setLocalFileSystemQuotaBytes(settings->localFileSystemQuotaBytes());
+#endif
+
 }
 
 WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
index bdd1c8b..01499fb 100644 (file)
@@ -141,3 +141,10 @@ void WKPageReplyExceededDatabaseQuota(WKPageRef page, bool allow)
     toImpl(page)->replyExceededDatabaseQuota(allow);
 #endif
 }
+
+void WKPageReplyExceededLocalFileSystemQuota(WKPageRef page, bool allow)
+{
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    toImpl(page)->replyExceededLocalFileSystemQuota(allow);
+#endif
+}
index a96728e..638d839 100644 (file)
@@ -50,6 +50,9 @@ typedef bool (*WKPageDecidePolicyForCertificateErrorCallback)(WKPageRef page, WK
 //#if ENABLE(TIZEN_INDEXED_DATABASE)
 typedef bool (*WKPageExceededIndexedDatabaseQuotaCallback)(WKPageRef page, WKSecurityOriginRef origin, long long currentUsage, WKFrameRef frame, const void* clientInfo);
 //#endif
+//#if ENABLE(TIZEN_FILE_SYSTEM)
+typedef bool (*WKPageExceededLocalFileSystemQuotaCallback)(WKPageRef page, WKSecurityOriginRef origin, long long currentUsage, WKFrameRef frame, const void* clientInfo);
+//#endif
 
 struct WKPageTizenClient {
     int                                                                 version;
@@ -73,6 +76,9 @@ struct WKPageTizenClient {
     //#if ENABLE(TIZEN_INDEXED_DATABASE)
     WKPageExceededIndexedDatabaseQuotaCallback                                  exceededIndexedDatabaseQuota;
     //#endif
+    //#if ENABLE(TIZEN_FILE_SYSTEM)
+    WKPageExceededLocalFileSystemQuotaCallback                                  exceededLocalFileSystemQuota;
+    //#endif
 };
 typedef struct WKPageTizenClient WKPageTizenClient;
 
@@ -123,6 +129,11 @@ WK_EXPORT void WKPageReplyExceededIndexedDatabaseQuota(WKPageRef page, bool allo
 // #if ENABLE(TIZEN_SQL_DATABASE)
 WK_EXPORT void WKPageReplyExceededDatabaseQuota(WKPageRef page, bool allow);
 // #endif
+
+//#if ENABLE(TIZEN_FILE_SYSTEM)
+WK_EXPORT void WKPageReplyExceededLocalFileSystemQuota(WKPageRef page, bool allow);
+//#endif
+
 #ifdef __cplusplus
 }
 #endif
index e90a50f..02cd6cb 100755 (executable)
@@ -161,6 +161,9 @@ struct Ewk_View_Callback_Context {
 #if ENABLE(TIZEN_SQL_DATABASE)
         Ewk_View_Exceeded_Database_Quota_Callback exceededDatabaseQuotaCallback;
 #endif
+#if ENABLE(TIZEN_FILE_SYSTEM)
+        Ewk_View_Exceeded_Local_File_System_Quota_Callback exceededLocalFileSystemQuotaCallback;
+#endif
     };
 
     Evas_Object* ewkView;
@@ -466,6 +469,9 @@ public:
 #if ENABLE(TIZEN_SQL_DATABASE)
     OwnPtr<Ewk_View_Callback_Context> exceededDatabaseQuotaContext;
 #endif
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    OwnPtr<Ewk_View_Callback_Context> exceededLocalFileSystemQuotaContext;
+#endif
     Ewk_Security_Origin* exceededQuotaOrigin;
     bool isWaitingForExceededQuotaPopupReply;
 #endif // #if OS(TIZEN)
index 1f9a9ec..8f0ff01 100755 (executable)
@@ -4635,3 +4635,58 @@ void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allo
     UNUSED_PARAM(allow);
 #endif
 }
+
+#if ENABLE(TIZEN_FILE_SYSTEM)
+bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
+
+    if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
+        return false;
+
+    impl->isWaitingForExceededQuotaPopupReply = true;
+    if (impl->exceededQuotaOrigin)
+        deleteSecurityOrigin(impl->exceededQuotaOrigin);
+    impl->exceededQuotaOrigin = createSecurityOrigin(origin);
+
+    TIZEN_LOGI("currentUsage(%lld)", currentUsage);
+
+    return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
+}
+#endif
+
+void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
+{
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
+
+    if (!impl->exceededLocalFileSystemQuotaContext)
+        impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
+    impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
+    impl->exceededLocalFileSystemQuotaContext->userData = userData;
+#else
+    UNUSED_PARAM(ewkView);
+    UNUSED_PARAM(callback);
+    UNUSED_PARAM(userData);
+#endif
+}
+
+void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
+{
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
+
+    TIZEN_LOGI("allow %d", allow);
+    WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
+    if (impl->exceededQuotaOrigin)
+        deleteSecurityOrigin(impl->exceededQuotaOrigin);
+    impl->exceededQuotaOrigin = 0;
+    impl->isWaitingForExceededQuotaPopupReply = false;
+#else
+    UNUSED_PARAM(ewkView);
+    UNUSED_PARAM(result);
+#endif
+}
index b6d4433..b7279be 100755 (executable)
@@ -717,6 +717,12 @@ EAPI void ewk_view_exceeded_database_quota_callback_set(Evas_Object* o, Ewk_View
 EAPI void ewk_view_exceeded_database_quota_reply(Evas_Object* o, Eina_Bool allow);
 // #endif
 
+//#if ENABLE(TIZEN_FILE_SYSTEM)
+typedef Eina_Bool (*Ewk_View_Exceeded_Local_File_System_Quota_Callback)(Evas_Object* o, Ewk_Security_Origin* origin,  long long currentQuota, void* user_data);
+EAPI void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* o, Ewk_View_Exceeded_Local_File_System_Quota_Callback callback, void* user_data);
+EAPI void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* o, Eina_Bool allow);
+//#endif
+
 /**
  * Gets the Ewk_Settings of this view.
  *
index a1a1eff..99db2ed 100755 (executable)
@@ -286,4 +286,8 @@ void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name,
 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value);
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage);
+#endif
+
 #endif // ewk_view_private_h
index 03b7b14..1a4eeb7 100755 (executable)
@@ -86,6 +86,15 @@ static bool exceededIndexedDatabaseQuota(WKPageRef page, WKSecurityOriginRef ori
 #endif
 }
 
+static bool exceededLocalFileSystemQuota(WKPageRef page, WKSecurityOriginRef origin, long long currentUsage, WKFrameRef frame, const void *clientInfo)
+{
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    return ewkViewExceededLocalFileSystemQuota(static_cast<Evas_Object*>(const_cast<void*>(clientInfo)), origin, currentUsage);
+#else
+    return false;
+#endif
+}
+
 void ewkViewTizenClientAttachClient(Evas_Object* ewkView)
 {
     EINA_SAFETY_ON_NULL_RETURN(ewkView);
@@ -98,7 +107,8 @@ void ewkViewTizenClientAttachClient(Evas_Object* ewkView)
         decidePolicyForUserMediaPermissionRequest,
         processJSBridgePlugin,
         decidePolicyForCertificateError,
-        exceededIndexedDatabaseQuota
+        exceededIndexedDatabaseQuota,
+        exceededLocalFileSystemQuota
     };
 
     WKPageSetPageTizenClient(toAPI(EwkViewImpl::fromEvasObject(ewkView)->page()), &tizenClient);
index e130191..08fbadb 100755 (executable)
@@ -1039,6 +1039,10 @@ void recordingSurfaceSetEnableSet(bool enable);
     void replyExceededDatabaseQuota(bool allow);
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    void replyExceededLocalFileSystemQuota(bool allow);
+#endif
+
 private:
     WebPageProxy(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
 
@@ -1402,6 +1406,10 @@ private:
     void exceededIndexedDatabaseQuota(uint64_t frameID, const String& originIdentifier, int64_t currentUsage, PassRefPtr<Messages::WebPageProxy::ExceededIndexedDatabaseQuota::DelayedReply> reply);
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    void exceededLocalFileSystemQuota(uint64_t frameID, const String& originIdentifier, int64_t currentUsage, PassRefPtr<Messages::WebPageProxy::ExceededLocalFileSystemQuota::DelayedReply> reply);
+#endif
+
     PageClient* m_pageClient;
     WebLoaderClient m_loaderClient;
     WebPolicyClient m_policyClient;
@@ -1660,6 +1668,10 @@ private:
 #if ENABLE(TIZEN_INDEXED_DATABASE)
     RefPtr<Messages::WebPageProxy::ExceededIndexedDatabaseQuota::DelayedReply> m_exceededIndexedDatabaseQuotaReply;
 #endif
+
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    RefPtr<Messages::WebPageProxy::ExceededLocalFileSystemQuota::DelayedReply> m_exceededLocalFileSystemQuotaReply;
+#endif
 };
 
 } // namespace WebKit
index 5b439e8..8d3cb98 100755 (executable)
@@ -467,4 +467,8 @@ messages -> WebPageProxy {
 #if ENABLE(TIZEN_INDEXED_DATABASE)
     ExceededIndexedDatabaseQuota(uint64_t frameID, WTF::String originIdentifier, int64_t currentUsage) -> (bool returnValue) Delayed
 #endif
+
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    ExceededLocalFileSystemQuota(uint64_t frameID, WTF::String originIdentifier, int64_t currentUsage) -> (bool allow) Delayed
+#endif
 }
index 4dff2e5..84098c2 100755 (executable)
@@ -1099,6 +1099,38 @@ void WebPageProxy::replyExceededDatabaseQuota(bool allow)
 }
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+void WebPageProxy::exceededLocalFileSystemQuota(uint64_t frameID, const String& originIdentifier, int64_t currentUsage, PassRefPtr<Messages::WebPageProxy::ExceededLocalFileSystemQuota::DelayedReply> reply)
+{
+    WebFrameProxy* frame = process()->webFrame(frameID);
+    MESSAGE_CHECK(frame);
+
+    // Since exceededLocalFileSystemQuota() can spin a nested run loop we need to turn off the responsiveness timer.
+    process()->responsivenessTimer()->stop();
+    m_exceededLocalFileSystemQuotaReply = reply;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
+#endif
+
+    RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
+
+    if (!m_tizenClient.exceededLocalFileSystemQuota(this, origin.get(), currentUsage, frame))
+        replyExceededLocalFileSystemQuota(false);
+}
+
+void WebPageProxy::replyExceededLocalFileSystemQuota(bool allow)
+{
+    if (!m_exceededLocalFileSystemQuotaReply)
+        return;
+
+    m_exceededLocalFileSystemQuotaReply->send(allow);
+    m_exceededLocalFileSystemQuotaReply = nullptr;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(false);
+#endif
+}
+#endif
+
 #endif // #if OS(TIZEN)
 
 void WebPageProxy::handleInputMethodKeydown(bool& handled)
index 3a1fd5b..8bc474c 100644 (file)
@@ -86,4 +86,14 @@ bool WebTizenClient::exceededIndexedDatabaseQuota(WebPageProxy* page, WebSecurit
     return m_client.exceededIndexedDatabaseQuota(toAPI(page), toAPI(origin), currentUsage, toAPI(frame), m_client.clientInfo);
 }
 #endif
+
+#if ENABLE(TIZEN_FILE_SYSTEM)
+bool WebTizenClient::exceededLocalFileSystemQuota(WebPageProxy* page, WebSecurityOrigin* origin, long long currentUsage, WebFrameProxy* frame)
+{
+    if (!m_client.exceededLocalFileSystemQuota)
+        return currentUsage;
+
+    return m_client.exceededLocalFileSystemQuota(toAPI(page), toAPI(origin), currentUsage, toAPI(frame), m_client.clientInfo);
+}
+#endif
 } // namespace WebKit
index c653f00..03afdba 100644 (file)
@@ -67,6 +67,10 @@ public:
 #if ENABLE(TIZEN_INDEXED_DATABASE)
     bool exceededIndexedDatabaseQuota(WebPageProxy*, WebSecurityOrigin*, long long, WebFrameProxy*);
 #endif
+
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    bool exceededLocalFileSystemQuota(WebPageProxy*, WebSecurityOrigin*, long long, WebFrameProxy*);
+#endif
 };
 
 } // namespace WebKit
index 6f83af7..bd3f50d 100755 (executable)
@@ -1026,4 +1026,22 @@ bool WebChromeClient::exceededIndexedDatabaseQuota(Frame* frame, int64_t current
 }
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+bool WebChromeClient::exceededLocalFileSystemQuota(Frame* frame, int64_t currentQuota)
+{
+    WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
+    SecurityOrigin* origin = frame->document()->securityOrigin();
+
+    unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0;
+    bool result = false;
+#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
+    WebProcess::WaitForJavaScriptPopupFinished waiting;
+#endif
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ExceededLocalFileSystemQuota(webFrame->frameID(), origin->databaseIdentifier(), currentQuota), Messages::WebPageProxy::ExceededLocalFileSystemQuota::Reply(result), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags))
+        return false;
+
+    return result;
+}
+#endif
+
 } // namespace WebKit
index 77e53d0..876ac46 100755 (executable)
@@ -268,6 +268,10 @@ private:
     virtual bool exceededIndexedDatabaseQuota(Frame*, int64_t) OVERRIDE;
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    virtual bool exceededLocalFileSystemQuota(Frame*, int64_t currentQuota) OVERRIDE;
+#endif
+
     String m_cachedToolTip;
     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
     mutable bool m_cachedMainFrameHasHorizontalScrollbar;
index 05f5572..f40a1ad 100755 (executable)
@@ -2478,6 +2478,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings->setTextAutosizingEnabled(store.getBoolValueForKey(WebPreferencesKey::textAutosizingEnabledKey()));
 #endif
 
+#if ENABLE(TIZEN_FILE_SYSTEM)
+    m_page->group().groupSettings()->setLocalFileSystemQuotaBytes(0x6400000); //100M
+#endif
+
     platformPreferencesDidChange(store);
 
     if (m_drawingArea)