SettingsDelPersData.cpp
SettingsAFProfile.cpp
SettingsAFCreator.cpp
+ SettingsUserAgent.cpp
AutoFillForm/AutoFillFormItem.cpp
)
set(SettingsUI_HEADERS
SettingsDelPersData.h
SettingsAFProfile.h
SettingsAFCreator.h
+ SettingsUserAgent.h
SettingsPrettySignalConnector.h
AutoFillForm/AutoFillFormItem.h
)
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));
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;
}
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__);
PRIVACY,
ZOOM,
ADVANCED,
- DEL_PERSONAL_DATA
+ DEL_PERSONAL_DATA,
+ USER_AGENT
};
class SettingsMain
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();
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(
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;
}
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__);
#include "SettingsDelPersData.h"
#include "SettingsAFProfile.h"
#include "SettingsAFCreator.h"
+#include "SettingsUserAgent.h"
#include "service_macros.h"
#include <string>
#include <map>
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
{
void showSettingsAutofillUI();
void showSettingsAutofillCreatorUI(bool);
void showSettingsPrivacyUI();
+ void showSettingsUserAgentUI();
void showSettingsAdvancedUI();
void showSettingsDelPrivDataUI();
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;
B_SIG<void ()> showTextPopup;
B_SIG<void (std::string)> setProfileName;
B_SIG<void ()> autoFillCleared;
+ B_SIG<void (const std::string&)> userAgentItemClicked;
private:
SettingsPrettySignalConnector(){};
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);
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__);
--- /dev/null
+/*
+ * 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);
+}
+
+}
+}
--- /dev/null
+/*
+ * 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_ */
// SETTINGS DELETE DATA
SPSC.deleteSelectedDataClicked.connect(
boost::bind(&SimpleUI::settingsDeleteSelectedData, this,_1));
+
+ SPSC.userAgentItemClicked.connect(
+ boost::bind(&SimpleUI::settingsOverrideUseragent, this,_1));
}
void SimpleUI::connectWebEngineSignals()
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();
+}
+
}
}
*/
void deleteBookmark(void);
+ void settingsOverrideUseragent(const std::string& userAgent);
+ void onOverrideUseragentButton(const std::string& newUA);
+
#if !PROFILE_MOBILE
/**
* @brief show Zoom Menu