Implement User Agent setting by config.xml
authorJihoon Chung <jihoon.chung@samsung.com>
Thu, 20 Dec 2012 10:30:21 +0000 (19:30 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Thu, 20 Dec 2012 10:55:36 +0000 (19:55 +0900)
[Issue#] JIRA (#TDIS-955)
[Problem] N/A
[Cause] N/A
[Solution] As requirment by JIRA, implement UA setting by
tizen:setting tag in the config.xml
[SCMRequest] N/A

Change-Id: I16472b0fcfc32840ce2ab218699874ac608b71dd

src/domain/widget_data_types.cpp
src/domain/widget_data_types.h
src/view/webkit/view_logic.cpp

index 490c88c..d92197c 100644 (file)
@@ -183,8 +183,12 @@ WidgetSettingList::WidgetSettingList(WidgetSettings &widgetSettings)
                     value << "]");
                 m_BackgroundSupport = BackgroundSupport_Disable;
             }
-        }
-        else {
+        } else if (name == SETTING_NAME_USER_AGENT) {
+            DPL::OptionalString userAgent = value;
+            if (!userAgent.IsNull()) {
+                m_UserAgent = DPL::ToUTF8String(*userAgent);
+            }
+        } else {
             LogError("Invalid setting name!! [" << name << "]");
         }
     }
@@ -234,6 +238,11 @@ bool WidgetSettingList::isEncrypted() const
     return false;
 }
 
+std::string WidgetSettingList::getUserAgent() const
+{
+    return m_UserAgent;
+}
+
 bool WidgetSettingList::operator ==(const WidgetSettingList& other) const
 {
     return m_RotationLock == other.m_RotationLock &&
@@ -241,5 +250,6 @@ bool WidgetSettingList::operator ==(const WidgetSettingList& other) const
         m_BackButtonPresence == other.m_BackButtonPresence &&
         m_ContextMenu == other.m_ContextMenu &&
         m_Encryption == other.m_Encryption &&
-        m_BackgroundSupport == other.m_BackgroundSupport;
+        m_BackgroundSupport == other.m_BackgroundSupport &&
+        m_UserAgent == other.m_UserAgent;
 }
index 2a1d1b6..cbaea0c 100644 (file)
@@ -137,6 +137,8 @@ static const DPL::String SETTING_NAME_CONTEXT_MENU =
     L"context-menu";
 static const DPL::String SETTING_NAME_BACKGROUND_SUPPORT =
     L"background-support";
+static const DPL::String SETTING_NAME_USER_AGENT =
+    L"user-agent";
 static const DPL::String SETTING_VALUE_ENABLE =
     L"enable";
 static const DPL::String SETTING_VALUE_DISABLE =
@@ -217,6 +219,8 @@ class WidgetSettingList
 
     bool isEncrypted() const;
 
+    std::string getUserAgent() const;
+
     bool operator ==(const WidgetSettingList& other) const;
 
   private:
@@ -226,6 +230,7 @@ class WidgetSettingList
     WidgetSettingContextMenu m_ContextMenu;
     WidgetSettingEncryption m_Encryption;
     WidgetSettingBackgroundSupport m_BackgroundSupport;
+    std::string m_UserAgent;
 };
 
 #endif /* WRT_SRC_DOMAIN_WIDGET_DATA_TYPES_H_ */
index 55fa930..da24012 100644 (file)
@@ -938,11 +938,17 @@ void ViewLogic::prepareEwkView(Evas_Object *wkView)
     Ewk_Settings* settings = ewk_view_settings_get(wkView);
 
     // set user agent
-    auto userAgentString =
-        ViewModule::UserAgentSupport::getUserAgentFromVconf();
-    if (!userAgentString.empty()) {
-        LogDebug("Setting custom user agent as: " << userAgentString);
-        ewk_view_user_agent_set(wkView, userAgentString.c_str());
+    std::string customUserAgent = m_model->SettingList.Get().getUserAgent();
+    if (customUserAgent.empty()) {
+        auto userAgentString =
+            ViewModule::UserAgentSupport::getUserAgentFromVconf();
+        if (!userAgentString.empty()) {
+            LogDebug("Setting user agent as: " << userAgentString);
+            ewk_view_user_agent_set(wkView, userAgentString.c_str());
+        }
+    } else {
+        LogDebug("Setting  custom user agent as: " << customUserAgent);
+        ewk_view_user_agent_set(wkView, customUserAgent.c_str());
     }
 
     // set custom header : language