[WRTjs][VD] Reduce IS_TIZEN_TV compile flag #2 47/306247/4
authorDongHyun Song <dh81.song@samsung.com>
Mon, 19 Feb 2024 06:34:08 +0000 (15:34 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Fri, 23 Feb 2024 02:22:18 +0000 (02:22 +0000)
Add BlockNavigation API to remove IS_TIZEN_TV for code readability.

Change-Id: I1134508597a4dbd99b3424fd551cb14d7d871a74
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt/src/browser/native_app_control.cc
wrt/src/browser/native_web_runtime.cc
wrt/src/browser/tv/native_web_runtime_delegate_tv.cc
wrt/src/browser/tv/native_web_runtime_delegate_tv.h
wrt/src/common/wrt_profile_delegate.h

index 85acbf3..a5f1125 100755 (executable)
 #include "wrt/src/base/file_utils.h"
 #include "wrt/src/base/string_utils.h"
 
-#if BUILDFLAG(IS_TIZEN_TV)
-#include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#include "wrt/src/common/application_data.h"
-#endif
-
 namespace wrt {
 
 namespace {
@@ -223,16 +218,8 @@ bool NativeAppControl::AddDataArray(
 }
 
 bool NativeAppControl::SendLaunchRequest() {
-#if BUILDFLAG(IS_TIZEN_TV)
-  auto& app_data = ApplicationData::GetInstance();
-  std::string vconfValue = "AppID:" + app_data.app_id() + ", URL is blocked.";
-  LOG(ERROR) << "key: rtc/memory/WebApp/LaunchFail value: " << vconfValue;
-  VconfHandle("rtc/memory/WebApp/LaunchFail").Set(vconfValue, true);
-  return true;
-#else
   return (app_control_send_launch_request(app_control_, nullptr, nullptr) ==
           APP_CONTROL_ERROR_NONE);
-#endif
 }
 
 bool NativeAppControl::Reply(
index ff9a902..f6389c2 100644 (file)
@@ -81,25 +81,17 @@ std::string GetApplicationName() {
   return appname;
 }
 
-static bool ProcessWellKnownScheme(const std::string& url) {
-  if (utils::StartsWith(url, "file:") ||
-      utils::StartsWith(url, "app:") ||
-      utils::StartsWith(url, "data:") ||
-      utils::StartsWith(url, "http:") ||
-      utils::StartsWith(url, "https:") ||
-      utils::StartsWith(url, "widget:") ||
-      utils::StartsWith(url, "about:") ||
-      utils::StartsWith(url, "blob:") ||
-      utils::StartsWith(url, "appcontrol:") ||
-      utils::StartsWith(url, "chrome-extension:")) {
-    return false;
-  }
-
-  auto request(NativeAppControl::MakeAppcontrolFromURL(url));
-  if (!request || !request->SendLaunchRequest())
-    LOG(ERROR) << "Fail to send appcontrol request: " << url;
-  // Should return true, to stop the WebEngine progress step about this URL
-  return true;
+bool IsWellKnownScheme(const std::string& url) {
+  return utils::StartsWith(url, "file:") ||
+         utils::StartsWith(url, "app:") ||
+         utils::StartsWith(url, "data:") ||
+         utils::StartsWith(url, "http:") ||
+         utils::StartsWith(url, "https:") ||
+         utils::StartsWith(url, "widget:") ||
+         utils::StartsWith(url, "about:") ||
+         utils::StartsWith(url, "blob:") ||
+         utils::StartsWith(url, "appcontrol:") ||
+         utils::StartsWith(url, "chrome-extension:");
 }
 
 std::vector<std::string> ParseTizenVersion(const std::string& tizen_string) {
@@ -360,19 +352,18 @@ bool NativeWebRuntime::ShouldAllowNavigation(const std::string& url) {
     return true;
 #endif
 
-  // scheme handling
-  // except(file , http, https, app, chrome-extension) pass to appcontrol and return false
-  if (ProcessWellKnownScheme(url))
-    return false;
-
-  // send launch request for blocked URL to guarrenty backward-compatibility.
-  if (resource_manager_->AllowNavigation(url))
+  if (IsWellKnownScheme(url) && resource_manager_->AllowNavigation(url))
     return true;
 
+  // send launch request for blocked URL to guarrenty backward-compatibility.
   LOG(ERROR) << "URL is blocked. send launch request for URL : " << url;
+  if (runtime_delegate_ && runtime_delegate_->BlockNavigation(url))
+    return false;
+
   auto request(NativeAppControl::MakeAppcontrolFromURL(url));
   if (!request || !request->SendLaunchRequest())
     LOG(ERROR) << "Fail to send appcontrol request: " << url;
+
   return false;
 }
 
index d425909..e3e20bc 100644 (file)
@@ -735,4 +735,14 @@ bool NativeWebRuntimeDelegateTV::IsMultitaskingSupport() {
   is_multitasking_support = decided_multitasking;
   return is_multitasking_support.value();
 }
+
+bool NativeWebRuntimeDelegateTV::BlockNavigation(const std::string& url) {
+  auto& app_data = ApplicationData::GetInstance();
+  std::string vconf_value = "AppID:" + app_data.app_id() + ", URL is blocked.";
+  LOG(ERROR) << "key: rtc/memory/WebApp/LaunchFail value: " << vconf_value;
+  LOG(ERROR) << "Blocked url : " << url;
+  VconfHandle("rtc/memory/WebApp/LaunchFail").Set(vconf_value, true);
+  return true;
+}
+
 }  // namespace wrt
index 3f614b2..43bde92 100644 (file)
@@ -67,6 +67,7 @@ class NativeWebRuntimeDelegateTV : public WRTProfileDelegate {
 
   void DidInitialized() override;
   void Finalize() override;
+  bool BlockNavigation(const std::string& url) override;
   void GetUserDataPath(base::FilePath& data_path) override;
   void HandleLowMemory() override;
   void Initialize(void* data) override;
index 5cdae8a..f7dcbe6 100755 (executable)
@@ -20,6 +20,7 @@ class WRTProfileDelegate {
   virtual void DidInitialized() {}
   virtual void Finalize() {}
 
+  virtual bool BlockNavigation(const std::string& url) {}
   virtual void GetUserDataPath(base::FilePath& data_path) {}
   virtual void HandleLowMemory() {}
   virtual bool IsAccessibilityMode() { return false; }