[M120 Migration][VD] Implement ewk_settings_disclose_set_cookie_headers_enabled 46/309646/2
authorjiangyuwei <yuwei.jiang@samsung.com>
Mon, 15 Apr 2024 03:33:51 +0000 (11:33 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 16 Apr 2024 04:30:36 +0000 (04:30 +0000)
Some apps(like Premium Play) which get cookie through xhr.getAllResponseHeaders.
Currently blink don't disclose response header with Set-Cookie field
to XMLHttpRequest.
wrtjs call SetDiscloseSetCookieEnabled to implement the function.
ewk_settings api does not delete avoid native app call the ewk api.

Reference:
 - https://review.tizen.org/gerrit/293944/

Change-Id: I6b84ffbffdb9072df23d242b7cdb3b021bdf2ddb
Signed-off-by: jiangyuwei <yuwei.jiang@samsung.com>
net/http/http_response_headers.cc
net/http/http_response_headers.h
services/network/public/cpp/net_ipc_param_traits.cc
tizen_src/ewk/efl_integration/public/ewk_settings.cc

index f68de4cda5bccc2666953a7d0f476247a8be162f..49e3e906e39dcf5f261c235f539136b988abad21 100644 (file)
@@ -193,6 +193,10 @@ const char HttpResponseHeaders::kContentRange[] = "Content-Range";
 const char HttpResponseHeaders::kLastModified[] = "Last-Modified";
 const char HttpResponseHeaders::kVary[] = "Vary";
 
+#if BUILDFLAG(IS_TIZEN_TV)
+bool HttpResponseHeaders::disclose_set_cookie_enabled_ = false;
+#endif
+
 struct HttpResponseHeaders::ParsedHeader {
   // A header "continuation" contains only a subsequent value for the
   // preceding header.  (Header values are comma separated.)
index 83b29783745123b925fc9334ef0888783c4d3e18..b64265d4fe302f924ad6acf61804700f5fcef50b 100644 (file)
@@ -399,6 +399,16 @@ class NET_EXPORT HttpResponseHeaders
   // with |PERSIST_SANS_COOKIES|.
   static bool IsCookieResponseHeader(base::StringPiece name);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  static void SetDiscloseSetCookieEnabled(bool value) {
+    disclose_set_cookie_enabled_ = value;
+  }
+
+  static bool DiscloseSetCookieEnabled() {
+    return disclose_set_cookie_enabled_;
+  }
+#endif
+
   // Write a representation of this object into tracing proto.
   void WriteIntoTrace(perfetto::TracedValue context) const;
 
@@ -520,6 +530,10 @@ class NET_EXPORT HttpResponseHeaders
 
   // The normalized http version (consistent with what GetStatusLine() returns).
   HttpVersion http_version_;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  static bool disclose_set_cookie_enabled_;
+#endif
 };
 
 using ResponseHeadersCallback =
index 09027cd66d8f1c92979b743d543d38c3ef0f85a0..02afa0a56762a9e71b59634130cb12ae89d1b022 100644 (file)
@@ -164,6 +164,13 @@ void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write(
     const param_type& p) {
   WriteParam(m, p.get() != nullptr);
   if (p.get()) {
+#if BUILDFLAG(IS_TIZEN_TV)
+    if (net::HttpResponseHeaders::DiscloseSetCookieEnabled()) {
+      LOG(INFO) << "disclose Set-Cookie headers over IPC";
+      p->Persist(m, net::HttpResponseHeaders::PERSIST_ALL);
+      return;
+    }
+#endif
     // Do not disclose Set-Cookie headers over IPC.
     p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES);
   }
index 86dd2d1657bb34c6915ca28860dd7683608bb01f..87e81e0ba6a2b618df2c8dd26f322062e6936f56 100644 (file)
@@ -849,7 +849,12 @@ Eina_Bool ewk_settings_selection_handle_enabled_get(const Ewk_Settings* settings
 
 void ewk_settings_disclose_set_cookie_headers_enabled(Ewk_Settings* settings, Eina_Bool Enabled)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  EINA_SAFETY_ON_NULL_RETURN(settings);
+  net::HttpResponseHeaders::SetDiscloseSetCookieEnabled(!!Enabled);
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV");
+#endif
 }
 
 Eina_Bool ewk_settings_mixed_contents_set(const Ewk_Settings* settings, Eina_Bool allow)