[M108 Migration] Implement view port setting and zoom factor API 09/287209/5
authorb.kiran <b.kiran@samsung.com>
Wed, 25 Jan 2023 04:56:48 +0000 (10:26 +0530)
committerBot Blink <blinkbot@samsung.com>
Fri, 27 Jan 2023 06:00:48 +0000 (06:00 +0000)
This patch implement below preference setting and
API for content scale.

1. As default meta view port enabling for mobile
2. Implement ewk api for view port set/get

Reference: https://review.tizen.org/gerrit/c/278887

Change-Id: Id030ba049d55d46e55aaa2b8c75e27f3c7ed5fe9
Signed-off-by: Bakka Uday Kiran <b.kiran@samsung.com>
content/browser/web_contents/web_contents_impl.cc
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

index 0f16da0..c2cd303 100644 (file)
 
 #if BUILDFLAG(IS_EFL)
 #include "content/browser/date_time_chooser_efl.h"
+#include "tizen/system_info.h"
 #endif
 
 #if BUILDFLAG(IS_ANDROID)
@@ -2829,6 +2830,13 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() {
       prefs.viewport_meta_enabled = false;
   }
 
+#if BUILDFLAG(IS_EFL)
+  if (IsMobileProfile())
+    prefs.viewport_meta_enabled = true;
+
+  prefs.viewport_enabled |= prefs.viewport_meta_enabled;
+#endif
+
   prefs.spatial_navigation_enabled =
       command_line.HasSwitch(switches::kEnableSpatialNavigation);
 
index e74e8a3..6e0ef15 100644 (file)
@@ -21,6 +21,7 @@
 #include "content/public/browser/browser_task_traits.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/dom_storage_context.h"
+#include "content/public/browser/host_zoom_map.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/storage_partition.h"
 #include "content/public/browser/storage_usage_info.h"
@@ -31,6 +32,7 @@
 #include "storage/browser/database/database_quota_client.h"
 #include "storage/browser/file_system/file_system_quota_client.h"
 #include "storage/browser/quota/quota_manager.h"
+#include "third_party/blink/public/common/page/page_zoom.h"
 #include "ui/gl/gl_shared_context_efl.h"
 
 #if defined(ENABLE_PLUGINS)
@@ -799,6 +801,26 @@ bool EWebContext::GetExtensibleAPI(const std::string& api_name) {
   return TizenExtensibleHost::GetInstance()->GetExtensibleAPI(api_name);
 }
 
+void EWebContext::SetDefaultZoomFactor(double zoom_factor) {
+  content::HostZoomMap* host_zoom_map =
+      content::HostZoomMap::GetDefaultForBrowserContext(browser_context_.get());
+  if (host_zoom_map) {
+    host_zoom_map->SetDefaultZoomLevel(
+        blink::PageZoomFactorToZoomLevel(zoom_factor));
+  }
+}
+
+double EWebContext::GetDefaultZoomFactor() const {
+  content::HostZoomMap* host_zoom_map =
+      content::HostZoomMap::GetDefaultForBrowserContext(browser_context_.get());
+  if (host_zoom_map) {
+    return blink::PageZoomLevelToZoomFactor(
+        host_zoom_map->GetDefaultZoomLevel());
+  }
+
+  return -1.0;
+}
+
 void EWebContext::SetInterceptRequestCallback(
     Ewk_Context* ewk_context,
     Ewk_Context_Intercept_Request_Callback callback,
index 04812da..560b3aa 100644 (file)
@@ -174,6 +174,9 @@ class EWebContext {
   bool SetExtensibleAPI(const std::string& api_name, bool enable);
   bool GetExtensibleAPI(const std::string& api_name);
 
+  void SetDefaultZoomFactor(double zoom_factor);
+  double GetDefaultZoomFactor() const;
+
   void SetInterceptRequestCallback(
       Ewk_Context* ewk_context,
       Ewk_Context_Intercept_Request_Callback callback,
index cd4e31d..f10f434 100644 (file)
@@ -269,6 +269,14 @@ void Ewk_Context::SetContextInterceptRequestCallback(
   impl->SetInterceptRequestCallback(this, callback, user_data);
 }
 
+void Ewk_Context::SetDefaultZoomFactor(double zoom_factor) {
+  impl->SetDefaultZoomFactor(zoom_factor);
+}
+
+double Ewk_Context::GetDefaultZoomFactor() const {
+  return impl->GetDefaultZoomFactor();
+}
+
 #if BUILDFLAG(IS_TIZEN_TV)
 void Ewk_Context::SetApplicationType(
     const Ewk_Application_Type application_type) {
index dce8618..d6daffc 100644 (file)
@@ -134,6 +134,10 @@ struct Ewk_Context : public base::RefCounted<Ewk_Context> {
     Ewk_Context_Notification_Cancel_Callback cancel_callback,
     void* user_data);
 
+  // default zoom factor
+  void SetDefaultZoomFactor(double zoom_factor);
+  double GetDefaultZoomFactor() const;
+
   void SetContextInterceptRequestCallback(
       Ewk_Context_Intercept_Request_Callback callback,
       void* user_data);
index 3e3d06f..358a967 100644 (file)
@@ -974,11 +974,6 @@ void ewk_context_form_autofill_credit_card_changed_callback_set(
   LOG_EWK_API_MOCKUP();
 }
 
-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) {
@@ -1002,3 +997,14 @@ Ewk_Application_Type ewk_context_application_type_get(Ewk_Context* ewkContext) {
   return EWK_APPLICATION_TYPE_OTHER;
 #endif
 }
+
+void ewk_context_default_zoom_factor_set(Ewk_Context* context,
+                                         double zoom_factor) {
+  EINA_SAFETY_ON_NULL_RETURN(context);
+  context->SetDefaultZoomFactor(zoom_factor);
+}
+
+double ewk_context_default_zoom_factor_get(Ewk_Context* context) {
+  EINA_SAFETY_ON_NULL_RETURN_VAL(context, -1.0);
+  return context->GetDefaultZoomFactor();
+}