[Title] Add to ewk api for setting/getting the User Agent by using system info library.
[Issue#] N/A
[Problem] Currently the UA was managed by Browser with hard coded string.
[Cause] UA issue is decided recently.
[Solution] Access the system info for User Agent by using capi-system-info and modify the ewk api.
Change-Id: Ie393928f6d4597da3dc3f96a149abbf9fe83a096
// TODO : More information(OS version, JavaScript Core version) will be added.
page.append(helpTextToRow("WebKit", String::format("%d.%d", WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION)));
- // FIXME : User Agent should be obtained from a page OBJECT. This will be fixed after refactoring 'about:' implementation itself.
- page.append(helpTextToRow("User Agent", "Mozilla/5.0 (Linux; Tizen 2.2; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 Mobile Safari/537.3"));
+
+ HashSet<Page*>::iterator begin = allPages->begin();
+ HashSet<Page*>::iterator end = allPages->end();
+ KURL unused;
+ if (begin != end)
+ page.append(helpTextToRow("User Agent", header((*begin)->mainFrame()->loader()->userAgent(unused))));
page.append(footer());
"${WEBKIT2_DIR}/WebProcess/WebCoreSupport/efl/tizen"
"${WEBKIT2_DIR}/WebProcess/WebPage/efl/tizen"
"${WTF_DIR}"
+ ${CAPI_INCLUDE_DIRS}
${ELEMENTARY_INCLUDE_DIRS}
${GLES_INCLUDE_DIRS} #FIXME
${TTS_INCLUDE_DIRS}
)
LIST(APPEND WebKit2_LIBRARIES
+ ${CAPI_LIBRARIES}
${ELEMENTARY_LIBRARIES}
${GLES20_LIBRARIES} #FIXME
${TTS_LIBRARIES}
WKEinaSharedString userAgent;
+#if OS(TIZEN)
+ WKEinaSharedString applicationName;
+#endif
+
#if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
WKEinaSharedString webAppIconURL;
Eina_List* webAppIconURLs;
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
+#if OS(TIZEN)
+ WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
+
+ int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
+ OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
+ WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
+ impl->userAgent = buffer.get();
+#else
if (!impl->userAgent) {
WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
impl->userAgent = buffer.get();
}
+#endif
return impl->userAgent;
}
+
+#if OS(TIZEN)
+Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* applicationName)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(applicationName, false);
+
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+ EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
+
+ WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKStringCreateWithUTF8CString(applicationName));
+ WKPageSetApplicationNameForUserAgent(toAPI(impl->pageProxy.get()), applicationNameString.get());
+
+ return true;
+}
+
+const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+ EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
+
+ WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKPageCopyApplicationNameForUserAgent(toAPI(impl->pageProxy.get())));
+
+ int length = WKStringGetMaximumUTF8CStringSize(applicationNameString.get());
+ OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
+ WKStringGetUTF8CString(applicationNameString.get(), buffer.get(), length);
+ impl->applicationName = buffer.get();
+
+ return impl->applicationName;
+}
+#endif
+
Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
{
#if ENABLE(TIZEN_CUSTOM_HEADERS)
* @return @c user agent string
*/
EAPI const char* ewk_view_user_agent_get(const Evas_Object* o);
+
+// #if OS(TIZEN)
+/**
+* Request to set the user agent with application name.
+*
+* @param o view object to set the user agent with application name
+*
+* @param application_name string to set the user agent
+*
+* @return @c EINA_TRUE on success or @c EINA_FALSE on failure
+*/
+EAPI Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* o, const char* application_name);
+
+/**
+* Returns application name string.
+*
+* @param o view object to get the application name
+*
+* @return @c application name
+*/
+EAPI const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* o);
+// #endif
+
//#if ENABLE(TIZEN_CUSTOM_HEADERS)
/**
* add custom header
#include <WebCore/ContentSecurityPolicy.h>
#endif
+#include <system_info.h>
+#include "WebKitVersion.h"
+
using namespace WebCore;
#endif
String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
{
#if OS(TIZEN)
- return String::fromUTF8("Mozilla/5.0 (Linux; Tizen 2.2; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 Mobile Safari/537.3");
+ WTF::String appleWebkitVer = makeString(String::number(WEBKIT_MAJOR_VERSION), '.', String::number(WEBKIT_MINOR_VERSION));
+
+ char* versionName = NULL;
+ WTF::String platformVer;
+ int ret = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &versionName);
+ if (ret == SYSTEM_INFO_ERROR_NONE) {
+ char* versionNameCopy = NULL;
+ versionNameCopy = strdup(versionName);
+
+ char* majorVersion = NULL;
+ char* minorVersion = NULL;
+ majorVersion = strtok(versionNameCopy, ".");
+ minorVersion = strtok(NULL, ".");
+
+ if (majorVersion == NULL || minorVersion == NULL) {
+ platformVer = String("2.2");
+ } else {
+ WTF::String platformVerMajor;
+ WTF::String platformVerMinor;
+ platformVerMajor = String(majorVersion);
+ platformVerMinor = String(minorVersion);
+ platformVer = makeString(platformVerMajor, ".", platformVerMinor);
+ }
+ free(versionNameCopy);
+ }
+
+ if (versionName)
+ free(versionName);
+
+ WTF::String userAgentString = makeString("Mozilla/5.0 (Linux; Tizen ", platformVer, "; sdk) AppleWebKit/", appleWebkitVer, " (KHTML, like Gecko)");
+ if (applicationNameForUserAgent.isEmpty())
+ userAgentString.append(makeString("Version/", platformVer));
+ else
+ userAgentString.append(applicationNameForUserAgent);
+ userAgentString.append(makeString(" Mobile Safari/", appleWebkitVer));
+
+ return userAgentString;
#endif
WTF::String platform;
capi-system-sensor
capi-telephony-network-info
capi-system-power
+ capi-system-info
)
FIND_PATH(APPFW_APPLICATION_INCLUDE_DIRS NAMES app.h
HINTS ${PC_CAPI_LIBRARY_DIRS} ${PC_CAPI_LIBDIR}
)
+FIND_PATH(SYSTEM_INFO_INCLUDE_DIRS NAMES system_info.h
+ HINTS ${PC_CAPI_INCLUDE_DIRS} ${PC_CAPI_INCLUDEDIR}
+)
+FIND_LIBRARY(SYSTEM_INFO_LIBRARIES NAMES capi-system-info
+ HINTS ${PC_CAPI_LIBRARY_DIRS} ${PC_CAPI_LIBDIR}
+)
+
SET(CAPI_INCLUDE_DIRS
${APPFW_APPLICATION_INCLUDE_DIRS}
${NETWORK_CONNECTION_INCLUDE_DIRS}
${SYSTEM_SENSOR_INCLUDE_DIRS}
${TELEPHONY_NETWORK_INCLUDE_DIRS}
${SYSTEM_POWER_INCLUDE_DIRS}
+ ${SYSTEM_INFO_INCLUDE_DIRS}
)
SET(CAPI_LIBRARIES
${APPFW_APPLICATION_LIBRARIES}
${SYSTEM_SENSOR_LIBRARIES}
${TELEPHONY_NETWORK_LIBRARIES}
${SYSTEM_POWER_LIBRARIES}
+ ${SYSTEM_INFO_LIBRARIES}
)
INCLUDE(FindPackageHandleStandardArgs)
# version up.
# -----------------------------------------------------------------------------
SET(WEBKIT_USER_AGENT_MAJOR_VERSION 537)
-SET(WEBKIT_USER_AGENT_MINOR_VERSION 2)
+SET(WEBKIT_USER_AGENT_MINOR_VERSION 3)
ADD_DEFINITIONS(-DWEBCORE_NAVIGATOR_VENDOR="Tizen")
ADD_DEFINITIONS(-DBUILDING_EFL__=1)
BuildRequires: pkgconfig(gles20)
BuildRequires: pkgconfig(tts)
BuildRequires: pkgconfig(capi-system-power)
+BuildRequires: pkgconfig(capi-system-info)
%description