X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fconfiguration_parser%2Fwidget_parser.cpp;h=026a84dcf1ffe154d9c9a1cd3e752756b75b5c2a;hb=9d4c1d751638c7d071e6ef65b9c5c519214a8d37;hp=7703f4b87229d2e0d2ead776090f8c89a56aa4ca;hpb=b4c104912e430657c32ab93af62504005aa61727;p=framework%2Fweb%2Fwrt-installer.git diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp index 7703f4b..026a84d 100644 --- a/src/configuration_parser/widget_parser.cpp +++ b/src/configuration_parser/widget_parser.cpp @@ -293,10 +293,15 @@ class AccessParser : public ElementParser return; } + if(m_strIRIOrigin == L"*") //wildcard match means yes for subdomains + { + m_bSubDomainAccess = true; + } + ConfigParserData::AccessInfo accessInfo(m_strIRIOrigin, m_bSubDomainAccess); //std::pair ret = - m_data.accessInfoSet.insert(accessInfo); + m_data.accessInfoSet.insert(accessInfo); } virtual void Verify() @@ -1093,6 +1098,15 @@ class AppServiceParser : public ElementParser NormalizeString(m_scheme); NormalizeString(m_mime); + // exception + DPL::String ignoreUri(L"file"); + + if (!m_scheme.IsNull() && *m_scheme == ignoreUri) + { + LogInfo("exception : '" << *m_scheme << "' scheme will be ignored."); + m_scheme = DPL::OptionalString::Null; + } + // verify duplicate element DPL::String wildString(L"*/*"); DPL::String nullString(L""); @@ -1271,15 +1285,22 @@ class AppControlParser : public ElementParser virtual void Verify() { + // exception + DPL::String ignoreUri(L"file"); + + if (!m_value.IsNull() && *m_value == ignoreUri) + { + LogInfo("exception : '" << *m_value << "' scheme will be ignored."); + m_value = DPL::OptionalString::Null; + } + if (m_value.IsNull() || *m_value == L"") { return; } DPL::String wildString(L"*/*"); - if ((m_data.m_uriList.find(wildString) == - m_data.m_uriList.end()) - && (m_data.m_uriList.find(*m_value) == - m_data.m_uriList.end())) + if ((m_data.m_uriList.find(wildString) == m_data.m_uriList.end()) + && (m_data.m_uriList.find(*m_value) == m_data.m_uriList.end())) { m_data.m_uriList.insert(*m_value); } else { @@ -1402,16 +1423,6 @@ class AppControlParser : public ElementParser return; } - FOREACH(iterator, m_data.appControlList) { - if (iterator->m_src == m_appControl.m_src && - iterator->m_operation == m_appControl.m_operation) - { - ThrowMsg(Exception::ParseError, - "app control element is duplicated " + - DPL::ToUTF8String(m_appControl.m_src) + ", " + - DPL::ToUTF8String(m_appControl.m_operation)); - } - } m_data.appControlList.push_back(m_appControl); } @@ -1750,7 +1761,7 @@ class CategoryParser : public ElementParser ConfigParserData& m_data; }; -class LiveboxParser : public ElementParser +class AppWidgetParser : public ElementParser { public: @@ -1963,12 +1974,12 @@ class LiveboxParser : public ElementParser if (name == L"box-size") { return DPL::MakeDelegate( this, - &LiveboxParser::BoxContentParser:: + &AppWidgetParser::BoxContentParser:: OnBoxSizeElement); } else if (name == L"pd") { return DPL::MakeDelegate( this, - &LiveboxParser::BoxContentParser:: + &AppWidgetParser::BoxContentParser:: OnPdElement); } else { ThrowMsg(Exception::ParseError, @@ -1985,6 +1996,9 @@ class LiveboxParser : public ElementParser if (attribute.name == L"mouse-event") { m_box.m_boxMouseEvent = attribute.value; } + if (attribute.name == L"touch-effect") { + m_box.m_boxTouchEffect = attribute.value; + } } } @@ -2032,11 +2046,11 @@ class LiveboxParser : public ElementParser const DPL::String& name) { if (name == L"box-label") { - return DPL::MakeDelegate(this, &LiveboxParser::OnBoxLabelElement); + return DPL::MakeDelegate(this, &AppWidgetParser::OnBoxLabelElement); } else if (name == L"box-icon") { - return DPL::MakeDelegate(this, &LiveboxParser::OnBoxIconElement); + return DPL::MakeDelegate(this, &AppWidgetParser::OnBoxIconElement); } else if (name == L"box-content") { - return DPL::MakeDelegate(this, &LiveboxParser::OnBoxContentElement); + return DPL::MakeDelegate(this, &AppWidgetParser::OnBoxContentElement); } else { return &IgnoringParser::Create; } @@ -2082,7 +2096,7 @@ class LiveboxParser : public ElementParser m_data.m_livebox.push_back(m_livebox); } - explicit LiveboxParser(ConfigParserData& data) : + explicit AppWidgetParser(ConfigParserData& data) : ElementParser(), m_data(data), m_properNamespace(false) @@ -2161,6 +2175,322 @@ class CspParser : public ElementParser DPL::OptionalString m_policy; }; +class CspReportOnlyParser : public ElementParser +{ + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + CspReportOnlyParser(ConfigParserData& data) : + ElementParser(), + m_data(data), + m_properNamespace(false) + {} + + virtual void Accept(const Element& element) + { + if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) { + m_properNamespace = true; + } + } + + virtual void Accept(const XmlAttribute& /*attribute*/) + {} + + virtual void Accept(const Text& text) + { + if (m_properNamespace) { + m_policy = text.value; + } + } + + virtual void Verify() + { + if (!m_policy.IsNull()) { + m_data.cspPolicyReportOnly = *m_policy; + } + } + + private: + ConfigParserData& m_data; + bool m_properNamespace; + DPL::OptionalString m_policy; +}; + +class AccountParser : public ElementParser +{ + public: + struct AccountProviderParser : public ElementParser + { + public: + + struct IconParser : public ElementParser + { + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Text& text) + { + if (text.value == L"") { + return; + } + m_value = text.value; + } + + virtual void Accept(const Element& /*element*/) + {} + + virtual void Accept(const XmlAttribute& attribute) + { + if (attribute.name == L"section") { + if (attribute.value == L"account") { + m_type = ConfigParserData::IconSectionType::DefaultIcon; + } else if (attribute.value == L"account-small") { + m_type = ConfigParserData::IconSectionType::SmallIcon; + } + } + } + + virtual void Verify() + { + if (m_value.IsNull() || *m_value == L"") { + return; + } + + std::pair icon; + icon.first = m_type; + icon.second = *m_value; + + m_data.m_iconSet.insert(icon); + } + + IconParser(ConfigParserData::AccountProvider& data) : + ElementParser(), + m_properNamespace(false), + m_data(data), + m_type(ConfigParserData::DefaultIcon) + {} + + private: + bool m_properNamespace; + ConfigParserData::IconSectionType m_type; + DPL::OptionalString m_value; + ConfigParserData::AccountProvider& m_data; + }; + + struct DisplayNameParser : public ElementParser + { + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Text& text) + { + if (text.value == L"") { + return; + } + m_value = text.value; + } + + virtual void Accept(const Element& element) + { + m_lang = element.lang; + m_value= L""; + } + + virtual void Accept(const XmlAttribute& /*attribute*/) + {} + + virtual void Verify() + { + if (m_value.IsNull() || *m_value == L"") { + return; + } + + std::pair name; + name.first = *m_lang; + name.second = *m_value; + + m_data.m_displayNameSet.insert(name); + } + + DisplayNameParser(ConfigParserData::AccountProvider& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + {} + + private: + bool m_properNamespace; + DPL::OptionalString m_lang; + DPL::OptionalString m_value; + ConfigParserData::AccountProvider& m_data; + }; + + struct CapabilityParser : public ElementParser + { + public: + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const Text& text) + { + if (text.value == L"") { + return; + } + m_value = text.value; + } + + virtual void Accept(const Element& /*element*/) + {} + + virtual void Accept(const XmlAttribute& /*attribute*/) + {} + + virtual void Verify() + { + if (m_value.IsNull() || *m_value == L"") { + return; + } + m_data.m_capabilityList.push_back(*m_value); + } + + CapabilityParser(ConfigParserData::AccountProvider& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + {} + + private: + bool m_properNamespace; + DPL::OptionalString m_value; + ConfigParserData::AccountProvider& m_data; + }; + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + if (name == L"icon") { + return DPL::MakeDelegate(this, &AccountProviderParser::OnIconElement); + } else if (name == L"display-name") { + return DPL::MakeDelegate(this, + &AccountProviderParser::OnDisplayNameElement); + } else if (name == L"capability") { + return DPL::MakeDelegate(this, &AccountProviderParser::OnCapabilityElement); + } else { + return &IgnoringParser::Create; + } + } + + virtual void Accept(const Text& text) + {} + + virtual void Accept(const Element& /*element*/) + {} + + virtual void Accept(const XmlAttribute& attribute) + { + if (attribute.name == L"multiple-accounts-support") { + if (attribute.value == L"") { + return; + } + + if (attribute.value == L"ture") { + m_multiSupport = true; + } + } + } + + virtual void Verify() + { + m_data.m_multiAccountSupport = m_multiSupport; + } + + ElementParserPtr OnIconElement() + { + return ElementParserPtr(new IconParser(m_data)); + } + + ElementParserPtr OnDisplayNameElement() + { + return ElementParserPtr(new DisplayNameParser(m_data)); + } + + ElementParserPtr OnCapabilityElement() + { + return ElementParserPtr(new CapabilityParser(m_data)); + } + + AccountProviderParser(ConfigParserData::AccountProvider& data) : + ElementParser(), + m_properNamespace(false), + m_data(data), + m_multiSupport(false) + {} + + private: + bool m_properNamespace; + bool m_multiSupport; + ConfigParserData::AccountProvider& m_data; + }; + + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + if (name == L"account-provider") { + return DPL::MakeDelegate(this, &AccountParser::OnProviderElement); + } else { + return &IgnoringParser::Create; + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) { + m_properNamespace = true; + } + } + + virtual void Accept(const XmlAttribute& /*attribute*/) + {} + + virtual void Accept(const Text& /*text*/) + {} + + virtual void Verify() + {} + + ElementParserPtr OnProviderElement() + { + return ElementParserPtr(new AccountProviderParser(m_account)); + } + + AccountParser(ConfigParserData& data) : + ElementParser(), + m_data(data), + m_account(data.accountProvider), + m_properNamespace(false) + {} + + private: + ConfigParserData& m_data; + ConfigParserData::AccountProvider& m_account; + bool m_properNamespace; + bool m_multiSupport; +}; + ElementParser::ActionFunc WidgetParser::GetElementParser( const DPL::String& /*ns*/, const DPL::String& @@ -2213,13 +2543,18 @@ WidgetParser::WidgetParser(ConfigParserData& data) : OnAppControlElement); m_map[L"category"] = DPL::MakeDelegate(this, &WidgetParser::OnCategoryElement); - m_map[L"livebox"] = DPL::MakeDelegate(this, &WidgetParser::OnLiveboxElement); + m_map[L"app-widget"] = DPL::MakeDelegate(this, &WidgetParser::OnAppWidgetElement); #ifdef CSP_ENABLED - m_map[L"Content-Security-Policy"] = DPL::MakeDelegate( + m_map[L"content-security-policy"] = DPL::MakeDelegate( this, &WidgetParser:: OnCspElement); + m_map[L"content-security-policy-report-only"] = DPL::MakeDelegate( + this, + &WidgetParser:: + OnCspReportOnlyElement); #endif + m_map[L"account"] = DPL::MakeDelegate(this, &WidgetParser::OnAccountElement); } ElementParserPtr WidgetParser::OnNameElement() @@ -2312,9 +2647,9 @@ ElementParserPtr WidgetParser::OnCategoryElement() return ElementParserPtr(new CategoryParser(m_data)); } -ElementParserPtr WidgetParser::OnLiveboxElement() +ElementParserPtr WidgetParser::OnAppWidgetElement() { - return ElementParserPtr(new LiveboxParser(m_data)); + return ElementParserPtr(new AppWidgetParser(m_data)); } ElementParserPtr WidgetParser::OnCspElement() @@ -2322,6 +2657,16 @@ ElementParserPtr WidgetParser::OnCspElement() return ElementParserPtr(new CspParser(m_data)); } +ElementParserPtr WidgetParser::OnCspReportOnlyElement() +{ + return ElementParserPtr(new CspReportOnlyParser(m_data)); +} + +ElementParserPtr WidgetParser::OnAccountElement() +{ + return ElementParserPtr(new AccountParser(m_data)); +} + void WidgetParser::Accept(const Element& element) { if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&