Add User Agent selection 41/90141/4
authorKamil Nowac <k.nowac@samsung.com>
Wed, 28 Sep 2016 08:18:12 +0000 (10:18 +0200)
committerKamil Nowa? <k.nowac@samsung.com>
Thu, 29 Sep 2016 08:32:17 +0000 (01:32 -0700)
[Issue]    http://suprem.sec.samsung.net/jira/browse/TWF-2203
[Problem]  User Agent selection needed for testing
[Solution] Added view
[Verify]   Settings->Developer mode->Select user agent
           User agent string should change

Change-Id: Ia2bf5b43525e0a7588bd489515117cb92b9ff3f9

services/SettingsUI/CMakeLists.txt
services/SettingsUI/SettingsMain.cpp
services/SettingsUI/SettingsMain.h
services/SettingsUI/SettingsManager.cpp
services/SettingsUI/SettingsManager.h
services/SettingsUI/SettingsPrettySignalConnector.h
services/SettingsUI/SettingsUI.cpp
services/SettingsUI/SettingsUserAgent.cpp [new file with mode: 0755]
services/SettingsUI/SettingsUserAgent.h [new file with mode: 0755]
services/SimpleUI/SimpleUI.cpp
services/SimpleUI/SimpleUI.h

index 57e7c7f8270608dff4ffdfcd2fd1f2378e02464a..47384c829285957092350ce4abea689aae3a4a31 100644 (file)
@@ -10,6 +10,7 @@ set(SettingsUI_SRCS
     SettingsDelPersData.cpp
     SettingsAFProfile.cpp
     SettingsAFCreator.cpp
+    SettingsUserAgent.cpp
     AutoFillForm/AutoFillFormItem.cpp
     )
 set(SettingsUI_HEADERS
@@ -22,6 +23,7 @@ set(SettingsUI_HEADERS
     SettingsDelPersData.h
     SettingsAFProfile.h
     SettingsAFCreator.h
+    SettingsUserAgent.h
     SettingsPrettySignalConnector.h
     AutoFillForm/AutoFillFormItem.h
     )
index d4f9973fa97f8c779168682ee32a77ddbaec048c..458fa0d506b911ea1437c554c94f230db7c339af 100644 (file)
@@ -74,12 +74,18 @@ void SettingsMain::updateButtonMap()
     advanced.sui = this;
     advanced.id = ADVANCED;
 
+    ItemData userAgent;
+    userAgent.buttonText = std::string("Developer Mode");
+    userAgent.sui = this;
+    userAgent.id = USER_AGENT;
+
     m_buttonsMap[SettingsMainOptions::HOME] = homePage;
     m_buttonsMap[SettingsMainOptions::SEARCH] = search;
     m_buttonsMap[SettingsMainOptions::AUTO_FILL_PROFILE] = autofill;
     m_buttonsMap[SettingsMainOptions::ZOOM] = zoom;
     m_buttonsMap[SettingsMainOptions::PRIVACY] = privacy;
     m_buttonsMap[SettingsMainOptions::ADVANCED] = advanced;
+    m_buttonsMap[SettingsMainOptions::USER_AGENT] = userAgent;
 
     SPSC.setSearchEngineSubText.connect(
         boost::bind(&SettingsMain::setSearchEngineSubText, this, _1));
@@ -106,6 +112,8 @@ bool SettingsMain::populateList(Evas_Object* genlist)
         appendGenlist(genlist, m_setting_item_class, &m_buttonsMap[SettingsMainOptions::PRIVACY], _privacy_cb);
     m_genlistItems[SettingsMainOptions::ADVANCED] =
         appendGenlist(genlist, m_setting_item_class, &m_buttonsMap[SettingsMainOptions::ADVANCED], _advanced_cb);
+    m_genlistItems[SettingsMainOptions::USER_AGENT] =
+        appendGenlist(genlist, m_setting_item_class, &m_buttonsMap[SettingsMainOptions::USER_AGENT], _user_agent_cb);
     return true;
 }
 
@@ -170,6 +178,12 @@ void SettingsMain::_advanced_cb(void*, Evas_Object*, void*)
     SPSC.settingsAdvancedClicked();
 }
 
+void SettingsMain::_user_agent_cb(void*, Evas_Object*, void*)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    SPSC.settingsUserAgentClicked();
+}
+
 void SettingsMain::_auto_fill_cb(void*, Evas_Object*, void*)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
index 87d464c69eb8bfe048c04e31d53f940d038acc37..3fcf6d0c0016ded674cd7d74ce1f2bb3b064ef63 100644 (file)
@@ -42,7 +42,8 @@ enum SettingsMainOptions {
     PRIVACY,
     ZOOM,
     ADVANCED,
-    DEL_PERSONAL_DATA
+    DEL_PERSONAL_DATA,
+    USER_AGENT
 };
 
 class SettingsMain
@@ -65,6 +66,7 @@ public:
     static void _advanced_cb(void *data, Evas_Object*obj , void* event_info);
     static void _auto_fill_cb(void* data, Evas_Object* obj, void* event_info);
     static void _privacy_cb(void* data, Evas_Object* obj, void * event_info);
+    static void _user_agent_cb(void*, Evas_Object*, void*);
     static void grid_item_check_changed(void* data, Evas_Object* obj, void*);
     void setSearchEngineSubText(int button);
     void setHomePageSubText();
index 620a7193adca911b61bcd26b942e5b74c1bd41c5..86b660d950a0a1f618b8645b10cc63fb576aca77 100644 (file)
@@ -51,6 +51,8 @@ void SettingsManager::connectOpenSignals()
         boost::bind(&SettingsManager::showSettingsAutofillUI, this));
     SPSC.settingsPrivacyClicked.connect(
         boost::bind(&SettingsManager::showSettingsPrivacyUI, this));
+    SPSC.settingsUserAgentClicked.connect(
+        boost::bind(&SettingsManager::showSettingsUserAgentUI, this));
     SPSC.settingsAdvancedClicked.connect(
         boost::bind(&SettingsManager::showSettingsAdvancedUI, this));
     SPSC.settingsDelPersDataClicked.connect(
@@ -88,6 +90,9 @@ std::shared_ptr<SettingsUI> SettingsManager::addView(const SettingsMainOptions&
             case DEL_PERSONAL_DATA:
                 m_settingsViews[s] = std::make_shared<SettingsDelPersData>(m_parent);
                 break;
+            case USER_AGENT:
+                m_settingsViews[s] = std::make_shared<SettingsUserAgent>(m_parent);
+                break;
             default:
                 break;
         }
@@ -134,6 +139,12 @@ void SettingsManager::showSettingsPrivacyUI()
     SPSC.showSettings(SettingsMainOptions::PRIVACY);
 }
 
+void SettingsManager::showSettingsUserAgentUI()
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    SPSC.showSettings(SettingsMainOptions::USER_AGENT);
+}
+
 void SettingsManager::showSettingsAdvancedUI()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
index bff2109b382c3b02b1134094e0c9dcf6247f812e..b7762de73425f8f39e86dbf759b35b407be93c6c 100644 (file)
@@ -27,6 +27,7 @@
 #include "SettingsDelPersData.h"
 #include "SettingsAFProfile.h"
 #include "SettingsAFCreator.h"
+#include "SettingsUserAgent.h"
 #include "service_macros.h"
 #include <string>
 #include <map>
@@ -37,7 +38,7 @@
 namespace tizen_browser{
 namespace base_ui{
 
-typedef std::shared_ptr<SettingsUI> SetPtr;
+using SetPtr = std::shared_ptr<SettingsUI>;
 class BROWSER_EXPORT SettingsManager
     : public tizen_browser::core::AbstractService
 {
@@ -55,6 +56,7 @@ public:
     void showSettingsAutofillUI();
     void showSettingsAutofillCreatorUI(bool);
     void showSettingsPrivacyUI();
+    void showSettingsUserAgentUI();
     void showSettingsAdvancedUI();
     void showSettingsDelPrivDataUI();
 
index 947ee2a3ac890d240a2e3860dcc9100f5fc413cc..b6e9b4baed9c9023a2b71a3e9e5c6cfc4cf1a362 100644 (file)
@@ -62,6 +62,7 @@ public:
     B_SIG<void ()> settingsHomePageClicked;
     B_SIG<void ()> settingsAutofillClicked;
     B_SIG<void ()> settingsAdvancedClicked;
+    B_SIG<void ()> settingsUserAgentClicked;
     B_SIG<void (bool)> settingsAutofillProfileClicked;
     B_SIG<void (const std::string&)> homePageChanged;
     B_SIG<std::string ()> requestCurrentPage;
@@ -75,6 +76,7 @@ public:
     B_SIG<void ()> showTextPopup;
     B_SIG<void (std::string)> setProfileName;
     B_SIG<void ()> autoFillCleared;
+    B_SIG<void (const std::string&)> userAgentItemClicked;
 
 private:
     SettingsPrettySignalConnector(){};
index 67e7d83d00625e820236fae202efb00113a5e691..0e8009155f4c033dc4ca5a7984a1071de74c1886 100755 (executable)
@@ -162,6 +162,19 @@ Evas_Object* SettingsUI::createActionBar(Evas_Object* settings_layout)
     return actionBar;
 }
 
+Evas_Object* SettingsUI::_gengrid_item_content_radio_get(void* data, Evas_Object* obj, const char* part)
+{
+    if (!data) {
+        BROWSER_LOGE("data is null");
+        return nullptr;
+    }
+    if (strcmp(part, "elm.swallow.end") == 0) {
+        auto itd = static_cast<ItemData*>(data);
+        return itd->sui->createRadioButton(obj, itd);
+    }
+    return nullptr;
+}
+
 char* SettingsUI::_gengrid_item_text_get(void* data, Evas_Object*, const char* part)
 {
    M_ASSERT(data);
@@ -224,19 +237,6 @@ Evas_Object* SettingsUI::_gengrid_item_content_normal_get(void* data, Evas_Objec
     return nullptr;
 }
 
-Evas_Object* SettingsUI::_gengrid_item_content_radio_get(void* data, Evas_Object* obj, const char* part)
-{
-    if (!data) {
-        BROWSER_LOGE("data is null");
-        return nullptr;
-    }
-    if (strcmp(part, "elm.swallow.end") == 0) {
-        auto itd = static_cast<ItemData*>(data);
-        return itd->sui->createRadioButton(obj, itd);
-    }
-    return nullptr;
-}
-
 void SettingsUI::_language_changed(void *data, Evas_Object* obj, void*)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
diff --git a/services/SettingsUI/SettingsUserAgent.cpp b/services/SettingsUI/SettingsUserAgent.cpp
new file mode 100755 (executable)
index 0000000..d0ef85a
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#include "SettingsUserAgent.h"
+
+#include "Config.h"
+#include "app_preference.h"
+
+namespace tizen_browser{
+namespace base_ui{
+
+SettingsUserAgent::SettingsUserAgent(Evas_Object* parent)
+{
+    init(parent);
+    updateButtonMap();
+};
+
+SettingsUserAgent::~SettingsUserAgent()
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+}
+
+void SettingsUserAgent::updateButtonMap()
+{
+    for (auto i = 0; i < UA_ITEMS_COUNT; ++i) {
+        ItemData content;
+        content.buttonText = m_uaList[i].name;
+        content.subText = m_uaList[i].uaString;
+        content.sui = this;
+        content.id = i;
+        m_buttonsMap[i] = content;
+    }
+}
+
+bool SettingsUserAgent::populateList(Evas_Object* genlist)
+{
+    m_naviframe->setLeftButtonVisible(false);
+    m_naviframe->setRightButtonVisible(false);
+    m_naviframe->setPrevButtonVisible(true);
+    m_naviframe->setTitle("User Agent");
+
+    for (auto i = 0; i < UA_ITEMS_COUNT; ++i) {
+        auto radioData = new RadioData(this, i);
+        elm_genlist_item_append(
+            genlist,
+            m_setting_check_radio_item_class,
+            &m_buttonsMap[i],
+            nullptr,
+            ELM_GENLIST_ITEM_NONE,
+            onGenlistClick,
+            radioData);
+    }
+    return true;
+}
+
+Evas_Object* SettingsUserAgent::createRadioButton(Evas_Object* obj, ItemData* itd)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    auto radio_button = elm_radio_add(obj);
+    if (radio_button) {
+        elm_radio_state_value_set(radio_button, itd->id);
+        elm_radio_group_add(radio_button, getRadioGroup());
+        evas_object_propagate_events_set(radio_button, EINA_FALSE);
+        evas_object_smart_callback_add(radio_button, "changed", onRadioClick, itd);
+        elm_access_object_unregister(radio_button);
+        m_radioMap[itd->id] = radio_button;
+    }
+    return radio_button;
+}
+
+void SettingsUserAgent::onGenlistClick(void *data, Evas_Object*, void*)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    if (!data) {
+        BROWSER_LOGD("[%s:%d] data is null", __PRETTY_FUNCTION__, __LINE__);
+        return;
+    }
+    auto radioData = static_cast<RadioData*>(data);
+    int id = radioData->radioId;
+    elm_radio_value_set(radioData->sua->m_radioMap[id], id);
+    evas_object_smart_callback_call(radioData->sua->m_radioMap[id], "changed", nullptr);
+}
+
+void SettingsUserAgent::onRadioClick(void *data, Evas_Object*, void*)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    if (!data) {
+        BROWSER_LOGD("[%s:%d] data is null", __PRETTY_FUNCTION__, __LINE__);
+        return;
+    }
+    auto itemData = static_cast<ItemData*>(data);
+    SPSC.userAgentItemClicked(itemData->subText);
+}
+
+}
+}
diff --git a/services/SettingsUI/SettingsUserAgent.h b/services/SettingsUI/SettingsUserAgent.h
new file mode 100755 (executable)
index 0000000..517a62a
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#ifndef SETTINGSUSERAGENT_MOB_H_
+#define SETTINGSUSERAGENT_MOB_H_
+
+#include "SettingsUI.h"
+
+#include <Elementary.h>
+#include <boost/concept_check.hpp>
+#include <string.h>
+#include <stdio.h>
+#include <vector>
+#include <Evas.h>
+#include <vconf.h>
+#include "BrowserLogger.h"
+#include "../SimpleUI/RadioPopup.h"
+#include "Tools/EflTools.h"
+#include "Tools/SettingsEnums.h"
+
+namespace tizen_browser{
+namespace base_ui{
+
+class SettingsUserAgent
+    : public SettingsUI
+{
+public:
+    SettingsUserAgent(Evas_Object* parent);
+    virtual ~SettingsUserAgent();
+    virtual bool populateList(Evas_Object* genlist) override;
+    virtual void updateButtonMap() override;
+    Evas_Object* createRadioButton(Evas_Object* obj, ItemData* itd) override;
+private:
+    struct UserAgentItem {
+        UserAgentItem(std::string&& n, std::string&& s)
+            : name(n)
+            , uaString(s)
+        {}
+        std::string name;
+        std::string uaString;
+    };
+
+    struct RadioData {
+        RadioData(SettingsUserAgent* suaUI, int id)
+            : sua(suaUI)
+            , radioId(id)
+        {};
+        SettingsUserAgent* sua;
+        int radioId;
+    };
+    static void onGenlistClick(void* data, Evas_Object* obj, void* event_info);
+    static void onRadioClick(void* data, Evas_Object* obj, void* event_info);
+
+    static const int UA_ITEMS_COUNT = 21;
+    std::array<UserAgentItem, UA_ITEMS_COUNT> m_uaList{{
+        UserAgentItem{"Default", "Mozilla/5.0 (Linux; Tizen 3.0; SAMSUNG TM1) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/1.0 Chrome/47.0.2526.69 Mobile safari/537.36"},
+        UserAgentItem{"Mobile - Kiran", "Mozilla/5.0 (Linux; Tizen 2.3; SAMSUNG SM-Z130H) AppleWebKit/537.3 (KHTML, like Gecko) SamsungBrowser/1.0 Mobile Safari/537.3"},
+        UserAgentItem{"Mobile - Tizen 2.4", "Mozilla/5.0 (Linux; Tizen 2.4.0; SAMSUNG TM1) AppleWebKit/537.3 (KHTML, like Gecko)SamsungBrowser/1.0 Mobile Safari/537.3"},
+        UserAgentItem{"Mobile - Tizen 3.0", "Mozilla/5.0 (Linux; Tizen 3.0; tm1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.69 Mobile safari/537.36"},
+        UserAgentItem{"Mobile - Android 4 SM-G900K  ", "Mozilla/5.0 (Linux; Android 4.4.2; SM-G900K Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.122 Mobile Safari/537.36"},
+        UserAgentItem{"Mobile - Android 5 SM-G531H", "Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-G531H Build/LMY48B) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.3 Chrome/38.0.2125.102 Mobile Safari/537.36"},
+        UserAgentItem{"Desktop - Firefox 22.0", "Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0"},
+        UserAgentItem{"Desktop - Chrome 35.0", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36"},
+        UserAgentItem{"Desktop - Internet Explorer 10", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; MS-RTC LM 8; Tablet PC 2.0; .NET4.0E)"},
+        UserAgentItem{"Desktop - Opera 21.0", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.132 Safari/537.36 OPR/21.0.1432.67 (Edition Campaign 38)"},
+        UserAgentItem{"Desktop - Safari 5.1.7", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2"},
+        UserAgentItem{"Desktop - Safari 6.0", "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25"},
+        UserAgentItem{"Apple iOS 7.0 - mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53"},
+        UserAgentItem{"Apple iOS 6.0 - pad", "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"},
+        UserAgentItem{"Apple iOS 6.0 - mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"},
+        UserAgentItem{"Apple iOS 5.0 - pad", "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"},
+        UserAgentItem{"Apple iOS 5.0 - mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"},
+        UserAgentItem{"Galaxy S5", "Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900K/KTU1AND8 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36"},
+        UserAgentItem{"Galaxy S4", "Mozilla/5.0 (Linux; Android 4.2.2; en-gb; SAMSUNG GT-I9500 Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Version/1.0 Chrome/18.0.1025.308 Mobile Safari/535.19"},
+        UserAgentItem{"Galaxy S note2", "Mozilla/5.0 (Linux; U; Android 4.3; ko-kr; SHV-E250K/KKUENC3 Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"},
+        UserAgentItem{"Custom UserAgent", ""}
+    }};
+
+    std::map<int, Evas_Object*> m_radioMap;
+};
+}
+}
+
+#endif /* SETTINGSUSERAGENT_MOB_H_ */
index 290920423cb5531c80a5678fedc4d11cdac49d51..841407a97d5f426916ce8e6e6017e8bf1fb92bd5 100755 (executable)
@@ -545,6 +545,9 @@ void SimpleUI::connectSettingsSignals()
     // SETTINGS DELETE DATA
     SPSC.deleteSelectedDataClicked.connect(
         boost::bind(&SimpleUI::settingsDeleteSelectedData, this,_1));
+
+    SPSC.userAgentItemClicked.connect(
+        boost::bind(&SimpleUI::settingsOverrideUseragent, this,_1));
 }
 
 void SimpleUI::connectWebEngineSignals()
@@ -2070,5 +2073,50 @@ void SimpleUI::deleteBookmark()
         text));
     evas_object_show(toast);
 }
+
+void SimpleUI::settingsOverrideUseragent(const std::string& userAgent)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    if (m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) {
+        NotificationPopup *popup =
+            NotificationPopup::createNotificationPopup(m_viewManager.getContent());
+        popup->show("Open a webpage to perform this operation.");
+        popup->dismiss();
+        closeSettingsUI();
+        return;
+    }
+
+    if (userAgent.empty()) {
+        InputPopup *inputPopup = InputPopup::createPopup(
+            m_viewManager.getContent(),
+            "Override UserAgent", "",
+            "",
+            _("IDS_BR_SK_DONE"),
+            _("IDS_BR_SK_CANCEL_ABB"),
+            true);
+        inputPopup->button_clicked.connect(
+            boost::bind(&SimpleUI::onOverrideUseragentButton, this, _1));
+        inputPopup->popupShown.connect(
+            boost::bind(&SimpleUI::showPopup, this, _1));
+        inputPopup->popupDismissed.connect(
+            boost::bind(&SimpleUI::dismissPopup, this, _1));
+        inputPopup->show();
+    }
+    else {
+        onOverrideUseragentButton(userAgent);
+    }
+}
+
+void SimpleUI::onOverrideUseragentButton(const std::string& newUA)
+{
+    BROWSER_LOGD("[%s]: Overriding useragent", __func__);
+    NotificationPopup *popup =
+        NotificationPopup::createNotificationPopup(m_viewManager.getContent());
+    m_webEngine->setUserAgent(newUA);
+    popup->show("UserAgent updated..");
+    popup->dismiss();
+    closeSettingsUI();
+}
+
 }
 }
index 6c5cb30cdb2f6e8edb9e3e5c6d2a98a9001a6440..0fe4ac482bf7bcbdc50c5ca4f87e1db0e3dfdbf3 100644 (file)
@@ -251,6 +251,9 @@ private:
      */
     void deleteBookmark(void);
 
+    void settingsOverrideUseragent(const std::string& userAgent);
+    void onOverrideUseragentButton(const std::string& newUA);
+
 #if !PROFILE_MOBILE
     /**
      * @brief show Zoom Menu