[M108 Migration] Implement ewk_settings_do_not_track_set() API 87/288887/3
authorJie Zhang <jie137.zhang@samsung.com>
Fri, 24 Feb 2023 05:44:45 +0000 (13:44 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 28 Feb 2023 09:15:59 +0000 (09:15 +0000)
Set to add http head DNT(do not track).

Reference:
- https://review.tizen.org/gerrit/#/c/279422/

Change-Id: Iee5403811413d091d53aa14b8ab4033ac576be0a
Signed-off-by: Jie Zhang <jie137.zhang@samsung.com>
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/public/ewk_settings.cc

index cfac19e..e561e8b 100644 (file)
@@ -2989,6 +2989,27 @@ bool EWebView::SetVisibility(bool enable) {
   return true;
 }
 
+void EWebView::SetDoNotTrack(Eina_Bool enable) {
+  // enable: 0 User tend to allow tracking on the target site.
+  // enable: 1 User tend to not be tracked on the target site.
+  if (web_contents_->GetMutableRendererPrefs()->enable_do_not_track == enable)
+    return;
+
+  // Set navigator.doNotTrack attribute
+  web_contents_->GetMutableRendererPrefs()->enable_do_not_track = enable;
+  web_contents_->SyncRendererPrefs();
+
+  // Set or remove DNT HTTP header, the effects will depend on design of target
+  // site.
+  if (!context())
+    return;
+
+  if (enable)
+    context()->HTTPCustomHeaderAdd("DNT", "1");
+  else
+    context()->HTTPCustomHeaderRemove("DNT");
+}
+
 #if defined(TIZEN_ATK_SUPPORT)
 void EWebView::UpdateSpatialNavigationStatus(Eina_Bool enable) {
   if (settings_->getPreferences().spatial_navigation_enabled == enable)
index 3df69fb..0b98cfc 100644 (file)
@@ -650,6 +650,7 @@ class EWebView {
                       const gfx::Vector2dF& latest_overscroll_delta);
 
   bool SetVisibility(bool enable);
+  void SetDoNotTrack(Eina_Bool);
 
 #if defined(TIZEN_ATK_SUPPORT)
   void UpdateSpatialNavigationStatus(Eina_Bool enable);
index 9d012e0..62ddad1 100644 (file)
@@ -809,6 +809,16 @@ Eina_Bool ewk_settings_mixed_contents_set(const Ewk_Settings* settings, Eina_Boo
   return EINA_FALSE;
 }
 
+Eina_Bool ewk_settings_do_not_track_set(Ewk_Settings* settings, Eina_Bool enabled)
+{
+  EWK_VIEW_IMPL_GET_OR_RETURN(
+      const_cast<Ewk_Settings*>(settings)->getEvasObject(), webview,
+      EINA_FALSE);
+  LOG(INFO) << "set do not track : " << enabled;
+  webview->SetDoNotTrack(enabled);
+  return EINA_TRUE;
+}
+
 Eina_Bool ewk_settings_viewport_meta_tag_set(Ewk_Settings* settings, Eina_Bool enable)
 {
   LOG_EWK_API_MOCKUP();