WebView - text encoding
authorSeungkeun Lee <sngn.lee@samsung.com>
Fri, 5 Jun 2015 07:38:22 +0000 (16:38 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Tue, 9 Jun 2015 01:28:00 +0000 (18:28 -0700)
 - Set Default encoding to UTF-8
 - Add interface to set encoding

Change-Id: I0dfedd4f6dabcf667469da57c77221c53ec9c956

src/runtime/web_view.cc
src/runtime/web_view.h
src/runtime/web_view_impl.cc
src/runtime/web_view_impl.h

index a203e68..14bd331 100755 (executable)
@@ -83,4 +83,8 @@ void WebView::SetCSPRule(const std::string& rule, bool report_only) {
   impl_->SetCSPRule(rule, report_only);
 }
 
+void WebView::SetDefaultEncoding(const std::string& encoding) {
+  impl_->SetDefaultEncoding(encoding);
+}
+
 }  // namespace wrt
index 96efa98..bef4241 100755 (executable)
@@ -101,6 +101,7 @@ class WebView {
   void SetAppInfo(const std::string& app_name, const std::string& version);
   bool SetUserAgent(const std::string& user_agent);
   void SetCSPRule(const std::string& rule, bool report_only);
+  void SetDefaultEncoding(const std::string& encoding);
 
   void SetEventListener(EventListener* listener);
   Evas_Object* evas_object() const;
index 52b70b4..3ae2068 100755 (executable)
@@ -30,6 +30,7 @@ namespace {
 // TODO(sngn.lee) : It should be declare in common header
 const char* kKeyNameBack = "back";
 const char* kKeyNameMenu = "menu";
+const char* kDefaultEncoding = "UTF-8";
 
 static int ToWebRotation(int r) {
   switch (r) {
@@ -121,6 +122,7 @@ void WebViewImpl::Initialize() {
 
   Ewk_Settings* settings = ewk_view_settings_get(ewk_view_);
   ewk_settings_scripts_can_open_windows_set(settings, EINA_TRUE);
+  ewk_settings_default_text_encoding_name_set(settings, kDefaultEncoding);
 
   // TODO(sngn.lee): "protocolhandler,registration,requested"
   //                  custom protocol handler
@@ -776,5 +778,11 @@ void WebViewImpl::SetCSPRule(const std::string& rule, bool report_only) {
       report_only ? EWK_REPORT_ONLY : EWK_ENFORCE_POLICY);
 }
 
+void WebViewImpl::SetDefaultEncoding(const std::string& encoding) {
+  if (ewk_settings_is_encoding_valid(encoding.c_str())) {
+    Ewk_Settings* settings = ewk_view_settings_get(ewk_view_);
+    ewk_settings_default_text_encoding_name_set(settings, encoding.c_str());
+  }
+}
 
 }  // namespace wrt
index 47801f5..f9cdc7e 100755 (executable)
@@ -46,6 +46,7 @@ class WebViewImpl {
   void SetAppInfo(const std::string& app_name, const std::string& version);
   bool SetUserAgent(const std::string& user_agent);
   void SetCSPRule(const std::string& rule, bool report_only);
+  void SetDefaultEncoding(const std::string& encoding);
 
   void SetEventListener(WebView::EventListener* listener);
   Evas_Object* evas_object() const;