[WRTjs][VD] Refactors to reduce IS_TIZEN_TV flag 17/308517/4
authorDongHyun Song <dh81.song@samsung.com>
Wed, 27 Mar 2024 02:00:32 +0000 (11:00 +0900)
committerBot Blink <blinkbot@samsung.com>
Thu, 28 Mar 2024 11:19:15 +0000 (11:19 +0000)
Seperates WRTBrowserContextTV class to reduce IS_TIZEN_TV flag

Change-Id: I5a45a309541bebe7f6ce84e3d04066c3dc844ea6
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt/filenames.gni
wrt/src/browser/tv/wrt_browser_context_tv.cc [new file with mode: 0644]
wrt/src/browser/tv/wrt_browser_context_tv.h [new file with mode: 0644]
wrt/src/browser/wrt_browser_context.cc
wrt/src/browser/wrt_browser_context.h

index a08c7bb..4fbf198 100644 (file)
@@ -210,6 +210,8 @@ wrt_lib_sources_tv = [
   "src/browser/tv/widget_state.h",
   "src/browser/tv/wrt_browser_client_tv.cc",
   "src/browser/tv/wrt_browser_client_tv.h",
+  "src/browser/tv/wrt_browser_context_tv.cc",
+  "src/browser/tv/wrt_browser_context_tv.h",
   "src/browser/tv/wrt_native_window_tv.cc",
   "src/browser/tv/wrt_native_window_tv.h",
   "src/browser/tv/wrt_xwalk_extension_browser_tv.cc",
diff --git a/wrt/src/browser/tv/wrt_browser_context_tv.cc b/wrt/src/browser/tv/wrt_browser_context_tv.cc
new file mode 100644 (file)
index 0000000..52804a5
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2024 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "wrt/src/browser/tv/wrt_browser_context_tv.h"
+
+namespace wrt {
+
+WRTBrowserContextTV::WRTBrowserContextTV(
+    const electron::PartitionOrPath partition_location,
+    bool in_memory,
+    base::Value::Dict options)
+    : WRTBrowserContext(partition_location, in_memory, std::move(options)),
+      web_cache_manager_(this) {}
+
+void WRTBrowserContextTV::ClearWebCache() {
+  web_cache_manager_.ClearCache();
+}
+
+}  // namespace wrt
diff --git a/wrt/src/browser/tv/wrt_browser_context_tv.h b/wrt/src/browser/tv/wrt_browser_context_tv.h
new file mode 100644 (file)
index 0000000..f3015fe
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2024 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BROWSER_WRT_BROWSER_CONTEXT_TV_H_
+#define BROWSER_WRT_BROWSER_CONTEXT_TV_H_
+
+#include "wrt/src/browser/wrt_browser_context.h"
+
+#include "tizen_src/ewk/efl_integration/browser/web_cache_efl/web_cache_manager_efl.h"
+
+namespace wrt {
+
+class WRTBrowserContextTV : public WRTBrowserContext {
+ public:
+  WRTBrowserContextTV(const electron::PartitionOrPath partition_location,
+                      bool in_memory,
+                      base::Value::Dict options);
+  virtual ~WRTBrowserContextTV() override = default;
+
+  WRTBrowserContextTV(const WRTBrowserContextTV&) = delete;
+  WRTBrowserContextTV& operator=(const WRTBrowserContextTV&) = delete;
+
+ private:
+  void ClearWebCache() override;
+
+  WebCacheManagerEfl web_cache_manager_;
+};
+
+}  // namespace wrt
+
+#endif  // BROWSER_WRT_BROWSER_CONTEXT_TV_H_
index 5f894fa..fc2955b 100755 (executable)
 #include "wrt/src/browser/wrt_special_storage_policy.h"
 #include "wrt/src/common/application_data.h"
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "wrt/src/browser/tv/wrt_browser_context_tv.h"
+
+using WRTBrowserContextType = wrt::WRTBrowserContextTV;
+#else
+using WRTBrowserContextType = wrt::WRTBrowserContext;
+#endif
+
 namespace {
 
 std::vector<base::WeakPtr<electron::ElectronBrowserContext>>
@@ -36,12 +44,7 @@ WRTBrowserContext::WRTBrowserContext(
     bool in_memory,
     base::Value::Dict options)
     : electron::ElectronBrowserContext(
-          partition_location, in_memory, std::move(options))
-#if BUILDFLAG(IS_TIZEN_TV)
-      ,
-      web_cache_manager_(this)
-#endif
-{
+          partition_location, in_memory, std::move(options)) {
   SetUserAgent(EflWebView::VersionInfo::GetInstance()->DefaultUserAgent());
   InitVisitedLinkWriter();
 
@@ -116,12 +119,6 @@ void WRTBrowserContext::DeleteCookies() {
                       base::BindOnce([](uint32_t num_deleted) {}));
 }
 
-#if BUILDFLAG(IS_TIZEN_TV)
-void WRTBrowserContext::ClearWebCache() {
-  web_cache_manager_.ClearCache();
-}
-#endif
-
 }  // namespace wrt
 
 namespace electron {
@@ -136,7 +133,7 @@ ElectronBrowserContext* ElectronBrowserContext::From(
   if (browser_context)
     return browser_context;
 
-  auto* new_context = new wrt::WRTBrowserContext(
+  auto* new_context = new WRTBrowserContextType(
       std::cref(partition), in_memory, std::move(options));
   browser_context_map()[key] =
       std::unique_ptr<ElectronBrowserContext>(new_context);
@@ -154,7 +151,7 @@ ElectronBrowserContext* ElectronBrowserContext::FromPath(
   }
 
   auto* new_context =
-      new wrt::WRTBrowserContext(std::cref(path), false, std::move(options));
+      new WRTBrowserContextType(std::cref(path), false, std::move(options));
   browser_context_map()[key] =
       std::unique_ptr<ElectronBrowserContext>(new_context);
   return new_context;
index 62ff83d..83be4b7 100755 (executable)
 #include "electron/shell/browser/electron_browser_context.h"
 #include "extensions/buildflags/buildflags.h"
 
-#if BUILDFLAG(IS_TIZEN_TV)
-#include "tizen_src/ewk/efl_integration/browser/web_cache_efl/web_cache_manager_efl.h"
-#endif
-
 namespace visitedlink {
 class VisitedLinkWriter;
 }
@@ -43,9 +39,8 @@ class WRTBrowserContext : public electron::ElectronBrowserContext,
 
   WRTSpecialStoragePolicy* GetWRTSpecialStoragePolicy();
 
-#if BUILDFLAG(IS_TIZEN_TV)
-  void ClearWebCache();
-#endif
+  // product specific features
+  virtual void ClearWebCache() {}
 
  private:
   // visitedlink::VisitedLinkDelegate implementation.
@@ -59,9 +54,6 @@ class WRTBrowserContext : public electron::ElectronBrowserContext,
   scoped_refptr<WRTSpecialStoragePolicy> wrt_special_storage_policy_;
   std::unique_ptr<content::BackgroundSyncController>
       background_sync_controller_;
-#if BUILDFLAG(IS_TIZEN_TV)
-  WebCacheManagerEfl web_cache_manager_;
-#endif
 };
 
 }  // namespace wrt