From 473be3d210b0da4c41ed0b5995c3a1318aba267e Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 27 Apr 2015 11:14:50 +0900 Subject: [PATCH] WebView : Support custom UserAgent - SetUserAgent - SetAppInfo Change-Id: I332d3228f8601144bca0333eb8f4b562c5c62a61 --- src/runtime/web_view.cc | 9 ++++++++- src/runtime/web_view.h | 2 ++ src/runtime/web_view_impl.cc | 11 +++++++++-- src/runtime/web_view_impl.h | 2 ++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/runtime/web_view.cc b/src/runtime/web_view.cc index c105038..aa713da 100755 --- a/src/runtime/web_view.cc +++ b/src/runtime/web_view.cc @@ -57,5 +57,12 @@ Evas_Object* WebView::evas_object() const { return impl_->evas_object(); } -} // namespace wrt +void WebView::SetAppInfo(const std::string& app_name, + const std::string& version) { + impl_->SetAppInfo(app_name, version); +} +void WebView::SetUserAgent(const std::string& user_agent) { + impl_->SetUserAgent(user_agent.c_str()); +} +} // namespace wrt diff --git a/src/runtime/web_view.h b/src/runtime/web_view.h index e451b64..4399deb 100755 --- a/src/runtime/web_view.h +++ b/src/runtime/web_view.h @@ -54,6 +54,8 @@ class WebView { void Reload(); void SetVisibility(bool show); bool EvalJavascript(const std::string& script); + void SetAppInfo(const std::string& app_name, const std::string& version); + void SetUserAgent(const std::string& user_agent); void SetEventListener(EventListener* listener); Evas_Object* evas_object() const; diff --git a/src/runtime/web_view_impl.cc b/src/runtime/web_view_impl.cc index b306a30..5592968 100755 --- a/src/runtime/web_view_impl.cc +++ b/src/runtime/web_view_impl.cc @@ -465,6 +465,13 @@ void WebViewImpl::SetEventListener(WebView::EventListener* listener) { listener_ = listener; } -} // namespace wrt - +void WebViewImpl::SetAppInfo(const std::string& app_name, + const std::string& version) { + std::string ua = app_name + "/" + version; + ewk_view_application_name_for_user_agent_set(ewk_view_, ua.c_str()); +} +void WebViewImpl::SetUserAgent(const std::string& user_agent) { + ewk_view_user_agent_set(ewk_view_, user_agent.c_str()); +} +} // namespace wrt diff --git a/src/runtime/web_view_impl.h b/src/runtime/web_view_impl.h index dd25077..3a89b96 100755 --- a/src/runtime/web_view_impl.h +++ b/src/runtime/web_view_impl.h @@ -30,6 +30,8 @@ class WebViewImpl { void Reload(); void SetVisibility(bool show); bool EvalJavascript(const std::string& script); + void SetAppInfo(const std::string& app_name, const std::string& version); + void SetUserAgent(const std::string& user_agent); void SetEventListener(WebView::EventListener* listener); Evas_Object* evas_object() const; -- 2.7.4