Implement allow-navigation
authorJihoon Chung <jihoon.chung@samsung.com>
Wed, 24 Apr 2013 08:40:24 +0000 (17:40 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Thu, 25 Apr 2013 06:33:32 +0000 (15:33 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Support allow-navigation
"allow-navigation" value is allowed origin for main resource
These origins only compare with main resource uri
(decidePolicyForNavigationAction, decidePolicyForNewWindowAction)
<tizen:allow-navigation>http://*.facebook.com https://*.facebook.com</tizen:allow-navigation>
[SCMRequest] N/A

Change-Id: I97403cb3d87989bae17517a5ddbfd0be77a5f8a1

modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h
modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
modules/widget_dao/orm/wrt_db [changed mode: 0755->0644]

index 553028f..726267e 100644 (file)
@@ -296,6 +296,8 @@ void WidgetDAO::registerWidgetInternal(
 
     registerWidgetWarpInfo(widgetHandle, widgetRegInfo);
 
+    registerWidgetAllowNavigationInfo(widgetHandle, widgetRegInfo);
+
     registerWidgetCertificates(widgetHandle, wacSecurity);
 
     CertificateChainList list;
@@ -615,6 +617,23 @@ void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
     }
 }
 
+void WidgetDAO::registerWidgetAllowNavigationInfo(DbWidgetHandle widgetHandle,
+                                                  const WidgetRegisterInfo &regInfo)
+{
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+    const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
+
+    FOREACH(allowNaviIt, widgetConfigurationInfo.allowNavigationInfoList)
+    {
+        WidgetAllowNavigation::Row row;
+        row.Set_app_id(widgetHandle);
+        row.Set_scheme(allowNaviIt->m_scheme);
+        row.Set_host(allowNaviIt->m_host);
+        DO_INSERT(row, WidgetAllowNavigation)
+    }
+}
+
 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
                                            const IWacSecurity &wacSecurity)
 {
index ae57410..1308357 100644 (file)
@@ -998,6 +998,25 @@ void WidgetDAOReadOnly::getWidgetAccessInfo(
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get accessinfo list")
 }
 
+void WidgetDAOReadOnly::getWidgetAllowNavigationInfo(
+    WidgetAllowNavigationInfoList& allowNavigationList) const
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetAllowNavigation, &WrtDatabase::interface())
+        select->Where(Equals<WidgetAllowNavigation::app_id>(m_widgetHandle));
+        WidgetAllowNavigation::Select::RowList rows = select->GetRowList();
+
+        FOREACH(it, rows) {
+            WidgetAllowNavigationInfo info;
+            info.scheme = it->Get_scheme();
+            info.host = it->Get_host();
+            allowNavigationList.push_back(info);
+        }
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get allow-navigation info list")
+}
+
 LanguageTags WidgetDAOReadOnly::getLanguageTags() const
 {
     //TODO check widget existance
index 1529d03..7f876d2 100644 (file)
@@ -130,6 +130,14 @@ struct WidgetAccessInfo
                info.bSubDomains == bSubDomains;
     }
 };
+typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
+
+struct WidgetAllowNavigationInfo
+{
+    DPL::String scheme;
+    DPL::String host;
+};
+typedef std::list<WidgetAllowNavigationInfo> WidgetAllowNavigationInfoList;
 
 struct EncryptedFileInfo
 {
@@ -152,8 +160,6 @@ struct EncryptedFileInfo
     }
 };
 
-typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
-
 typedef std::list<DPL::String> WindowModeList;
 
 typedef std::list<DPL::String> PrivilegeList;
index aa0c6b9..9447805 100644 (file)
@@ -238,12 +238,22 @@ class ConfigParserData
         CapabilityList m_capabilityList;
     };
 
-    LiveboxList m_livebox;
-
     typedef std::list<DPL::OptionalString> DependsPkgList;
-
     typedef std::set<DPL::String> CategoryList;
 
+    struct AllowNavigationInfo
+    {
+        AllowNavigationInfo(DPL::String scheme,
+                            DPL::String host) :
+            m_scheme(scheme),
+            m_host(host)
+        { }
+        DPL::String m_scheme;
+        DPL::String m_host;
+    };
+    typedef std::list<AllowNavigationInfo> AllowNavigationInfoList;
+
+    LiveboxList m_livebox;
     StringsList nameSpaces;
 
     LocalizedDataSet localizedDataSet;
@@ -289,6 +299,9 @@ class ConfigParserData
     DPL::OptionalString tizenPkgId;
     DPL::OptionalString tizenAppId;
 
+    // allow-navigation
+    AllowNavigationInfoList allowNavigationInfoList;
+
     //csp polic for widget
     DPL::OptionalString cspPolicy;
     DPL::OptionalString cspPolicyReportOnly;
index b92cb38..0d2e326 100644 (file)
@@ -443,6 +443,8 @@ class WidgetDAOReadOnly
      * @param[out] outAccessInfoList list filled with access info structures
      */
     void getWidgetAccessInfo(WidgetAccessInfoList& outAccessInfoList) const;
+    void getWidgetAllowNavigationInfo(
+        WidgetAllowNavigationInfoList& allowNavigationInfoList) const;
 
     /**
      * WAC 2.0 extension
index b3c276a..3647d4e 100644 (file)
@@ -186,6 +186,9 @@ class WidgetDAO : public WidgetDAOReadOnly
     static void registerWidgetWarpInfo(
         DbWidgetHandle widgetHandle,
         const WidgetRegisterInfo &regInfo);
+    static void registerWidgetAllowNavigationInfo(
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetCertificates(
         DbWidgetHandle widgetHandle,
         const IWacSecurity &wacSecurity);
old mode 100755 (executable)
new mode 100644 (file)
index 3a16855..40360ac
@@ -217,6 +217,17 @@ CREATE_TABLE(WidgetWARPInfo)
     )
 CREATE_TABLE_END()
 
+CREATE_TABLE(WidgetAllowNavigation)
+    COLUMN_NOT_NULL(app_id,     INT,)
+    COLUMN_NOT_NULL(scheme,     TEXT,)
+    COLUMN_NOT_NULL(host,       TEXT,)
+
+    TABLE_CONSTRAINTS(
+        PRIMARY KEY(app_id, scheme, host)
+        FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
+    )
+CREATE_TABLE_END()
+
 CREATE_TABLE(WidgetSecuritySettings)
     COLUMN_NOT_NULL(app_id,                 INT,)
     COLUMN_NOT_NULL(security_popup_usage,   INT, DEFAULT 1)