[M108 Migration][API] Implement application type by EWK API 12/286712/4
authorayush.k123 <ayush.k123@samsung.com>
Wed, 11 Jan 2023 10:45:36 +0000 (16:15 +0530)
committerBot Blink <blinkbot@samsung.com>
Thu, 12 Jan 2023 09:33:15 +0000 (09:33 +0000)
Support function of set and get application type.
  EWK_APPLICATION_TYPE_WEBBROWSER = 0,
  EWK_APPLICATION_TYPE_HBBTV = 1,
  EWK_APPLICATION_TYPE_TIZENWRT = 2,
  EWK_APPLICATION_TYPE_OTHER = 3

Can distinguish application type in Chromium as:
  IsWebBrowser
  IsHbbTV
  IsTizenWRT

References: https://review.tizen.org/gerrit/273943/

Change-Id: I8a0af3761f7ef1d46854e16b1abff11cda5d1147
Signed-off-by: Ayush Kumar <ayush.k123@samsung.com>
18 files changed:
third_party/blink/public/BUILD.gn
third_party/blink/public/platform/web_application_type.h [new file with mode: 0644]
third_party/blink/renderer/platform/BUILD.gn
tizen_src/chromium_impl/third_party/blink/renderer/platform/blink_platform_efl.gni [new file with mode: 0644]
tizen_src/chromium_impl/third_party/blink/renderer/platform/web_application_type.cc [new file with mode: 0644]
tizen_src/ewk/efl_integration/BUILD.gn
tizen_src/ewk/efl_integration/common/application_type.cc [new file with mode: 0644]
tizen_src/ewk/efl_integration/common/application_type.h [new file with mode: 0644]
tizen_src/ewk/efl_integration/common/content_switches_efl.cc
tizen_src/ewk/efl_integration/common/content_switches_efl.h
tizen_src/ewk/efl_integration/content_browser_client_efl.cc
tizen_src/ewk/efl_integration/content_browser_client_efl.h
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/eweb_context.h
tizen_src/ewk/efl_integration/private/ewk_context_private.cc
tizen_src/ewk/efl_integration/private/ewk_context_private.h
tizen_src/ewk/efl_integration/public/ewk_context.cc
tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc

index efb2ee4..80a314b 100644 (file)
@@ -408,6 +408,10 @@ source_set("blink_headers") {
     "web/web_window_features.h",
   ]
 
+  if (tizen_product_tv) {
+    sources += [ "platform/web_application_type.h" ]
+  }
+
   if (is_mac) {
     sources += [
       "platform/mac/web_sandbox_support.h",
diff --git a/third_party/blink/public/platform/web_application_type.h b/third_party/blink/public/platform/web_application_type.h
new file mode 100644 (file)
index 0000000..4d6d96a
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2018 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 WEB_APPLICATION_TYPE_H_
+#define WEB_APPLICATION_TYPE_H_
+
+namespace blink {
+
+enum class ApplicationType : unsigned {
+  WEBBROWSER = 0,
+  HBBTV,
+  TIZENWRT,
+  OTHER
+};
+
+void SetApplicationType(const ApplicationType appType);
+bool IsWebBrowser();
+bool IsHbbTV();
+bool IsTIZENWRT();
+
+}  // namespace blink
+
+#endif
index 05707e3..d9ab1a9 100644 (file)
@@ -17,6 +17,10 @@ import("//third_party/blink/renderer/build/scripts/scripts.gni")
 import("//third_party/blink/renderer/config.gni")
 import("//third_party/blink/renderer/platform/platform_generated.gni")
 import("//v8/gni/v8.gni")
+if (use_efl) {
+  import(
+      "//tizen_src/chromium_impl/third_party/blink/renderer/platform/blink_platform_efl.gni")
+}
 
 # Most targets in this file are private actions so use that as the default.
 visibility = [
@@ -1788,6 +1792,10 @@ component("platform") {
     deps += [ "//third_party/libjxl:libjxl" ]
   }
 
+  if (use_efl) {
+    sources += external_blink_platform_files
+  }
+
   if (current_cpu == "x86" || current_cpu == "x64") {
     deps += [ ":blink_x86_avx" ]
     sources += [ "audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc" ]
diff --git a/tizen_src/chromium_impl/third_party/blink/renderer/platform/blink_platform_efl.gni b/tizen_src/chromium_impl/third_party/blink/renderer/platform/blink_platform_efl.gni
new file mode 100644 (file)
index 0000000..e7591db
--- /dev/null
@@ -0,0 +1,11 @@
+# Copyright (c) 2023 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.
+
+import("//build/config/features.gni")
+
+external_blink_platform_files = []
+
+if (tizen_product_tv) {
+  external_blink_platform_files += [ "//tizen_src/chromium_impl/third_party/blink/renderer/platform/web_application_type.cc" ]
+}
\ No newline at end of file
diff --git a/tizen_src/chromium_impl/third_party/blink/renderer/platform/web_application_type.cc b/tizen_src/chromium_impl/third_party/blink/renderer/platform/web_application_type.cc
new file mode 100644 (file)
index 0000000..9e589e4
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2018 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 "third_party/blink/public/platform/web_application_type.h"
+
+namespace blink {
+
+namespace {
+ApplicationType s_applicationType = ApplicationType::WEBBROWSER;
+}  // namespace
+
+void SetApplicationType(const ApplicationType appType) {
+  s_applicationType = appType;
+}
+
+bool IsWebBrowser() {
+  return s_applicationType == ApplicationType::WEBBROWSER;
+}
+
+bool IsHbbTV() {
+  return s_applicationType == ApplicationType::HBBTV;
+}
+
+bool IsTIZENWRT() {
+  return s_applicationType == ApplicationType::TIZENWRT;
+}
+
+}  // namespace blink
index eb52644..ccf84e3 100644 (file)
@@ -562,6 +562,13 @@ shared_library("chromium-ewk") {
     "wrt/wrtwidget.h",
   ]
 
+  if (tizen_product_tv) {
+    sources += [
+      "common/application_type.cc",
+      "common/application_type.h",
+    ]
+  }
+
   # FIXME: ewk_bringup definition should be removed.
   if (!ewk_bringup) {
     sources += [
diff --git a/tizen_src/ewk/efl_integration/common/application_type.cc b/tizen_src/ewk/efl_integration/common/application_type.cc
new file mode 100644 (file)
index 0000000..f98ed91
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright 2018 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 "common/application_type.h"
+
+#include "third_party/blink/public/platform/web_application_type.h"
+
+namespace content {
+
+// Make sure the enum values of content::ApplicationType and
+// blink::ApplicationType match.
+#define STATIC_ASSERT_ENUM_MATCH(name)                                     \
+  static_assert(                                                           \
+      content::name == static_cast<content::ApplicationType>(blink::name), \
+      #name " value must match in content and blink.")
+
+STATIC_ASSERT_ENUM_MATCH(ApplicationType::WEBBROWSER);
+STATIC_ASSERT_ENUM_MATCH(ApplicationType::HBBTV);
+STATIC_ASSERT_ENUM_MATCH(ApplicationType::TIZENWRT);
+STATIC_ASSERT_ENUM_MATCH(ApplicationType::OTHER);
+
+void SetApplicationType(const ApplicationType app_type) {
+  blink::SetApplicationType(static_cast<blink::ApplicationType>(app_type));
+}
+
+bool IsWebBrowser() {
+  return blink::IsWebBrowser();
+}
+
+bool IsHbbTV() {
+  return blink::IsHbbTV();
+}
+
+bool IsTIZENWRT() {
+  return blink::IsTIZENWRT();
+}
+}  // namespace content
diff --git a/tizen_src/ewk/efl_integration/common/application_type.h b/tizen_src/ewk/efl_integration/common/application_type.h
new file mode 100644 (file)
index 0000000..78a7356
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2018 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.
+
+// Define all the application type.
+#ifndef APPLICATION_TYPE_H_
+#define APPLICATION_TYPE_H_
+
+namespace content {
+
+enum class ApplicationType : unsigned {
+  WEBBROWSER = 0,
+  HBBTV,
+  TIZENWRT,
+  OTHER
+};
+
+void SetApplicationType(const ApplicationType app_type);
+bool IsWebBrowser();
+bool IsHbbTV();
+bool IsTIZENWRT();
+}  // namespace content
+#endif  // APPLICATION_TYPE_H_
index bde2e47..1e8d1f9 100644 (file)
@@ -13,6 +13,11 @@ namespace switches {
 const char kEnableViewMode[]    = "enable-view-mode";
 const char kInjectedBundlePath[] = "injected-bundle-path";
 
+#if BUILDFLAG(IS_TIZEN_TV)
+// Save ApplicationType in command line.
+const char kApplicationType[] = "application-type";
+#endif
+
 // Widget Info
 const char kTizenAppId[] = "widget-id";
 const char kWidgetScale[] = "widget-scale";
index 25519a6..abefe6d 100644 (file)
@@ -18,6 +18,10 @@ namespace switches {
 // different modes using CSS Media Queries.
 CONTENT_EXPORT extern const char kEnableViewMode[];
 CONTENT_EXPORT extern const char kInjectedBundlePath[];
+#if BUILDFLAG(IS_TIZEN_TV)
+// Save ApplicationType in command line.
+CONTENT_EXPORT extern const char kApplicationType[];
+#endif
 CONTENT_EXPORT extern const char kTizenAppId[];
 CONTENT_EXPORT extern const char kWidgetScale[];
 CONTENT_EXPORT extern const char kWidgetTheme[];
index bbe1fa0..0e27dd4 100644 (file)
@@ -105,45 +105,59 @@ ContentBrowserClientEfl::CreateBrowserMainParts(bool is_integration_test) {
   return browser_main_parts;
 }
 
+void ContentBrowserClientEfl::AppendExtraCommandLineSwitchesInternal(
+    base::CommandLine* command_line,
+    int child_process_id) {
+  if (!command_line->HasSwitch(switches::kProcessType))
+    return;
+
+  if (command_line->GetSwitchValueASCII(switches::kProcessType) !=
+      switches::kRendererProcess)
+    return;
+
+  content::RenderProcessHost* host =
+      content::RenderProcessHost::FromID(child_process_id);
+  if (!host)
+    return;
+
+  EWebContext* context =
+      static_cast<BrowserContextEfl*>(host->GetBrowserContext())->WebContext();
+  if (!context)
+    return;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  Ewk_Application_Type application_type = context->GetApplicationType();
+  command_line->AppendSwitchASCII(
+      switches::kApplicationType,
+      base::NumberToString(static_cast<int>(application_type)));
+#endif
+
+  const std::string& injectedBundlePath = context->GetInjectedBundlePath();
+  if (injectedBundlePath.empty())
+    return;
+
+  command_line->AppendSwitchASCII(switches::kInjectedBundlePath,
+                                  injectedBundlePath);
+
+  const std::string& tizen_app_id = context->GetTizenAppId();
+  command_line->AppendSwitchASCII(switches::kTizenAppId, tizen_app_id);
+
+  double scale = context->GetWidgetScale();
+  command_line->AppendSwitchASCII(switches::kWidgetScale,
+                                  base::NumberToString(scale));
+
+  const std::string& widget_theme = context->GetWidgetTheme();
+  command_line->AppendSwitchASCII(switches::kWidgetTheme, widget_theme);
+
+  const std::string& widget_encoded_bundle = context->GetWidgetEncodedBundle();
+  command_line->AppendSwitchASCII(switches::kWidgetEncodedBundle,
+                                  widget_encoded_bundle);
+}
+
 void ContentBrowserClientEfl::AppendExtraCommandLineSwitches(
     base::CommandLine* command_line,
     int child_process_id) {
-  if (command_line->HasSwitch(switches::kProcessType)) {
-    std::string processType =
-        command_line->GetSwitchValueASCII(switches::kProcessType);
-    if (processType == switches::kRendererProcess) {
-      if (content::RenderProcessHost* host =
-              content::RenderProcessHost::FromID(child_process_id)) {
-        if (EWebContext* context =
-                static_cast<BrowserContextEfl*>(host->GetBrowserContext())
-                    ->WebContext()) {
-          const std::string& injectedBundlePath =
-              context->GetInjectedBundlePath();
-          if (!injectedBundlePath.empty()) {
-            command_line->AppendSwitchASCII(switches::kInjectedBundlePath,
-                                            injectedBundlePath);
-
-            const std::string& tizen_app_id = context->GetTizenAppId();
-            command_line->AppendSwitchASCII(
-                switches::kTizenAppId, tizen_app_id);
-
-            double scale = context->GetWidgetScale();
-            command_line->AppendSwitchASCII(switches::kWidgetScale,
-                                            base::NumberToString(scale));
-
-            const std::string& widget_theme = context->GetWidgetTheme();
-            command_line->AppendSwitchASCII(switches::kWidgetTheme,
-                                            widget_theme);
-
-            const std::string& widget_encoded_bundle =
-                context->GetWidgetEncodedBundle();
-            command_line->AppendSwitchASCII(switches::kWidgetEncodedBundle,
-                                            widget_encoded_bundle);
-          }
-        }
-      }
-    }
-  }
+  AppendExtraCommandLineSwitchesInternal(command_line, child_process_id);
   CommandLineEfl::AppendProcessSpecificArgs(*command_line);
 }
 
index b0615ec..7c977c0 100644 (file)
@@ -153,6 +153,8 @@ class ContentBrowserClientEfl : public ContentBrowserClient {
                                              const GURL& target_url);
 
   void NotifyAcceptLangsChanged();
+  void AppendExtraCommandLineSwitchesInternal(base::CommandLine* command_line,
+                                              int child_process_id);
 
   BrowserMainPartsEfl* browser_main_parts_efl_;
 
index 316070f..fca6eeb 100644 (file)
 #include "content_browser_client_efl.h"
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "common/application_type.h"
+#endif
+
 using content::BrowserThread;
 using content::BrowserContext;
 using content::BrowserContextEfl;
@@ -282,6 +286,9 @@ EWebContext::EWebContext(bool incognito, const std::string& injectedBundlePath)
       injected_bundle_handle_(nullptr),
 #endif
       widget_scale_(0),
+#if BUILDFLAG(IS_TIZEN_TV)
+      application_type_(EWK_APPLICATION_TYPE_WEBBROWSER),
+#endif
       m_pixmap(0),
       inspector_server_(NULL) {
 #if BUILDFLAG(IS_TIZEN)
@@ -817,3 +824,30 @@ void EWebContext::SetInterceptRequestCallback(
   resource_context_efl->SetInterceptRequestCallback(ewk_context, callback,
                                                     user_data);
 }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void EWebContext::SetApplicationType(
+    const Ewk_Application_Type application_type) {
+  application_type_ = application_type;
+  switch (application_type) {
+    case EWK_APPLICATION_TYPE_WEBBROWSER:
+      content::SetApplicationType(content::ApplicationType::WEBBROWSER);
+      break;
+    case EWK_APPLICATION_TYPE_HBBTV:
+      content::SetApplicationType(content::ApplicationType::HBBTV);
+      break;
+    case EWK_APPLICATION_TYPE_TIZENWRT:
+      content::SetApplicationType(content::ApplicationType::TIZENWRT);
+      break;
+    case EWK_APPLICATION_TYPE_OTHER:
+      content::SetApplicationType(content::ApplicationType::OTHER);
+      break;
+    default:
+      LOG(ERROR) << "Invalid application type. set application type WEBBROWSER "
+                    "as default !!";
+      application_type_ = EWK_APPLICATION_TYPE_WEBBROWSER;
+      content::SetApplicationType(content::ApplicationType::WEBBROWSER);
+      break;
+  }
+}
+#endif
index 795f308..04812da 100644 (file)
@@ -179,6 +179,11 @@ class EWebContext {
       Ewk_Context_Intercept_Request_Callback callback,
       void* user_data);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetApplicationType(const Ewk_Application_Type application_type);
+  Ewk_Application_Type GetApplicationType() const { return application_type_; }
+#endif
+
  private:
   EWebContext(bool incognito);
   EWebContext(const std::string& injectedBundlePath);
@@ -208,6 +213,10 @@ class EWebContext {
   std::unique_ptr<EwkDidStartDownloadCallback> start_download_callback_;
   std::unique_ptr<EwkMimeOverrideCallback> mime_override_callback_;
   int m_pixmap;
+#if BUILDFLAG(IS_TIZEN_TV)
+  Ewk_Application_Type application_type_;
+#endif
+
   content::DevToolsDelegateEfl* inspector_server_;
   std::unique_ptr<EWebContextNotificationCallback> notification_cb_;
 };
index 6b97f16..cd4e31d 100644 (file)
@@ -268,3 +268,14 @@ void Ewk_Context::SetContextInterceptRequestCallback(
     void* user_data) {
   impl->SetInterceptRequestCallback(this, callback, user_data);
 }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void Ewk_Context::SetApplicationType(
+    const Ewk_Application_Type application_type) {
+  impl->SetApplicationType(application_type);
+}
+
+Ewk_Application_Type Ewk_Context::GetApplicationType() const {
+  return impl->GetApplicationType();
+}
+#endif
index c0940ef..dce8618 100644 (file)
@@ -138,6 +138,12 @@ struct Ewk_Context : public base::RefCounted<Ewk_Context> {
       Ewk_Context_Intercept_Request_Callback callback,
       void* user_data);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Application Type
+  void SetApplicationType(const Ewk_Application_Type application_type);
+  Ewk_Application_Type GetApplicationType() const;
+#endif
+
  private:
   EWebContext* impl;
 
index e42cc9f..8fa3ea0 100644 (file)
@@ -847,10 +847,6 @@ void ewk_context_form_password_data_update(Ewk_Context* context, const char* url
   LOG_EWK_API_MOCKUP();
 }
 
-void ewk_context_application_type_set(Ewk_Context* ewkContext, const Ewk_Application_Type applicationType) {
-  LOG_EWK_API_MOCKUP();
-}
-
 Eina_Bool ewk_context_pwa_storage_path_set(Ewk_Context* context, const char* pwa_storage_path) {
   LOG_EWK_API_MOCKUP();
   return EINA_FALSE;
@@ -982,3 +978,27 @@ void ewk_context_default_zoom_factor_set(Ewk_Context* context,
                                          double zoom_factor) {
   LOG_EWK_API_MOCKUP();
 }
+
+void ewk_context_application_type_set(
+    Ewk_Context* ewkContext,
+    const Ewk_Application_Type applicationType) {
+#if BUILDFLAG(IS_TIZEN_TV)
+  EINA_SAFETY_ON_NULL_RETURN(ewkContext);
+  LOG(INFO) << "Set current application type: " << applicationType;
+  ewkContext->SetApplicationType(applicationType);
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV");
+#endif
+}
+
+Ewk_Application_Type ewk_context_application_type_get(Ewk_Context* ewkContext) {
+#if BUILDFLAG(IS_TIZEN_TV)
+  EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, EWK_APPLICATION_TYPE_OTHER);
+  LOG(INFO) << "Get current application type: "
+            << ewkContext->GetApplicationType();
+  return ewkContext->GetApplicationType();
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV");
+  return EWK_APPLICATION_TYPE_OTHER;
+#endif
+}
index e36f486..eb24496 100644 (file)
 #include "content/common/wrt/wrt_url_parse.h"
 #include "wrt/wrtwidget.h"
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "common/application_type.h"
+#endif
+
 #if defined(TIZEN_AUTOFILL_SUPPORT)
 using autofill::AutofillAgent;
 using autofill::PasswordAutofillAgent;
@@ -99,6 +103,19 @@ void ContentRendererClientEfl::RenderThreadStarted() {
 
   const base::CommandLine& command_line =
       *base::CommandLine::ForCurrentProcess();
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (command_line.HasSwitch(switches::kApplicationType)) {
+    std::string type =
+        command_line.GetSwitchValueASCII(switches::kApplicationType);
+    int app_type = 0;
+    base::StringToInt(type, &app_type);
+    LOG(INFO) << "Sync application type for render thread: " << app_type;
+    content::SetApplicationType(
+        static_cast<content::ApplicationType>(app_type));
+  }
+#endif
+
   if (command_line.HasSwitch(switches::kInjectedBundlePath)) {
     std::string tizen_app_id =
         command_line.GetSwitchValueASCII(switches::kTizenAppId);