Add Web storage API
authorHyun Lee <hyunn.lee@samsung.com>
Mon, 18 Mar 2013 09:30:24 +0000 (18:30 +0900)
committerHyun Lee <hyunn.lee@samsung.com>
Mon, 18 Mar 2013 12:52:28 +0000 (21:52 +0900)
Change-Id: Ibed57140aa6239fa1176980052940aaa9c07f78a
Signed-off-by: Hyun Lee <hyunn.lee@samsung.com>
CMakeLists.txt
inc/FWebControls.h
inc/FWebCtrlWebStorageManager.h
src/controls/FWebCtrlWebStorageManager.cpp [new file with mode: 0755]
src/controls/FWebCtrl_WebPresenter.cpp
src/controls/FWebCtrl_WebPresenter.h
src/controls/FWebCtrl_WebStorageManagerImpl.cpp [new file with mode: 0755]
src/controls/FWebCtrl_WebStorageManagerImpl.h [new file with mode: 0755]

index 0e31ae6..cf51265 100755 (executable)
@@ -82,6 +82,8 @@ SET (${this_target}_SOURCE_FILES
        src/controls/FWebCtrl_UserConfirmPopup.cpp
        src/controls/FWebCtrl_WebPopup.cpp
        src/controls/FWebCtrl_CertificatePopup.cpp
+       src/controls/FWebCtrlWebStorageManager.cpp
+       src/controls/FWebCtrl_WebStorageManagerImpl.cpp
 )
 ## Add Definitions
 ADD_DEFINITIONS(${OSP_DEFINITIONS} -D_MODEL_RES_WVGA)
index 6473a43..01ef909 100755 (executable)
@@ -37,6 +37,7 @@
 #include <FWebCtrlPageNavigationList.h>
 #include <FWebCtrlWeb.h>
 #include <FWebCtrlWebSetting.h>
+#include <FWebCtrlWebStorageManager.h>
 
 /**
  * @namespace  Tizen::Web::Controls
index a7cf936..5be40a2 100755 (executable)
@@ -24,6 +24,7 @@
 #ifndef _FWEB_CTRL_WEB_STORAGE_MANAGER_H_\r
 #define _FWEB_CTRL_WEB_STORAGE_MANAGER_H_\r
 \r
+#include <unique_ptr.h>\r
 #include <FBaseString.h>\r
 \r
 namespace Tizen { namespace Base { namespace Collection\r
@@ -102,6 +103,7 @@ public:
         * @param[in]   origin                  The origin\r
         * @param[in]   quota                   The quota of the web storage to set in bytes\r
         * @exception   E_SUCCESS                       The method is successful.\r
+        * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
         * @exception   E_UNSUPPORTED_TYPE      The specified storageType is not supported.\r
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
         */\r
@@ -121,10 +123,11 @@ public:
         * @param[in]   storageType             The web storage type\r
         * @param[in]   origin                  The origin\r
         * @exception   E_SUCCESS                       The method is successful.\r
+        * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
         * @exception   E_UNSUPPORTED_TYPE      The specified storageType is not supported.\r
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
         */\r
-       long GetQuotaForOrigin(WebStorageType storageType, const Tizen::Base::String& origin);\r
+       long GetQuotaForOrigin(WebStorageType storageType, const Tizen::Base::String& origin);\r
 \r
        /**\r
         * Gets the usage for the given origin for the given storage type.\r
@@ -139,6 +142,7 @@ public:
         * @param[in]   storageType             The web storage type\r
         * @param[in]   origin                  The origin\r
         * @exception   E_SUCCESS                       The method is successful.\r
+        * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
         * @exception   E_UNSUPPORTED_TYPE      The specified storageType is not supported.\r
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
         * @remarks             The specific error code can be accessed using the GetLastResult() method.\r
@@ -158,6 +162,7 @@ public:
         * @param[in]   storageType             The web storage type\r
         * @param[in]   origin                  The origin\r
         * @exception   E_SUCCESS                       The method is successful.\r
+        * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
         * @exception   E_UNSUPPORTED_TYPE      The specified storageType is not supported.\r
         * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
         * @see RemoveAll()\r
@@ -186,10 +191,11 @@ public:
         *\r
         * @since               2.1\r
         *\r
+        *\r
         * @return              A pointer to the %WebStorageManager instance, @n\r
         *                                      else @c null if it fails\r
         * @exception   E_SUCCESS                       The method is successful.\r
-        * @exception   E_OUT_OF_MEMORY The memory is insufficient.\r
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.\r
         * @remarks             The specific error code can be accessed using the GetLastResult() method.\r
         */\r
        static WebStorageManager* GetInstance(void);\r
diff --git a/src/controls/FWebCtrlWebStorageManager.cpp b/src/controls/FWebCtrlWebStorageManager.cpp
new file mode 100755 (executable)
index 0000000..d49eb6e
--- /dev/null
@@ -0,0 +1,209 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FWebCtrlWebStorageManager.cpp
+ * @brief              The file contains the definition of FWebCtrlWebStorageManager class.
+ *
+ * The file contains the definition of FWebCtrlWebStorageManager class.
+ */
+#include <unique_ptr.h>
+#include <FBaseColIList.h>
+#include <FBaseSysLog.h>
+#include <FWebCtrlWebStorageManager.h>
+#include <FSec_AccessController.h>
+#include "FWebCtrl_WebStorageManagerImpl.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+
+namespace Tizen { namespace Web { namespace Controls
+{
+
+
+WebStorageManager* WebStorageManager::__pInstance = null;
+
+
+WebStorageManager::WebStorageManager(void)
+       : __pWebStorageManagerImpl(null)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr<_WebStorageManagerImpl> pWebStorageManagerImpl(new (std::nothrow) _WebStorageManagerImpl());
+       SysTryReturnVoidResult(NID_WEB_CTRL, pWebStorageManagerImpl.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pWebStorageManagerImpl = pWebStorageManagerImpl.release();
+}
+
+
+WebStorageManager::~WebStorageManager(void)
+{
+}
+
+
+void
+WebStorageManager::InitWebStorageManager(void)
+{
+       std::unique_ptr<WebStorageManager> pInstance(new (std::nothrow) WebStorageManager());
+       SysTryReturnVoidResult(NID_WEB_CTRL, pInstance.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pInstance = pInstance.release();
+       std::atexit(DestroyWebStorageManager);
+}
+
+
+void
+WebStorageManager::DestroyWebStorageManager(void)
+{
+       delete __pInstance;
+       __pInstance = null;
+}
+
+
+WebStorageManager*
+WebStorageManager::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+       if (__pInstance== null)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitWebStorageManager);
+               result r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+
+IList*
+WebStorageManager::GetOriginListN(WebStorageType storageType) const
+{
+       SysAssertf(__pWebStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+       result r = E_SUCCESS;
+       
+       r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       IList* pList = __pWebStorageManagerImpl->GetOriginListN(storageType);
+       SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return pList;
+}
+
+
+result
+WebStorageManager::SetQuotaForOrigin(WebStorageType storageType, const String& origin, long quota)
+{
+       SysAssertf(__pWebStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
+       SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.",  GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       r = __pWebStorageManagerImpl->SetQuotaForOrigin(storageType, origin, quota);
+       SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+long
+WebStorageManager::GetQuotaForOrigin(WebStorageType storageType, const String& origin)
+{
+       SysAssertf(__pWebStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+       result r = E_SUCCESS;
+       long quota = 0;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, 0, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       quota = __pWebStorageManagerImpl->GetQuotaForOrigin(storageType, origin);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, 0, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return quota;
+}
+
+
+long
+WebStorageManager::GetUsageForOrigin(WebStorageType storageType, const String& origin) const
+{
+       SysAssertf(__pWebStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+       result r = E_SUCCESS;
+       long usage = 0;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, 0, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       usage = __pWebStorageManagerImpl->GetQuotaForOrigin(storageType, origin);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, 0, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       return usage;
+}
+
+
+result
+WebStorageManager::Remove(WebStorageType storageType, const String& origin)
+{
+       SysAssertf(__pWebStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
+       SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.",  GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       r = __pWebStorageManagerImpl->Remove(storageType, origin);
+       SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+result
+WebStorageManager::RemoveAll(WebStorageType storageType)
+{
+       SysAssertf(__pWebStorageManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
+       SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.",  GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       r = __pWebStorageManagerImpl->RemoveAll(storageType);
+       SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+
+}}} // Tizen::Web::Controls
\ No newline at end of file
index 1d189f4..90a2cbf 100755 (executable)
 namespace Tizen { namespace Web { namespace Controls
 {
 
+
 _WebPresenter::_WebPresenter(void)
        : __stopState(false)
        , __boolean(false)
        , __string(L"")
        , __integer(0)
+       , __pIList(null)
+       , __longInteger(0)
 {
        //empty statement
 }
 
+
 _WebPresenter::~_WebPresenter(void)
 {
 }
@@ -70,6 +74,8 @@ _WebPresenter::WaitAsyncProcess(Tizen::Base::String& result)
 
        result = __string;
 }
+
+
 void
 _WebPresenter::WaitAsyncProcess(int& result)
 {
@@ -78,6 +84,25 @@ _WebPresenter::WaitAsyncProcess(int& result)
        result = __integer;
 }
 
+
+void
+_WebPresenter::WaitAsyncProcess(Eina_List* result)
+{
+       ProcessEvent();
+
+       result = __pIList;
+}
+
+
+void
+_WebPresenter::WaitAsyncProcess(long& result)
+{
+       ProcessEvent();
+
+       result = __longInteger;
+}
+
+
 void
 _WebPresenter::ProcessEvent(void)
 {
@@ -120,4 +145,22 @@ _WebPresenter::EndAsyncProcess(int result)
        __integer = result;
        __stopState = true;
 }
+
+
+void
+_WebPresenter::EndAsyncProcess(const Eina_List* result)
+{
+       __pIList = const_cast<Eina_List*>(result);
+       __stopState = true;
+}
+
+
+void
+_WebPresenter::EndAsyncProcess(long result)
+{
+       __longInteger = result;
+       __stopState = true;
+}
+
+
 }}} // Tizen::Web::Controls
index e747554..f3c2e93 100755 (executable)
@@ -45,10 +45,14 @@ public:
        void WaitAsyncProcess(bool& result);
        void WaitAsyncProcess(Tizen::Base::String& result);
        void WaitAsyncProcess(int& result);
+       void WaitAsyncProcess(Eina_List* result);
+       void WaitAsyncProcess(long& result);
 
        void EndAsyncProcess(bool result);
        void EndAsyncProcess(const Tizen::Base::String& result);
        void EndAsyncProcess(int result);
+       void EndAsyncProcess(const Eina_List* result);
+       void EndAsyncProcess(long result);
 
 private:
        _WebPresenter(const _WebPresenter& rhs);
@@ -61,9 +65,10 @@ private:
        bool __stopState;
 
        bool __boolean;
-
        Tizen::Base::String __string;
        int __integer;
+       Eina_List* __pIList;
+       long __longInteger;
 };
 
 }}} // Tizen::Web::Controls
diff --git a/src/controls/FWebCtrl_WebStorageManagerImpl.cpp b/src/controls/FWebCtrl_WebStorageManagerImpl.cpp
new file mode 100755 (executable)
index 0000000..b464c60
--- /dev/null
@@ -0,0 +1,340 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FWebCtrl_WebStorageManagerImpl.cpp
+ * @brief              The file contains the definition of _WebStorageManagerImpl class.
+ */
+#include <EWebKit2.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColIList.h>
+#include <FBaseSysLog.h>
+#include "FWebCtrl_Utility.h"
+#include "FWebCtrl_WebPresenter.h"
+#include "FWebCtrl_WebStorageManagerImpl.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace Web { namespace Controls
+{
+
+
+void
+OnOriginReceived(Eina_List* pOrigins, void* pUserData)
+{
+       _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
+
+       pPresenter->EndAsyncProcess(pOrigins);
+}
+
+
+void
+OnIntReceived(int64_t integer, void* pUserData)
+{
+       _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
+
+
+
+       pPresenter->EndAsyncProcess((long)integer);
+}
+
+
+void
+OnUIntReceived(uint64_t integer, void* pUserData)
+{
+       _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
+
+
+
+       pPresenter->EndAsyncProcess((long)integer);
+}
+
+
+_WebStorageManagerImpl::_WebStorageManagerImpl(void)
+{
+}
+
+
+_WebStorageManagerImpl::~_WebStorageManagerImpl(void)
+{
+}
+
+
+IList*
+_WebStorageManagerImpl::GetOriginListN(WebStorageType storageType)
+{
+       Ewk_Context* pDefaultContext = ewk_context_default_get();
+       Eina_List* pOriginEinaList;
+       ArrayList* pOriginList;
+       _WebPresenter presenter;
+       presenter.InitAsyncProcess();
+
+       switch (storageType)
+       {
+       case WEB_STORAGE_TYPE_APPLICATION_CACHE:
+               ewk_context_application_cache_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_SQL_DATABASE:
+               ewk_context_web_database_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_STORAGE:
+               ewk_context_web_storage_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_FILE_SYSTEM:
+               ewk_context_local_file_system_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       default:
+               break;
+       }
+
+       presenter.WaitAsyncProcess(pOriginEinaList);
+
+       pOriginList = new (std::nothrow) ArrayList();
+       pOriginList->Construct();
+
+       for(; pOriginEinaList; pOriginEinaList = eina_list_next(pOriginEinaList))
+       {
+               Ewk_Security_Origin* pOrigin = static_cast<Ewk_Security_Origin*>(eina_list_data_get(pOriginEinaList));
+               String* pStringOrigin = new (std::nothrow) String(_Utility::CreateOrigin(pOrigin));
+               pOriginList->Add(pStringOrigin);
+       }
+       
+       return pOriginList;
+}
+
+
+result
+_WebStorageManagerImpl::SetQuotaForOrigin(WebStorageType storageType, const String& origin, long quota)
+{
+       Ewk_Context* pDefaultContext = ewk_context_default_get();
+
+       SysTryReturnResult(NID_WEB_CTRL, (storageType == WEB_STORAGE_TYPE_WEB_SQL_DATABASE) || (storageType == WEB_STORAGE_TYPE_APPLICATION_CACHE), E_UNSUPPORTED_TYPE, "[%s] This storage type is not supported.", GetErrorMessage(E_UNSUPPORTED_TYPE));
+
+       Ewk_Security_Origin* pOrigin = CompareOrigin(storageType, origin);
+       SysTryReturnResult(NID_WEB_CTRL, pOrigin, E_INVALID_ARG, "[%s] This origin does not exist.", GetErrorMessage(E_INVALID_ARG));
+
+       switch (storageType)
+       {
+       case WEB_STORAGE_TYPE_APPLICATION_CACHE:
+               ewk_context_application_cache_quota_for_origin_set(pDefaultContext, pOrigin, quota);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_SQL_DATABASE:
+               ewk_context_web_database_quota_for_origin_set(pDefaultContext, pOrigin, quota); 
+               break;
+
+       default:
+               break;
+       }
+       return E_SUCCESS;
+}
+
+
+long
+_WebStorageManagerImpl::GetQuotaForOrigin(WebStorageType storageType, const String& origin)
+{
+       Ewk_Context* pDefaultContext = ewk_context_default_get();
+       long quota = 0;
+
+       SysTryReturn(NID_WEB_CTRL, storageType == WEB_STORAGE_TYPE_WEB_SQL_DATABASE, 0, E_UNSUPPORTED_TYPE, "[%s] This storage type is not supported.", GetErrorMessage(E_UNSUPPORTED_TYPE));
+
+       Ewk_Security_Origin* pOrigin = CompareOrigin(storageType, origin);
+       SysTryReturnResult(NID_WEB_CTRL, pOrigin, E_INVALID_ARG, "[%s] This origin does not exist.", GetErrorMessage(E_INVALID_ARG));
+
+       _WebPresenter presenter;
+       presenter.InitAsyncProcess();
+
+       switch (storageType)
+       {
+       case WEB_STORAGE_TYPE_APPLICATION_CACHE:
+               ewk_context_application_cache_usage_for_origin_get(pDefaultContext, pOrigin, OnIntReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_SQL_DATABASE:
+               ewk_context_web_database_quota_for_origin_get(pDefaultContext, OnUIntReceived, &presenter, pOrigin);
+               break;
+
+       default:
+               break;
+       }
+
+       presenter.WaitAsyncProcess(quota);
+
+       return quota;
+}
+
+
+long
+_WebStorageManagerImpl::GetUsageForOrigin(WebStorageType storageType, const String& origin)
+{
+       Ewk_Context* pDefaultContext = ewk_context_default_get();
+       long usage = 0;
+
+       SysTryReturn(NID_WEB_CTRL, (storageType != WEB_STORAGE_TYPE_INDEXED_DATABASE) && (storageType != WEB_STORAGE_TYPE_FILE_SYSTEM), 0, E_UNSUPPORTED_TYPE, "[%s] This storage type is not supported.", GetErrorMessage(E_UNSUPPORTED_TYPE));
+
+       Ewk_Security_Origin* pOrigin = CompareOrigin(storageType, origin);
+       SysTryReturnResult(NID_WEB_CTRL, pOrigin, E_INVALID_ARG, "[%s] This origin does not exist.", GetErrorMessage(E_INVALID_ARG));
+
+       _WebPresenter presenter;
+       presenter.InitAsyncProcess();
+
+       switch (storageType)
+       {
+       case WEB_STORAGE_TYPE_APPLICATION_CACHE:
+               //ewk_context_application_cache_usage_for_origin_get(pDefaultContext, pOrigin, OnIntReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_SQL_DATABASE:
+               ewk_context_web_database_usage_for_origin_get(pDefaultContext, OnUIntReceived, &presenter, pOrigin);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_STORAGE :
+               ewk_context_web_storage_usage_for_origin_get(pDefaultContext, pOrigin, OnUIntReceived, &presenter);
+               break;
+
+       default:
+               break;
+       }
+
+       presenter.WaitAsyncProcess(usage);
+
+       return usage;
+}
+
+
+result
+_WebStorageManagerImpl::Remove(WebStorageType storageType, const String& origin)
+{
+       Ewk_Context* pDefaultContext = ewk_context_default_get();
+
+       SysTryReturnResult(NID_WEB_CTRL, storageType != WEB_STORAGE_TYPE_INDEXED_DATABASE, E_UNSUPPORTED_TYPE, "[%s] This storage type is not supported.", GetErrorMessage(E_UNSUPPORTED_TYPE));
+
+       Ewk_Security_Origin* pOrigin = CompareOrigin(storageType, origin);
+       SysTryReturnResult(NID_WEB_CTRL, pOrigin, E_INVALID_ARG, "[%s] This origin does not exist.", GetErrorMessage(E_INVALID_ARG));
+
+       switch (storageType)
+       {
+       case WEB_STORAGE_TYPE_APPLICATION_CACHE:
+               ewk_context_application_cache_delete(pDefaultContext, pOrigin);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_SQL_DATABASE:
+               ewk_context_web_database_delete(pDefaultContext, pOrigin);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_STORAGE :
+               ewk_context_web_storage_origin_delete(pDefaultContext, pOrigin);
+               break;
+
+       case WEB_STORAGE_TYPE_FILE_SYSTEM:
+               ewk_context_local_file_system_delete(pDefaultContext, pOrigin);
+               break;
+
+       default:
+               break;
+       }
+
+       return E_SUCCESS;
+}
+
+
+result
+_WebStorageManagerImpl::RemoveAll(WebStorageType storageType)
+{
+       Ewk_Context* pDefaultContext = ewk_context_default_get();
+
+       switch (storageType)
+       {
+       case WEB_STORAGE_TYPE_APPLICATION_CACHE:
+               ewk_context_application_cache_delete_all(pDefaultContext);
+               break;
+
+       case WEB_STORAGE_TYPE_INDEXED_DATABASE :
+               ewk_context_web_indexed_database_delete_all(pDefaultContext);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_SQL_DATABASE:
+               ewk_context_web_database_delete_all(pDefaultContext);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_STORAGE :
+               ewk_context_web_storage_delete_all(pDefaultContext);
+               break;
+
+       case WEB_STORAGE_TYPE_FILE_SYSTEM:
+               ewk_context_local_file_system_all_delete(pDefaultContext);
+               break;
+
+       default:
+               break;
+       }
+       return E_SUCCESS;
+}
+
+
+Ewk_Security_Origin*
+_WebStorageManagerImpl::CompareOrigin(WebStorageType storageType, const String& origin)
+{
+       Ewk_Context* pDefaultContext = ewk_context_default_get();
+       _WebPresenter presenter;
+       Eina_List* pOriginList;
+       presenter.InitAsyncProcess();
+
+       switch (storageType)
+       {
+       case WEB_STORAGE_TYPE_APPLICATION_CACHE:
+               ewk_context_application_cache_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_SQL_DATABASE:
+               ewk_context_web_database_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_WEB_STORAGE:
+               ewk_context_web_storage_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       case WEB_STORAGE_TYPE_FILE_SYSTEM:
+               ewk_context_local_file_system_origins_get(pDefaultContext, OnOriginReceived, &presenter);
+               break;
+
+       default:
+               break;
+       }
+
+       presenter.WaitAsyncProcess(pOriginList);
+
+       for(; pOriginList; pOriginList = eina_list_next(pOriginList))
+       {
+               Ewk_Security_Origin* pOrigin = static_cast<Ewk_Security_Origin*>(eina_list_data_get(pOriginList));
+               int cmp = origin.CompareTo(_Utility::CreateOrigin(pOrigin));
+               
+               if (cmp ==0)
+               {
+                       return pOrigin;
+               }
+       }
+       return null;
+}
+}}} // Tizen::Web::Controls
diff --git a/src/controls/FWebCtrl_WebStorageManagerImpl.h b/src/controls/FWebCtrl_WebStorageManagerImpl.h
new file mode 100755 (executable)
index 0000000..6f917aa
--- /dev/null
@@ -0,0 +1,69 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+\r
+/**\r
+ * @file               FWebCtrl_WebStorageManagerImpl.h\r
+ * @brief              The file contains the declaration of _WebStorageManagerImpl class.\r
+ *\r
+ * The file contains the declaration of _WebStorageManagerImpl class.\r
+ */\r
+#ifndef _FWEB_CTRL_INTERNAL_WEB_STORAGE_MANAGER_IMPL_H_\r
+#define _FWEB_CTRL_INTERNAL_WEB_STORAGE_MANAGER_IMPL_H_\r
+\r
+#include <ewk_security_origin.h>\r
+#include <FBaseString.h>\r
+#include <FWebCtrlWebStorageManager.h>\r
+\r
+namespace Tizen { namespace Base { namespace Collection\r
+{\r
+class IList;\r
+}}}\r
+\r
+namespace Tizen { namespace Web { namespace Controls\r
+{\r
+\r
+class _WebStorageManagerImpl\r
+       : public Tizen::Base::Object\r
+{\r
+public:\r
+       _WebStorageManagerImpl(void);\r
+\r
+       virtual ~_WebStorageManagerImpl(void);\r
+\r
+       Tizen::Base::Collection::IList* GetOriginListN(WebStorageType storageType);\r
+\r
+       result SetQuotaForOrigin(WebStorageType storageType, const Tizen::Base::String& origin, long quota);\r
+\r
+       long GetQuotaForOrigin(WebStorageType storageType, const Tizen::Base::String& origin);\r
+\r
+       long GetUsageForOrigin(WebStorageType storageType, const Tizen::Base::String& origin);\r
+\r
+       result Remove(WebStorageType storageType, const Tizen::Base::String& origin);\r
+\r
+       result RemoveAll(WebStorageType storageType);\r
+\r
+       Ewk_Security_Origin* CompareOrigin(WebStorageType storageType, const Tizen::Base::String& origin);\r
+\r
+private:\r
+       _WebStorageManagerImpl(const _WebStorageManagerImpl& rhs);\r
+\r
+       _WebStorageManagerImpl& operator=(const _WebStorageManagerImpl& rhs);\r
+\r
+};\r
+\r
+}}} // Tizen::Web::Controls\r
+#endif // _FWEB_CTRL_INTERNAL_WEB_STORAGE_MANAGER_IMPL_H_
\ No newline at end of file