Support security origin database
authorJihoon Chung <jihoon.chung@samsung.com>
Thu, 8 Nov 2012 02:43:44 +0000 (11:43 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 23 Nov 2012 02:06:30 +0000 (11:06 +0900)
[Issue#] N/A
[Problem] Implement security origin for WebApplication
[Cause] N/A
[Solution] For keeping enhancement launching time and create security
origin DAO by ondemand, implement security origin using singleton.
Singleton will initialize securityOriginDAO when webkit required user
permission
[SCMRequest] N/A

Change-Id: Ib149a935ee1369a6c7226098fd314ab26c40249a

src/view/common/CMakeLists.txt
src/view/common/view_logic_security_origin_support.cpp [new file with mode: 0644]
src/view/common/view_logic_security_origin_support.h [new file with mode: 0644]
src/view/webkit/view_logic.cpp
src/view/webkit/view_logic.h

index 46422a7..4fc52b5 100644 (file)
@@ -40,6 +40,7 @@ PKG_CHECK_MODULES(VIEW_COMMON_DEP
     secure-storage
     ui-gadget-1
     wrt-commons-auto-save-dao-rw
+    wrt-commons-security-origin-dao
     REQUIRED
 )
 
@@ -56,6 +57,7 @@ SET(VIEW_COMMON_SOURCES
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_geolocation_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_password_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_security_support.cpp
+    ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_security_origin_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_storage_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_uri_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_user_agent_support.cpp
diff --git a/src/view/common/view_logic_security_origin_support.cpp b/src/view/common/view_logic_security_origin_support.cpp
new file mode 100644 (file)
index 0000000..b37f0c7
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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    view_logic_security_origin_support.cpp
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   Support security origin dao
+ */
+
+#include "view_logic_security_origin_support.h"
+
+#include <memory>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao.h>
+#include <widget_model.h>
+
+namespace ViewModule {
+
+class SecurityOriginSupportImplementation
+{
+  private:
+    WidgetModel* m_model;
+    SecurityOriginDB::SecurityOriginDAOPtr m_securityOriginDAO;
+
+  public:
+    SecurityOriginSupportImplementation(WidgetModel* widgetModel) :
+        m_model(NULL)
+    {
+        Assert(widgetModel);
+        m_model = widgetModel;
+    }
+
+    ~SecurityOriginSupportImplementation()
+    {
+    }
+
+    SecurityOriginDB::SecurityOriginDAO* getSecurityOriginDAO(void)
+    {
+        Assert(m_model);
+        if (!m_securityOriginDAO) {
+            LogDebug("initialize securityOriginDAO");
+            m_securityOriginDAO =
+                SecurityOriginDB::SecurityOriginDAOPtr(
+                    new SecurityOriginDB::SecurityOriginDAO(
+                        m_model->Handle.Get()));
+            // initialize security result data. Remove allow, deny for
+            m_securityOriginDAO->removeSecurityOriginData(
+                SecurityOriginDB::RESULT_ALLOW_ONCE);
+            m_securityOriginDAO->removeSecurityOriginData(
+                SecurityOriginDB::RESULT_DENY_ONCE);
+        }
+        return m_securityOriginDAO.get();
+    }
+};
+
+SecurityOriginSupport::SecurityOriginSupport(WidgetModel* widgetModel) :
+    m_impl(new SecurityOriginSupportImplementation(widgetModel))
+{
+}
+
+SecurityOriginSupport::~SecurityOriginSupport()
+{
+}
+
+SecurityOriginDB::SecurityOriginDAO* SecurityOriginSupport::getSecurityOriginDAO(void)
+{
+    return m_impl->getSecurityOriginDAO();
+}
+} // namespace ViewModule
diff --git a/src/view/common/view_logic_security_origin_support.h b/src/view/common/view_logic_security_origin_support.h
new file mode 100644 (file)
index 0000000..4eab3d7
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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    view_logic_security_origin_support.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   Header file for security origin
+ */
+
+#ifndef VIEW_LOGIC_SECURITY_ORIGIN_SUPPORT_H_
+#define VIEW_LOGIC_SECURITY_ORIGIN_SUPPORT_H_
+
+#include <memory>
+#include <wrt-commons/security-origin-dao/security_origin_dao.h>
+
+class WidgetModel;
+namespace SecurityOriginDB {
+    class SecurityOriginDAO;
+}
+
+namespace ViewModule {
+
+class SecurityOriginSupportImplementation;
+
+class SecurityOriginSupport
+{
+  public:
+    SecurityOriginSupport(WidgetModel* widgetModel);
+    virtual ~SecurityOriginSupport();
+    SecurityOriginDB::SecurityOriginDAO* getSecurityOriginDAO();
+
+  private:
+    std::unique_ptr<SecurityOriginSupportImplementation> m_impl;
+};
+} // namespace ViewModule
+
+
+#endif // VIEW_LOGIC_SECURITY_ORIGIN_SUPPORT_H_
index a6b6bfb..e58cc91 100644 (file)
@@ -43,6 +43,7 @@
 #include <common/view_logic_custom_header_support.h>
 #include <common/view_logic_password_support.h>
 #include <common/view_logic_security_support.h>
+#include <common/view_logic_security_origin_support.h>
 #include <common/view_logic_storage_support.h>
 #include <common/view_logic_uri_support.h>
 #include <common/view_logic_user_agent_support.h>
@@ -459,6 +460,7 @@ void ViewLogic::initializeSupport()
     m_schemeSupport.reset(new SchemeSupport(m_model->Type.Get().appType));
     ViewModule::StorageSupport::initializeStorage(m_model);
     m_appsSupport->initialize(m_model);
+    m_securityOriginSupport.reset(new ViewModule::SecurityOriginSupport(m_model));
 
     // temp
     // m_vibrationSupport->initialize();
index 89ccd05..016b76c 100644 (file)
@@ -35,6 +35,9 @@
 #include <EWebKit2.h>
 
 class SchemeSupport;
+namespace ViewModule {
+class SecurityOriginSupport;
+}
 
 class ViewLogic : public ViewModule::IViewModule
 {
@@ -274,6 +277,7 @@ class ViewLogic : public ViewModule::IViewModule
     std::unique_ptr<SchemeSupport> m_schemeSupport;
     std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
     std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
+    std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
 };
 
 #endif //VIEW_LOGIC_H_