From a33a1a86ddccd1dd0d17db570b4ac90766a71323 Mon Sep 17 00:00:00 2001 From: "ayush.k123" Date: Wed, 11 Jan 2023 16:15:36 +0530 Subject: [PATCH 01/16] [M108 Migration][API] Implement application type by EWK API 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 --- third_party/blink/public/BUILD.gn | 4 + .../blink/public/platform/web_application_type.h | 24 ++++++ third_party/blink/renderer/platform/BUILD.gn | 8 ++ .../blink/renderer/platform/blink_platform_efl.gni | 11 +++ .../renderer/platform/web_application_type.cc | 29 ++++++++ tizen_src/ewk/efl_integration/BUILD.gn | 7 ++ .../ewk/efl_integration/common/application_type.cc | 38 ++++++++++ .../ewk/efl_integration/common/application_type.h | 23 ++++++ .../efl_integration/common/content_switches_efl.cc | 5 ++ .../efl_integration/common/content_switches_efl.h | 4 + .../efl_integration/content_browser_client_efl.cc | 86 +++++++++++++--------- .../efl_integration/content_browser_client_efl.h | 2 + tizen_src/ewk/efl_integration/eweb_context.cc | 34 +++++++++ tizen_src/ewk/efl_integration/eweb_context.h | 9 +++ .../efl_integration/private/ewk_context_private.cc | 11 +++ .../efl_integration/private/ewk_context_private.h | 6 ++ .../ewk/efl_integration/public/ewk_context.cc | 28 ++++++- .../renderer/content_renderer_client_efl.cc | 17 +++++ 18 files changed, 306 insertions(+), 40 deletions(-) create mode 100644 third_party/blink/public/platform/web_application_type.h create mode 100644 tizen_src/chromium_impl/third_party/blink/renderer/platform/blink_platform_efl.gni create mode 100644 tizen_src/chromium_impl/third_party/blink/renderer/platform/web_application_type.cc create mode 100644 tizen_src/ewk/efl_integration/common/application_type.cc create mode 100644 tizen_src/ewk/efl_integration/common/application_type.h diff --git a/third_party/blink/public/BUILD.gn b/third_party/blink/public/BUILD.gn index efb2ee4..80a314b 100644 --- a/third_party/blink/public/BUILD.gn +++ b/third_party/blink/public/BUILD.gn @@ -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 index 0000000..4d6d96a --- /dev/null +++ b/third_party/blink/public/platform/web_application_type.h @@ -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 diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn index 05707e3..d9ab1a9 100644 --- a/third_party/blink/renderer/platform/BUILD.gn +++ b/third_party/blink/renderer/platform/BUILD.gn @@ -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 index 0000000..e7591db --- /dev/null +++ b/tizen_src/chromium_impl/third_party/blink/renderer/platform/blink_platform_efl.gni @@ -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 index 0000000..9e589e4 --- /dev/null +++ b/tizen_src/chromium_impl/third_party/blink/renderer/platform/web_application_type.cc @@ -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 diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index eb52644..ccf84e3 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -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 index 0000000..f98ed91 --- /dev/null +++ b/tizen_src/ewk/efl_integration/common/application_type.cc @@ -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(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(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 index 0000000..78a7356 --- /dev/null +++ b/tizen_src/ewk/efl_integration/common/application_type.h @@ -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_ diff --git a/tizen_src/ewk/efl_integration/common/content_switches_efl.cc b/tizen_src/ewk/efl_integration/common/content_switches_efl.cc index bde2e47..1e8d1f9 100644 --- a/tizen_src/ewk/efl_integration/common/content_switches_efl.cc +++ b/tizen_src/ewk/efl_integration/common/content_switches_efl.cc @@ -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"; diff --git a/tizen_src/ewk/efl_integration/common/content_switches_efl.h b/tizen_src/ewk/efl_integration/common/content_switches_efl.h index 25519a6..abefe6d 100644 --- a/tizen_src/ewk/efl_integration/common/content_switches_efl.h +++ b/tizen_src/ewk/efl_integration/common/content_switches_efl.h @@ -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[]; diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc index bbe1fa0..0e27dd4 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc @@ -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(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(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(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); } diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.h b/tizen_src/ewk/efl_integration/content_browser_client_efl.h index b0615ec..7c977c0 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.h +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.h @@ -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_; diff --git a/tizen_src/ewk/efl_integration/eweb_context.cc b/tizen_src/ewk/efl_integration/eweb_context.cc index 316070f..fca6eeb 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.cc +++ b/tizen_src/ewk/efl_integration/eweb_context.cc @@ -58,6 +58,10 @@ #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 diff --git a/tizen_src/ewk/efl_integration/eweb_context.h b/tizen_src/ewk/efl_integration/eweb_context.h index 795f308..04812da 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.h +++ b/tizen_src/ewk/efl_integration/eweb_context.h @@ -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 start_download_callback_; std::unique_ptr mime_override_callback_; int m_pixmap; +#if BUILDFLAG(IS_TIZEN_TV) + Ewk_Application_Type application_type_; +#endif + content::DevToolsDelegateEfl* inspector_server_; std::unique_ptr notification_cb_; }; diff --git a/tizen_src/ewk/efl_integration/private/ewk_context_private.cc b/tizen_src/ewk/efl_integration/private/ewk_context_private.cc index 6b97f16..cd4e31d 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_context_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_context_private.cc @@ -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 diff --git a/tizen_src/ewk/efl_integration/private/ewk_context_private.h b/tizen_src/ewk/efl_integration/private/ewk_context_private.h index c0940ef..dce8618 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_context_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_context_private.h @@ -138,6 +138,12 @@ struct Ewk_Context : public base::RefCounted { 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; diff --git a/tizen_src/ewk/efl_integration/public/ewk_context.cc b/tizen_src/ewk/efl_integration/public/ewk_context.cc index e42cc9f..8fa3ea0 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_context.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_context.cc @@ -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 +} diff --git a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc index e36f486..eb24496 100644 --- a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc +++ b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc @@ -59,6 +59,10 @@ #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(app_type)); + } +#endif + if (command_line.HasSwitch(switches::kInjectedBundlePath)) { std::string tizen_app_id = command_line.GetSwitchValueASCII(switches::kTizenAppId); -- 2.7.4 From acc28f99e0a99dd202e7f0dd4d366e490f2ad66e Mon Sep 17 00:00:00 2001 From: "ayush.k123" Date: Wed, 11 Jan 2023 14:28:50 +0530 Subject: [PATCH 02/16] [M108 Migration] Migrate patches related to NavigationThrottle and Ewk_Error This patch enables proper functionality of ewk_error_* APIs. References: https://review.tizen.org/gerrit/273622/ Change-Id: I150edcb9497529bac5b7f8eb2c08a596f8145cfc Signed-off-by: Ayush Kumar --- tizen_src/ewk/efl_integration/BUILD.gn | 3 + .../browser/navigation_throttle_efl.cc | 45 +++++++ .../browser/navigation_throttle_efl.h | 27 ++++ .../efl_integration/content_browser_client_efl.cc | 10 ++ .../efl_integration/content_browser_client_efl.h | 2 + tizen_src/ewk/efl_integration/eweb_view.cc | 9 +- tizen_src/ewk/efl_integration/eweb_view.h | 4 +- .../efl_integration/private/ewk_error_private.cc | 139 +++++++++++++++++++++ .../efl_integration/private/ewk_error_private.h | 16 ++- tizen_src/ewk/efl_integration/public/ewk_error.cc | 105 +--------------- .../efl_integration/web_contents_delegate_efl.cc | 3 +- 11 files changed, 250 insertions(+), 113 deletions(-) create mode 100644 tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc create mode 100644 tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h create mode 100644 tizen_src/ewk/efl_integration/private/ewk_error_private.cc diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index ccf84e3..67046b2 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -203,6 +203,8 @@ shared_library("chromium-ewk") { "browser/mime_override_manager_efl.h", "browser/navigation_policy_handler_efl.cc", "browser/navigation_policy_handler_efl.h", + "browser/navigation_throttle_efl.cc", + "browser/navigation_throttle_efl.h", "browser/network_service/proxying_url_loader_efl.cc", "browser/network_service/proxying_url_loader_efl.h", "browser/network_service/proxying_url_loader_factory_efl.cc", @@ -371,6 +373,7 @@ shared_library("chromium-ewk") { "private/ewk_cookie_manager_private.h", "private/ewk_custom_handlers_private.cc", "private/ewk_custom_handlers_private.h", + "private/ewk_error_private.cc", "private/ewk_error_private.h", "private/ewk_favicon_database_private.h", "private/ewk_frame_private.cc", diff --git a/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc new file mode 100644 index 0000000..a0cecf5 --- /dev/null +++ b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc @@ -0,0 +1,45 @@ +// Copyright 2019 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 "browser/navigation_throttle_efl.h" + +#include "common/web_contents_utils.h" +#include "content/public/browser/navigation_handle.h" +#include "eweb_view.h" + +#if BUILDFLAG(IS_TIZEN_TV) +#include "common/application_type.h" +#endif + +namespace content { + +NavigationThrottleEfl::NavigationThrottleEfl( + NavigationHandle* navigation_handle) + : NavigationThrottle(navigation_handle) {} + +NavigationThrottleEfl::~NavigationThrottleEfl() = default; + +NavigationThrottle::ThrottleCheckResult +NavigationThrottleEfl::WillFailRequest() { + auto* handle = navigation_handle(); + auto* web_view = + web_contents_utils::WebViewFromWebContents(handle->GetWebContents()); + if (web_view) { + int error_code = handle->GetNetErrorCode(); + web_view->InvokeLoadError(handle->GetURL(), error_code, + error_code == net::ERR_ABORTED); +#if BUILDFLAG(IS_TIZEN_TV) + // In VD tizen, WebBrowser will load error page by itself. + if (IsWebBrowser()) + return NavigationThrottle::CANCEL_AND_IGNORE; +#endif + } + return NavigationThrottle::PROCEED; +} + +const char* NavigationThrottleEfl::GetNameForLogging() { + return "NavigationThrottleEfl"; +} + +} // namespace content diff --git a/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h new file mode 100644 index 0000000..d138db2 --- /dev/null +++ b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h @@ -0,0 +1,27 @@ +// Copyright 2019 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 NAVIGATION_THROTTLE_EFL_H_ +#define NAVIGATION_THROTTLE_EFL_H_ + +#include "content/public/browser/navigation_throttle.h" + +namespace content { +class NavigationThrottleEfl : public NavigationThrottle { + public: + explicit NavigationThrottleEfl(NavigationHandle* navigation_handle); + + NavigationThrottleEfl(NavigationThrottleEfl&) = delete; + NavigationThrottleEfl& operator=(NavigationThrottleEfl&) = delete; + + ~NavigationThrottleEfl() override; + + NavigationThrottle::ThrottleCheckResult WillFailRequest() override; + + const char* GetNameForLogging() override; +}; + +} // namespace content + +#endif // NAVIGATION_THROTTLE_EFL_H_ diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc index 0e27dd4..0140567 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc @@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/strings/string_number_conversions.h" #include "browser/editor_client_observer.h" +#include "browser/navigation_throttle_efl.h" #include "browser/network_service/proxying_url_loader_factory_efl.h" #include "browser/notification/notification_controller_efl.h" #include "browser/quota_permission_context_efl.h" @@ -20,6 +21,7 @@ #include "components/error_page/common/error.h" #include "components/error_page/common/localized_error.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host_iterator.h" #include "content/public/browser/web_contents.h" @@ -426,6 +428,14 @@ ContentBrowserClientEfl::CreateQuotaPermissionContext() { return new QuotaPermissionContextEfl(); } +std::vector> +ContentBrowserClientEfl::CreateThrottlesForNavigation( + NavigationHandle* handle) { + std::vector> throttles; + throttles.push_back(std::make_unique(handle)); + return throttles; +} + std::string ContentBrowserClientEfl::GetProduct() { return EflWebView::VersionInfo::GetInstance()->ProductNameAndVersionForUserAgent(); } diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.h b/tizen_src/ewk/efl_integration/content_browser_client_efl.h index 7c977c0..6bee4ac 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.h +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.h @@ -126,6 +126,8 @@ class ContentBrowserClientEfl : public ContentBrowserClient { void SetPreferredLangs(const std::string& preferred_langs); void AddAcceptLangsChangedCallback(AcceptLangsChangedCallback callback); void RemoveAcceptLangsChangedCallback(AcceptLangsChangedCallback callback); + std::vector> CreateThrottlesForNavigation( + NavigationHandle* handle) override; private: bool WillCreateURLLoaderFactory( diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 28ae038..18b8468 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -922,12 +922,11 @@ void EWebView::LoadData(const char* data, void EWebView::InvokeLoadError(const GURL& url, int error_code, - const std::string& error_description) { - std::unique_ptr<_Ewk_Error> err( - new _Ewk_Error(error_code, url.possibly_invalid_spec().c_str(), - error_description.c_str())); + bool is_cancellation) { + _Ewk_Error err(error_code, is_cancellation, + url.possibly_invalid_spec().c_str()); - SmartCallback().call(err.get()); + SmartCallback().call(&err); } void EWebView::ShowPopupMenu(const std::vector& items, diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index c25546d..00a71e1 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -257,9 +257,7 @@ class EWebView { const char* base_uri, const char* unreachable_uri = NULL); - void InvokeLoadError(const GURL& url, - int error_code, - const std::string& error_description); + void InvokeLoadError(const GURL& url, int error_code, bool is_cancellation); void SetViewAuthCallback(Ewk_View_Authentication_Callback callback, void* user_data); diff --git a/tizen_src/ewk/efl_integration/private/ewk_error_private.cc b/tizen_src/ewk/efl_integration/private/ewk_error_private.cc new file mode 100644 index 0000000..8426f4d --- /dev/null +++ b/tizen_src/ewk/efl_integration/private/ewk_error_private.cc @@ -0,0 +1,139 @@ +// Copyright (C) 2012 Intel Corporation. +// Copyright 2013 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 "private/ewk_error_private.h" + +#include "base/notreached.h" +#include "public/ewk_error.h" + +int ConvertErrorCode(int error_code) { + switch (error_code) { + case net::ERR_ABORTED: + return EWK_ERROR_CODE_CANCELED; + + case net::ERR_FILE_EXISTS: + case net::ERR_FILE_NOT_FOUND: + case net::ERR_FILE_NO_SPACE: + case net::ERR_FILE_PATH_TOO_LONG: + case net::ERR_FILE_TOO_BIG: + case net::ERR_FILE_VIRUS_INFECTED: + return EWK_ERROR_CODE_FAILED_FILE_IO; + + case net::ERR_CONNECTION_ABORTED: + case net::ERR_CONNECTION_CLOSED: + case net::ERR_CONNECTION_FAILED: + case net::ERR_CONNECTION_REFUSED: + case net::ERR_CONNECTION_RESET: + return EWK_ERROR_CODE_CANT_CONNECT; + + case net::ERR_DNS_MALFORMED_RESPONSE: + case net::ERR_DNS_SERVER_REQUIRES_TCP: + case net::ERR_DNS_SERVER_FAILED: + case net::ERR_DNS_TIMED_OUT: + case net::ERR_DNS_CACHE_MISS: + case net::ERR_DNS_SEARCH_EMPTY: + case net::ERR_DNS_SORT_ERROR: + case net::ERR_HOST_RESOLVER_QUEUE_TOO_LARGE: + case net::ERR_NAME_NOT_RESOLVED: + case net::ERR_NAME_RESOLUTION_FAILED: + return EWK_ERROR_CODE_CANT_LOOKUP_HOST; + + case net::ERR_BAD_SSL_CLIENT_AUTH_CERT: + case net::ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED: + case net::ERR_SSL_HANDSHAKE_NOT_COMPLETED: + return EWK_ERROR_CODE_FAILED_TLS_HANDSHAKE; + + case net::ERR_CERT_AUTHORITY_INVALID: + case net::ERR_CERT_COMMON_NAME_INVALID: + case net::ERR_CERT_CONTAINS_ERRORS: + case net::ERR_CERT_DATE_INVALID: + case net::ERR_CERT_INVALID: + case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: + case net::ERR_CERT_NON_UNIQUE_NAME: + case net::ERR_CERT_NO_REVOCATION_MECHANISM: + case net::ERR_CERT_REVOKED: + case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: + case net::ERR_CERT_WEAK_KEY: + case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: + return EWK_ERROR_CODE_INVALID_CERTIFICATE; + + case net::ERR_TIMED_OUT: + case net::ERR_CONNECTION_TIMED_OUT: + return EWK_ERROR_CODE_REQUEST_TIMEOUT; + + case net::ERR_TOO_MANY_REDIRECTS: + return EWK_ERROR_CODE_TOO_MANY_REDIRECTS; + + case net::ERR_TEMPORARILY_THROTTLED: + return EWK_ERROR_CODE_TOO_MANY_REQUESTS; + + case net::ERR_ADDRESS_INVALID: + case net::ERR_INVALID_URL: + return EWK_ERROR_CODE_BAD_URL; + + case net::ERR_DISALLOWED_URL_SCHEME: + case net::ERR_UNKNOWN_URL_SCHEME: + return EWK_ERROR_CODE_UNSUPPORTED_SCHEME; + + case net::ERR_CLIENT_AUTH_CERT_TYPE_UNSUPPORTED: + case net::ERR_INVALID_AUTH_CREDENTIALS: + case net::ERR_MALFORMED_IDENTITY: + case net::ERR_MISCONFIGURED_AUTH_ENVIRONMENT: + case net::ERR_MISSING_AUTH_CREDENTIALS: + case net::ERR_PROXY_AUTH_REQUESTED_WITH_NO_CONNECTION: + case net::ERR_PROXY_AUTH_UNSUPPORTED: + case net::ERR_UNEXPECTED_PROXY_AUTH: + case net::ERR_UNSUPPORTED_AUTH_SCHEME: + return EWK_ERROR_CODE_AUTHENTICATION; + + case net::ERR_CACHE_CHECKSUM_MISMATCH: + case net::ERR_CACHE_CHECKSUM_READ_FAILURE: + case net::ERR_CACHE_LOCK_TIMEOUT: + case net::ERR_CACHE_RACE: + case net::ERR_IMPORT_SERVER_CERT_FAILED: + return EWK_ERROR_CODE_INTERNAL_SERVER; + + default: + return EWK_ERROR_CODE_UNKNOWN; + } +} + +const char* GetDescriptionFromErrorCode(int error_code) { + switch (ConvertErrorCode(error_code)) { + case EWK_ERROR_CODE_CANCELED: + return "User canceled"; + case EWK_ERROR_CODE_CANT_SUPPORT_MIMETYPE: + return "Can't show page for this MIME Type"; + case EWK_ERROR_CODE_FAILED_FILE_IO: + return "Error regarding to file io"; + case EWK_ERROR_CODE_CANT_CONNECT: + return "Cannot connect to Network"; + case EWK_ERROR_CODE_CANT_LOOKUP_HOST: + return "Fail to look up host from DNS"; + case EWK_ERROR_CODE_FAILED_TLS_HANDSHAKE: + return "Fail to SSL/TLS handshake"; + case EWK_ERROR_CODE_INVALID_CERTIFICATE: + return "Received certificate is invalid"; + case EWK_ERROR_CODE_REQUEST_TIMEOUT: + return "Connection timeout"; + case EWK_ERROR_CODE_TOO_MANY_REDIRECTS: + return "Too many redirects"; + case EWK_ERROR_CODE_TOO_MANY_REQUESTS: + return "Too many requests during this load"; + case EWK_ERROR_CODE_BAD_URL: + return "Malformed url"; + case EWK_ERROR_CODE_UNSUPPORTED_SCHEME: + return "Unsupported scheme"; + case EWK_ERROR_CODE_AUTHENTICATION: + return "User authentication failed on server"; + case EWK_ERROR_CODE_INTERNAL_SERVER: + return "Web server has internal server error"; + case EWK_ERROR_CODE_UNKNOWN: + return "Unknown"; + default: + NOTREACHED(); + return "Unknown"; + } +} diff --git a/tizen_src/ewk/efl_integration/private/ewk_error_private.h b/tizen_src/ewk/efl_integration/private/ewk_error_private.h index a3e56a1..31b5ba9 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_error_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_error_private.h @@ -7,21 +7,27 @@ #define ewk_error_private_h #include +#include "net/base/net_errors.h" + +int ConvertErrorCode(int error_code); +const char* GetDescriptionFromErrorCode(int error_code); struct _Ewk_Error { int error_code; + bool is_cancellation; Eina_Stringshare* url; Eina_Stringshare* description; Eina_Stringshare* domain; - _Ewk_Error(int error_code_in, const char* url_in, const char* description_in) - : error_code(error_code_in), + _Ewk_Error(int error_code_in, bool is_cancellation_in, const char* url_in) + : error_code(ConvertErrorCode(error_code_in)), + is_cancellation(is_cancellation_in), url(eina_stringshare_add(url_in)), - description(eina_stringshare_add(description_in)), + description( + eina_stringshare_add(GetDescriptionFromErrorCode(error_code_in))), // Chromium always reports "net" as error domain anyways, // so we just hardcode it. - domain(eina_stringshare_add("net")) { - } + domain(eina_stringshare_add("net")) {} ~_Ewk_Error() { eina_stringshare_del(url); diff --git a/tizen_src/ewk/efl_integration/public/ewk_error.cc b/tizen_src/ewk/efl_integration/public/ewk_error.cc index 6feff94..fea70ec 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_error.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_error.cc @@ -27,13 +27,10 @@ #include "ewk_error_internal.h" #include "components/error_page/common/error.h" -#include "net/base/net_errors.h" #include "private/ewk_error_private.h" #include "private/ewk_private.h" -static Ewk_Error_Code convertErrorCode(const Ewk_Error* error); - Ewk_Error_Type ewk_error_type_get(const Ewk_Error* error) { EINA_SAFETY_ON_NULL_RETURN_VAL(error, EWK_ERROR_TYPE_NONE); @@ -50,19 +47,19 @@ Ewk_Error_Type ewk_error_type_get(const Ewk_Error* error) const char* ewk_error_url_get(const Ewk_Error* error) { - EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(error, nullptr); return error->url; } int ewk_error_code_get(const Ewk_Error* error) { EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0); - return convertErrorCode(error); + return error->error_code; } const char* ewk_error_description_get(const Ewk_Error* error) { - EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(error, nullptr); return error->description; } @@ -74,96 +71,6 @@ const char* ewk_error_domain_get(const Ewk_Error* error) Eina_Bool ewk_error_cancellation_get(const Ewk_Error* error) { - return EINA_FALSE; -} - -static Ewk_Error_Code convertErrorCode(const Ewk_Error* error) -{ - switch (error->error_code) { - case net::ERR_ABORTED: - return EWK_ERROR_CODE_CANCELED; - - case net::ERR_FILE_EXISTS: - case net::ERR_FILE_NOT_FOUND: - case net::ERR_FILE_NO_SPACE: - case net::ERR_FILE_PATH_TOO_LONG: - case net::ERR_FILE_TOO_BIG: - case net::ERR_FILE_VIRUS_INFECTED: - return EWK_ERROR_CODE_FAILED_FILE_IO; - - case net::ERR_CONNECTION_ABORTED: - case net::ERR_CONNECTION_CLOSED: - case net::ERR_CONNECTION_FAILED: - case net::ERR_CONNECTION_REFUSED: - case net::ERR_CONNECTION_RESET: - return EWK_ERROR_CODE_CANT_CONNECT; - - case net::ERR_DNS_MALFORMED_RESPONSE: - case net::ERR_DNS_SERVER_REQUIRES_TCP: - case net::ERR_DNS_SERVER_FAILED: - case net::ERR_DNS_TIMED_OUT: - case net::ERR_DNS_CACHE_MISS: - case net::ERR_DNS_SEARCH_EMPTY: - case net::ERR_DNS_SORT_ERROR: - case net::ERR_HOST_RESOLVER_QUEUE_TOO_LARGE: - case net::ERR_NAME_NOT_RESOLVED: - return EWK_ERROR_CODE_CANT_LOOKUP_HOST; - - case net::ERR_BAD_SSL_CLIENT_AUTH_CERT: - case net::ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED: - case net::ERR_SSL_HANDSHAKE_NOT_COMPLETED: - return EWK_ERROR_CODE_FAILED_TLS_HANDSHAKE; - - case net::ERR_CERT_AUTHORITY_INVALID: - case net::ERR_CERT_COMMON_NAME_INVALID: - case net::ERR_CERT_CONTAINS_ERRORS: - case net::ERR_CERT_DATE_INVALID: - case net::ERR_CERT_INVALID: - case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: - case net::ERR_CERT_NON_UNIQUE_NAME: - case net::ERR_CERT_NO_REVOCATION_MECHANISM: - case net::ERR_CERT_REVOKED: - case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: - case net::ERR_CERT_WEAK_KEY: - case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: - return EWK_ERROR_CODE_INVALID_CERTIFICATE; - - case net::ERR_TIMED_OUT: - case net::ERR_CONNECTION_TIMED_OUT: - return EWK_ERROR_CODE_REQUEST_TIMEOUT; - - case net::ERR_TOO_MANY_REDIRECTS: - return EWK_ERROR_CODE_TOO_MANY_REDIRECTS; - - case net::ERR_TEMPORARILY_THROTTLED: - return EWK_ERROR_CODE_TOO_MANY_REQUESTS; - - case net::ERR_ADDRESS_INVALID: - case net::ERR_INVALID_URL: - return EWK_ERROR_CODE_BAD_URL; - case net::ERR_DISALLOWED_URL_SCHEME: - case net::ERR_UNKNOWN_URL_SCHEME: - return EWK_ERROR_CODE_UNSUPPORTED_SCHEME; - - case net::ERR_CLIENT_AUTH_CERT_TYPE_UNSUPPORTED: - case net::ERR_INVALID_AUTH_CREDENTIALS: - case net::ERR_MALFORMED_IDENTITY: - case net::ERR_MISCONFIGURED_AUTH_ENVIRONMENT: - case net::ERR_MISSING_AUTH_CREDENTIALS: - case net::ERR_PROXY_AUTH_REQUESTED_WITH_NO_CONNECTION: - case net::ERR_PROXY_AUTH_UNSUPPORTED: - case net::ERR_UNEXPECTED_PROXY_AUTH: - case net::ERR_UNSUPPORTED_AUTH_SCHEME: - return EWK_ERROR_CODE_AUTHENTICATION; - - case net::ERR_CACHE_CHECKSUM_MISMATCH: - case net::ERR_CACHE_CHECKSUM_READ_FAILURE: - case net::ERR_CACHE_LOCK_TIMEOUT: - case net::ERR_CACHE_RACE: - case net::ERR_IMPORT_SERVER_CERT_FAILED: - return EWK_ERROR_CODE_INTERNAL_SERVER; - - default: - return EWK_ERROR_CODE_UNKNOWN; - } -} + EINA_SAFETY_ON_NULL_RETURN_VAL(error, EINA_FALSE); + return error->is_cancellation; +} \ No newline at end of file diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index 8936be0..ac72d7c 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -435,7 +435,8 @@ void WebContentsDelegateEfl::DidFailLoad(RenderFrameHost* render_frame_host, if (!IsMainFrame(render_frame_host)) return; - web_view_->InvokeLoadError(validated_url, error_code, std::string()); + web_view_->InvokeLoadError(validated_url, error_code, + error_code == net::ERR_ABORTED); } void WebContentsDelegateEfl::DidUpdateFaviconURL( -- 2.7.4 From 2150c54b5c769157a724137e98b967f426fff5ed Mon Sep 17 00:00:00 2001 From: Bakka Uday Kiran Date: Thu, 12 Jan 2023 12:01:42 +0530 Subject: [PATCH 03/16] [M108 Migration] Add debug log for network request This patch adds debug log for network request. Reference: https://review.tizen.org/gerrit/277882 Change-Id: I018d3c4325cc1ab1310e3bf167c166308b379a67 Signed-off-by: Bakka Uday Kiran --- net/url_request/url_request_http_job.cc | 3 +++ third_party/blink/renderer/core/frame/location.cc | 1 + 2 files changed, 4 insertions(+) diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 0a622f7..5648a3f 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -1129,6 +1129,9 @@ void URLRequestHttpJob::OnStartCompleted(int result) { } else { // Even on an error, there may be useful information in the response // info (e.g. whether there's a cached copy). + LOG(ERROR) << "[NETWORK ERROR] Failing url : " << request_->url().spec() + << " Error code : " << result + << " Error message : " << ErrorToString(result); if (transaction_.get()) response_info_ = transaction_->GetResponseInfo(); NotifyStartError(result); diff --git a/third_party/blink/renderer/core/frame/location.cc b/third_party/blink/renderer/core/frame/location.cc index 9274084..4d516af 100644 --- a/third_party/blink/renderer/core/frame/location.cc +++ b/third_party/blink/renderer/core/frame/location.cc @@ -270,6 +270,7 @@ void Location::SetLocation(const String& url, return; } + LOG(INFO) << "Set location to url[" << url.Utf8().data() << "]"; V8DOMActivityLogger* activity_logger = V8DOMActivityLogger::CurrentActivityLoggerIfIsolatedWorld(); if (activity_logger) { -- 2.7.4 From 99b029fca724088d4b204a0b274b25976f01e449 Mon Sep 17 00:00:00 2001 From: Gajendra N Date: Wed, 11 Jan 2023 17:15:35 +0530 Subject: [PATCH 04/16] [M108 Migration] Fix incorrect module dependancy Fixing dependency issue : `ui/` shouldn't depend on `content/`, which may result in build breaks caused by not yet generated mojo files. IMContentEfl which resides in ui layer had a direct dependancy on content::RenderWidgetHostImpl, which is incorrect as per chromium guidelines. Instead, introduce a public helper class as proxy to route calls at content layer. Reference: https://review.tizen.org/gerrit/285551 Change-Id: Ia1ecd29fc9badf58e89c997b6c081880de1c4f66 Signed-off-by: Gajendra N --- .../rwhv_aura_offscreen_helper_efl.cc | 91 +++++++++++++++++++++- .../renderer_host/rwhv_aura_offscreen_helper_efl.h | 3 + .../public/browser/render_widget_host_helper.h | 59 ++++++++++++++ .../ui/ozone/platform/efl/im_context_efl.cc | 75 ++++++++---------- .../ui/ozone/platform/efl/im_context_efl.h | 12 +-- 5 files changed, 191 insertions(+), 49 deletions(-) create mode 100644 tizen_src/chromium_impl/content/public/browser/render_widget_host_helper.h diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc index ef0542e..c7b0b2e 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc @@ -11,6 +11,7 @@ #include "content/browser/renderer_host/render_widget_host_view_aura.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_view_aura.h" +#include "content/public/browser/render_widget_host_helper.h" #include "content/public/browser/web_contents_delegate.h" #include "gpu/command_buffer/service/texture_base.h" #include "skia/ext/image_operations.h" @@ -39,10 +40,96 @@ namespace content { +class RenderWidgetHostHelperAura : public RenderWidgetHostHelper { + public: + explicit RenderWidgetHostHelperAura(RWHVAuraOffscreenHelperEfl* rwhv_helper) + : rwhv_helper_(rwhv_helper) {} + ~RenderWidgetHostHelperAura() override = default; + + bool HasRenderWidgetHost() const override { + return !!rwhv_helper_->GetRenderWidgetHostImpl(); + } + + void ExtendSelectionAndDelete(int32_t before, int32_t after) override { + auto* handler = GetFrameWidgetInputHandler(); + if (!handler) + return; + + handler->ExtendSelectionAndDelete(before, after); + } + + void SetCompositionFromExistingText( + int32_t start, + int32_t end, + const std::vector& ime_text_spans) override { + auto* handler = GetFrameWidgetInputHandler(); + if (!handler) + return; + + handler->SetCompositionFromExistingText(start, end, ime_text_spans); + } + + void ImeCommitText(const std::u16string& text, + const std::vector& ime_text_spans, + const gfx::Range& replacement_range, + int relative_cursor_pos) override { + auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl(); + if (!rwhi) + return; + + rwhi->ImeCommitText(text, ime_text_spans, replacement_range, + relative_cursor_pos); + } + + void ImeFinishComposingText(bool keep_selection) override { + auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl(); + if (!rwhi) + return; + + rwhi->ImeFinishComposingText(keep_selection); + } + + void ImeSetComposition(const std::u16string& text, + const std::vector& ime_text_spans, + const gfx::Range& replacement_range, + int selection_start, + int selection_end) override { + auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl(); + if (!rwhi) + return; + + rwhi->ImeSetComposition(text, ime_text_spans, replacement_range, + selection_start, selection_end); + } + + bool ExistsSelectedText() override { return false; } + + bool ImeHandleKeyEventEnabled() override { return true; } + + gfx::Size GetPhysicalBackingSize() const override { + return rwhv_helper_->GetPhysicalBackingSize(); + } + + Evas_Object* EwkView() const override { return rwhv_helper_->ewk_view(); } + + private: + blink::mojom::FrameWidgetInputHandler* GetFrameWidgetInputHandler() const { + auto* rwhi = rwhv_helper_->GetRenderWidgetHostImpl(); + if (!rwhi) + return nullptr; + + return rwhi->GetFrameWidgetInputHandler(); + } + + RWHVAuraOffscreenHelperEfl* rwhv_helper_; +}; + RWHVAuraOffscreenHelperEfl::RWHVAuraOffscreenHelperEfl( RenderWidgetHostViewAura* rwhva, WebContents* web_contents) - : rwhv_aura_(rwhva), web_contents_(web_contents) { + : rwhv_aura_(rwhva), + web_contents_(web_contents), + rwh_helper_(std::make_unique(this)) { Initialize(); } @@ -576,7 +663,7 @@ ui::IMContextEfl* RWHVAuraOffscreenHelperEfl::GetIMContextEfl() { if (!im_context_efl_) { if (GetEventHandler() && GetEventHandler()->GetIMContextEfl()) { im_context_efl_ = GetEventHandler()->GetIMContextEfl(); - im_context_efl_->SetRWHVHelper(this); + im_context_efl_->SetRWHHelper(rwh_helper_.get()); return im_context_efl_; } LOG(ERROR) << "im_context_efl_ is not set"; diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h index 35fc17c..004a800 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h @@ -34,6 +34,7 @@ class IMContextEfl; namespace content { +class RenderWidgetHostHelper; class RenderWidgetHostImpl; class RenderWidgetHostViewAura; class WebContents; @@ -136,6 +137,8 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl { ui::IMContextEfl* im_context_efl_ = nullptr; RenderWidgetHostViewAura* rwhv_aura_ = nullptr; WebContents* web_contents_ = nullptr; + + std::unique_ptr rwh_helper_; }; } // namespace content diff --git a/tizen_src/chromium_impl/content/public/browser/render_widget_host_helper.h b/tizen_src/chromium_impl/content/public/browser/render_widget_host_helper.h new file mode 100644 index 0000000..743a4c0 --- /dev/null +++ b/tizen_src/chromium_impl/content/public/browser/render_widget_host_helper.h @@ -0,0 +1,59 @@ +// Copyright 2022 Samsung Electronics Inc. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_HELPER_H_ +#define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_HELPER_H_ + +#include + +#include + +#include "content/common/content_export.h" +#include "ui/base/ime/ime_text_span.h" +#include "ui/gfx/geometry/size.h" +#include "ui/gfx/range/range.h" + +namespace content { + +// Class used as IME input proxy. See `ImContextEfl`. +class CONTENT_EXPORT RenderWidgetHostHelper { + public: + RenderWidgetHostHelper() = default; + virtual ~RenderWidgetHostHelper() = default; + + RenderWidgetHostHelper(const RenderWidgetHostHelper&) = delete; + RenderWidgetHostHelper& operator=(const RenderWidgetHostHelper&) = delete; + + virtual bool HasRenderWidgetHost() const = 0; + + // IM related APIs defined in `RenderWidgetHostImpl` + virtual void ExtendSelectionAndDelete(int32_t before, int32_t after) = 0; + virtual void SetCompositionFromExistingText( + int32_t start, + int32_t end, + const std::vector& ime_text_spans) = 0; + virtual void ImeCommitText(const std::u16string& text, + const std::vector& ime_text_spans, + const gfx::Range& replacement_range, + int relative_cursor_pos) = 0; + virtual void ImeFinishComposingText(bool keep_selection) = 0; + virtual void ImeSetComposition( + const std::u16string& text, + const std::vector& ime_text_spans, + const gfx::Range& replacement_range, + int selection_start, + int selection_end) = 0; + + // API defined `SelectionControllerEfl` + virtual bool ExistsSelectedText() = 0; + + // APIs defined in `RenderWidgetHostViewAuraHelperEfl` + virtual bool ImeHandleKeyEventEnabled() = 0; + virtual gfx::Size GetPhysicalBackingSize() const = 0; + virtual Evas_Object* EwkView() const = 0; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_HELPER_H_ diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc b/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc index b7fb24d..234085f 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc @@ -9,11 +9,10 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" -#include "content/browser/renderer_host/render_widget_host_impl.h" -#include "content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h" -#include "content/public/browser/web_contents_delegate.h" +#include "content/public/browser/render_widget_host_helper.h" #include "tizen/system_info.h" #include "ui/base/ime/ime_text_span.h" +#include "ui/events/event.h" #include "ui/ozone/platform/efl/efl_event_handler.h" #include "ui/ozone/platform/efl/efl_platform_event_source.h" #include "ui/ozone/platform/efl/efl_window.h" @@ -591,15 +590,15 @@ void IMContextEfl::OnPreeditChanged(void* data, void IMContextEfl::OnInputPanelStateChanged(int state) { if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) { - if (rwhv_helper_ && rwhv_helper_->ewk_view()) { + if (rwh_helper_ && rwh_helper_->EwkView()) { is_showing_ = true; - evas_object_smart_callback_call(rwhv_helper_->ewk_view(), + evas_object_smart_callback_call(rwh_helper_->EwkView(), "editorclient,ime,opened", 0); } } else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) { - if (rwhv_helper_ && rwhv_helper_->ewk_view()) { + if (rwh_helper_ && rwh_helper_->EwkView()) { is_showing_ = false; - evas_object_smart_callback_call(rwhv_helper_->ewk_view(), + evas_object_smart_callback_call(rwh_helper_->EwkView(), "editorclient,ime,closed", 0); } } @@ -609,19 +608,19 @@ void IMContextEfl::OnInputPanelGeometryChanged() { Eina_Rectangle rect; ecore_imf_context_input_panel_geometry_get(context_, &rect.x, &rect.y, &rect.w, &rect.h); - if (rwhv_helper_ && rwhv_helper_->ewk_view()) { - evas_object_smart_callback_call(rwhv_helper_->ewk_view(), + if (rwh_helper_ && rwh_helper_->EwkView()) { + evas_object_smart_callback_call(rwh_helper_->EwkView(), "inputmethod,changed", static_cast(&rect)); } } void IMContextEfl::OnCandidateInputPanelStateChanged(int state) { - if (rwhv_helper_ && rwhv_helper_->ewk_view()) { + if (rwh_helper_ && rwh_helper_->EwkView()) { if (state == ECORE_IMF_CANDIDATE_PANEL_SHOW) { - evas_object_smart_callback_call(rwhv_helper_->ewk_view(), + evas_object_smart_callback_call(rwh_helper_->EwkView(), "editorclient,candidate,opened", 0); } else { - evas_object_smart_callback_call(rwhv_helper_->ewk_view(), + evas_object_smart_callback_call(rwh_helper_->EwkView(), "editorclient,candidate,closed", 0); } } @@ -651,8 +650,7 @@ bool IMContextEfl::OnRetrieveSurrounding(char** text, int* offset) { } void IMContextEfl::OnDeleteSurrounding(void* event_info) { - auto rwhi = GetRenderWidgetHostImpl(); - if (!rwhi) { + if (!HasRenderWidgetHostImpl()) { LOG(ERROR) << "rwhi is nullptr"; return; } @@ -667,9 +665,8 @@ void IMContextEfl::OnDeleteSurrounding(void* event_info) { int after = event->n_chars + event->offset; if (is_transaction_finished_) { - if (rwhi->GetFrameWidgetInputHandler()) { - rwhi->GetFrameWidgetInputHandler()->ExtendSelectionAndDelete(before, - after); + if (rwh_helper_) { + rwh_helper_->ExtendSelectionAndDelete(before, after); } } else { int begin = event->offset < 0 ? 0 : event->offset; @@ -681,17 +678,14 @@ void IMContextEfl::OnDeleteSurrounding(void* event_info) { text_span.underline_style = ui::ImeTextSpan::UnderlineStyle::kNone; #endif ime_text_spans.push_back(text_span); - if (rwhi->GetFrameWidgetInputHandler()) { - rwhi->GetFrameWidgetInputHandler()->SetCompositionFromExistingText( - begin, end, ime_text_spans); + if (rwh_helper_) { + rwh_helper_->SetCompositionFromExistingText(begin, end, ime_text_spans); } } } void IMContextEfl::OnCandidateInputPanelLanguageChanged(Ecore_IMF_Context*) { - auto rwhi = GetRenderWidgetHostImpl(); - - if (!rwhi || composition_.text.length() == 0) + if (!HasRenderWidgetHostImpl() || composition_.text.length() == 0) return; CancelComposition(); @@ -717,12 +711,12 @@ bool IMContextEfl::IsFocused() const { } bool IMContextEfl::WebViewWillBeResized() { - if (!context_ || !rwhv_helper_) + if (!context_ || !rwh_helper_) return false; return IsVisible() - ? default_view_size_ == rwhv_helper_->GetPhysicalBackingSize() - : default_view_size_ != rwhv_helper_->GetPhysicalBackingSize(); + ? default_view_size_ == rwh_helper_->GetPhysicalBackingSize() + : default_view_size_ != rwh_helper_->GetPhysicalBackingSize(); } void IMContextEfl::ClearQueues() { @@ -858,21 +852,21 @@ void IMContextEfl::ProcessNextPreeditText(bool processed) { // if text is selected status. bool text_selected = composition_text.text.length() == 0; #if !defined(EWK_BRINGUP) - if (rwhv_helper_) { + if (rwh_helper_) { text_selected = - text_selected && rwhv_helper_->GetSelectionController() && - rwhv_helper_->GetSelectionController()->ExistsSelectedText(); + text_selected && rwh_helper_->GetSelectionController() && + rwh_helper_->GetSelectionController()->ExistsSelectedText(); } #endif if (!text_selected) { - if (auto rwhi = GetRenderWidgetHostImpl()) { + if (HasRenderWidgetHostImpl()) { const std::vector& underlines = reinterpret_cast&>( composition_text.ime_text_spans); - rwhi->ImeSetComposition(composition_text.text, underlines, - gfx::Range::InvalidRange(), - composition_text.selection.start(), - composition_text.selection.end()); + rwh_helper_->ImeSetComposition(composition_text.text, underlines, + gfx::Range::InvalidRange(), + composition_text.selection.start(), + composition_text.selection.end()); } else LOG(ERROR) << "rwhi is nullptr"; } @@ -913,22 +907,21 @@ void IMContextEfl::PushToKeyDownEventQueue(KeyEvent key) { keydown_event_queue_.push(key); } -content::RenderWidgetHostImpl* IMContextEfl::GetRenderWidgetHostImpl() const { - return rwhv_helper_ ? rwhv_helper_->GetRenderWidgetHostImpl() : nullptr; +bool IMContextEfl::HasRenderWidgetHostImpl() const { + return rwh_helper_ && rwh_helper_->HasRenderWidgetHost(); } void IMContextEfl::ConfirmComposition(std::u16string& text) { - auto rwhi = GetRenderWidgetHostImpl(); - if (!rwhi) { + if (!HasRenderWidgetHostImpl()) { LOG(ERROR) << "rwhi is nullptr"; return; } if (text.length()) { - rwhi->ImeCommitText(text, std::vector(), - gfx::Range::InvalidRange(), 0); + rwh_helper_->ImeCommitText(text, std::vector(), + gfx::Range::InvalidRange(), 0); } - rwhi->ImeFinishComposingText(false); + rwh_helper_->ImeFinishComposingText(false); } void IMContextEfl::SetSurroundingText(std::string value) { diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.h b/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.h index 7a6ad99..2fb8f8e 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.h +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.h @@ -23,8 +23,7 @@ typedef struct _Ecore_IMF_Context Ecore_IMF_Context; namespace content { -class RenderWidgetHostImpl; -class RWHVAuraOffscreenHelperEfl; +class RenderWidgetHostHelper; } // namespace content namespace ui { @@ -76,8 +75,9 @@ class IMContextEfl { void UpdateCaretBounds(const gfx::Rect& caret_bounds); bool IsShow(); - void SetRWHVHelper(content::RWHVAuraOffscreenHelperEfl* rwhv_helper) { - rwhv_helper_ = rwhv_helper; + // To forward RenderWidgetHostImpl calls. + void SetRWHHelper(content::RenderWidgetHostHelper* rwh_helper) { + rwh_helper_ = rwh_helper; } #if BUILDFLAG(IS_TIZEN_TV) @@ -167,7 +167,7 @@ class IMContextEfl { void ProcessNextPreeditText(bool processed); void ProcessNextKeyDownEvent(); void ProcessNextKeyUpEvent(); - content::RenderWidgetHostImpl* GetRenderWidgetHostImpl() const; + bool HasRenderWidgetHostImpl() const; void SendFakeCompositionKeyEvent(const std::u16string& buf); @@ -213,7 +213,7 @@ class IMContextEfl { bool is_keyevent_processing_ = false; bool is_transaction_finished_ = true; InputMethodAuraLinux* im_aura_ = nullptr; - content::RWHVAuraOffscreenHelperEfl* rwhv_helper_ = nullptr; + content::RenderWidgetHostHelper* rwh_helper_ = nullptr; }; } // namespace ui -- 2.7.4 From a808a5e433625db526dbbb518cf9977520e297aa Mon Sep 17 00:00:00 2001 From: Bakka Uday Kiran Date: Fri, 13 Jan 2023 17:26:34 +0530 Subject: [PATCH 05/16] [M108 Migration] Remove unsupported display modes of web app manifest This patch removes added web app display modes without ACR. It will be added according to ACR process when needed. Reference: https://review.tizen.org/gerrit/c/283563 Change-Id: I1eb79456f727db0e319e56901a53ce977beb5a00 Signed-off-by: Bakka Uday Kiran --- .../private/ewk_manifest_private.cc | 49 ++++++++++------------ .../ewk/efl_integration/public/ewk_manifest.h | 14 +++---- 2 files changed, 28 insertions(+), 35 deletions(-) diff --git a/tizen_src/ewk/efl_integration/private/ewk_manifest_private.cc b/tizen_src/ewk/efl_integration/private/ewk_manifest_private.cc index ddb79b0..ed1e700 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_manifest_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_manifest_private.cc @@ -11,6 +11,27 @@ const int64_t _Ewk_View_Request_Manifest::kInvalidOrMissingColor = static_cast(std::numeric_limits::max()) + 1; +static Ewk_View_Web_Display_Mode DisplayModeToEwkDisplayMode( + blink::mojom::DisplayMode display) { + switch (display) { + case blink::mojom::DisplayMode::kUndefined: + return WebDisplayModeUndefined; + case blink::mojom::DisplayMode::kBrowser: + return WebDisplayModeBrowser; + case blink::mojom::DisplayMode::kMinimalUi: + return WebDisplayModeMinimalUi; + case blink::mojom::DisplayMode::kStandalone: + return WebDisplayModeStandalone; + case blink::mojom::DisplayMode::kFullscreen: + return WebDisplayModeFullscreen; + case blink::mojom::DisplayMode::kBorderless: + return WebDisplayModeBorderless; + default: + NOTIMPLEMENTED(); + return WebDisplayModeUndefined; + } +} + _Ewk_View_Request_Manifest::_Ewk_View_Request_Manifest( blink::mojom::ManifestPtr manifest) { if (manifest->short_name && !manifest->short_name->empty()) @@ -24,8 +45,7 @@ _Ewk_View_Request_Manifest::_Ewk_View_Request_Manifest( int orientation = static_cast(manifest->orientation); orientation_type = static_cast(orientation); - int display = static_cast(manifest->display); - web_display_mode = static_cast(display); + web_display_mode = DisplayModeToEwkDisplayMode(manifest->display); // Set the theme color based on the manifest value. theme_color = manifest->has_theme_color ? manifest->theme_color @@ -57,31 +77,6 @@ _Ewk_View_Request_Manifest::~_Ewk_View_Request_Manifest() {} _Ewk_View_Request_Manifest::Icon::Icon() {} _Ewk_View_Request_Manifest::Icon::~Icon() {} -static_assert(int(blink::mojom::DisplayMode::kUndefined) == - int(WebDisplayModeUndefined), - "mismatching enums: WebDisplayModeUndefined"); -static_assert(int(blink::mojom::DisplayMode::kBrowser) == - int(WebDisplayModeBrowser), - "mismatching enums: WebDisplayModeBrowser"); -static_assert(int(blink::mojom::DisplayMode::kMinimalUi) == - int(WebDisplayModeMinimalUi), - "mismatching enums: WebDisplayModeMinimalUi"); -static_assert(int(blink::mojom::DisplayMode::kStandalone) == - int(WebDisplayModeStandalone), - "mismatching enums: WebDisplayModeStandalone"); -static_assert(int(blink::mojom::DisplayMode::kFullscreen) == - int(WebDisplayModeFullscreen), - "mismatching enums: WebDisplayModeFullscreen"); -static_assert(int(blink::mojom::DisplayMode::kWindowControlsOverlay) == - int(WebDisplayModeWindowControlsOverlay), - "mismatching enums: WebDisplayModeWindowControlsOverlay"); -static_assert(int(blink::mojom::DisplayMode::kTabbed) == - int(WebDisplayModeTabbed), - "mismatching enums: WebDisplayModeTabbed"); -static_assert(int(blink::mojom::DisplayMode::kMaxValue) == - int(WebDisplayModeLast), - "mismatching enums: WebDisplayModeLast"); - static_assert(int(device::mojom::ScreenOrientationLockType::DEFAULT) == int(WebScreenOrientationLockDefault), "mismatching enums: WebScreenOrientationLockDefault"); diff --git a/tizen_src/ewk/efl_integration/public/ewk_manifest.h b/tizen_src/ewk/efl_integration/public/ewk_manifest.h index fe5a203..8a1048b 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_manifest.h +++ b/tizen_src/ewk/efl_integration/public/ewk_manifest.h @@ -65,14 +65,12 @@ typedef enum _Ewk_View_Orientation_Type Ewk_View_Orientation_Type; * @since_tizen 3.0 */ enum _Ewk_View_Web_Display_Mode { - WebDisplayModeUndefined = 0, /**< undefined */ - WebDisplayModeBrowser, /**< browser */ - WebDisplayModeMinimalUi, /**< minimul-ui */ - WebDisplayModeStandalone, /**< standalone */ - WebDisplayModeFullscreen, /**< fullscreen */ - WebDisplayModeWindowControlsOverlay, /**< window-controls-overlay*/ - WebDisplayModeTabbed, /**< tabbed */ - WebDisplayModeBorderless, /**< borderless */ + WebDisplayModeUndefined = 0, /**< undefined */ + WebDisplayModeBrowser, /**< browser */ + WebDisplayModeMinimalUi, /**< minimal-ui */ + WebDisplayModeStandalone, /**< standalone */ + WebDisplayModeFullscreen, /**< fullscreen */ + WebDisplayModeBorderless, /**< borderless */ WebDisplayModeLast = WebDisplayModeBorderless }; -- 2.7.4 From 23adf087f8923227a7cdde12ad3b0206bc304304 Mon Sep 17 00:00:00 2001 From: Bakka Uday Kiran Date: Mon, 16 Jan 2023 13:06:47 +0530 Subject: [PATCH 06/16] [M108 Migration] Remove EWK_BRINGUP from EWebView::Find This patch removes EWK_BRINGUP from EWebView::Find. Reference: https://review.tizen.org/gerrit/c/273287 Change-Id: Idd59f673439176c6e8b61380a1458bb1878dc579 Signed-off-by: Bakka Uday Kiran --- tizen_src/ewk/efl_integration/eweb_view.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 18b8468..f8af786 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -1171,7 +1171,7 @@ void EWebView::CancelContextMenu(int request_id) { context_menu_->HideContextMenu(); } -void EWebView::Find(const char* text, Ewk_Find_Options find_options) { +void EWebView::Find(const char* text, Ewk_Find_Options ewk_find_options) { std::u16string find_text = base::UTF8ToUTF16(text); bool find_next = (previous_text_ == find_text); @@ -1180,15 +1180,13 @@ void EWebView::Find(const char* text, Ewk_Find_Options find_options) { previous_text_ = find_text; } -#if !defined(EWK_BRINGUP) // FIXME: m71 bringup - blink::WebFindOptions web_find_options; - web_find_options.forward = !(find_options & EWK_FIND_OPTIONS_BACKWARDS); - web_find_options.match_case = - !(find_options & EWK_FIND_OPTIONS_CASE_INSENSITIVE); - web_find_options.find_next = find_next; + auto find_options = blink::mojom::FindOptions::New(); + find_options->forward = !(ewk_find_options & EWK_FIND_OPTIONS_BACKWARDS); + find_options->match_case = + !(ewk_find_options & EWK_FIND_OPTIONS_CASE_INSENSITIVE); - web_contents_->Find(current_find_request_id_, find_text, web_find_options); -#endif + web_contents_->Find(current_find_request_id_, find_text, + std::move(find_options)); } void EWebView::SetScale(double scale_factor) { -- 2.7.4 From 2802ce0b75986508230cb0f2fb852391c0d9fb80 Mon Sep 17 00:00:00 2001 From: "ayush.k123" Date: Thu, 12 Jan 2023 16:54:39 +0530 Subject: [PATCH 07/16] [M108 Migration] Enable proper functionality for ewk_policy_decision_* APIs. This patch migrates the following commits to enables proper functionality of ewk_policy_decision_* APIs Reference: 1. https://review.tizen.org/gerrit/273968/ 2. https://review.tizen.org/gerrit/279203/ 3. https://review.tizen.org/gerrit/280669/ Change-Id: Ic599e5a9d0d9bfa345ab06dc045227814bd6c931 Signed-off-by: Ayush Kumar --- tizen_src/ewk/efl_integration/BUILD.gn | 7 +- .../browser/navigation_policy_handler_efl.cc | 36 +--- .../browser/navigation_policy_handler_efl.h | 32 +--- .../browser/navigation_throttle_efl.cc | 116 ++++++++++++- .../browser/navigation_throttle_efl.h | 14 ++ .../browser_url_loader_throttle_efl.cc | 72 ++++++++ .../browser_url_loader_throttle_efl.h | 56 ++++++ .../browser/policy_response_delegate_efl.cc | 188 +++++++-------------- .../browser/policy_response_delegate_efl.h | 45 +++-- .../browser/policy_response_params.h | 26 +++ .../browser/render_message_filter_efl.cc | 4 +- .../resource_dispatcher_host_delegate_efl.h | 67 -------- .../browser/resource_throttle_efl.cc | 25 --- .../browser/resource_throttle_efl.h | 46 ----- .../efl_integration/content_browser_client_efl.cc | 19 +++ .../efl_integration/content_browser_client_efl.h | 8 + tizen_src/ewk/efl_integration/eweb_view.cc | 14 +- tizen_src/ewk/efl_integration/eweb_view.h | 6 +- .../efl_integration/private/ewk_frame_private.cc | 7 +- .../efl_integration/private/ewk_frame_private.h | 3 +- .../private/ewk_policy_decision_private.cc | 161 ++++++------------ .../private/ewk_policy_decision_private.h | 30 ++-- .../efl_integration/public/ewk_policy_decision.cc | 4 +- ...c_blink_ewk_policy_decision_scheme_get_func.cpp | 75 +++++--- 24 files changed, 551 insertions(+), 510 deletions(-) create mode 100644 tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.cc create mode 100644 tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.h create mode 100644 tizen_src/ewk/efl_integration/browser/policy_response_params.h delete mode 100644 tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.h delete mode 100644 tizen_src/ewk/efl_integration/browser/resource_throttle_efl.cc delete mode 100644 tizen_src/ewk/efl_integration/browser/resource_throttle_efl.h mode change 100755 => 100644 tizen_src/ewk/unittest/utc_blink_ewk_policy_decision_scheme_get_func.cpp diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index 67046b2..78c3d88 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -215,8 +215,6 @@ shared_library("chromium-ewk") { "browser/quota_permission_context_efl.h", "browser/render_message_filter_efl.cc", "browser/render_message_filter_efl.h", - "browser/resource_throttle_efl.cc", - "browser/resource_throttle_efl.h", "browser/scoped_allow_wait_for_legacy_web_view_api.h", "browser/scoped_wait_for_ewk.h", "browser/sound_effect.cc", @@ -314,6 +312,8 @@ shared_library("chromium-ewk") { "browser/inputpicker/InputPicker.h", "browser/inputpicker/color_chooser_efl.cc", "browser/inputpicker/color_chooser_efl.h", + "browser/network_service/browser_url_loader_throttle_efl.cc", + "browser/network_service/browser_url_loader_throttle_efl.h", "browser/notification/notification_controller_efl.cc", "browser/notification/notification_controller_efl.h", "browser/notification/notification_helper.cc", @@ -322,6 +322,7 @@ shared_library("chromium-ewk") { "browser/password_manager/password_manager_client_efl.h", "browser/password_manager/password_store_factory.cc", "browser/password_manager/password_store_factory.h", + "browser/policy_response_params.h", "browser/selectpicker/popup_menu_item.cc", "browser/selectpicker/popup_menu_item.h", "browser/selectpicker/popup_menu_item_private.h", @@ -577,8 +578,6 @@ shared_library("chromium-ewk") { sources += [ "browser/editor_client_observer.cc", "browser/editor_client_observer.h", - "browser/resource_dispatcher_host_delegate_efl.cc", - "browser/resource_dispatcher_host_delegate_efl.h", "chromium_ewk.gypi", "file_chooser_controller_efl.cc", "file_chooser_controller_efl.h", diff --git a/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.cc b/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.cc index ded3e67f..ae82bd9 100644 --- a/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.cc @@ -4,39 +4,9 @@ #include "browser/navigation_policy_handler_efl.h" -#include "content/browser/renderer_host/render_view_host_delegate.h" -#include "content/common/render_messages_efl.h" -#include "content/public/browser/render_view_host.h" -#include "ipc/ipc_message.h" - -NavigationPolicyHandlerEfl::NavigationPolicyHandlerEfl( - content::RenderViewHost* rvh, - const NavigationPolicyParams& params) - : rvh_(rvh), - decision_(Undecied), - params_(params) { - DCHECK(rvh); -} - -NavigationPolicyHandlerEfl::~NavigationPolicyHandlerEfl() { -} - -void NavigationPolicyHandlerEfl::DownloadNavigation() { - // indicate that we handle it - if (SetDecision(Handled)) { - NOTIMPLEMENTED() << "[M37] RequestOpenURL was moved to WebContentsImpl, " - << "how to access it from here?"; -#if !defined(EWK_BRINGUP) - WindowOpenDisposition disposition = SAVE_TO_DISK; - rvh_->GetDelegate()->RequestOpenURL(rvh_, params_.url, params_.referrer, - disposition, params_.frame_id, params_.is_redirect, false); -#endif - } -} - -bool NavigationPolicyHandlerEfl::SetDecision(NavigationPolicyHandlerEfl::Decision d) { - if (decision_ == Undecied && d != Undecied) { - decision_ = d; +bool NavigationPolicyHandlerEfl::SetDecision(Decision decision) { + if (decision_ == Undecided && decision != Undecided) { + decision_ = decision; return true; } diff --git a/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.h b/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.h index cfa8a44..f048259 100644 --- a/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.h +++ b/tizen_src/ewk/efl_integration/browser/navigation_policy_handler_efl.h @@ -5,36 +5,22 @@ #ifndef NAVIGATION_POLICY_HANDLER_EFL_H_ #define NAVIGATION_POLICY_HANDLER_EFL_H_ -#include "common/navigation_policy_params.h" - -namespace content { -class RenderViewHost; -} - -namespace IPC { -class Message; -} - class NavigationPolicyHandlerEfl { public: - enum Decision { - Undecied = 0, - Handled, - Unhandled - }; + enum Decision { Undecided = 0, Handled, Unhandled }; + + NavigationPolicyHandlerEfl() = default; + ~NavigationPolicyHandlerEfl() = default; + + NavigationPolicyHandlerEfl(const NavigationPolicyHandlerEfl&) = delete; + NavigationPolicyHandlerEfl& operator=(const NavigationPolicyHandlerEfl&) = + delete; - NavigationPolicyHandlerEfl( - content::RenderViewHost* rvh, - const NavigationPolicyParams& params); - virtual ~NavigationPolicyHandlerEfl(); - void DownloadNavigation(); Decision GetDecision() const { return decision_; } bool SetDecision(Decision); private: - content::RenderViewHost* rvh_; - Decision decision_; - NavigationPolicyParams params_; + Decision decision_ = Undecided; }; #endif /* NAVIGATION_POLICY_HANDLER_EFL_H_ */ diff --git a/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc index a0cecf5..a49a7b0 100644 --- a/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.cc @@ -4,9 +4,14 @@ #include "browser/navigation_throttle_efl.h" +#include "base/bind.h" +#include "common/navigation_policy_params.h" #include "common/web_contents_utils.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_handle.h" #include "eweb_view.h" +#include "third_party/blink/public/platform/web_string.h" +#include "third_party/blink/public/web/web_navigation_type.h" #if BUILDFLAG(IS_TIZEN_TV) #include "common/application_type.h" @@ -14,18 +19,48 @@ namespace content { +static blink::WebNavigationType GetNavigationTypeFromPageTransition( + const ui::PageTransition& transition) { + switch (ui::PageTransitionStripQualifier(transition)) { + case ui::PAGE_TRANSITION_LINK: + return (transition & ui::PAGE_TRANSITION_FORWARD_BACK) + ? blink::kWebNavigationTypeBackForward + : blink::kWebNavigationTypeLinkClicked; + case ui::PAGE_TRANSITION_FORM_SUBMIT: + return (transition & ui::PAGE_TRANSITION_FORWARD_BACK) + ? blink::kWebNavigationTypeFormResubmittedBackForward + : blink::kWebNavigationTypeFormSubmitted; + case ui::PAGE_TRANSITION_RELOAD: + return blink::kWebNavigationTypeReload; + default: + return blink::kWebNavigationTypeOther; + } + NOTREACHED(); + return blink::kWebNavigationTypeOther; +} + NavigationThrottleEfl::NavigationThrottleEfl( NavigationHandle* navigation_handle) - : NavigationThrottle(navigation_handle) {} + : NavigationThrottle(navigation_handle), weak_factory_(this) {} NavigationThrottleEfl::~NavigationThrottleEfl() = default; NavigationThrottle::ThrottleCheckResult +NavigationThrottleEfl::WillStartRequest() { + return HandleNavigation(false /* is_redirect */); +} + +NavigationThrottle::ThrottleCheckResult +NavigationThrottleEfl::WillRedirectRequest() { + return HandleNavigation(true /* is_redirect */); +} + +NavigationThrottle::ThrottleCheckResult NavigationThrottleEfl::WillFailRequest() { auto* handle = navigation_handle(); auto* web_view = web_contents_utils::WebViewFromWebContents(handle->GetWebContents()); - if (web_view) { + if (handle->IsInMainFrame() && web_view) { int error_code = handle->GetNetErrorCode(); web_view->InvokeLoadError(handle->GetURL(), error_code, error_code == net::ERR_ABORTED); @@ -42,4 +77,81 @@ const char* NavigationThrottleEfl::GetNameForLogging() { return "NavigationThrottleEfl"; } +NavigationThrottle::ThrottleCheckResult NavigationThrottleEfl::HandleNavigation( + bool is_redirect) { +#if BUILDFLAG(IS_TIZEN_TV) + if ((IsTIZENWRT() && navigation_handle()->GetURL().SchemeIsFileSystem()) || + navigation_handle()->GetURL().SchemeIs(url::kDataScheme)) + return NavigationThrottle::PROCEED; +#endif + if (ShouldHandleAsyncronously()) { + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&NavigationThrottleEfl::HandleNavigationAsync, + weak_factory_.GetWeakPtr(), + GetNavigationPolicyParams(is_redirect))); + return NavigationThrottle::DEFER; + } + return HandleNavigationImpl(GetNavigationPolicyParams(is_redirect)) + ? NavigationThrottle::CANCEL_AND_IGNORE + : NavigationThrottle::PROCEED; +} + +void NavigationThrottleEfl::HandleNavigationAsync( + const NavigationPolicyParams& params) { + if (HandleNavigationImpl(params)) + CancelDeferredNavigation(NavigationThrottle::CANCEL_AND_IGNORE); + else + Resume(); +} + +bool NavigationThrottleEfl::HandleNavigationImpl( + const NavigationPolicyParams& params) { + auto* web_view = web_contents_utils::WebViewFromWebContents( + navigation_handle()->GetWebContents()); + if (!web_view) + return false; + + bool handled = false; + web_view->InvokePolicyNavigationCallback(params, &handled); + return handled; +} + +bool NavigationThrottleEfl::ShouldHandleAsyncronously() const { + // Ported from InterceptNavigationThrottle::ShouldCheckAsynchronously, + // see components/navigation_interception/intercept_navigation_throttle.cc + // + // Do not apply the async optimization for: + // - POST navigations, to ensure we aren't violating idempotency. + // - Subframe navigations, which aren't observed on Android, and should be + // fast on other platforms. + // - non-http/s URLs, which are more likely to be intercepted. + return navigation_handle()->IsInMainFrame() && + !navigation_handle()->IsPost() && + navigation_handle()->GetURL().SchemeIsHTTPOrHTTPS(); +} + +NavigationPolicyParams NavigationThrottleEfl::GetNavigationPolicyParams( + bool is_redirect) const { + auto* handle = navigation_handle(); + NavigationPolicyParams params; + + params.url = handle->GetURL(); + params.httpMethod = handle->IsPost() ? "POST" : "GET"; + params.type = + GetNavigationTypeFromPageTransition(handle->GetPageTransition()); + std::string auth; + handle->GetRequestHeaders().GetHeader(net::HttpRequestHeaders::kAuthorization, + &auth); + params.auth = blink::WebString::FromUTF8(auth); + std::string cookie; + handle->GetRequestHeaders().GetHeader(net::HttpRequestHeaders::kCookie, + &cookie); + params.cookie = cookie; + params.should_replace_current_entry = handle->DidReplaceEntry(); + params.is_main_frame = handle->IsInMainFrame(); + params.is_redirect = is_redirect; + + return params; +} + } // namespace content diff --git a/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h index d138db2..039a52a 100644 --- a/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h +++ b/tizen_src/ewk/efl_integration/browser/navigation_throttle_efl.h @@ -5,8 +5,11 @@ #ifndef NAVIGATION_THROTTLE_EFL_H_ #define NAVIGATION_THROTTLE_EFL_H_ +#include "base/memory/weak_ptr.h" #include "content/public/browser/navigation_throttle.h" +struct NavigationPolicyParams; + namespace content { class NavigationThrottleEfl : public NavigationThrottle { public: @@ -17,9 +20,20 @@ class NavigationThrottleEfl : public NavigationThrottle { ~NavigationThrottleEfl() override; + NavigationThrottle::ThrottleCheckResult WillStartRequest() override; + NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override; NavigationThrottle::ThrottleCheckResult WillFailRequest() override; const char* GetNameForLogging() override; + + private: + NavigationThrottle::ThrottleCheckResult HandleNavigation(bool is_redirect); + void HandleNavigationAsync(const NavigationPolicyParams& params); + bool HandleNavigationImpl(const NavigationPolicyParams& params); + bool ShouldHandleAsyncronously() const; + NavigationPolicyParams GetNavigationPolicyParams(bool is_redirect) const; + + base::WeakPtrFactory weak_factory_; }; } // namespace content diff --git a/tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.cc b/tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.cc new file mode 100644 index 0000000..ec9dd71 --- /dev/null +++ b/tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.cc @@ -0,0 +1,72 @@ +// Copyright 2020 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 "browser/network_service/browser_url_loader_throttle_efl.h" + +#include "browser/policy_response_delegate_efl.h" +#include "services/network/public/mojom/url_response_head.mojom.h" +#include "third_party/blink/public/common/loader/resource_type_util.h" +#include "tizen/system_info.h" +#include "url/gurl.h" + +// static +std::unique_ptr +BrowserURLLoaderThrottleEfl::MaybeCreate( + const network::ResourceRequest& request, + const base::RepeatingCallback& + web_contents_getter) { + if (IsMobileProfile() && + !blink::IsResourceTypeFrame( + static_cast(request.resource_type))) { + return nullptr; + } + + if (!request.url.SchemeIsHTTPOrHTTPS() && !request.url.SchemeIsFile()) + return nullptr; + + return base::WrapUnique( + new BrowserURLLoaderThrottleEfl(request, web_contents_getter)); +} + +BrowserURLLoaderThrottleEfl::BrowserURLLoaderThrottleEfl( + const network::ResourceRequest& request, + const base::RepeatingCallback& web_contents_getter) + : request_(request), web_contents_getter_(web_contents_getter) {} + +BrowserURLLoaderThrottleEfl::~BrowserURLLoaderThrottleEfl() { + if (policy_response_delegate_) + policy_response_delegate_->ThrottleDestroyed(); +} + +void BrowserURLLoaderThrottleEfl::WillProcessResponse( + const GURL& response_url, + network::mojom::URLResponseHead* response_head, + bool* defer) { + auto* web_contents = web_contents_getter_.Run(); + if (!web_contents) { + // The request is not associated with a WebContents. We will just use a + // response in this case. + return; // LCOV_EXCL_LINE + } + policy_response_delegate_ = new PolicyResponseDelegateEfl( + request_, response_head, web_contents, this, defer); +} + +void BrowserURLLoaderThrottleEfl::UpdateDeferredResponseHead( + const network::mojom::URLResponseHead* new_response_head) { + if (delegate_) { + delegate_->UpdateDeferredResponseHead(new_response_head->Clone(), + mojo::ScopedDataPipeConsumerHandle()); + } +} + +void BrowserURLLoaderThrottleEfl::Resume() { + if (delegate_) + delegate_->Resume(); +} + +void BrowserURLLoaderThrottleEfl::Ignore() { + if (delegate_) + delegate_->CancelWithError(net::ERR_ABORTED); +} diff --git a/tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.h b/tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.h new file mode 100644 index 0000000..e64776d --- /dev/null +++ b/tizen_src/ewk/efl_integration/browser/network_service/browser_url_loader_throttle_efl.h @@ -0,0 +1,56 @@ +// Copyright 2020 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_URL_LOADER_THROTTLE_EFL_H_ +#define BROWSER_URL_LOADER_THROTTLE_EFL_H_ + +#include + +#include "base/callback.h" +#include "base/memory/scoped_refptr.h" +#include "services/network/public/cpp/resource_request.h" +#include "third_party/blink/public/common/loader/url_loader_throttle.h" + +namespace content { +class WebContents; +} + +class PolicyResponseDelegateEfl; + +class BrowserURLLoaderThrottleEfl : public blink::URLLoaderThrottle { + public: + static std::unique_ptr MaybeCreate( + const network::ResourceRequest& request, + const base::RepeatingCallback& + web_contents_getter); + + ~BrowserURLLoaderThrottleEfl() override; + + // blink::URLLoaderThrottle implementation: + void WillProcessResponse(const GURL& response_url, + network::mojom::URLResponseHead* response_head, + bool* defer) override; + + void UpdateDeferredResponseHead( + const network::mojom::URLResponseHead* new_response_head); + + void Resume(); + void Ignore(); + + private: + BrowserURLLoaderThrottleEfl( + const network::ResourceRequest& request, + const base::RepeatingCallback& + web_contents_getter); + + BrowserURLLoaderThrottleEfl(const BrowserURLLoaderThrottleEfl&) = delete; + BrowserURLLoaderThrottleEfl& operator=(const BrowserURLLoaderThrottleEfl&) = + delete; + + network::ResourceRequest request_; + base::RepeatingCallback web_contents_getter_; + scoped_refptr policy_response_delegate_; +}; + +#endif // URL_LOADER_THROTTLE_EFL_H_ diff --git a/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.cc b/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.cc index d782c80..0378c0d 100644 --- a/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.cc @@ -4,155 +4,95 @@ #include "browser/policy_response_delegate_efl.h" +#include + #include "base/task/thread_pool.h" #include "browser/mime_override_manager_efl.h" -#include "browser/resource_throttle_efl.h" +#include "browser/network_service/browser_url_loader_throttle_efl.h" +#include "browser/policy_response_params.h" #include "common/web_contents_utils.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" #include "eweb_view.h" +#include "net/base/upload_bytes_element_reader.h" #include "private/ewk_policy_decision_private.h" - -using content::BrowserThread; -using content::RenderViewHost; -using content::RenderFrameHost; -using content::WebContents; - -using web_contents_utils::WebContentsFromFrameID; -using web_contents_utils::WebContentsFromViewID; +#include "services/network/public/cpp/data_element.h" +#include "services/network/public/cpp/features.h" +#include "services/network/public/mojom/url_response_head.mojom-forward.h" using web_contents_utils::WebViewFromWebContents; +// Network service PolicyResponseDelegateEfl::PolicyResponseDelegateEfl( - net::URLRequest* request, - ResourceThrottleEfl* throttle) - : policy_decision_(new _Ewk_Policy_Decision(request->url(), - request, - this)), - throttle_(throttle), - render_process_id_(0), - render_frame_id_(0), - render_view_id_(0) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -#if !defined(EWK_BRINGUP) // FIXME: m85 bringup - ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); - - if (info) { - info->GetAssociatedRenderFrame(&render_process_id_, &render_frame_id_); - render_view_id_ = info->GetRouteID(); - - } else { - ResourceRequestInfo::GetRenderFrameForRequest(request, &render_process_id_, &render_frame_id_); - } -#endif - // Chromium internal downloads are not associated with any frame or view, we should - // accept them without EWK-specific logic. For example notification icon is internal - // chromium download - if (render_process_id_ > 0 && (render_frame_id_ > 0 || render_view_id_ > 0)) { - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::UI}, - base::BindOnce( - &PolicyResponseDelegateEfl::HandlePolicyResponseOnUIThread, this)); - } else { - // Async call required! - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&PolicyResponseDelegateEfl::UseResponseOnIOThread, - this)); + const network::ResourceRequest& request, + network::mojom::URLResponseHead* response_head, + content::WebContents* web_contents, + BrowserURLLoaderThrottleEfl* throttle, + bool* defer) + : response_head_(response_head), url_loader_throttle_(throttle) { + PolicyResponseParams params; + params.request_url = request.url; + + OverrideMimeTypeIfNeeded(web_contents, request.url.spec(), response_head); + params.mime_type = response_head->mime_type; + + if (request.request_body) { + for (const auto& element : *request.request_body->elements()) { + if (element.type() != network::DataElement::Tag::kBytes) + break; + + const std::vector& bytes = + element.As().bytes(); + params.post_data.append(reinterpret_cast(bytes.data()), + bytes.size()); + } } -} - -void PolicyResponseDelegateEfl::HandlePolicyResponseOnUIThread() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(policy_decision_.get()); - - WebContents* web_contents = NULL; + params.is_main_frame = request.is_outermost_main_frame; + params.response_headers = response_head->headers; - DCHECK(render_process_id_ > 0); - DCHECK(render_frame_id_ > 0 || render_view_id_ > 0); + policy_decision_.reset(new _Ewk_Policy_Decision(params, this)); - if (render_frame_id_ > 0) { - web_contents = WebContentsFromFrameID( - render_process_id_, render_frame_id_); - } else { - web_contents = WebContentsFromViewID(render_process_id_, render_view_id_); - } + // web_view_ takes owenership of Ewk_Policy_Decision. This is same as + // WK2/Tizen + WebViewFromWebContents(web_contents) + ->InvokePolicyResponseCallback(policy_decision_.release(), defer); + deferred_ = *defer; +} - if (!web_contents) { - // this is a situation where we had frame/view info on IO thread but it - // does not exist now in UI. We'll ignore such responses - IgnoreResponse(); +/* LCOV_EXCL_START */ +void PolicyResponseDelegateEfl::OverrideMimeTypeIfNeeded( + content::WebContents* web_contents, + const std::string& url_spec, + network::mojom::URLResponseHead* response_head) { + auto* browser_context = static_cast( + web_contents->GetBrowserContext()); + if (!browser_context) return; - } - content::BrowserContextEfl* browser_context = - static_cast( - web_contents->GetBrowserContext()); - if (browser_context) { - std::string mime_type; - const char* mime_type_chars = policy_decision_->GetResponseMime(); - if (mime_type_chars) - mime_type.assign(mime_type_chars); - - std::string url_spec; - const char* url_spec_chars = policy_decision_->GetUrl(); - if (url_spec_chars) - url_spec.assign(url_spec_chars); - - std::string new_mime_type; - if (browser_context->WebContext()->OverrideMimeForURL( - url_spec, mime_type, new_mime_type)) { - MimeOverrideManagerEfl* mime_override_manager_efl = - MimeOverrideManagerEfl::GetInstance(); - mime_override_manager_efl->PushOverriddenMime(url_spec, new_mime_type); - } + std::string new_mime_type; + if (browser_context->WebContext()->OverrideMimeForURL( + url_spec, response_head->mime_type, new_mime_type)) { + response_head->mime_type = new_mime_type; } - - // Delegate may be retrieved ONLY on UI thread - policy_decision_->InitializeOnUIThread(); - - // web_view_ takes owenership of Ewk_Policy_Decision. This is same as WK2/Tizen - WebViewFromWebContents(web_contents)-> - InvokePolicyResponseCallback(policy_decision_.release()); } +/* LCOV_EXCL_STOP */ void PolicyResponseDelegateEfl::UseResponse() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&PolicyResponseDelegateEfl::UseResponseOnIOThread, this)); -} - -void PolicyResponseDelegateEfl::IgnoreResponse() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - base::ThreadPool::PostTask( - FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&PolicyResponseDelegateEfl::IgnoreResponseOnIOThread, - this)); -} - -void PolicyResponseDelegateEfl::UseResponseOnIOThread() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (throttle_) { - throttle_->Resume(); - // decision is already taken so there is no need to use throttle anymore. - throttle_ = NULL; + if (url_loader_throttle_ && deferred_) { + url_loader_throttle_->Resume(); + url_loader_throttle_ = nullptr; } } -void PolicyResponseDelegateEfl::IgnoreResponseOnIOThread() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (throttle_) { - throttle_->Ignore(); - throttle_ = NULL; - +/* LCOV_EXCL_START */ +void PolicyResponseDelegateEfl::IgnoreResponse() { + if (url_loader_throttle_) { + url_loader_throttle_->Ignore(); + url_loader_throttle_ = nullptr; } } +/* LCOV_EXCL_STOP */ void PolicyResponseDelegateEfl::ThrottleDestroyed(){ - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - // The throttle has gone so don't try to do anything about it further. - throttle_ = NULL; + // The throttle has gone so don't try to do anything about it further. + url_loader_throttle_ = nullptr; } diff --git a/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.h b/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.h index 2d8d300..dbb8013 100644 --- a/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/browser/policy_response_delegate_efl.h @@ -6,6 +6,8 @@ #define POLICY_RESPONSE_DELEGATE_EFL_H_ #include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" +#include "content/public/browser/web_contents.h" #include "private/ewk_policy_decision_private.h" #include "public/ewk_policy_decision.h" #include "url/gurl.h" @@ -15,40 +17,47 @@ class URLRequest; class HttpResponseHeaders; } -namespace content { -class ResourceController; -} +namespace network { +struct ResourceRequest; +namespace mojom { +class URLResponseHead; +} // namespace mojom +} // namespace network -class ResourceThrottleEfl; +class BrowserURLLoaderThrottleEfl; class _Ewk_Policy_Decision; -class PolicyResponseDelegateEfl: public base::RefCountedThreadSafe { +class PolicyResponseDelegateEfl + : public base::RefCountedThreadSafe, + public base::SupportsWeakPtr { public: - PolicyResponseDelegateEfl(net::URLRequest* request, - ResourceThrottleEfl* throttle); + PolicyResponseDelegateEfl(const network::ResourceRequest& request, + network::mojom::URLResponseHead* response_head, + content::WebContents* web_contents, + BrowserURLLoaderThrottleEfl* throttle, + bool* defer); + + PolicyResponseDelegateEfl(const PolicyResponseDelegateEfl&) = delete; + PolicyResponseDelegateEfl& operator=(const PolicyResponseDelegateEfl&) = + delete; void UseResponse(); void IgnoreResponse(); void ThrottleDestroyed(); - int GetRenderProcessId() const { return render_process_id_; } - int GetRenderFrameId() const { return render_frame_id_; } - int GetRenderViewId() const { return render_view_id_; } - private: friend class base::RefCountedThreadSafe; - void HandlePolicyResponseOnUIThread(); - void UseResponseOnIOThread(); - void IgnoreResponseOnIOThread(); + void OverrideMimeTypeIfNeeded(content::WebContents* web_contents, + const std::string& url_spec, + network::mojom::URLResponseHead* response_head); std::unique_ptr<_Ewk_Policy_Decision> policy_decision_; + network::mojom::URLResponseHead* response_head_ = nullptr; // A throttle which blocks response and invokes policy mechanism. // It is used to cancel or resume response processing. - ResourceThrottleEfl* throttle_; - int render_process_id_; - int render_frame_id_; - int render_view_id_; + BrowserURLLoaderThrottleEfl* url_loader_throttle_ = nullptr; + bool deferred_ = false; }; #endif /* POLICY_RESPONSE_DELEGATE_EFL_H_ */ diff --git a/tizen_src/ewk/efl_integration/browser/policy_response_params.h b/tizen_src/ewk/efl_integration/browser/policy_response_params.h new file mode 100644 index 0000000..a03b929 --- /dev/null +++ b/tizen_src/ewk/efl_integration/browser/policy_response_params.h @@ -0,0 +1,26 @@ +// Copyright 2020 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 POLICY_RESPONSE_PARAMS_H_ +#define POLICY_RESPONSE_PARAMS_H_ + +#include + +#include "net/http/http_response_headers.h" +#include "url/gurl.h" + +struct PolicyResponseParams { + PolicyResponseParams() = default; + PolicyResponseParams(const PolicyResponseParams& params) = default; + ~PolicyResponseParams() = default; + + GURL request_url; + std::string mime_type; + std::string post_data; + bool is_main_frame = false; + bool allow_download = false; + scoped_refptr response_headers; +}; + +#endif // POLICY_RESPONSE_PARAMS_H_ diff --git a/tizen_src/ewk/efl_integration/browser/render_message_filter_efl.cc b/tizen_src/ewk/efl_integration/browser/render_message_filter_efl.cc index d459bac..436d7da 100644 --- a/tizen_src/ewk/efl_integration/browser/render_message_filter_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/render_message_filter_efl.cc @@ -61,8 +61,8 @@ void RenderMessageFilterEfl::OnDecideNavigationPolicy( if (content::WebContents* web_contents = WebContentsFromViewID(render_process_id_, params.render_view_id)) { - WebViewFromWebContents(web_contents)->InvokePolicyNavigationCallback( - web_contents->GetRenderViewHost(), params, handled); + WebViewFromWebContents(web_contents) + ->InvokePolicyNavigationCallback(params, handled); } } diff --git a/tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.h b/tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.h deleted file mode 100644 index 4e0dac5..0000000 --- a/tizen_src/ewk/efl_integration/browser/resource_dispatcher_host_delegate_efl.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2014 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 RESOURCE_DISPATCHER_HOST_DELEGATE_EFL_H -#define RESOURCE_DISPATCHER_HOST_DELEGATE_EFL_H - -#include "base/compiler_specific.h" - -namespace net { -class AuthChallengeInfo; -class URLRequest; -} - -namespace content { - -class ResourceDispatcherHostLoginDelegate; - -class ResourceDispatcherHostDelegateEfl - : public ResourceDispatcherHostDelegate { - public: - ResourceDispatcherHostDelegateEfl() {} - - // ResourceDispatcherHostDelegate implementation. - // - // Called after ShouldBeginRequest to allow the embedder to add resource - // throttles. - void RequestBeginning(net::URLRequest* request, - content::ResourceContext* resource_context, - content::AppCacheService* appcache_service, - std::vector>* - throttles) override; - - // Called to trigger download. - void DownloadStarting(net::URLRequest* request, - content::ResourceContext* resource_context, - bool is_content_initiated, - bool must_download, - bool is_new_request, - std::vector>* - throttles) override; - -// Create login delegate. -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( - net::AuthChallengeInfo* auth_info, - net::URLRequest* request) override; -#endif - - // EWK_BRINGUP: Removed in upversion. - // Returns true if mime type should be overridden, otherwise returns false. - bool ShouldOverrideMimeType(const GURL& url, - std::string& new_mime_type) const; - - private: - void TriggerNewDownloadStartCallback(net::URLRequest* request, - const std::string& user_agent, - const std::string& content_disposition, - const std::string& mime_type, - int64_t content_length, - int render_process_id, - int render_view_id); -}; - -} // namespace content - -#endif // RESOURCE_DISPATCHER_HOST_DELEGATE_EFL_H diff --git a/tizen_src/ewk/efl_integration/browser/resource_throttle_efl.cc b/tizen_src/ewk/efl_integration/browser/resource_throttle_efl.cc deleted file mode 100644 index 67c1a7e..0000000 --- a/tizen_src/ewk/efl_integration/browser/resource_throttle_efl.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 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 "browser/policy_response_delegate_efl.h" -#include "browser/resource_throttle_efl.h" - -ResourceThrottleEfl::~ResourceThrottleEfl() { - if (policy_delegate_.get()) { - //If resourceThrottleEfl is destroyed, inform delegate that it cannot - //use controller anymore. - policy_delegate_->ThrottleDestroyed(); - } -} - -void ResourceThrottleEfl::WillProcessResponse( - const GURL& response_url, - network::mojom::URLResponseHead* response_head, - bool* defer) { - //Stop processing until decision will be granted. - *defer = true; - - policy_delegate_ = new PolicyResponseDelegateEfl(&request_, - this); -} diff --git a/tizen_src/ewk/efl_integration/browser/resource_throttle_efl.h b/tizen_src/ewk/efl_integration/browser/resource_throttle_efl.h deleted file mode 100644 index b8c6446..0000000 --- a/tizen_src/ewk/efl_integration/browser/resource_throttle_efl.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 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 RESOURCE_THROTTLE__EFL_H_ -#define RESOURCE_THROTTLE__EFL_H_ - -#include "browser/policy_response_delegate_efl.h" -#include "net/url_request/url_request.h" -#include "third_party/blink/public/common/loader/url_loader_throttle.h" - -class ResourceThrottleEfl : public blink::URLLoaderThrottle { - public: - ResourceThrottleEfl(net::URLRequest& request) - : request_(request), policy_delegate_(nullptr) {} - - ~ResourceThrottleEfl() override; - - // blink::URLLoaderThrottle overrides; - void WillProcessResponse(const GURL& response_url, - network::mojom::URLResponseHead* response_head, - bool* defer) override; - - void Resume() { - // EWK_BRINGUP. Removed in upstream - // 64fa092bc4ccdcb1c0cc08b93d6c1bd49363adb0 - // controller()->Resume(); -#if !defined(EWK_BRINGUP) // FIXME: m85 bringup - Resume(); -#endif - } - - void Ignore() { - // EWK_BRINGUP. Removed in upstream - // 64fa092bc4ccdcb1c0cc08b93d6c1bd49363adb0 - // controller()->CancelAndIgnore(); -#if !defined(EWK_BRINGUP) // FIXME: m85 bringup - Cancel(); -#endif - } - - private: - net::URLRequest& request_; - scoped_refptr policy_delegate_; -}; -#endif /*RESOURCE_THROTTLE__EFL_H_*/ diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc index 0140567..4529c67 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc @@ -8,6 +8,7 @@ #include "base/strings/string_number_conversions.h" #include "browser/editor_client_observer.h" #include "browser/navigation_throttle_efl.h" +#include "browser/network_service/browser_url_loader_throttle_efl.h" #include "browser/network_service/proxying_url_loader_factory_efl.h" #include "browser/notification/notification_controller_efl.h" #include "browser/quota_permission_context_efl.h" @@ -28,6 +29,7 @@ #include "content/public/common/content_switches.h" #include "devtools_manager_delegate_efl.h" #include "eweb_context.h" +#include "services/network/public/cpp/features.h" #include "shared_url_loader_factory_efl.h" #include "web_contents_delegate_efl.h" #include "web_contents_view_delegate_ewk.h" @@ -550,4 +552,21 @@ bool ContentBrowserClientEfl::WillCreateURLLoaderFactory( return true; } +std::vector> +ContentBrowserClientEfl::CreateURLLoaderThrottles( + const network::ResourceRequest& request, + content::BrowserContext* browser_context, + const base::RepeatingCallback& wc_getter, + content::NavigationUIData* navigation_ui_data, + int frame_tree_node_id) { + std::vector> result; + + auto browser_throttle = + BrowserURLLoaderThrottleEfl::MaybeCreate(request, wc_getter); + if (browser_throttle) + result.push_back(std::move(browser_throttle)); + + return result; +} + } // namespace content diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.h b/tizen_src/ewk/efl_integration/content_browser_client_efl.h index 6bee4ac..cef8cb6 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.h +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.h @@ -8,6 +8,7 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" #include "net/cookies/canonical_cookie.h" +#include "third_party/blink/public/common/loader/url_loader_throttle.h" #include "third_party/blink/public/web/web_window_features.h" namespace base { @@ -128,6 +129,13 @@ class ContentBrowserClientEfl : public ContentBrowserClient { void RemoveAcceptLangsChangedCallback(AcceptLangsChangedCallback callback); std::vector> CreateThrottlesForNavigation( NavigationHandle* handle) override; + std::vector> + CreateURLLoaderThrottles( + const network::ResourceRequest& request, + content::BrowserContext* browser_context, + const base::RepeatingCallback& wc_getter, + content::NavigationUIData* navigation_ui_data, + int frame_tree_node_id) override; private: bool WillCreateURLLoaderFactory( diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index f8af786..70727b5 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -573,29 +573,31 @@ void EWebView::InvokeAuthCallback(LoginDelegateEfl* login_delegate, } void EWebView::InvokePolicyResponseCallback( - _Ewk_Policy_Decision* policy_decision) { + _Ewk_Policy_Decision* policy_decision, + bool* defer) { SmartCallback().call( policy_decision); - if (policy_decision->isSuspended()) + if (policy_decision->isSuspended()) { + *defer = true; return; + } if (!policy_decision->isDecided()) policy_decision->Use(); - delete policy_decision; + policy_decision->SelfDeleteIfNecessary(); } void EWebView::InvokePolicyNavigationCallback( - RenderViewHost* rvh, - const NavigationPolicyParams params, + const NavigationPolicyParams& params, bool* handled) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); SmartCallback().call(); std::unique_ptr<_Ewk_Policy_Decision> policy_decision( - new _Ewk_Policy_Decision(params, rvh)); + new _Ewk_Policy_Decision(params)); SmartCallback().call( policy_decision.get()); diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 00a71e1..83b9bd4 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -326,9 +326,9 @@ class EWebView { bool GetSnapshotAsync(Eina_Rectangle rect, Ewk_Web_App_Screenshot_Captured_Callback callback, void* user_data); - void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision); - void InvokePolicyNavigationCallback(content::RenderViewHost* rvh, - NavigationPolicyParams params, + void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision, + bool* defer); + void InvokePolicyNavigationCallback(const NavigationPolicyParams& params, bool* handled); void UseSettingsFont(); diff --git a/tizen_src/ewk/efl_integration/private/ewk_frame_private.cc b/tizen_src/ewk/efl_integration/private/ewk_frame_private.cc index b3c6754..5e64e46 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_frame_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_frame_private.cc @@ -28,8 +28,7 @@ _Ewk_Frame::_Ewk_Frame(RenderFrameHost* rfh) is_main_frame_ = wc->GetPrimaryMainFrame() == rfh; } -_Ewk_Frame::_Ewk_Frame(const NavigationPolicyParams ¶ms) - : is_main_frame_(params.is_main_frame) -{ -} +_Ewk_Frame::_Ewk_Frame(const NavigationPolicyParams& params) + : is_main_frame_(params.is_main_frame) {} +_Ewk_Frame::_Ewk_Frame(bool is_main_frame) : is_main_frame_(is_main_frame) {} diff --git a/tizen_src/ewk/efl_integration/private/ewk_frame_private.h b/tizen_src/ewk/efl_integration/private/ewk_frame_private.h index 83e58da..60236b4 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_frame_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_frame_private.h @@ -14,7 +14,8 @@ struct NavigationPolicyParams; class _Ewk_Frame { public: _Ewk_Frame(content::RenderFrameHost* rfh); - _Ewk_Frame(const NavigationPolicyParams ¶ms); + _Ewk_Frame(const NavigationPolicyParams& params); + _Ewk_Frame(bool is_main_frame); bool IsMainFrame() const { return is_main_frame_; } diff --git a/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.cc b/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.cc index 2a11597..4d94bc87 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.cc @@ -6,17 +6,16 @@ #include +#include "browser/policy_response_params.h" +#include "common/navigation_policy_params.h" +#include "content/browser/loader/download_utils_impl.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_view_host.h" #include "eweb_view.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request_context.h" #include "private/ewk_frame_private.h" -#include "third_party/blink/public/common/mime_util/mime_util.h" using content::BrowserThread; -using content::RenderFrameHost; -using content::RenderViewHost; namespace { void FreeStringShare(void* data) { @@ -24,11 +23,13 @@ void FreeStringShare(void* data) { } } -_Ewk_Policy_Decision::_Ewk_Policy_Decision(const GURL& request_url, - net::URLRequest* request, +_Ewk_Policy_Decision::_Ewk_Policy_Decision(const PolicyResponseParams& params, PolicyResponseDelegateEfl* delegate) : web_view_(NULL), - policy_response_delegate_(delegate), + policy_response_delegate_(AsWeakPtr(delegate)), + frame_(new _Ewk_Frame(params.is_main_frame)), + http_body_(params.post_data), + response_mime_(params.mime_type), response_headers_(NULL), decision_type_(EWK_POLICY_DECISION_USE), navigation_type_(EWK_POLICY_NAVIGATION_TYPE_OTHER), @@ -37,46 +38,36 @@ _Ewk_Policy_Decision::_Ewk_Policy_Decision(const GURL& request_url, response_status_code_(0), type_(POLICY_RESPONSE) { DCHECK(delegate); - DCHECK(request); - net::HttpResponseHeaders* response_headers = request->response_headers(); + ParseUrl(params.request_url); - ParseUrl(request_url); - if (response_headers) { - response_status_code_ = response_headers->response_code(); - - request->GetMimeType(&response_mime_); + if (!params.response_headers) + return; -#if !defined(EWK_BRINGUP) // FIXME: m76 bringup - if ((!content::IsResourceTypeFrame(resource_type) && - !resource_type == content::RESOURCE_TYPE_FAVICON) || - (!blink::IsSupportedMimeType(response_mime_))) { - decision_type_ = EWK_POLICY_DECISION_DOWNLOAD; - } -#endif + response_status_code_ = params.response_headers->response_code(); - if (request_url.has_password() && request_url.has_username()) - SetAuthorizationIfNecessary(request_url); + if (content::download_utils::IsDownload( + params.request_url, params.response_headers.get(), response_mime_)) + decision_type_ = EWK_POLICY_DECISION_DOWNLOAD; - std::string set_cookie_; + if (params.request_url.has_password() && params.request_url.has_username()) + SetAuthorizationIfNecessary(params.request_url); - if (response_headers->EnumerateHeader(NULL, "Set-Cookie", &set_cookie_)) - cookie_ = set_cookie_; + params.response_headers->EnumerateHeader(nullptr, "Set-Cookie", &cookie_); - size_t iter = 0; - std::string name; - std::string value; - response_headers_ = eina_hash_string_small_new(FreeStringShare); - while (response_headers->EnumerateHeaderLines(&iter, &name, &value)) - eina_hash_add(response_headers_, name.c_str(), - eina_stringshare_add(value.c_str())); + size_t iter = 0; + std::string name; + std::string value; + response_headers_ = eina_hash_string_small_new(FreeStringShare); + while (params.response_headers->EnumerateHeaderLines(&iter, &name, &value)) { + eina_hash_add(response_headers_, name.c_str(), + eina_stringshare_add(value.c_str())); } } -_Ewk_Policy_Decision::_Ewk_Policy_Decision(const NavigationPolicyParams& params, - content::RenderViewHost* rvh) +_Ewk_Policy_Decision::_Ewk_Policy_Decision(const NavigationPolicyParams& params) : web_view_(NULL), - navigation_policy_handler_(new NavigationPolicyHandlerEfl(rvh, params)), + navigation_policy_handler_(new NavigationPolicyHandlerEfl()), frame_(new _Ewk_Frame(params)), cookie_(params.cookie), http_method_(params.httpMethod), @@ -106,11 +97,10 @@ _Ewk_Policy_Decision::_Ewk_Policy_Decision(EWebView* view) DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(view); - RenderFrameHost* rfh = NULL; + content::RenderFrameHost* rfh = nullptr; // we can use main frame here - if (view) { - view->web_contents().GetPrimaryMainFrame(); - } + if (view) + rfh = view->web_contents().GetPrimaryMainFrame(); frame_.reset(new _Ewk_Frame(rfh)); } @@ -120,6 +110,7 @@ _Ewk_Policy_Decision::~_Ewk_Policy_Decision() { } void _Ewk_Policy_Decision::Use() { + DCHECK(policy_response_delegate_.get()); is_decided_ = true; switch (type_) { case POLICY_RESPONSE: @@ -138,11 +129,13 @@ void _Ewk_Policy_Decision::Use() { } if (isSuspended()) { - BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); + is_suspended_ = false; + SelfDeleteIfNecessary(); } } void _Ewk_Policy_Decision::Ignore() { + DCHECK(policy_response_delegate_.get()); is_decided_ = true; switch (type_) { case _Ewk_Policy_Decision::POLICY_RESPONSE: @@ -161,29 +154,8 @@ void _Ewk_Policy_Decision::Ignore() { } if (isSuspended()) { - BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); - } -} - -void _Ewk_Policy_Decision::Download() { - is_decided_ = true; - switch (type_) { - case _Ewk_Policy_Decision::POLICY_RESPONSE: - policy_response_delegate_->UseResponse(); - break; - case _Ewk_Policy_Decision::POLICY_NAVIGATION: - navigation_policy_handler_->DownloadNavigation(); - break; - case _Ewk_Policy_Decision::POLICY_NEWWINDOW: - can_create_window_ = false; - break; - default: - NOTREACHED(); - break; - } - - if (isSuspended()) { - BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); + is_suspended_ = false; + SelfDeleteIfNecessary(); } } @@ -197,41 +169,6 @@ bool _Ewk_Policy_Decision::Suspend() { return false; } -void _Ewk_Policy_Decision::InitializeOnUIThread() { - DCHECK(type_ == _Ewk_Policy_Decision::POLICY_RESPONSE); - DCHECK(policy_response_delegate_.get()); - - if (policy_response_delegate_.get()) { - RenderFrameHost* host = - RenderFrameHost::FromID(policy_response_delegate_->GetRenderProcessId(), - policy_response_delegate_->GetRenderFrameId()); - - // Download request has no render frame id, they're detached. We override it - // with main frame from render view id - if (!host) { - RenderViewHost* viewhost = RenderViewHost::FromID( - policy_response_delegate_->GetRenderProcessId(), - policy_response_delegate_->GetRenderViewId()); - - // DCHECK(viewhost); - if (viewhost) { - content::WebContents* web_contents = - content::WebContents::FromRenderViewHost(viewhost); - host = web_contents->GetPrimaryMainFrame(); - } - } - - if (host) { - /* - * In some situations there is no renderer associated to the response - * Such case can be observed while running TC - * utc_blink_ewk_geolocation_permission_request_suspend_func - */ - frame_.reset(new _Ewk_Frame(host)); - } - } -} - _Ewk_Frame* _Ewk_Policy_Decision::GetFrameRef() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // Ups, forgot to initialize something? @@ -282,29 +219,41 @@ const char* _Ewk_Policy_Decision::GetCookie() const { } const char* _Ewk_Policy_Decision::GetAuthUser() const { - return auth_user_.empty() ? NULL : auth_user_.c_str(); + return auth_user_.c_str(); } const char* _Ewk_Policy_Decision::GetAuthPassword() const { - return auth_password_.empty() ? NULL : auth_password_.c_str(); + return auth_password_.c_str(); } const char* _Ewk_Policy_Decision::GetUrl() const { - return url_.empty() ? NULL : url_.c_str(); + return url_.c_str(); } const char* _Ewk_Policy_Decision::GetHttpMethod() const { - return http_method_.empty() ? NULL : http_method_.c_str(); + return http_method_.c_str(); +} + +const char* _Ewk_Policy_Decision::GetHttpBody() const { + return http_body_.c_str(); } const char* _Ewk_Policy_Decision::GetScheme() const { - return scheme_.empty() ? NULL : scheme_.c_str(); + return scheme_.c_str(); } const char* _Ewk_Policy_Decision::GetHost() const { - return host_.empty() ? NULL : host_.c_str(); + return host_.c_str(); } const char* _Ewk_Policy_Decision::GetResponseMime() const { - return response_mime_.empty() ? NULL : response_mime_.c_str(); + return response_mime_.c_str(); +} + +void _Ewk_Policy_Decision::SelfDeleteIfNecessary() { + if (!deleted_) { + content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE, + this); + deleted_ = true; + } } diff --git a/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.h b/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.h index f5dc3c5..ac7df3e 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_policy_decision_private.h @@ -17,15 +17,12 @@ // Basic type of authorization - 'type username:password' #define BASIC_AUTHORIZATION "BASIC" -namespace net { -class URLRequest; -} - class EWebView; class GURL; -struct NavigationPolicyParams; +struct PolicyResponseParams; class PolicyResponseDelegateEfl; -class _Ewk_Frame; +struct NavigationPolicyParams; +struct _Ewk_Frame; namespace content { class RenderViewHost; @@ -36,14 +33,13 @@ class _Ewk_Policy_Decision { /** * Constructs _Ewk_Policy_Decision with navigation type POLICY_RESPONSE */ - explicit _Ewk_Policy_Decision(const GURL& request_url, - net::URLRequest* request, + explicit _Ewk_Policy_Decision(const PolicyResponseParams& params, PolicyResponseDelegateEfl* delegate); - /** - * Constructs _Ewk_Policy_Decision with navigation type POLICY_NAVIGATION - */ - explicit _Ewk_Policy_Decision(const NavigationPolicyParams ¶ms, content::RenderViewHost* rvh); + /** + * Constructs _Ewk_Policy_Decision with navigation type POLICY_NAVIGATION + */ + explicit _Ewk_Policy_Decision(const NavigationPolicyParams& params); /** * Constructs _Ewk_Policy_Decision with navigation type POLICY_NEWWINDOW @@ -54,7 +50,6 @@ class _Ewk_Policy_Decision { void Use(); void Ignore(); - void Download(); bool Suspend(); bool isDecided() const { return is_decided_; } @@ -66,6 +61,7 @@ class _Ewk_Policy_Decision { const char* GetAuthPassword() const; const char* GetUrl() const; const char* GetHttpMethod() const; + const char* GetHttpBody() const; const char* GetScheme() const; const char* GetHost() const; const char* GetResponseMime() const; @@ -77,10 +73,10 @@ class _Ewk_Policy_Decision { _Ewk_Frame* GetFrameRef() const; - void InitializeOnUIThread(); void ParseUrl(const GURL& url); + void SelfDeleteIfNecessary(); -private: + private: /** * @brief sets userID and password * @param request_url requested url - user:password@address @@ -100,12 +96,13 @@ private: }; EWebView* web_view_; - scoped_refptr policy_response_delegate_; + base::WeakPtr policy_response_delegate_; std::unique_ptr navigation_policy_handler_; std::unique_ptr<_Ewk_Frame> frame_; std::string cookie_; std::string url_; std::string http_method_; + std::string http_body_; std::string host_; std::string scheme_; std::string response_mime_; @@ -119,6 +116,7 @@ private: std::string auth_password_; PolicyType type_; bool can_create_window_ = true; + bool deleted_ = false; }; #endif // ewk_policy_decision_private_h diff --git a/tizen_src/ewk/efl_integration/public/ewk_policy_decision.cc b/tizen_src/ewk/efl_integration/public/ewk_policy_decision.cc index 50b8a9a0..caa6621 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_policy_decision.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_policy_decision.cc @@ -143,6 +143,6 @@ Eina_Bool ewk_policy_decision_is_main_frame(const Ewk_Policy_Decision* policyDec const char* ewk_policy_decision_http_body_get(Ewk_Policy_Decision* policyDecision) { - LOG_EWK_API_MOCKUP(); - return NULL; + EINA_SAFETY_ON_NULL_RETURN_VAL(policyDecision, NULL); + return policyDecision->GetHttpBody(); } diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_policy_decision_scheme_get_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_policy_decision_scheme_get_func.cpp old mode 100755 new mode 100644 index 547e681..fb48564 --- a/tizen_src/ewk/unittest/utc_blink_ewk_policy_decision_scheme_get_func.cpp +++ b/tizen_src/ewk/unittest/utc_blink_ewk_policy_decision_scheme_get_func.cpp @@ -1,4 +1,4 @@ -// Copyright 2014 Samsung Electronics. All rights reserved. +// Copyright 2014-2016 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. @@ -13,47 +13,66 @@ protected: evas_object_smart_callback_add(GetEwkWebView(), "policy,navigation,decide", policy_navigation_decide, this); } - void PreTearDown() - { - evas_object_smart_callback_del(GetEwkWebView(), "policy,navigation,decide", policy_navigation_decide); - } + utc_blink_ewk_policy_decision_scheme_get() : received_scheme_(nullptr) {} - void LoadFinished(Evas_Object* webview) { - - EventLoopStop(utc_blink_ewk_base::Failure); + void PreTearDown() { + evas_object_smart_callback_del(GetEwkWebView(), "policy,navigation,decide", + policy_navigation_decide); } - static void policy_navigation_decide(void* data, Evas_Object* webview, void* event_info) - { + static void policy_navigation_decide(void* data, + Evas_Object* webview, + void* event_info) { utc_message("[policy_navigation_decide] :: \n"); - utc_blink_ewk_policy_decision_scheme_get *owner = static_cast(data); - Ewk_Policy_Decision* policy_decision = (Ewk_Policy_Decision*)event_info; + auto owner = static_cast(data); + auto policy_decision = static_cast(event_info); + if (!policy_decision) { + utc_message("[policy_navigation_decide] :: policy_decision is nullptr"); + owner->EventLoopStop(Failure); + return; + } + owner->received_scheme_ = ewk_policy_decision_scheme_get(policy_decision); + owner->EventLoopStop(Success); + } - if (policy_decision && ewk_policy_decision_scheme_get(policy_decision)) { + static void job_do_http(utc_blink_ewk_base* data) { + auto owner = static_cast(data); + ASSERT_EQ(EINA_TRUE, ewk_view_url_set(owner->GetEwkWebView(), + "http://www.google.com")); + } - owner->EventLoopStop(utc_blink_ewk_base::Success); - } + static void job_do_mailto(utc_blink_ewk_base* data) { + auto owner = static_cast(data); + ASSERT_EQ(EINA_TRUE, ewk_view_url_set(owner->GetEwkWebView(), + "mailto:someone@example.com")); } + + const char* received_scheme_; }; /** - * @brief Tests if the scheme for policy decision is returned properly. + * @brief Tests if the scheme for policy decision is returned properly. Expected + * scheme is http. + */ +TEST_F(utc_blink_ewk_policy_decision_scheme_get, POS_HTTP) { + SetTestJob(utc_blink_ewk_policy_decision_scheme_get::job_do_http); + ASSERT_EQ(Success, EventLoopStart()); + ASSERT_STREQ("http", received_scheme_); +} + +/** + * @brief Tests if the scheme for policy decision is returned properly. Expected + * scheme is mailto. */ -TEST_F(utc_blink_ewk_policy_decision_scheme_get, POS_TEST) -{ - Eina_Bool result = ewk_view_url_set(GetEwkWebView(), "http://www.google.com"); - if (!result) - FAIL(); - - utc_blink_ewk_base::MainLoopResult main_result = EventLoopStart(); - if (main_result != utc_blink_ewk_base::Success) - FAIL(); +TEST_F(utc_blink_ewk_policy_decision_scheme_get, POS_MAILTO) { + SetTestJob(utc_blink_ewk_policy_decision_scheme_get::job_do_mailto); + ASSERT_EQ(Success, EventLoopStart()); + ASSERT_STREQ("mailto", received_scheme_); } /** * @brief Tests if function works properly in case of NULL of a webview */ -TEST_F(utc_blink_ewk_policy_decision_scheme_get, NEG_TEST) -{ - utc_check_eq(0, ewk_policy_decision_scheme_get(0)); +TEST_F(utc_blink_ewk_policy_decision_scheme_get, NEG_INVALID_PARAM) { + ASSERT_EQ(nullptr, ewk_policy_decision_scheme_get(nullptr)); } -- 2.7.4 From 781ab3c3667d3068266489110a988accec86f4fb Mon Sep 17 00:00:00 2001 From: "ayush.k123" Date: Mon, 16 Jan 2023 16:38:18 +0530 Subject: [PATCH 08/16] [M108 Migration][Sensor] Generic Sensor implementation This patch adds implementation of generic sensors to return sensor readings for types ACCELEROMETER, LINEAR_ACCELERATION & GYROSCOPE. References: https://review.tizen.org/gerrit/274260/ Change-Id: I22e22a07d926a1ec87d59206ebc65dcf18da1f5c Signed-off-by: Ayush Kumar --- services/device/generic_sensor/BUILD.gn | 8 + .../generic_sensor/platform_sensor_provider.cc | 4 + .../device/generic_sensor/generic_sensor_efl.gni | 12 + .../device/generic_sensor/platform_sensor_efl.cc | 93 ++++++++ .../device/generic_sensor/platform_sensor_efl.h | 56 +++++ .../generic_sensor/platform_sensor_provider_efl.cc | 40 ++++ .../generic_sensor/platform_sensor_provider_efl.h | 41 ++++ .../generic_sensor/platform_sensor_reader_efl.cc | 245 +++++++++++++++++++++ .../generic_sensor/platform_sensor_reader_efl.h | 95 ++++++++ 9 files changed, 594 insertions(+) create mode 100644 tizen_src/chromium_impl/services/device/generic_sensor/generic_sensor_efl.gni create mode 100644 tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.cc create mode 100644 tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.h create mode 100644 tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.cc create mode 100644 tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.h create mode 100644 tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.cc create mode 100644 tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.h diff --git a/services/device/generic_sensor/BUILD.gn b/services/device/generic_sensor/BUILD.gn index d42193d..f477eef 100644 --- a/services/device/generic_sensor/BUILD.gn +++ b/services/device/generic_sensor/BUILD.gn @@ -13,6 +13,10 @@ if (is_android) { import("//build/config/android/rules.gni") # For generate_jni(). } +if (is_tizen) { + import("//tizen_src/chromium_impl/services/device/generic_sensor/generic_sensor_efl.gni") +} + source_set("generic_sensor") { visibility = [ "//services/device:*" ] @@ -92,6 +96,10 @@ source_set("generic_sensor") { ] } + if (is_tizen) { + sources += external_device_sensor_efl_sources + } + if (is_chromeos) { deps += [ "//chromeos/components/sensors:buildflags" ] } diff --git a/services/device/generic_sensor/platform_sensor_provider.cc b/services/device/generic_sensor/platform_sensor_provider.cc index bfcbd5b..b74b46b 100644 --- a/services/device/generic_sensor/platform_sensor_provider.cc +++ b/services/device/generic_sensor/platform_sensor_provider.cc @@ -14,6 +14,8 @@ #include "services/device/generic_sensor/platform_sensor_provider_mac.h" #elif BUILDFLAG(IS_ANDROID) #include "services/device/generic_sensor/platform_sensor_provider_android.h" +#elif BUILDFLAG(IS_TIZEN) +#include "services/device/generic_sensor/platform_sensor_provider_efl.h" #elif BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" #include "build/build_config.h" @@ -37,6 +39,8 @@ std::unique_ptr PlatformSensorProvider::Create() { return std::make_unique(); #elif BUILDFLAG(IS_ANDROID) return std::make_unique(); +#elif BUILDFLAG(IS_TIZEN) + return std::make_unique(); #elif BUILDFLAG(IS_WIN) if (PlatformSensorProvider::UseWindowsWinrt()) { return std::make_unique(); diff --git a/tizen_src/chromium_impl/services/device/generic_sensor/generic_sensor_efl.gni b/tizen_src/chromium_impl/services/device/generic_sensor/generic_sensor_efl.gni new file mode 100644 index 0000000..aa27c2c --- /dev/null +++ b/tizen_src/chromium_impl/services/device/generic_sensor/generic_sensor_efl.gni @@ -0,0 +1,12 @@ +# Copyright (c) 2019 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. + +external_device_sensor_efl_sources = [ + "//tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.cc", + "//tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.h", + "//tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.cc", + "//tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.h", + "//tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.cc", + "//tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.h", +] diff --git a/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.cc b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.cc new file mode 100644 index 0000000..59a3966 --- /dev/null +++ b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.cc @@ -0,0 +1,93 @@ +// Copyright (c) 2019 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 "services/device/generic_sensor/platform_sensor_efl.h" + +#include "base/time/time.h" +#include "services/device/generic_sensor/platform_sensor_reader_efl.h" +#include "tizen/system_info.h" + +namespace device { + +namespace { + +// Checks if at least one value has been changed. +bool HaveValuesChanged(const SensorReading& lhs, const SensorReading& rhs) { + if (IsEmulatorArch()) { + // On emulators, sensor readings are constant unless changed in control + // panel sensor sliders, because of which few devicemotion web-tct + // failures were seen on testhub. To avoid the same, we skip below values + // comparison and force send to blink for succesfully dispatching events. + return true; + } + + for (size_t i = 0; i < SensorReadingRaw::kValuesCount; ++i) { + if (lhs.raw.values[i] != rhs.raw.values[i]) + return true; + } + return false; +} + +} // namespace + +PlatformSensorEfl::PlatformSensorEfl(mojom::SensorType type, + SensorReadingSharedBuffer* reading_buffer, + PlatformSensorProvider* provider) + : PlatformSensor(type, reading_buffer, provider), + default_configuration_(PlatformSensorConfiguration()), + weak_factory_(this) { + sensor_reader_ = SensorReaderEfl::Create(weak_factory_.GetWeakPtr(), type); +} + +PlatformSensorEfl::~PlatformSensorEfl() { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); +} + +mojom::ReportingMode PlatformSensorEfl::GetReportingMode() { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); + return mojom::ReportingMode::ON_CHANGE; +} + +void PlatformSensorEfl::UpdatePlatformSensorReading(SensorReading reading) { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); + if (GetReportingMode() == mojom::ReportingMode::ON_CHANGE && + !HaveValuesChanged(reading, old_values_)) { + return; + } + old_values_ = reading; + reading.raw.timestamp = + (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); + UpdateSharedBufferAndNotifyClients(reading); +} + +void PlatformSensorEfl::NotifyPlatformSensorError() { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); + NotifySensorError(); +} + +bool PlatformSensorEfl::StartSensor( + const PlatformSensorConfiguration& configuration) { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); + sensor_reader_->StartFetchingData(configuration); + return true; +} + +void PlatformSensorEfl::StopSensor() { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); + sensor_reader_->StopFetchingData(); +} + +bool PlatformSensorEfl::CheckSensorConfiguration( + const PlatformSensorConfiguration& configuration) { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); + return configuration.frequency() > 0 && + configuration.frequency() <= default_configuration_.frequency(); +} + +PlatformSensorConfiguration PlatformSensorEfl::GetDefaultConfiguration() { + DCHECK(main_task_runner()->RunsTasksInCurrentSequence()); + return default_configuration_; +} + +} // namespace device diff --git a/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.h b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.h new file mode 100644 index 0000000..a9fcd98 --- /dev/null +++ b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_efl.h @@ -0,0 +1,56 @@ +// Copyright (c) 2019 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 SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_EFL_H_ +#define SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_EFL_H_ + +#include "services/device/generic_sensor/platform_sensor.h" + +namespace device { + +class SensorReaderEfl; + +class PlatformSensorEfl : public PlatformSensor { + public: + PlatformSensorEfl(mojom::SensorType type, + SensorReadingSharedBuffer* reading_buffer, + PlatformSensorProvider* provider); + + PlatformSensorEfl(const PlatformSensorEfl&) = delete; + PlatformSensorEfl& operator=(const PlatformSensorEfl&) = delete; + + mojom::ReportingMode GetReportingMode() override; + + // Called by a sensor reader. Takes new readings. + void UpdatePlatformSensorReading(SensorReading reading); + + // Called by a sensor reader if an error occurs. + void NotifyPlatformSensorError(); + + protected: + ~PlatformSensorEfl() override; + bool StartSensor(const PlatformSensorConfiguration& configuration) override; + void StopSensor() override; + bool CheckSensorConfiguration( + const PlatformSensorConfiguration& configuration) override; + PlatformSensorConfiguration GetDefaultConfiguration() override; + + private: + const PlatformSensorConfiguration default_configuration_; + + // A sensor reader that reads values from sensor files + // and stores them to a SensorReading structure. + std::unique_ptr sensor_reader_; + + // Stores previously read values that are used to + // determine whether the recent values are changed + // and IPC can be notified that updates are available. + SensorReading old_values_; + + base::WeakPtrFactory weak_factory_; +}; + +} // namespace device + +#endif // SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_EFL_H_ diff --git a/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.cc b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.cc new file mode 100644 index 0000000..1b67c26 --- /dev/null +++ b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2019 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 "services/device/generic_sensor/platform_sensor_provider_efl.h" + +#include +#include + +#include "base/memory/ref_counted.h" +#include "base/memory/singleton.h" +#include "services/device/generic_sensor/platform_sensor_efl.h" +#include "services/device/generic_sensor/platform_sensor_reader_efl.h" + +namespace device { + +PlatformSensorProviderEfl::PlatformSensorProviderEfl() {} + +PlatformSensorProviderEfl::~PlatformSensorProviderEfl() {} + +void PlatformSensorProviderEfl::CreateSensorInternal( + mojom::SensorType type, + SensorReadingSharedBuffer* reading_buffer, + CreateSensorCallback callback) { + if (!SensorReaderEfl::IsSensorTypeSupported(type)) { + std::move(callback).Run(nullptr); + return; + } + + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + scoped_refptr sensor = + new PlatformSensorEfl(type, reading_buffer, this); + std::move(callback).Run(sensor); +} + +void PlatformSensorProviderEfl::FreeResources() { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); +} + +} // namespace device diff --git a/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.h b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.h new file mode 100644 index 0000000..d382187 --- /dev/null +++ b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_provider_efl.h @@ -0,0 +1,41 @@ +// Copyright (c) 2019 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 SERVICES_DEVICE_GENERIC_SENSOR_PUBLIC_PLATFORM_SENSOR_PROVIDER_EFL_H_ +#define SERVICES_DEVICE_GENERIC_SENSOR_PUBLIC_PLATFORM_SENSOR_PROVIDER_EFL_H_ + +#include "services/device/generic_sensor/platform_sensor_provider.h" + +namespace base { +template +struct DefaultSingletonTraits; +} // namespace base + +namespace device { + +class PlatformSensorEfl; + +class PlatformSensorProviderEfl : public PlatformSensorProvider { + public: + PlatformSensorProviderEfl(); + ~PlatformSensorProviderEfl() override; + + PlatformSensorProviderEfl(const PlatformSensorProviderEfl&) = delete; + PlatformSensorProviderEfl& operator=(const PlatformSensorProviderEfl&) = + delete; + + protected: + void CreateSensorInternal(mojom::SensorType type, + SensorReadingSharedBuffer* reading_buffer, + CreateSensorCallback callback) override; + + void FreeResources() override; + + private: + friend struct base::DefaultSingletonTraits; +}; + +} // namespace device + +#endif // SERVICES_DEVICE_GENERIC_SENSOR_PUBLIC_PLATFORM_SENSOR_PROVIDER_EFL_H_ diff --git a/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.cc b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.cc new file mode 100644 index 0000000..efdd097 --- /dev/null +++ b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.cc @@ -0,0 +1,245 @@ +// Copyright (c) 2019 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 "services/device/generic_sensor/platform_sensor_reader_efl.h" + +#include "base/threading/thread_restrictions.h" +#include "services/device/generic_sensor/platform_sensor_efl.h" + +namespace device { + +// static +bool SensorReaderEfl::IsSensorTypeSupported(mojom::SensorType type) { + sensor_type_e sensor_type; + switch (type) { + case mojom::SensorType::ACCELEROMETER: + case mojom::SensorType::LINEAR_ACCELERATION: + sensor_type = SENSOR_ACCELEROMETER; + break; + case mojom::SensorType::ABSOLUTE_ORIENTATION_EULER_ANGLES: + case mojom::SensorType::RELATIVE_ORIENTATION_EULER_ANGLES: + case mojom::SensorType::GYROSCOPE: + sensor_type = SENSOR_GYROSCOPE; + break; + default: + return false; + } + + bool supported = false; + sensor_is_supported(sensor_type, &supported); + if (!supported) + LOG(INFO) << "Sensor type : " << type << " not supported!"; + else + LOG(INFO) << "Sensor type : " << type << " is supported.."; + + return supported; +} + +// static +std::unique_ptr SensorReaderEfl::Create( + base::WeakPtr sensor, + mojom::SensorType type) { + return std::make_unique(sensor, type); +} + +SensorReaderEfl::~SensorReaderEfl() { + if (sensor_accelerometer_) { + sensor_listener_unset_event_cb(listener_accelerometer_); + sensor_listener_stop(listener_accelerometer_); + sensor_destroy_listener(listener_accelerometer_); + } + + if (sensor_gyroscope_) { + sensor_listener_stop(listener_gyroscope_); + sensor_destroy_listener(listener_gyroscope_); + } +} + +SensorReaderEfl::SensorReaderEfl(base::WeakPtr sensor, + mojom::SensorType type) + : sensor_(sensor), is_reading_active_(false), type_(type) { + sensor_accelerometer_ = nullptr; + sensor_gyroscope_ = nullptr; + listener_accelerometer_ = nullptr; + listener_gyroscope_ = nullptr; + has_last_reading_ = false; + + Initialize(); +} + +void SensorReaderEfl::Initialize() { + switch (type_) { + case mojom::SensorType::ACCELEROMETER: + case mojom::SensorType::LINEAR_ACCELERATION: + sensor_get_default_sensor(SENSOR_ACCELEROMETER, &sensor_accelerometer_); + if (sensor_accelerometer_) + sensor_create_listener(sensor_accelerometer_, &listener_accelerometer_); + break; + case mojom::SensorType::ABSOLUTE_ORIENTATION_EULER_ANGLES: + case mojom::SensorType::RELATIVE_ORIENTATION_EULER_ANGLES: + case mojom::SensorType::GYROSCOPE: + sensor_get_default_sensor(SENSOR_GYROSCOPE, &sensor_gyroscope_); + if (sensor_gyroscope_) + sensor_create_listener(sensor_gyroscope_, &listener_gyroscope_); + break; + default: + return; + } +} + +void SensorReaderEfl::StartFetchingData( + const PlatformSensorConfiguration& configuration) { + if (is_reading_active_) + StopFetchingData(); + + SetListenerCallbacks(); +} + +void SensorReaderEfl::StopFetchingData() { + is_reading_active_ = false; + + UnsetListenerCallbacks(); +} + +void SensorReaderEfl::SetListenerCallbacks() { + switch (type_) { + case mojom::SensorType::ACCELEROMETER: + case mojom::SensorType::LINEAR_ACCELERATION: { + int min_interval = 0; + sensor_get_min_interval(&sensor_accelerometer_, &min_interval); + sensor_listener_set_event_cb(listener_accelerometer_, min_interval, + SensorReaderEfl::OnSensorDataChanged, this); + if (SENSOR_ERROR_NONE == sensor_listener_start(listener_accelerometer_)) + LOG(INFO) << "Accelerometer Listener started"; + else + LOG(INFO) << "Accelerometer Listener failed to start"; + break; + } + case mojom::SensorType::ABSOLUTE_ORIENTATION_EULER_ANGLES: + case mojom::SensorType::RELATIVE_ORIENTATION_EULER_ANGLES: + case mojom::SensorType::GYROSCOPE: { + int min_interval = 0; + sensor_get_min_interval(&sensor_gyroscope_, &min_interval); + sensor_listener_set_event_cb(listener_gyroscope_, min_interval, + SensorReaderEfl::OnSensorDataChanged, this); + if (SENSOR_ERROR_NONE == sensor_listener_start(listener_gyroscope_)) + LOG(INFO) << "Gyroscope Listener started"; + else + LOG(INFO) << "Gyroscope Listener failed to start"; + break; + } + default: + return; + } + + is_reading_active_ = true; +} + +void SensorReaderEfl::UnsetListenerCallbacks() { + if (sensor_accelerometer_) { + sensor_listener_unset_event_cb(listener_accelerometer_); + sensor_listener_stop(listener_accelerometer_); + } + if (sensor_gyroscope_) + sensor_listener_stop(listener_gyroscope_); +} + +void SensorReaderEfl::OnSensorDataChanged(sensor_h sensor, + sensor_event_s* event, + void* user_data) { + SensorReaderEfl* self = static_cast(user_data); + SensorReading readings; + + switch (self->type_) { + case mojom::SensorType::LINEAR_ACCELERATION: { + double x = event->values[0]; + double y = event->values[1]; + double z = event->values[2]; + + double gravityX = x * 0.2f; + double gravityY = y * 0.2f; + double gravityZ = z * 0.2f; + + if (self->has_last_reading_) { + gravityX += (self->last_reading_.acceleration_including_gravity.x - + self->last_reading_.linear_acceleration.x) * + 0.8f; + gravityY += (self->last_reading_.acceleration_including_gravity.y - + self->last_reading_.linear_acceleration.y) * + 0.8f; + gravityZ += (self->last_reading_.acceleration_including_gravity.z - + self->last_reading_.linear_acceleration.z) * + 0.8f; + } + + readings.accel.x = x - gravityX; + readings.accel.y = y - gravityX; + readings.accel.z = z - gravityZ; + + self->last_reading_.acceleration_including_gravity.x = x; + self->last_reading_.acceleration_including_gravity.y = y; + self->last_reading_.acceleration_including_gravity.z = z; + + self->last_reading_.linear_acceleration.x = readings.accel.x; + self->last_reading_.linear_acceleration.y = readings.accel.y; + self->last_reading_.linear_acceleration.z = readings.accel.z; + self->has_last_reading_ = true; + break; + } + case mojom::SensorType::ACCELEROMETER: { + readings.accel.x = event->values[0]; + readings.accel.y = event->values[1]; + readings.accel.z = event->values[2]; + break; + } + case mojom::SensorType::ABSOLUTE_ORIENTATION_EULER_ANGLES: + case mojom::SensorType::RELATIVE_ORIENTATION_EULER_ANGLES: { + // For orientation data, capture gyroscope readings and write to + // |orientation_euler| + sensor_event_s event_gyroscope; + if (SENSOR_ERROR_NONE == + sensor_listener_read_data(self->listener_gyroscope_, + &event_gyroscope)) { + LOG(INFO) << "Rotation rate available"; + readings.orientation_euler.x = event_gyroscope.values[0]; + readings.orientation_euler.y = event_gyroscope.values[1]; + readings.orientation_euler.z = event_gyroscope.values[2]; + } + break; + } + case mojom::SensorType::GYROSCOPE: { + sensor_event_s event_gyroscope; + if (SENSOR_ERROR_NONE == + sensor_listener_read_data(self->listener_gyroscope_, + &event_gyroscope)) { + LOG(INFO) << "Rotation rate available"; + readings.gyro.x = event_gyroscope.values[0]; + readings.gyro.y = event_gyroscope.values[1]; + readings.gyro.z = event_gyroscope.values[2]; + } + break; + } + default: + LOG(INFO) << "Unknown sensor type!"; + return; + } + + // Update readings to shared buffer + if (self->is_reading_active_ && self->sensor_) { + self->sensor_->PostTaskToMainSequence( + FROM_HERE, + base::BindOnce(&PlatformSensorEfl::UpdatePlatformSensorReading, + self->sensor_, readings)); + } +} + +void SensorReaderEfl::NotifyReadError() { + if (is_reading_active_ && sensor_) { + sensor_->PostTaskToMainSequence( + FROM_HERE, + base::BindOnce(&PlatformSensorEfl::NotifyPlatformSensorError, sensor_)); + } +} + +} // namespace device diff --git a/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.h b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.h new file mode 100644 index 0000000..2bbe67f --- /dev/null +++ b/tizen_src/chromium_impl/services/device/generic_sensor/platform_sensor_reader_efl.h @@ -0,0 +1,95 @@ +// Copyright (c) 2019 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 SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_EFL_H_ +#define SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_EFL_H_ + +#include + +#include "base/callback.h" +#include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" +#include "services/device/public/cpp/generic_sensor/sensor_reading.h" +#include "services/device/public/mojom/sensor.mojom.h" + +namespace base { +class SingleThreadTaskRunner; +} + +namespace device { + +class PlatformSensorConfiguration; +class PlatformSensorEfl; + +// A generic reader class that can be implemented with two different strategies: +// polling and on trigger. All methods are not thread-safe and must be called +// on a polling thread that allows I/O. +class SensorReaderEfl { + public: + // Creates a new instance of SensorReaderEfl. At the moment, only polling + // reader is supported. + static std::unique_ptr Create( + base::WeakPtr sensor, + mojom::SensorType type); + + SensorReaderEfl(base::WeakPtr sensor, + mojom::SensorType type); + ~SensorReaderEfl(); + + SensorReaderEfl(const SensorReaderEfl&) = delete; + SensorReaderEfl& operator=(const SensorReaderEfl&) = delete; + + // Starts fetching data based on strategy this reader has chosen. + // Only polling strategy is supported at the moment. + void StartFetchingData(const PlatformSensorConfiguration& configuration); + // Stops fetching data. + void StopFetchingData(); + + static void OnSensorDataChanged(sensor_h sensor, + sensor_event_s* event, + void* user_data); + static bool IsSensorTypeSupported(mojom::SensorType type); + + private: + // Initializes system sensor handles and sets/unsets listener callbacks. + void Initialize(); + void SetListenerCallbacks(); + void UnsetListenerCallbacks(); + + // A sensor that this reader is owned by and notifies about errors and + // readings to. + base::WeakPtr sensor_; + + // A task runner that is used to report about new readings and errors + // to a |sensor_|. + scoped_refptr task_runner_; + + // Indicates if reading is active. + bool is_reading_active_; + + // Notifies |sensor_| about an error. + void NotifyReadError(); + + // Sensor type + mojom::SensorType type_; + + // Previously calculated readings used for calculating Linear Acceleration. + struct LastReading { + SensorReadingXYZ acceleration_including_gravity; + SensorReadingXYZ linear_acceleration; + }; + struct LastReading last_reading_; + bool has_last_reading_; + + // capi-system-sensor handles. + sensor_h sensor_accelerometer_; + sensor_h sensor_gyroscope_; + sensor_listener_h listener_accelerometer_; + sensor_listener_h listener_gyroscope_; +}; + +} // namespace device + +#endif // SERVICES_DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_READER_EFL_H_ -- 2.7.4 From 4e8668a53254521f3782a9c1ade6c30e56b255dc Mon Sep 17 00:00:00 2001 From: Gajendra N Date: Fri, 13 Jan 2023 11:55:34 +0530 Subject: [PATCH 09/16] [M108 Migration][IME] Support IME additional functionalities Functionalities: 1) Notify FocusedNodeChanged and TextInputStateChanged status 2) New parameters during FocusedNodeChanged: password_minlength, radio_or_checkbox, input_maxlength, editable etc. 3) |is_in_form_tag| check 4) inputDevice and remote control info 5) Few other IME related changes, etc. References: https://review.tizen.org/gerrit/279650 https://review.tizen.org/gerrit/284673 Change-Id: I3cf646b83727a2aa6d3f23216afa22e972eb80e6 Signed-off-by: Gajendra N --- .../renderer_host/render_frame_host_delegate.h | 8 ++- .../renderer_host/render_frame_host_impl.cc | 10 ++- .../browser/renderer_host/render_frame_host_impl.h | 8 ++- .../renderer_host/render_widget_host_view_aura.cc | 30 ++++++++- .../renderer_host/render_widget_host_view_aura.h | 11 +++- .../renderer_host/render_widget_host_view_base.h | 10 ++- content/browser/web_contents/web_contents_impl.cc | 17 ++++- content/browser/web_contents/web_contents_impl.h | 8 ++- .../web_coalesced_input_event_mojom_traits.cc | 14 +++- .../blink/public/common/input/web_keyboard_event.h | 22 +++++++ third_party/blink/public/mojom/BUILD.gn | 7 ++ third_party/blink/public/mojom/frame/frame.mojom | 9 ++- .../blink/public/mojom/input/input_handler.mojom | 7 ++ .../blink/public/platform/web_text_input_info.h | 5 ++ third_party/blink/public/web/web_input_element.h | 3 + third_party/blink/renderer/core/dom/document.cc | 66 ++++++++++++++++++- .../core/editing/ime/input_method_controller.cc | 14 ++++ .../core/editing/ime/input_method_controller.h | 4 ++ .../blink/renderer/core/events/keyboard_event.cc | 8 +++ .../blink/renderer/core/events/keyboard_event.h | 1 + .../blink/renderer/core/events/keyboard_event.idl | 3 + .../renderer/core/exported/web_input_element.cc | 6 ++ .../renderer/core/frame/web_frame_widget_impl.cc | 8 +++ .../widget/input/widget_base_input_handler.cc | 15 +++++ .../blink/renderer/platform/widget/widget_base.cc | 13 ++++ .../blink/renderer/platform/widget/widget_base.h | 8 +++ .../rwhv_aura_offscreen_helper_efl.cc | 77 ++++++++++++++++++++++ .../renderer_host/rwhv_aura_offscreen_helper_efl.h | 20 ++++++ .../ozone/platform/efl/efl_input_method_context.cc | 9 +++ .../ui/ozone/platform/efl/efl_keycode_map.h | 20 ++++++ .../ui/ozone/platform/efl/im_context_efl.cc | 19 ++++++ ui/base/ime/mojom/BUILD.gn | 5 ++ ui/base/ime/mojom/text_input_state.mojom | 7 ++ ui/events/blink/web_input_event_traits.cc | 9 +++ ui/events/event.cc | 12 ++++ ui/events/keycodes/keyboard_codes_posix.h | 9 +++ 36 files changed, 486 insertions(+), 16 deletions(-) diff --git a/content/browser/renderer_host/render_frame_host_delegate.h b/content/browser/renderer_host/render_frame_host_delegate.h index 3cd9dd8..b27e11e 100644 --- a/content/browser/renderer_host/render_frame_host_delegate.h +++ b/content/browser/renderer_host/render_frame_host_delegate.h @@ -381,7 +381,13 @@ class CONTENT_EXPORT RenderFrameHostDelegate { virtual void OnFocusedElementChangedInFrame( RenderFrameHostImpl* frame, const gfx::Rect& bounds_in_root_view, - blink::mojom::FocusType focus_type) {} + blink::mojom::FocusType focus_type +#if BUILDFLAG(IS_EFL) + , + blink::mojom::FocusedNodeChangedParamsPtr params +#endif + ) { + } // The page is trying to open a new page (e.g. a popup window). The window // should be created associated the process of |opener|, but it should not diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index e4e16cc..c735f4a 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc @@ -6821,7 +6821,8 @@ void RenderFrameHostImpl::DidDispatchDOMContentLoadedEvent() { void RenderFrameHostImpl::FocusedElementChanged( bool is_editable_element, const gfx::Rect& bounds_in_frame_widget, - blink::mojom::FocusType focus_type) { + blink::mojom::FocusType focus_type, + blink::mojom::FocusedNodeChangedParamsPtr params) { if (!GetView()) return; @@ -6832,7 +6833,12 @@ void RenderFrameHostImpl::FocusedElementChanged( gfx::Rect(GetView()->TransformPointToRootCoordSpace( bounds_in_frame_widget.origin()), bounds_in_frame_widget.size()), - focus_type); + focus_type +#if BUILDFLAG(IS_EFL) + , + std::move(params) +#endif + ); } void RenderFrameHostImpl::TextSelectionChanged(const std::u16string& text, diff --git a/content/browser/renderer_host/render_frame_host_impl.h b/content/browser/renderer_host/render_frame_host_impl.h index 246afde..db82798 100644 --- a/content/browser/renderer_host/render_frame_host_impl.h +++ b/content/browser/renderer_host/render_frame_host_impl.h @@ -2204,9 +2204,11 @@ class CONTENT_EXPORT RenderFrameHostImpl void UpdateFaviconURL( std::vector favicon_urls) override; void DownloadURL(blink::mojom::DownloadURLParamsPtr params) override; - void FocusedElementChanged(bool is_editable_element, - const gfx::Rect& bounds_in_frame_widget, - blink::mojom::FocusType focus_type) override; + void FocusedElementChanged( + bool is_editable_element, + const gfx::Rect& bounds_in_frame_widget, + blink::mojom::FocusType focus_type, + blink::mojom::FocusedNodeChangedParamsPtr params) override; void TextSelectionChanged(const std::u16string& text, uint32_t offset, const gfx::Range& range) override; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 297f4dc..fcee03c 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -578,6 +578,14 @@ void RenderWidgetHostViewAura::SelectionChanged(const std::u16string& text, if (offscreen_helper_) offscreen_helper_->SelectionChanged(text, offset, range); } + +void RenderWidgetHostViewAura::TextInputStateChanged( + const ui::mojom::TextInputState& params) { + RenderWidgetHostViewBase::TextInputStateChanged(params); + + if (offscreen_helper_) + offscreen_helper_->TextInputStateChanged(params); +} #endif void RenderWidgetHostViewAura::EnsureSurfaceSynchronizedForWebTest() { @@ -650,6 +658,11 @@ void RenderWidgetHostViewAura::HideImpl() { DCHECK(visibility_ == Visibility::HIDDEN || visibility_ == Visibility::OCCLUDED); +#if BUILDFLAG(IS_EFL) + if (offscreen_helper_) + offscreen_helper_->Hide(); +#endif + if (!host()->is_hidden()) { host()->WasHidden(); aura::WindowTreeHost* host = window_->GetHost(); @@ -2049,7 +2062,14 @@ viz::SurfaceId RenderWidgetHostViewAura::GetCurrentSurfaceId() const { void RenderWidgetHostViewAura::FocusedNodeChanged( bool editable, - const gfx::Rect& node_bounds_in_screen) { + const gfx::Rect& node_bounds_in_screen +#if BUILDFLAG(IS_TIZEN_TV) + , + bool is_radio_or_checkbox, + int password_input_minlength, + int input_maxlength +#endif +) { // The last gesture most likely caused the focus change. The focus reason will // be incorrect if the focus was triggered without a user gesture. // TODO(https://crbug.com/824604): Get the focus reason from the renderer @@ -2061,6 +2081,14 @@ void RenderWidgetHostViewAura::FocusedNodeChanged( input_method->CancelComposition(this); has_composition_text_ = false; +#if BUILDFLAG(IS_TIZEN_TV) + if (offscreen_helper_) { + offscreen_helper_->FocusedNodeChanged(editable, is_radio_or_checkbox, + password_input_minlength, + input_maxlength); + } +#endif + #if BUILDFLAG(IS_WIN) if (window_ && virtual_keyboard_controller_win_) { virtual_keyboard_controller_win_->FocusedNodeChanged(editable); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index f106b68..fa5af30 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -201,7 +201,15 @@ class CONTENT_EXPORT RenderWidgetHostViewAura viz::FrameSinkId GetRootFrameSinkId() override; viz::SurfaceId GetCurrentSurfaceId() const override; void FocusedNodeChanged(bool is_editable_node, - const gfx::Rect& node_bounds_in_screen) override; + const gfx::Rect& node_bounds_in_screen +#if BUILDFLAG(IS_TIZEN_TV) + , + bool is_radio_or_checkbox, + int password_input_minlength, + int input_maxlength +#endif + ) override; + void OnSynchronizedDisplayPropertiesChanged(bool rotation = false) override; viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties( const cc::RenderFrameMetadata& metadata) override; @@ -415,6 +423,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura void SelectionChanged(const std::u16string& text, size_t offset, const gfx::Range& range) override; + void TextInputStateChanged(const ui::mojom::TextInputState& params) override; #endif protected: diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index ec2b115..ee2ad3c 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -248,7 +248,15 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView { virtual void SetMainFrameAXTreeID(ui::AXTreeID id) {} // Informs that the focused DOM node has changed. virtual void FocusedNodeChanged(bool is_editable_node, - const gfx::Rect& node_bounds_in_screen) {} + const gfx::Rect& node_bounds_in_screen +#if BUILDFLAG(IS_TIZEN_TV) + , + bool is_radio_or_checkbox, + int password_input_minlength, + int input_maxlength +#endif + ) { + } // Requests to start stylus writing and returns true if successful. virtual bool RequestStartStylusWriting(); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 5b8d390..0d4eb02 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -7934,7 +7934,12 @@ void WebContentsImpl::OnAdvanceFocus(RenderFrameHostImpl* source_rfh) { void WebContentsImpl::OnFocusedElementChangedInFrame( RenderFrameHostImpl* frame, const gfx::Rect& bounds_in_root_view, - blink::mojom::FocusType focus_type) { + blink::mojom::FocusType focus_type +#if BUILDFLAG(IS_EFL) + , + blink::mojom::FocusedNodeChangedParamsPtr params +#endif +) { OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::OnFocusedElementChangedInFrame", "render_frame_host", frame); @@ -7948,8 +7953,14 @@ void WebContentsImpl::OnFocusedElementChangedInFrame( origin += root_view->GetViewBounds().OffsetFromOrigin(); gfx::Rect bounds_in_screen(origin, bounds_in_root_view.size()); - root_view->FocusedNodeChanged(frame->has_focused_editable_element(), - bounds_in_screen); + root_view->FocusedNodeChanged( + frame->has_focused_editable_element(), bounds_in_screen +#if BUILDFLAG(IS_TIZEN_TV) + , + params->is_radio_or_checkbox_input_node, params->password_input_minlength, + params->input_maxlength +#endif + ); FocusedNodeDetails details = {frame->has_focused_editable_element(), bounds_in_screen, focus_type}; diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index f8d6342..bd28298 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -701,7 +701,13 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, void OnFocusedElementChangedInFrame( RenderFrameHostImpl* frame, const gfx::Rect& bounds_in_root_view, - blink::mojom::FocusType focus_type) override; + blink::mojom::FocusType focus_type +#if BUILDFLAG(IS_EFL) + , + blink::mojom::FocusedNodeChangedParamsPtr params +#endif + ) override; + void OnAdvanceFocus(RenderFrameHostImpl* source_rfh) override; FrameTree* CreateNewWindow( RenderFrameHostImpl* opener, diff --git a/third_party/blink/common/input/web_coalesced_input_event_mojom_traits.cc b/third_party/blink/common/input/web_coalesced_input_event_mojom_traits.cc index 053d68b..7fc97c7 100644 --- a/third_party/blink/common/input/web_coalesced_input_event_mojom_traits.cc +++ b/third_party/blink/common/input/web_coalesced_input_event_mojom_traits.cc @@ -118,6 +118,13 @@ bool StructTraitsis_browser_shortcut = key_data->is_browser_shortcut; CopyString(key_event->text, key_data->text); CopyString(key_event->unmodified_text, key_data->unmodified_text); + +#if BUILDFLAG(IS_TIZEN_TV) + key_event->is_from_rc = key_data->is_from_rc; + strncpy(key_event->device_name, key_data->device_name.c_str(), + sizeof(key_event->device_name) - 1); + key_event->device_name[sizeof(key_event->device_name) - 1] = '\0'; +#endif } else if (blink::WebInputEvent::IsGestureEventType(type)) { blink::mojom::GestureDataPtr gesture_data; if (!event.ReadGestureData(&gesture_data)) @@ -385,7 +392,12 @@ StructTraitsdom_key, key_event->dom_code, key_event->windows_key_code, key_event->native_key_code, key_event->is_system_key, key_event->is_browser_shortcut, key_event->text, - key_event->unmodified_text); + key_event->unmodified_text +#if BUILDFLAG(IS_TIZEN_TV) + , + key_event->is_from_rc, key_event->device_name +#endif + ); } // static diff --git a/third_party/blink/public/common/input/web_keyboard_event.h b/third_party/blink/public/common/input/web_keyboard_event.h index eb0be1e..33e94ce 100644 --- a/third_party/blink/public/common/input/web_keyboard_event.h +++ b/third_party/blink/public/common/input/web_keyboard_event.h @@ -19,6 +19,20 @@ class BLINK_COMMON_EXPORT WebKeyboardEvent : public WebInputEvent { // them PODs. static const size_t kTextLengthCap = 4; +#if BUILDFLAG(IS_TIZEN_TV) + // The devicename list: + // const std::string devicenameSmartView = "SMART_VIEW"; + // const std::string devicenamePanelKey = "wt61p807 panel key device"; + // const std::string devicenameRemote = "wt61p807 rc device"; + // const std::string devicenameIME = "ime"; + // const std::string devicenameSmartRC = "Smart Control"; + // const std::string devicenameUSBKeyboard = "CHICONY HP Basic USB Keyboard"; + // etc: device name set by evas_device_name_set + + // Maxmimum Length of device name + static const size_t kDeviceNameLengthCap = 40; +#endif + // |windows_key_code| is the Windows key code associated with this key // event. Sometimes it's direct from the event (i.e. on Windows), // sometimes it's via a mapping function. If you want a list, see @@ -63,6 +77,14 @@ class BLINK_COMMON_EXPORT WebKeyboardEvent : public WebInputEvent { char16_t text[kTextLengthCap] = {}; char16_t unmodified_text[kTextLengthCap] = {}; +#if BUILDFLAG(IS_TIZEN_TV) + // Whether the key event from Remote Control + bool is_from_rc = false; + + // This is a string identifying device name + char device_name[kDeviceNameLengthCap] = {}; +#endif + WebKeyboardEvent(Type type, int modifiers, base::TimeTicks time_stamp) : WebInputEvent(type, modifiers, time_stamp) {} diff --git a/third_party/blink/public/mojom/BUILD.gn b/third_party/blink/public/mojom/BUILD.gn index 0adc86b..ea681fe 100644 --- a/third_party/blink/public/mojom/BUILD.gn +++ b/third_party/blink/public/mojom/BUILD.gn @@ -10,6 +10,10 @@ if (is_android) { import("//build/config/android/config.gni") } +if (use_efl) { + import("//tizen_src/build/config/tizen_features.gni") +} + # This target includes all mojom interfaces which can be used from # renderer/platform. In particular these mojom interfaces can't use types that # are typemapped to a type in renderer/core. @@ -325,6 +329,9 @@ mojom("mojom_platform") { if (is_android || is_mac) { enabled_features += [ "is_using_open_color_chooser" ] } + if (tizen_product_tv) { + enabled_features += [ "is_tizen_tv" ] + } shared_cpp_typemaps = [ { diff --git a/third_party/blink/public/mojom/frame/frame.mojom b/third_party/blink/public/mojom/frame/frame.mojom index f7b27a6..7a4564f 100644 --- a/third_party/blink/public/mojom/frame/frame.mojom +++ b/third_party/blink/public/mojom/frame/frame.mojom @@ -182,6 +182,12 @@ interface KeepAliveHandleFactory { pending_receiver keep_alive_handle); }; +struct FocusedNodeChangedParams { + bool is_radio_or_checkbox_input_node; + int32 password_input_minlength; + int32 input_maxlength; +}; + // Implemented in Browser, this interface defines frame-specific methods that // will be invoked from the render process (e.g. content::RenderFrameHostImpl). // @@ -412,7 +418,8 @@ interface LocalFrameHost { // local root's view, and it will be an empty bounds if there is no focused // element. FocusedElementChanged(bool is_editable_element, - gfx.mojom.Rect bounds_in_frame_widget, blink.mojom.FocusType focus_type); + gfx.mojom.Rect bounds_in_frame_widget, blink.mojom.FocusType focus_type, + FocusedNodeChangedParams params); // Notification that the text selection has changed. // Note: The second parameter is the character based offset of the diff --git a/third_party/blink/public/mojom/input/input_handler.mojom b/third_party/blink/public/mojom/input/input_handler.mojom index d5f3287..f51bf3d 100644 --- a/third_party/blink/public/mojom/input/input_handler.mojom +++ b/third_party/blink/public/mojom/input/input_handler.mojom @@ -44,6 +44,13 @@ struct KeyData { bool is_browser_shortcut; mojo_base.mojom.String16 text; mojo_base.mojom.String16 unmodified_text; + + [EnableIf=is_tizen_tv] + bool is_from_rc; + + // Only for TV, identify the device name property in keyboard event + [EnableIf=is_tizen_tv] + string device_name; }; struct PointerData { diff --git a/third_party/blink/public/platform/web_text_input_info.h b/third_party/blink/public/platform/web_text_input_info.h index b0402f9..d0c228f 100644 --- a/third_party/blink/public/platform/web_text_input_info.h +++ b/third_party/blink/public/platform/web_text_input_info.h @@ -64,6 +64,11 @@ struct BLINK_PLATFORM_EXPORT WebTextInputInfo { // The end position of the current composition, or -1 if there is none. int composition_end = -1; +#if BUILDFLAG(IS_EFL) + // The value whether focused input field is included in 'Form' tag. + bool is_in_form_tag = false; +#endif + // The inputmode attribute value of the currently focused input field. WebTextInputMode input_mode = kWebTextInputModeDefault; diff --git a/third_party/blink/public/web/web_input_element.h b/third_party/blink/public/web/web_input_element.h index 7fa7456..9215d75 100644 --- a/third_party/blink/public/web/web_input_element.h +++ b/third_party/blink/public/web/web_input_element.h @@ -70,6 +70,9 @@ class BLINK_EXPORT WebInputElement final : public WebFormControlElement { // defaultMaxLength() when no valid has been set, whereas 'maxLength' IDL // attribute returns -1. int MaxLength() const; +#if BUILDFLAG(IS_TIZEN_TV) + int MinLength() const; +#endif void SetActivatedSubmit(bool); int size() const; void SetChecked(bool, diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc index 0b4458b..45c0ae6 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc @@ -355,6 +355,10 @@ #include "third_party/blink/renderer/platform/wtf/text/string_buffer.h" #include "third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "third_party/blink/public/web/web_input_element.h" +#endif + #ifndef NDEBUG using WeakDocumentSet = blink::HeapHashSet>; static WeakDocumentSet& LiveDocumentSet(); @@ -439,6 +443,56 @@ bool DefaultFaviconAllowedByCSP(const Document* document, const IconURL& icon) { ContentSecurityPolicy::CheckHeaderType::kCheckAll); } +#if BUILDFLAG(IS_TIZEN_TV) +static bool IsRadioOrCheckboxInputNode(Element* element) { + if (!element) + return false; + + element->GetDocument().UpdateStyleAndLayoutTree(); + blink::WebElement web_element = WebElement(element); + + if (web_element.IsNull() || !web_element.HasHTMLTagName("input")) + return false; + + const WebInputElement input = web_element.To(); + if (input.IsRadioButton() || input.IsCheckbox()) + return true; + + return false; +} + +static int PasswordInputElementMinLength(Element* element) { + if (!element) + return -1; + + element->GetDocument().UpdateStyleAndLayoutTree(); + blink::WebElement web_element = WebElement(element); + + if (web_element.IsNull() || !web_element.HasHTMLTagName("input")) + return -1; + + const WebInputElement input = web_element.To(); + if (input.IsPasswordField()) + return input.MinLength(); + + return -1; +} + +static int InputElementMaxLength(Element* element) { + if (!element) + return -1; + + element->GetDocument().UpdateStyleAndLayoutTree(); + blink::WebElement web_element = WebElement(element); + + if (web_element.IsNull() || !web_element.HasHTMLTagName("input")) + return -1; + + const WebInputElement input = web_element.To(); + return input.MaxLength(); +} +#endif // IS_TIZEN_TV + } // namespace static const unsigned kCMaxWriteRecursionDepth = 21; @@ -5167,8 +5221,18 @@ void Document::SendFocusNotification(Element* new_focused_element, } } + auto params = mojom::blink::FocusedNodeChangedParams::New(); +#if BUILDFLAG(IS_TIZEN_TV) + if (new_focused_element) { + params->is_radio_or_checkbox_input_node = + IsRadioOrCheckboxInputNode(new_focused_element); + params->password_input_minlength = + PasswordInputElementMinLength(new_focused_element); + params->input_maxlength = InputElementMaxLength(new_focused_element); + } +#endif GetFrame()->GetLocalFrameHostRemote().FocusedElementChanged( - is_editable, element_bounds_in_dips, focus_type); + is_editable, element_bounds_in_dips, focus_type, std::move(params)); } void Document::NotifyFocusedElementChanged(Element* old_focused_element, diff --git a/third_party/blink/renderer/core/editing/ime/input_method_controller.cc b/third_party/blink/renderer/core/editing/ime/input_method_controller.cc index 125ad0d..015d5c6 100644 --- a/third_party/blink/renderer/core/editing/ime/input_method_controller.cc +++ b/third_party/blink/renderer/core/editing/ime/input_method_controller.cc @@ -1582,6 +1582,9 @@ WebTextInputInfo InputMethodController::TextInputInfo() const { info.virtual_keyboard_policy = VirtualKeyboardPolicyOfFocusedElement(); info.type = TextInputType(); info.flags = TextInputFlags(); +#if BUILDFLAG(IS_EFL) + info.is_in_form_tag = IsFocusedElementInFormTag(); +#endif if (info.type == kWebTextInputTypeNone) return info; @@ -1896,4 +1899,15 @@ WebVector InputMethodController::GetImeTextSpans() const { return ime_text_spans; } +#if BUILDFLAG(IS_EFL) +bool InputMethodController::IsFocusedElementInFormTag() const { + Node* node = GetDocument().FocusedElement(); + if (!node || !IsTextControl(*node)) + return false; + + TextControlElement* text_control = ToTextControl(node); + return text_control && text_control->Form(); +} +#endif + } // namespace blink diff --git a/third_party/blink/renderer/core/editing/ime/input_method_controller.h b/third_party/blink/renderer/core/editing/ime/input_method_controller.h index a088acd..a570dca 100644 --- a/third_party/blink/renderer/core/editing/ime/input_method_controller.h +++ b/third_party/blink/renderer/core/editing/ime/input_method_controller.h @@ -243,6 +243,10 @@ class CORE_EXPORT InputMethodController final // 3) SetComposingText() (SetComposition()) void RemoveSuggestionMarkerInCompositionRange(); +#if BUILDFLAG(IS_EFL) + bool IsFocusedElementInFormTag() const; +#endif + void DispatchCompositionUpdateEvent(LocalFrame& frame, const String& text); void DispatchBeforeInputFromComposition(EventTarget* target, InputEvent::InputType input_type, diff --git a/third_party/blink/renderer/core/events/keyboard_event.cc b/third_party/blink/renderer/core/events/keyboard_event.cc index cfc48b2..e63ca0e 100644 --- a/third_party/blink/renderer/core/events/keyboard_event.cc +++ b/third_party/blink/renderer/core/events/keyboard_event.cc @@ -223,4 +223,12 @@ void KeyboardEvent::Trace(Visitor* visitor) const { UIEventWithKeyState::Trace(visitor); } +const String KeyboardEvent::inputDevice() const { +#if BUILDFLAG(IS_TIZEN_TV) + return KeyEvent() ? FromUTF8(KeyEvent()->device_name) : FromUTF8(""); +#else + return FromUTF8("undefined"); +#endif +} + } // namespace blink diff --git a/third_party/blink/renderer/core/events/keyboard_event.h b/third_party/blink/renderer/core/events/keyboard_event.h index 039c16c..21b27c8 100644 --- a/third_party/blink/renderer/core/events/keyboard_event.h +++ b/third_party/blink/renderer/core/events/keyboard_event.h @@ -97,6 +97,7 @@ class CORE_EXPORT KeyboardEvent final : public UIEventWithKeyState { unsigned which() const override; bool isComposing() const { return is_composing_; } + const String inputDevice() const; void Trace(Visitor*) const override; private: diff --git a/third_party/blink/renderer/core/events/keyboard_event.idl b/third_party/blink/renderer/core/events/keyboard_event.idl index 6ef9b98..aa2d4c3 100644 --- a/third_party/blink/renderer/core/events/keyboard_event.idl +++ b/third_party/blink/renderer/core/events/keyboard_event.idl @@ -40,6 +40,9 @@ readonly attribute boolean isComposing; boolean getModifierState(DOMString keyArg); + // Property to send device name when key event occurs + readonly attribute DOMString inputDevice; + // https://w3c.github.io/uievents/#idl-interface-KeyboardEvent-initializers [CallWith=ScriptState, Measure] void initKeyboardEvent(DOMString type, optional boolean bubbles = false, diff --git a/third_party/blink/renderer/core/exported/web_input_element.cc b/third_party/blink/renderer/core/exported/web_input_element.cc index 9099f3e..3eeddc5 100644 --- a/third_party/blink/renderer/core/exported/web_input_element.cc +++ b/third_party/blink/renderer/core/exported/web_input_element.cc @@ -92,6 +92,12 @@ int WebInputElement::MaxLength() const { return max_len == -1 ? DefaultMaxLength() : max_len; } +#if BUILDFLAG(IS_TIZEN_TV) +int WebInputElement::MinLength() const { + return ConstUnwrap()->minLength(); +} +#endif + void WebInputElement::SetActivatedSubmit(bool activated) { Unwrap()->SetActivatedSubmit(activated); } diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc index 5e5704a..18c4feb 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc @@ -3521,6 +3521,14 @@ void WebFrameWidgetImpl::DidHandleGestureEvent(const WebGestureEvent& event) { else widget_base_->ShowVirtualKeyboard(); } +#elif BUILDFLAG(IS_EFL) + if (!HasFocus()) + return; + + if ((event.GetType() == WebInputEvent::Type::kGestureTap) || + (event.GetType() == WebInputEvent::Type::kGestureLongPress)) { + widget_base_->ShowVirtualKeyboard(); + } #endif } diff --git a/third_party/blink/renderer/platform/widget/input/widget_base_input_handler.cc b/third_party/blink/renderer/platform/widget/input/widget_base_input_handler.cc index 36665ff..e69dd4f 100644 --- a/third_party/blink/renderer/platform/widget/input/widget_base_input_handler.cc +++ b/third_party/blink/renderer/platform/widget/input/widget_base_input_handler.cc @@ -413,6 +413,21 @@ void WidgetBaseInputHandler::HandleInputEvent( } #endif +#if BUILDFLAG(IS_TIZEN_TV) + if (WebInputEvent::IsKeyboardEventType(input_event.GetType())) { + // Allow to show IME by TV RC device OK key + const WebKeyboardEvent& key_event = + static_cast(input_event); + if (key_event.windows_key_code == ui::VKEY_RETURN && + key_event.is_from_rc == true && + widget_->client()->GetTextInputType() != + WebTextInputType::kWebTextInputTypeNone) { + widget_->ShowVirtualKeyboard(); + prevent_default = true; + } + } +#endif + if (WebInputEvent::IsGestureEventType(input_event.GetType())) { const WebGestureEvent& gesture_event = static_cast(input_event); diff --git a/third_party/blink/renderer/platform/widget/widget_base.cc b/third_party/blink/renderer/platform/widget/widget_base.cc index 2e57c4f..78bb164 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.cc +++ b/third_party/blink/renderer/platform/widget/widget_base.cc @@ -1013,6 +1013,9 @@ void WidgetBase::UpdateTextInputStateInternal(bool show_virtual_keyboard, text_input_info_ != new_info || !new_info.ime_text_spans.empty() || can_compose_inline_ != new_can_compose_inline || always_hide_ime_ != always_hide_ime || vk_policy_ != new_vk_policy || +#if BUILDFLAG(IS_EFL) + (text_input_is_in_form_tag_ != new_info.is_in_form_tag) || +#endif (new_vk_policy == ui::mojom::VirtualKeyboardPolicy::MANUAL && (last_vk_visibility_request != ui::mojom::VirtualKeyboardVisibilityRequest::NONE)) || @@ -1066,6 +1069,12 @@ void WidgetBase::UpdateTextInputStateInternal(bool show_virtual_keyboard, params->show_ime_if_needed = show_virtual_keyboard; params->always_hide_ime = always_hide_ime; params->reply_to_request = reply_to_request; +#if BUILDFLAG(IS_EFL) + params->is_in_form_tag = new_info.is_in_form_tag; + text_input_is_in_form_tag_ = new_info.is_in_form_tag; + params->is_user_action = is_user_action_; + is_user_action_ = true; +#endif widget_host_->TextInputStateChanged(std::move(params)); text_input_info_ = new_info; @@ -1116,6 +1125,10 @@ void WidgetBase::ShowVirtualKeyboardOnElementFocus() { // mouse button or the finger and a text input element is focused at that // time. Focus event itself shouldn't trigger virtual keyboard. UpdateTextInputState(); +#elif BUILDFLAG(IS_EFL) + // If webview hasn't focus, IME shouldn't be shown. + if (has_focus_) + ShowVirtualKeyboard(); #else ShowVirtualKeyboard(); #endif diff --git a/third_party/blink/renderer/platform/widget/widget_base.h b/third_party/blink/renderer/platform/widget/widget_base.h index b73ee82..a26cd3b 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.h +++ b/third_party/blink/renderer/platform/widget/widget_base.h @@ -542,6 +542,14 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget, // Indicates that we shouldn't bother generated paint events. bool is_hidden_; +#if BUILDFLAG(IS_EFL) + // Check the focus is by user gesture. + bool is_user_action_ = true; + + // Stores an indication of if current input is in form tag. + bool text_input_is_in_form_tag_ = false; +#endif + // Delayed callback to ensure we have only one delayed ScheduleAnimation() // call going at a time. TaskRunnerTimer request_animation_after_delay_timer_; diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc index c7b0b2e..749b0d0 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc @@ -660,6 +660,8 @@ ui::EflEventHandler* RWHVAuraOffscreenHelperEfl::GetEventHandler() { } ui::IMContextEfl* RWHVAuraOffscreenHelperEfl::GetIMContextEfl() { + // im_context_efl_ is always nullptr on desktop efl. +#if BUILDFLAG(IS_TIZEN) if (!im_context_efl_) { if (GetEventHandler() && GetEventHandler()->GetIMContextEfl()) { im_context_efl_ = GetEventHandler()->GetIMContextEfl(); @@ -668,6 +670,7 @@ ui::IMContextEfl* RWHVAuraOffscreenHelperEfl::GetIMContextEfl() { } LOG(ERROR) << "im_context_efl_ is not set"; } +#endif return im_context_efl_; } @@ -680,6 +683,80 @@ gfx::Point RWHVAuraOffscreenHelperEfl::ConvertPointInViewPix(gfx::Point point) { gfx::ScalePoint(gfx::PointF(point), device_scale_factor_)); } +void RWHVAuraOffscreenHelperEfl::TextInputStateChanged( + const ui::mojom::TextInputState& params) { + auto im_context = GetIMContextEfl(); + if (!im_context) { + LOG(ERROR) << "im_context is nullptr"; + return; + } + +#if BUILDFLAG(IS_TIZEN_TV) + if (!rwhv_aura_->IsShowing() || !HasFocus()) +#else + if (!rwhv_aura_->IsShowing()) +#endif + return; + + bool show_ime_if_needed = params.show_ime_if_needed; + + if (show_ime_if_needed && !params.is_user_action) + show_ime_if_needed = false; + + // Prevent scroll and zoom for autofocus'ed elements. + if (show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { + // If webview isn't resized yet, return previous IME state. + bool is_ime_show = im_context->WebViewWillBeResized() + ? !im_context->IsVisible() + : im_context->IsVisible(); + if (im_context && !is_ime_show) + is_scrolling_needed_ = true; + } + + if (im_context) { + im_context->SetIsInFormTag(params.is_in_form_tag); +#if BUILDFLAG(IS_TIZEN_TV) + im_context->UpdateInputMethodState( + params.type, params.can_compose_inline, show_ime_if_needed, + password_input_minlength_, input_maxlength_); +#else + im_context->UpdateInputMethodState(params.type, params.can_compose_inline, + show_ime_if_needed); +#endif + } +} + +void RWHVAuraOffscreenHelperEfl::FocusedNodeChanged( + bool editable +#if BUILDFLAG(IS_TIZEN_TV) + , + bool is_radio_or_checkbox, + int password_input_minlength, + int input_maxlength +#endif +) { + +#if BUILDFLAG(IS_TIZEN_TV) + radio_or_checkbox_focused_ = is_radio_or_checkbox; + password_input_minlength_ = password_input_minlength; + input_maxlength_ = input_maxlength; +#endif + + auto im_context = GetIMContextEfl(); + if (im_context && is_focused_node_editable_) { + // focus out from an editable node, + // need reset ime context. + // or else will cause previous preedit text be copied. + if (im_context->IsVisible()) { + im_context->CancelComposition(); + } else { + // add ime focus out when focus out from an editable node. + im_context->OnFocusOut(); + } + } + is_focused_node_editable_ = editable; +} + gfx::Size RWHVAuraOffscreenHelperEfl::GetPhysicalBackingSize() const { int w, h; evas_object_geometry_get(content_image_elm_host_, nullptr, nullptr, &w, &h); diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h index 004a800..c4c91f6 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h @@ -27,6 +27,10 @@ #include "ui/gfx/native_widget_types.h" #include "ui/gfx/range/range.h" +#if BUILDFLAG(IS_TIZEN_TV) +#define DEFAULT_MAX_LENGTH std::numeric_limits::max() +#endif + namespace ui { class EflEventHandler; class IMContextEfl; @@ -67,6 +71,14 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl { bool HasFocus(); void SetPageVisibility(bool visible); void TextInputStateChanged(const ui::mojom::TextInputState& params); + void FocusedNodeChanged(bool editable +#if BUILDFLAG(IS_TIZEN_TV) + , + bool is_radio_or_checkbox, + int password_input_minlength, + int input_maxlength +#endif + ); RenderWidgetHostViewAura* rwhva() { return rwhv_aura_; } void OnMouseOrTouchEvent(ui::Event* event); @@ -134,6 +146,14 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl { gfx::SizeF scaled_contents_size_; gfx::Size custom_viewport_size_; +#if BUILDFLAG(IS_TIZEN_TV) + bool radio_or_checkbox_focused_ = false; + int password_input_minlength_ = -1; + int input_maxlength_ = DEFAULT_MAX_LENGTH; +#endif + bool is_focused_node_editable_ = false; + bool is_scrolling_needed_ = false; + ui::IMContextEfl* im_context_efl_ = nullptr; RenderWidgetHostViewAura* rwhv_aura_ = nullptr; WebContents* web_contents_ = nullptr; diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_input_method_context.cc b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_input_method_context.cc index 34162ad..4bda2bd 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_input_method_context.cc +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_input_method_context.cc @@ -42,13 +42,22 @@ void EflInputMethodContext::Reset() { } void EflInputMethodContext::Focus() { +#if !BUILDFLAG(IS_TIZEN_TV) if (im_context_ && !im_context_->IsVisible()) im_context_->ShowPanel(); +#else + if (im_context_ && !im_context_->IsFocused()) + im_context_->OnFocusIn(); +#endif } void EflInputMethodContext::Blur() { if (im_context_ && im_context_->IsVisible()) im_context_->HidePanel(); +#if BUILDFLAG(IS_TIZEN_TV) + else if (im_context_ && im_context_->IsFocused()) + im_context_->OnFocusOut(); +#endif } void EflInputMethodContext::SetCursorLocation(const gfx::Rect& rect) { diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h index ee4542e..a83ceac 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_keycode_map.h @@ -8,6 +8,26 @@ namespace ui { +// TV RC device names +const std::string kDeviceNameSmartView = "SMART_VIEW"; +const std::string kDeviceNamePanelKey = "wt61p807 panel key device"; +const std::string kDeviceNameRemote = "wt61p807 rc device"; +const std::string kDeviceNameSmartRC = "Smart Control"; +// To allow to receive Tomato send key events +const std::string kDeviceNameAutoModeDevice = "AUTO_MODE_DEVICE"; +const std::string kDeviceNameIME = "ime"; + +bool IsRCDevice(Evas_Device_Class device_id, const std::string device_name) { + if (device_id == EVAS_DEVICE_CLASS_KEYBOARD) { + return (!device_name.compare(kDeviceNameRemote) || + !device_name.compare(kDeviceNameSmartView) || + !device_name.compare(kDeviceNamePanelKey) || + !device_name.compare(kDeviceNameAutoModeDevice) || + device_name.find(kDeviceNameSmartRC) != std::string::npos); + } + return false; +} + static ui::KeyboardCode UIKeyCodeFromEflKey(const char* key) { static std::unordered_map code_from_key_map({ {"Shift_L", ui::VKEY_SHIFT}, {"Shift_R", ui::VKEY_SHIFT}, diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc b/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc index 234085f..e728f1d 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/im_context_efl.cc @@ -17,6 +17,10 @@ #include "ui/ozone/platform/efl/efl_platform_event_source.h" #include "ui/ozone/platform/efl/efl_window.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "tizen_src/ewk/efl_integration/common/application_type.h" +#endif + #ifdef IM_CTX_DEBUG #define IM_CTX_LOG_CHANNEL LOG(ERROR) #else @@ -247,6 +251,10 @@ void IMContextEfl::UpdateInputMethodType(TextInputType type, } #if BUILDFLAG(IS_TIZEN_TV) + // 2017 WebBrowser App want no recommended list same as 2015, 2016. + if (content::IsWebBrowser()) + allow_prediction = false; + // Always enable "Up" and "Down" key // Set IMEUp=2, IMEDown=2 will always enable the 'up' and 'down' arrow key std::string im_data("IMEUp=2&IMEDown=2"); @@ -511,6 +519,17 @@ void IMContextEfl::SendFakeCompositionKeyEvent(const std::u16string& buf) { if (event.key_code() == 0) event.set_key_code(static_cast(229)); +#if BUILDFLAG(IS_TIZEN_TV) + if (content::IsTIZENWRT()) { + // a-z, A-Z, 0-9 + int key_code = event.key_code(); + if ((key_code >= 65 && key_code <= 90) || + (key_code >= 48 && key_code <= 57)) { + event.set_key_code(static_cast(229)); + } + } +#endif + is_keyevent_processing_ = true; PushToKeyUpEventQueue(event.key_code()); EflPlatformEventSource::GetInstance()->DispatchEflEvent(&event); diff --git a/ui/base/ime/mojom/BUILD.gn b/ui/base/ime/mojom/BUILD.gn index 956712c..9799fdb 100644 --- a/ui/base/ime/mojom/BUILD.gn +++ b/ui/base/ime/mojom/BUILD.gn @@ -76,6 +76,11 @@ mojom("mojom") { export_class_attribute_blink = "BLINK_PLATFORM_EXPORT" export_define_blink = "BLINK_PLATFORM_IMPLEMENTATION=1" export_header_blink = "third_party/blink/public/platform/web_common.h" + + enabled_features = [] + if (use_efl) { + enabled_features += [ "is_efl" ] + } } mojom("test_interfaces") { diff --git a/ui/base/ime/mojom/text_input_state.mojom b/ui/base/ime/mojom/text_input_state.mojom index 1c5e065..c86a2c7 100644 --- a/ui/base/ime/mojom/text_input_state.mojom +++ b/ui/base/ime/mojom/text_input_state.mojom @@ -77,5 +77,12 @@ struct TextInputState { // Information of ime text spans at the cursor position. array ime_text_spans_info; + + [EnableIf=is_efl] + bool is_in_form_tag = false; + + // Whether the focus is by user gesture. + [EnableIf=is_efl] + bool is_user_action = true; }; diff --git a/ui/events/blink/web_input_event_traits.cc b/ui/events/blink/web_input_event_traits.cc index 5273703..6c0e434 100644 --- a/ui/events/blink/web_input_event_traits.cc +++ b/ui/events/blink/web_input_event_traits.cc @@ -30,10 +30,19 @@ namespace { void ApppendEventDetails(const WebKeyboardEvent& event, std::string* result) { StringAppendF(result, "{\n WinCode: %d\n NativeCode: %d\n IsSystem: %d\n" +#if BUILDFLAG(IS_TIZEN_TV) + " Text: %s\n UnmodifiedText: %s\n" + " IsFromRc: %d\n DeviceName: %s\n}", + event.windows_key_code, event.native_key_code, + event.is_system_key, reinterpret_cast(event.text), + reinterpret_cast(event.unmodified_text), + event.is_from_rc, event.device_name); +#else " Text: %s\n UnmodifiedText: %s\n}", event.windows_key_code, event.native_key_code, event.is_system_key, reinterpret_cast(event.text), reinterpret_cast(event.unmodified_text)); +#endif } void ApppendEventDetails(const WebMouseEvent& event, std::string* result) { diff --git a/ui/events/event.cc b/ui/events/event.cc index faf8d8e..2721ef0 100644 --- a/ui/events/event.cc +++ b/ui/events/event.cc @@ -42,6 +42,10 @@ #include "ui/events/keycodes/platform_key_map_win.h" #endif +#if BUILDFLAG(IS_TIZEN_TV) +#include "tizen/system_info.h" +#endif + namespace ui { namespace { @@ -1097,6 +1101,14 @@ char16_t KeyEvent::GetText() const { char16_t KeyEvent::GetUnmodifiedText() const { if (!is_char_ && (key_code_ == VKEY_RETURN)) return '\r'; + +#if BUILDFLAG(IS_TIZEN_TV) + if (key_code_ == VKEY_IME_DONE) + return '\r'; + else if (key_code_ == 0) + return 0; +#endif + return GetCharacter(); } diff --git a/ui/events/keycodes/keyboard_codes_posix.h b/ui/events/keycodes/keyboard_codes_posix.h index 22ef547..e8f04f4 100644 --- a/ui/events/keycodes/keyboard_codes_posix.h +++ b/ui/events/keycodes/keyboard_codes_posix.h @@ -31,6 +31,8 @@ #ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODES_POSIX_H_ #define UI_EVENTS_KEYCODES_KEYBOARD_CODES_POSIX_H_ +#include "build/build_config.h" + namespace ui { // When adding a new KeyboardCode, be sure to also update the associated mojom @@ -253,6 +255,13 @@ enum KeyboardCode { VKEY_DICTATE = 0xEE, // All applications - this also triggers the launcher in Chrome OS. VKEY_ALL_APPLICATIONS = 0xEF, + +#if BUILDFLAG(IS_TIZEN_TV) + // TV IME "Select" key, no X Server keycode, 0xFF60 ISF code. + VKEY_IME_DONE = 0xFF60, + // TV IME "Cancel" key, no X Server keycode, 0xFF69 ISF code. + VKEY_IME_CANCEL = 0xFF69, +#endif }; } // namespace ui -- 2.7.4 From 9030b34c2c79f4caa7d7d79cbe266578d529b2db Mon Sep 17 00:00:00 2001 From: v-saha Date: Mon, 16 Jan 2023 15:41:42 +0530 Subject: [PATCH 10/16] [M108 Migration] Add implementation of SetUserAgentOverride This commit adds missing implementation for SetUserAgentOverride. This also removes EWK_BRINGUP in EWebView::GetUserAgent() so that ewk_view_user_agent_get() returns the actual user agent string instead of empty string. Reference: https://review.tizen.org/gerrit/273266 Change-Id: I71f2893a7dae1c77a42bed9c78f48867ca38bc2b Signed-off-by: v-saha --- .../browser/web_contents/web_contents_impl_efl.cc | 24 +++++++++++++++++++++- tizen_src/ewk/efl_integration/eweb_view.cc | 11 +++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc index 60e7f33..95c65e5 100644 --- a/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc +++ b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc @@ -23,6 +23,7 @@ #include "content/public/browser/web_contents_efl_delegate.h" #include "content/public/common/content_client.h" #include "content/public/common/result_codes.h" +#include "net/http/http_util.h" // Majority of the code in this file was taken directly from // WebContentsImpl::CreateNewWindow. Compared to the original, the function @@ -81,7 +82,28 @@ std::unique_ptr WebContentsImplEfl::Clone() { void WebContentsImplEfl::SetUserAgentOverride( const blink::UserAgentOverride& ua_override, - bool override_in_new_tabs) {} + bool override_in_new_tabs) { + if (GetUserAgentOverride() == ua_override) + return; + + if (!ua_override.ua_string_override.empty() && + !net::HttpUtil::IsValidHeaderValue(ua_override.ua_string_override)) { + return; + } + + should_override_user_agent_in_new_tabs_ = override_in_new_tabs; + + renderer_preferences_.user_agent_override = ua_override; + + // Send the new override string to all renderers in the current page. + SyncRendererPrefs(); + + // In chromium upstream, the page is reloaded if a load is currently in + // progress. However, the behaviour is different for chromium efl port. + + observers_.NotifyObservers(&WebContentsObserver::UserAgentOverrideSet, + ua_override); +} WebContentsImpl* WebContentsImplEfl::CreateWebContentsForNewWindow( BrowserContext* browser_context, diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 70727b5..8737a42 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -811,12 +811,13 @@ void EWebView::set_magnifier(bool status) { } const char* EWebView::GetUserAgent() const { - if (!web_contents_->GetUserAgentOverride().ua_string_override.empty()) - user_agent_ = web_contents_->GetUserAgentOverride().ua_string_override; -#if !defined(EWK_BRINGUP) // FIXME: m73 bringup + std::string user_agent = + web_contents_->GetUserAgentOverride().ua_string_override; + if (user_agent.empty()) + user_agent_ = content::GetContentClientExport()->browser()->GetUserAgent(); else - user_agent_ = content::GetContentClientExport()->GetUserAgent(); -#endif + user_agent_ = user_agent; + return user_agent_.c_str(); } -- 2.7.4 From 01b54fa439dfb260f9a04e2e0e97d5d4734193c5 Mon Sep 17 00:00:00 2001 From: Bakka Uday Kiran Date: Tue, 17 Jan 2023 10:36:12 +0530 Subject: [PATCH 11/16] [M108 Migration] Remove EWK_BRINGUP from EWebView::ExecuteJavaScript This patch removes EWK_BRINGUP from EWebView::ExecuteJavaScript. Reference: https://review.tizen.org/gerrit/c/273504 Change-Id: I602c63a2284edc1681899ba68d511beeefb629ad Signed-off-by: Bakka Uday Kiran --- tizen_src/ewk/efl_integration/eweb_view.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 8737a42..2dd7acf 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -700,11 +700,11 @@ class JavaScriptCallbackDetails { }; void JavaScriptComplete(JavaScriptCallbackDetails* script_callback_data, - const base::Value* result) { + base::Value result) { if (!script_callback_data->callback_func_) return; - std::string return_string = result->GetString(); + std::string return_string = result.GetString(); script_callback_data->callback_func_(script_callback_data->view_, return_string.c_str(), script_callback_data->user_data_); @@ -734,16 +734,15 @@ bool EWebView::ExecuteJavaScript(const char* script, std::u16string js_script; base::UTF8ToUTF16(script, strlen(script), &js_script); if (callback) { -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup JavaScriptCallbackDetails* script_callback_data = new JavaScriptCallbackDetails(callback, userdata, evas_object_); + RenderFrameHost::JavaScriptResultCallback js_callback = + base::BindOnce(&JavaScriptComplete, base::Owned(script_callback_data)); // In M47, it isn't possible anymore to execute javascript in the generic // case. We need to call ExecuteJavaScriptForTests to keep the behaviour // unchanged @see https://codereview.chromium.org/1123783002 render_frame_host->ExecuteJavaScriptWithUserGestureForTests( - js_script, - base::BindOnce(&JavaScriptComplete, base::Owned(script_callback_data))); -#endif + js_script, std::move(js_callback)); } else { // We use ExecuteJavaScriptWithUserGestureForTests instead of // ExecuteJavaScript because -- 2.7.4 From 29e34f5e106477d4f3cc0409664c2af93c9139f1 Mon Sep 17 00:00:00 2001 From: Venugopal S M Date: Wed, 11 Mar 2020 20:39:24 +0530 Subject: [PATCH 12/16] [M108 Aura Migration][MM] Remove pulseaudio dependency This patch disables pulse audio for chromium. Reference: https://review.tizen.org/gerrit/280375 Change-Id: I7fb42320d45ee9127d97ca302132ee285bc2c578 Signed-off-by: Venugopal S M --- media/media_options.gni | 2 +- packaging/chromium-efl.spec | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/media/media_options.gni b/media/media_options.gni index 7ff34f1..c30cd07 100644 --- a/media/media_options.gni +++ b/media/media_options.gni @@ -185,7 +185,7 @@ declare_args() { # TODO(crbug.com/986021): We shouldn't have to do this, but it's unclear why # our test bots are hanging and all of the ones that don't hang just fall # back to ALSA after a connection error anyways. - if (!use_cras && !is_castos && !is_asan && !is_tsan) { + if (!use_cras && !is_castos && !is_asan && !is_tsan && !is_tizen) { use_pulseaudio = true } } diff --git a/packaging/chromium-efl.spec b/packaging/chromium-efl.spec index e7c90cc..01e43e7 100644 --- a/packaging/chromium-efl.spec +++ b/packaging/chromium-efl.spec @@ -92,7 +92,6 @@ BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(libexif) BuildRequires: pkgconfig(libffi) BuildRequires: pkgconfig(libpng) -BuildRequires: pkgconfig(libpulse) BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(libudev) -- 2.7.4 From f49c567be43aa2202ff79a806b4e4f140255ae2e Mon Sep 17 00:00:00 2001 From: v-saha Date: Fri, 6 Jan 2023 11:55:05 +0530 Subject: [PATCH 13/16] [M108 Migration] Fix crashes observed during browser / renderer exit This patch fixes crashes related to VD Fonts iterator and NativeTCT Reference: https://review.tizen.org/gerrit/277645 Change-Id: Ic76f2b365c63507f446c538240774b9629b76b2e Signed-off-by: v-saha --- .../blink/renderer/platform/fonts/font_fallback_iterator.cc | 4 ++++ .../renderer/platform/fonts/shaping/harfbuzz_shaper.cc | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc b/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc index bb6625f..256fcf4 100644 --- a/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc +++ b/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc @@ -154,7 +154,11 @@ scoped_refptr FontFallbackIterator::Next( if (fallback_stage_ == kFirstCandidateForNotdefGlyph) { fallback_stage_ = kOutOfLuck; if (!first_candidate_) +#if BUILDFLAG(IS_TIZEN) + return nullptr; +#else FontCache::CrashWithFontInfo(&font_description_); +#endif return first_candidate_; } diff --git a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc index b480215..c55d58e 100644 --- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc +++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc @@ -788,6 +788,12 @@ void HarfBuzzShaper::ShapeSegment( current_font_data_for_range_set = fallback_iterator.Next(fallback_chars_hint); +#if BUILDFLAG(IS_TIZEN) + if (!current_font_data_for_range_set) { + hb_buffer_reset(range_data->buffer); + break; + } +#endif if (!current_font_data_for_range_set->FontData()) { DCHECK(range_data->reshape_queue.empty()); break; @@ -796,6 +802,13 @@ void HarfBuzzShaper::ShapeSegment( continue; } +#if BUILDFLAG(IS_TIZEN) + if (!current_font_data_for_range_set || + !current_font_data_for_range_set->FontData()) { + break; + } +#endif + const SimpleFontData* font_data = current_font_data_for_range_set->FontData(); SmallCapsIterator::SmallCapsBehavior small_caps_behavior = -- 2.7.4 From dbbd1b1d3a7928183154d25da6a0603259a985d7 Mon Sep 17 00:00:00 2001 From: Chandan Padhi Date: Tue, 17 Jan 2023 20:06:51 +0530 Subject: [PATCH 14/16] [M108 Migration][UA] Refactor user agent strings This commit, 1. reduces system api access 2. moves combination of the user_agent_string to constructor 3. fixes script execution in gn file to get the chromium version in defined pattern 4. removes unnecessary code These changes are required for User Agent String Test in Behavior TCT. References: https://review.tizen.org/gerrit/279991/ https://review.tizen.org/gerrit/281101/ Change-Id: I46787be994fdeada8e11d703a903b5069ed7de46 Signed-off-by: Chandan Padhi --- tizen_src/.gn | 2 + tizen_src/ewk/efl_integration/BUILD.gn | 20 ++- .../ewk/efl_integration/common/version_info.cc | 138 +++++++++------------ .../ewk/efl_integration/common/version_info.h | 77 ++---------- .../efl_integration/content_browser_client_efl.cc | 2 +- tizen_src/ewk/efl_integration/eweb_view.cc | 16 ++- 6 files changed, 101 insertions(+), 154 deletions(-) diff --git a/tizen_src/.gn b/tizen_src/.gn index dd41125..61095fe 100644 --- a/tizen_src/.gn +++ b/tizen_src/.gn @@ -172,6 +172,8 @@ exec_script_whitelist = "//remoting/remoting_version.gni", "//remoting/host/installer/win/generate_clsids.gni", + "//tizen_src/ewk/efl_integration/BUILD.gn", + "//tools/grit/grit_rule.gni", "//tools/gritsettings/BUILD.gn", ] diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index 78c3d88..e9d015b 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -11,10 +11,9 @@ import("//printing/buildflags/buildflags.gni") tizen_autofill_support = false # Components used to auto generate CHROMIUM_VERSION preprocessor define. -#TODO : below uncomment -#version_file = "//chrome/VERSION" -#version_script = "//build/util/version.py" -#version_pattern = "@MAJOR@.@MINOR@.@BUILD@.@PATCH@" +version_file = "//chrome/VERSION" +version_script = "//build/util/version.py" +version_pattern = "@MAJOR@.@MINOR@.@BUILD@.@PATCH@" shared_library("chromium-ewk") { testonly = true @@ -98,8 +97,17 @@ shared_library("chromium-ewk") { deps += [ "//printing" ] } - # TODO : needs to check for generating this macro define - defines = [ "CHROMIUM_VERSION=\" +#endif namespace EflWebView { const char kOSTypeLinux[] = "Linux"; -VersionInfo* VersionInfo::version_info_ = NULL; +VersionInfo* VersionInfo::version_info_ = nullptr; VersionInfo* VersionInfo::GetInstance() { - if(!version_info_) - version_info_ = new VersionInfo; + if (!version_info_) + version_info_ = new VersionInfo(); return version_info_; } void VersionInfo::DeleteInstance() { - if(version_info_) + if (version_info_) { delete version_info_; - version_info_ = NULL; + version_info_ = nullptr; + } } VersionInfo::VersionInfo() - : product_name_(PRODUCT_NAME), - product_version_(PRODUCT_VERSION) { -} + : system_info_(OSType()), user_agent_(CreateUserAgent()) {} -void VersionInfo::SetProductName(const std::string& name) { - if(name.empty()) - product_name_ = PRODUCT_NAME; - else - product_name_ = name; -} +VersionInfo::~VersionInfo() = default; -std::string VersionInfo::LastChange() const { - return LAST_CHANGE; -} +std::string VersionInfo::CreateUserAgent() const { + if (IsTvProfile()) { + // FIXME : The hard-coded user agent for tizen tv + return "Mozilla/5.0 (SMART-TV; LINUX; Tizen 5.0) AppleWebKit/537.36 " + "(KHTML, like Gecko) Version/5.0 TV Safari/537.36"; + } -bool VersionInfo::IsOfficialBuild() const { - return IS_OFFICIAL_BUILD; -} + std::string product = product_name_; + if (!product.empty()) + product += " "; + + product += VersionForUserAgent(); -std::string VersionInfo::CreateVersionString() const { - std::string current_version; - if (is_valid()) { - current_version += Version(); - current_version += " ("; - current_version += " "; - current_version += LastChange(); - current_version += " "; - current_version += OSType(); - current_version += ")"; + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kUseMobileUserAgent)) { + product += " Mobile"; } - return current_version; + + return content::BuildUserAgentFromOSAndProduct(system_info_, product); } std::string VersionInfo::OSType() const { #if BUILDFLAG(IS_TIZEN) - char *device_model = NULL; - char *tizen_version = NULL; - char *platform_name = NULL; + char* device_model = nullptr; + char* tizen_version = nullptr; + char* platform_name = nullptr; std::string device_model_str; std::string tizen_version_str; std::string platform_name_str; - int result = system_info_get_platform_string("http://tizen.org/feature/platform.version", - &tizen_version); + int result = system_info_get_platform_string( + "http://tizen.org/feature/platform.version", &tizen_version); if (result == SYSTEM_INFO_ERROR_NONE) { - tizen_version_str.assign(tizen_version); + tizen_version_str.assign(tizen_version, 3); free(tizen_version); } - result = system_info_get_platform_string("http://tizen.org/system/platform.name", - &platform_name); + + result = system_info_get_platform_string( + "http://tizen.org/system/platform.name", &platform_name); if (result == SYSTEM_INFO_ERROR_NONE) { platform_name_str.assign(platform_name); free(platform_name); } + result = system_info_get_platform_string("http://tizen.org/system/model_name", &device_model); if (result == SYSTEM_INFO_ERROR_NONE) { device_model_str.assign(device_model); + device_model_str.insert(0, "SAMSUNG "); free(device_model); } - return std::string(kOSTypeLinux) + ("; ") + - platform_name_str + (" ") + + + return std::string(kOSTypeLinux) + ("; ") + platform_name_str + (" ") + tizen_version_str + ("; ") + device_model_str; #else return kOSTypeLinux; #endif } -std::string VersionInfo::ProductNameAndVersionForUserAgent() const { - if (!is_valid()) - return std::string(); +void VersionInfo::UpdateUserAgentWithAppName(const std::string& name) { + if (name.empty()) + return; + product_name_ = name; + user_agent_ = CreateUserAgent(); +} + +void VersionInfo::UpdateUserAgent(const std::string& user_agent) { + if (user_agent.empty()) + return; + user_agent_ = user_agent; +} +std::string VersionInfo::VersionForUserAgent() const { // Some WebRTC web-sites need the Chrome version number to check // if the browser supports the WebRTC feature. // TODO(max koo): Do we need to open our real version number // or just use Chrome/aa.bb.cc.dd as Chromium/Chrome do? - // TODO(suchit): Need to fix for chromium version in gn file - return std::string("Chrome/") /*+ CHROMIUM_VERSION*/; + LOG(INFO) << "CHROMIUM_VERSION:" << CHROMIUM_VERSION; + return std::string("Chrome/") + CHROMIUM_VERSION; } std::string VersionInfo::DefaultUserAgent() const { - // TODO: Remove this during UA bringup patch. - // With default user agent, Google homepage layout is improper on desktop efl, - // so temporarily set content shell's user agent. - return std::string( - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " - "Chrome/999.77.34.5 Safari/537.36"); - - char* override_ua = getenv("CHROMIUM_EFL_OVERRIDE_UA_STRING"); - if (override_ua) - return override_ua; - - std::string product = ProductNameAndVersionForUserAgent(); - - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseMobileUserAgent)) { - product += " Mobile"; - } - -// FIXME : The hard-coded user agent for tizen tv - if (IsTvProfile()) { - return "Mozilla/5.0 (SmartHub; SMART-TV; U; Linux/SmartTV+2013; Maple2012) " - "AppleWebKit/535.20+ (KHTML, like Gecko) SmartTV Safari/535.20+"; - } else { - return content::BuildUserAgentFromOSAndProduct(EflWebView::VersionInfo::GetInstance()->OSType(), - product); - } + return user_agent_; } } //namespace EflWebView diff --git a/tizen_src/ewk/efl_integration/common/version_info.h b/tizen_src/ewk/efl_integration/common/version_info.h index 11e0be7..cb4fbb0 100644 --- a/tizen_src/ewk/efl_integration/common/version_info.h +++ b/tizen_src/ewk/efl_integration/common/version_info.h @@ -7,90 +7,39 @@ #include -#include "build/tizen_version.h" - namespace EflWebView { -// An instance of VersionInfo has information about the -// current running build of Chrome. + class VersionInfo { public: - // The possible channels for an installation, from most fun to most stable. - enum Channel { - CHANNEL_UNKNOWN = 0, // Probably blue - CHANNEL_CANARY, // Yellow - CHANNEL_DEV, // Technicolor - CHANNEL_BETA, // Rainbow - CHANNEL_STABLE // Full-spectrum - }; - static VersionInfo* GetInstance(); static void DeleteInstance(); - // In the rare case where we fail to get the version info, - // is_valid() will return false. The other functions will return - // the empty string in this case, so it's not harmful if you don't - // check is_valid(). - bool is_valid() const - { return true; } - - // E.g. "Chrome/a.b.c.d" - std::string ProductNameAndVersionForUserAgent() const; // Default user agent std::string DefaultUserAgent() const; - // E.g. "Chromium" or "Google Chrome". - std::string Name() const - { return product_name_; } - - void SetProductName(const std::string& name); - - // Version number, e.g. "6.0.490.1". - std::string Version() const - { return product_version_; } - - // The SVN revision of this release. E.g. "55800". - std::string LastChange() const; - - // Whether this is an "official" release of the current Version(): - // whether knowing Version() is enough to completely determine what - // LastChange() is. - bool IsOfficialBuild() const; - - // OS type. E.g. "Windows", "Linux", "FreeBSD", ... - std::string OSType() const; + // E.g. "Chrome/a.b.c.d" + std::string VersionForUserAgent() const; - // Returns a human-readable modifier for the version string. For a branded - // build, this modifier is the channel ("canary", "dev", or "beta", but "" - // for stable). On Windows, this may be modified with additional information - // after a hyphen. For multi-user installations, it will return "canary-m", - // "dev-m", "beta-m", and for a stable channel multi-user installation, "m". - // In branded builds, when the channel cannot be determined, "unknown" will - // be returned. In unbranded builds, the modifier is usually an empty string - // (""), although on Linux, it may vary in certain distributions. - // GetVersionStringModifier() is intended to be used for display purposes. - // To simply test the channel, use GetChannel(). - static std::string GetVersionStringModifier() - { return "" ; } + std::string AppName() const { return product_name_; } - // Returns the channel for the installation. In branded builds, this will be - // CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_DEV, or CHANNEL_CANARY. In unbranded - // builds, or in branded builds when the channel cannot be determined, this - // will be CHANNEL_UNKNOWN. - static Channel GetChannel() - { return CHANNEL_DEV; } + void UpdateUserAgentWithAppName(const std::string& name); - // Returns a version string to be displayed in "About Chromium" dialog. - std::string CreateVersionString() const; + // To update the default user agent with restored (Session data) User Agent. + void UpdateUserAgent(const std::string& user_agent); private: VersionInfo(); - ~VersionInfo() { } + ~VersionInfo(); VersionInfo(const VersionInfo&) = delete; VersionInfo& operator=(const VersionInfo&) = delete; + std::string OSType() const; + std::string CreateUserAgent() const; + std::string product_name_; - std::string product_version_; + std::string system_info_; + std::string user_agent_; static VersionInfo* version_info_; }; diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc index 4529c67..878d02a 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc @@ -439,7 +439,7 @@ ContentBrowserClientEfl::CreateThrottlesForNavigation( } std::string ContentBrowserClientEfl::GetProduct() { - return EflWebView::VersionInfo::GetInstance()->ProductNameAndVersionForUserAgent(); + return EflWebView::VersionInfo::GetInstance()->VersionForUserAgent(); } std::string ContentBrowserClientEfl::GetUserAgent() { diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 2dd7acf..3e44712 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -204,6 +204,12 @@ void EWebView::Initialize() { SetMouseEventsEnabled(true); } + std::string user_agent = + EflWebView::VersionInfo::GetInstance()->DefaultUserAgent(); + web_contents_->SetUserAgentOverride( + blink::UserAgentOverride::UserAgentOnly(user_agent), + false /* override_in_new_tabs */); + popupMenuItems_ = 0; popupPicker_ = 0; @@ -769,9 +775,13 @@ bool EWebView::SetUserAgent(const char* userAgent) { } bool EWebView::SetUserAgentAppName(const char* application_name) { - EflWebView::VersionInfo::GetInstance()->SetProductName( + EflWebView::VersionInfo::GetInstance()->UpdateUserAgentWithAppName( application_name ? application_name : ""); - + std::string user_agent = + EflWebView::VersionInfo::GetInstance()->DefaultUserAgent(); + web_contents_->SetUserAgentOverride( + blink::UserAgentOverride::UserAgentOnly(user_agent), + false /* override_in_new_tabs */); return true; } @@ -821,7 +831,7 @@ const char* EWebView::GetUserAgent() const { } const char* EWebView::GetUserAgentAppName() const { - user_agent_app_name_ = EflWebView::VersionInfo::GetInstance()->Name(); + user_agent_app_name_ = EflWebView::VersionInfo::GetInstance()->AppName(); return user_agent_app_name_.c_str(); } -- 2.7.4 From dffd083eb74d1b63fe3f664db6d0b46e18ecf909 Mon Sep 17 00:00:00 2001 From: Gajendra N Date: Tue, 17 Jan 2023 14:39:53 +0530 Subject: [PATCH 15/16] Add WebContentsViewAuraHelperEfl class This patch introduces helper class for WebContentsViewAura for routing some calls to efl delegate classes. Also cleans up unnecessary code. Change-Id: I2949b17af7cdd05610973fb7f7b616b6d466cdb8 Signed-off-by: Gajendra N --- .../browser/web_contents/web_contents_view_aura.cc | 12 +- .../browser/web_contents/web_contents_view_aura.h | 14 ++ .../chromium_impl/content/browser/browser_efl.gni | 2 + .../web_contents_view_aura_helper_efl.cc | 181 +++++++++++++++++++++ .../web_contents_view_aura_helper_efl.h | 100 ++++++++++++ tizen_src/ewk/efl_integration/eweb_view.cc | 31 ++-- tizen_src/ewk/efl_integration/eweb_view.h | 5 +- 7 files changed, 322 insertions(+), 23 deletions(-) create mode 100644 tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.cc create mode 100644 tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.h diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index bdbb5a3..1662f20 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -711,7 +711,17 @@ WebContentsViewAura::WebContentsViewAura( current_rvh_for_drag_(ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE), drag_in_progress_(false), - init_rwhv_with_null_parent_for_testing_(false) {} + init_rwhv_with_null_parent_for_testing_(false) { +#if BUILDFLAG(IS_EFL) + if (!base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableOffscreenRendering)) { + return; + } + + wcva_helper_ = std::make_unique( + this, web_contents_, delegate_.get()); +#endif +} WebContentsViewAura::~WebContentsViewAura() { if (!window_) diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 3425436..db0945e 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -34,6 +34,10 @@ #include "ui/base/dragdrop/drop_target_event.h" #include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h" +#if BUILDFLAG(IS_EFL) +#include "content/browser/web_contents/web_contents_view_aura_helper_efl.h" +#endif + namespace ui { class DropTargetEvent; class TouchSelectionController; @@ -76,6 +80,12 @@ class CONTENT_EXPORT WebContentsViewAura static void InstallCreateHookForTests( RenderWidgetHostViewCreateFunction create_render_widget_host_view); +#if BUILDFLAG(IS_EFL) + WebContentsViewAuraHelperEfl* wcva_helper() const { + return wcva_helper_.get(); + } +#endif + private: // Just the metadata from DropTargetEvent that's safe and cheap to copy to // help locate drop events in the callback. @@ -398,6 +408,10 @@ class CONTENT_EXPORT WebContentsViewAura // Non-null when the WebContents is being captured for video. std::unique_ptr video_capture_lock_; +#if BUILDFLAG(IS_EFL) + std::unique_ptr wcva_helper_; +#endif + base::WeakPtrFactory weak_ptr_factory_{this}; }; diff --git a/tizen_src/chromium_impl/content/browser/browser_efl.gni b/tizen_src/chromium_impl/content/browser/browser_efl.gni index 668d5d0..4a1548a 100644 --- a/tizen_src/chromium_impl/content/browser/browser_efl.gni +++ b/tizen_src/chromium_impl/content/browser/browser_efl.gni @@ -87,6 +87,8 @@ external_content_browser_efl_sources = [ "//tizen_src/chromium_impl/content/browser/tracing/tracing_controller_efl.h", "//tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc", "//tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.h", + "//tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.cc", + "//tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.h", "//tizen_src/chromium_impl/content/browser/web_contents/web_drag_dest_efl.cc", "//tizen_src/chromium_impl/content/browser/web_contents/web_drag_dest_efl.h", "//tizen_src/chromium_impl/content/browser/web_contents/web_drag_source_efl.cc", diff --git a/tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.cc b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.cc new file mode 100644 index 0000000..abdc627 --- /dev/null +++ b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.cc @@ -0,0 +1,181 @@ +// Copyright (c) 2022 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 "content/browser/web_contents/web_contents_view_aura_helper_efl.h" + +#include "content/browser/web_contents/web_contents_view_aura.h" + +namespace content { + +WebContentsViewAuraHelperEfl::WebContentsViewAuraHelperEfl( + WebContentsViewAura* wcva, + WebContentsImpl* web_contents, + WebContentsViewDelegate* delegate) + : wcv_aura_(wcva), web_contents_(web_contents), view_delegate_(delegate) {} + +WebContentsViewAuraHelperEfl::~WebContentsViewAuraHelperEfl() { + popup_client_.reset(); +} + +void WebContentsViewAuraHelperEfl::DidSelectPopupMenuItems( + std::vector& indices) { + popup_client_->DidAcceptIndices(indices); +} + +#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) +void WebContentsViewAuraHelperEfl::ShowPopupMenu( + RenderFrameHost* render_frame_host, + mojo::PendingRemote popup_client, + const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + std::vector items, + bool right_aligned, + bool allow_multiple_selection) { + if (popup_client_) + HidePopupMenu(); + + popup_client_.Bind(std::move(popup_client)); + popup_client_.set_disconnect_handler(base::BindOnce( + &WebContentsViewAuraHelperEfl::HidePopupMenu, base::Unretained(this))); + + if (efl_delegate_) { + efl_delegate_->ShowPopupMenu( + render_frame_host, bounds, item_height, item_font_size, selected_item, + std::move(items), right_aligned, allow_multiple_selection); + } +} + +void WebContentsViewAuraHelperEfl::HidePopupMenu() { + if (efl_delegate_) + efl_delegate_->HidePopupMenu(); + popup_client_.reset(); +} + +void WebContentsViewAuraHelperEfl::DidCancelPopupMenu() { + if (popup_client_) + popup_client_->DidCancel(); +} +#endif + +void WebContentsViewAuraHelperEfl::SetEflDelegate( + WebContentsEflDelegate* delegate) { + efl_delegate_ = delegate; +} + +WebContentsEflDelegate* WebContentsViewAuraHelperEfl::GetEflDelegate() { + return efl_delegate_; +} + +void WebContentsViewAuraHelperEfl::UpdateDragDest(RenderViewHost* host) { + // Drag-and-drop is entirely managed by BrowserPluginGuest for guest + // processes in a largely platform independent way. WebDragDestEfl + // will result in spurious messages being sent to the guest process which + // will violate assumptions. + if (host->GetProcess() && host->GetProcess()->IsForGuestsOnly()) { + DCHECK(!drag_dest_); + return; + } + + RenderWidgetHostView* view = web_contents_->GetRenderWidgetHostView(); + if (!view) + return; + + // Create the new drag_dest_. + drag_dest_.reset(new WebDragDestEfl(web_contents_)); + drag_dest_->SetPageScaleFactor(page_scale_factor_); + + if (view_delegate_) + drag_dest_->SetDelegate(view_delegate_->GetDragDestDelegate()); +} + +void WebContentsViewAuraHelperEfl::StartDragging( + const DropData& drop_data, + blink::DragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const blink::mojom::DragEventSourceInfo& event_info, + RenderWidgetHostImpl* source_rwh) { + if (drag_dest_) { + drag_dest_->SetDropData(drop_data); + drag_dest_->SetAction(allowed_ops); + } + + if (!drag_source_) { + drag_source_.reset(new WebDragSourceEfl(web_contents_)); + drag_source_->SetPageScaleFactor(page_scale_factor_); + } + + if (!drag_source_->StartDragging(drop_data, allowed_ops, event_info.location, + *image.bitmap(), image_offset)) { + web_contents_->SystemDragEnded(source_rwh); + } +} + +DropData* WebContentsViewAuraHelperEfl::GetDropData() const { + if (drag_dest_) + return drag_dest_->GetDropData(); + return nullptr; +} + +bool WebContentsViewAuraHelperEfl::IsDragging() const { + if (!drag_source_) + return false; + return drag_source_->IsDragging(); +} + +void WebContentsViewAuraHelperEfl::SetPageScaleFactor(float scale) { + page_scale_factor_ = scale; + if (drag_source_) + drag_source_->SetPageScaleFactor(scale); + if (drag_dest_) + drag_dest_->SetPageScaleFactor(scale); +} + +void WebContentsViewAuraHelperEfl::OnSelectionRectReceived( + const gfx::Rect& selection_rect) const { +#if !defined(EWK_BRINGUP) + view_delegate_->OnSelectionRectReceived(selection_rect); +#endif +} + +void WebContentsViewAuraHelperEfl::ShowContextMenu( + const ContextMenuParams& params) { + if (efl_delegate_) + efl_delegate_->ShowContextMenu(params); +} + +void WebContentsViewAuraHelperEfl::CancelContextMenu(int request_id) { + if (efl_delegate_) + efl_delegate_->CancelContextMenu(request_id); +} + +bool WebContentsViewAuraHelperEfl::ImePanelEnabled() const { +#if !defined(EWK_BRINGUP) + if (efl_delegate_) + return efl_delegate_->ImePanelEnabled(); +#endif + return true; +} + +bool WebContentsViewAuraHelperEfl::ImeHandleKeyEventEnabled() const { +#if !defined(EWK_BRINGUP) + if (efl_delegate_) + return efl_delegate_->ImeHandleKeyEventEnabled(); +#endif + return true; +} + +void WebContentsViewAuraHelperEfl::OnOverscrolled( + const gfx::Vector2dF& accumulated_overscroll, + const gfx::Vector2dF& latest_overscroll_delta) { +#if !defined(EWK_BRINGUP) + if (efl_delegate_) + efl_delegate_->OnOverscrolled(accumulated_overscroll, + latest_overscroll_delta); +#endif +} + +} // namespace content diff --git a/tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.h b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.h new file mode 100644 index 0000000..a732c19 --- /dev/null +++ b/tizen_src/chromium_impl/content/browser/web_contents/web_contents_view_aura_helper_efl.h @@ -0,0 +1,100 @@ +// Copyright (c) 2022 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_CONTENTS_VIEW_AURA_HELPER_EFL +#define WEB_CONTENTS_VIEW_AURA_HELPER_EFL + +#include "content/browser/web_contents/web_contents_impl.h" +#include "content/browser/web_contents/web_contents_view.h" +#include "content/browser/web_contents/web_drag_dest_efl.h" +#include "content/browser/web_contents/web_drag_source_efl.h" +#include "content/common/buildflags.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents_efl_delegate.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/remote.h" +#include "third_party/blink/public/common/page/drag_operation.h" +#include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h" +#include "ui/gfx/image/image_skia.h" + +namespace content { + +class RenderFrameHost; +class RenderWidgetHostImpl; +class RenderWidgetHostViewBase; +class WebContentsViewAura; +class WebContentsImpl; + +class CONTENT_EXPORT WebContentsViewAuraHelperEfl { + public: + WebContentsViewAuraHelperEfl(WebContentsViewAura* wcva, + WebContentsImpl* web_contents, + WebContentsViewDelegate* delegate); + ~WebContentsViewAuraHelperEfl(); + + WebContentsViewAuraHelperEfl(const WebContentsViewAuraHelperEfl&) = delete; + WebContentsViewAuraHelperEfl& operator=(const WebContentsViewAuraHelperEfl&) = + delete; + + void DidSelectPopupMenuItems(std::vector& indices); +#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) + void ShowPopupMenu( + RenderFrameHost* render_frame_host, + mojo::PendingRemote popup_client, + const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + std::vector items, + bool right_aligned, + bool allow_multiple_selection); + void HidePopupMenu(); + void DidCancelPopupMenu(); +#endif + bool ImePanelEnabled() const; + bool ImeHandleKeyEventEnabled() const; + + void SetEflDelegate(WebContentsEflDelegate*); + WebContentsEflDelegate* GetEflDelegate(); + void UpdateDragDest(RenderViewHost* host); + void StartDragging(const DropData& drop_data, + blink::DragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const blink::mojom::DragEventSourceInfo& event_info, + RenderWidgetHostImpl* source_rwh); + + DropData* GetDropData() const; + bool IsDragging() const; + void SetPageScaleFactor(float); + + void OnSelectionRectReceived(const gfx::Rect& selection_rect) const; + void ShowContextMenu(const ContextMenuParams& params); + void CancelContextMenu(int request_id); + + void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll, + const gfx::Vector2dF& latest_overscroll_delta); + + private: + mojo::Remote popup_client_; + + WebContentsViewAura* wcv_aura_ = nullptr; + WebContentsImpl* web_contents_ = nullptr; + + // Delegate owned by WebContentsImplEfl + WebContentsEflDelegate* efl_delegate_ = nullptr; + + // Our optional, generic views wrapper. + WebContentsViewDelegate* view_delegate_ = nullptr; + + // Helpers handling drag source/destination related interactions with EFL. + std::unique_ptr drag_source_; + std::unique_ptr drag_dest_; + float page_scale_factor_ = 1.0f; +}; + +} // namespace content + +#endif diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 3e44712..7da077e 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -26,6 +26,8 @@ #include "content/browser/renderer_host/ui_events_helper.h" #include "content/browser/web_contents/web_contents_impl_efl.h" #include "content/browser/web_contents/web_contents_view.h" +#include "content/browser/web_contents/web_contents_view_aura.h" +#include "content/browser/web_contents/web_contents_view_aura_helper_efl.h" #include "content/common/content_client_export.h" #include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_task_traits.h" @@ -185,11 +187,6 @@ void EWebView::Initialize() { scroll_detector_.reset(new ScrollDetector(this)); - web_contents_delegate_.reset(new WebContentsDelegateEfl(this)); - web_contents_->SetDelegate(web_contents_delegate_.get()); - back_forward_list_.reset( - new _Ewk_Back_Forward_List(web_contents_->GetController())); - DCHECK(web_contents_->GetRenderViewHost()); // Settings (content::WebPreferences) will be initalized by // RenderViewHostImpl::ComputeWebkitPrefs() based on command line switches. @@ -311,6 +308,11 @@ content::RenderWidgetHostViewAura* EWebView::rwhva() const { web_contents_->GetRenderWidgetHostView()); } +content::WebContentsViewAura* EWebView::wcva() const { + WebContentsImpl* wc = static_cast(web_contents_.get()); + return static_cast(wc->GetView()); +} + void EWebView::ResetContextMenuController() { return context_menu_.reset(); } @@ -645,12 +647,7 @@ void EWebView::HandleTouchEvents(Ewk_Touch_Event_Type type, } #endif } -#if !defined(USE_AURA) -content::WebContentsViewEfl* EWebView::GetWebContentsViewEfl() const { - WebContentsImpl* wc = static_cast(web_contents_.get()); - return static_cast(wc->GetView()); -} -#endif + bool EWebView::TouchEventsEnabled() const { return touch_events_enabled_; } @@ -1965,9 +1962,7 @@ double EWebView::GetScale() { void EWebView::DidChangePageScaleFactor(double scale_factor) { page_scale_factor_ = scale_factor; -#if !defined(USE_AURA) - GetWebContentsViewEfl()->SetPageScaleFactor(scale_factor); -#endif + wcva()->wcva_helper()->SetPageScaleFactor(scale_factor); SetScaledContentsSize(); } @@ -2114,11 +2109,7 @@ void EWebView::SetCertificatePem(const std::string& certificate) { } bool EWebView::IsDragging() const { -#if !defined(USE_AURA) - return GetWebContentsViewEfl()->IsDragging(); -#else - return false; -#endif + return wcva()->wcva_helper()->IsDragging(); } void EWebView::ShowFileChooser(content::RenderFrameHost* render_frame_host, @@ -2302,6 +2293,8 @@ void EWebView::InitializeContent() { WebContentsImplEfl* wc_efl = static_cast(web_contents_.get()); wc_efl->SetEflDelegate(new WebContentsEflDelegateEwk(this)); + wcva()->wcva_helper()->SetEflDelegate(wc_efl->GetEflDelegate()); + back_forward_list_.reset( new _Ewk_Back_Forward_List(web_contents_->GetController())); diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 83b9bd4..6b09cf1 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -66,6 +66,7 @@ class RenderFrameHost; class RenderViewHost; class RenderWidgetHostViewAura; class WebContentsDelegateEfl; +class WebContentsViewAura; class ContextMenuControllerEfl; class PopupControllerEfl; } @@ -184,6 +185,7 @@ class EWebView { content::WebContentsEflDelegate::WebContentsCreateCallback); static Evas_Object* GetHostWindowDelegate(const content::WebContents*); + content::WebContentsViewAura* wcva() const; content::RenderWidgetHostViewAura* rwhva() const; Ewk_Context* context() const { return context_.get(); } Evas_Object* evas_object() const { return evas_object_; } @@ -506,9 +508,6 @@ class EWebView { int y, Ewk_Hit_Test_Mode mode, WebViewAsyncRequestHitTestDataCallback* cb); -#if !defined(USE_AURA) - content::WebContentsViewEfl* GetWebContentsViewEfl() const; -#endif #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP) static void cameraResultCb(service_h request, service_h reply, -- 2.7.4 From 6d30a22e404e60873f06d1c284c80ef899151588 Mon Sep 17 00:00:00 2001 From: "ayush.k123" Date: Mon, 16 Jan 2023 18:15:08 +0530 Subject: [PATCH 16/16] [M108 Migration] Bring up Geolocation This patch brings up Geolocation feature to M108. Reference: https://review.tizen.org/gerrit/274261/ Change-Id: I004a61ee5b1800c97c5ca97f3714e5fce16a8a59 Signed-off-by: Ayush Kumar --- services/device/geolocation/location_arbitrator.cc | 17 ++- .../modules/geolocation/geolocation_coordinates.cc | 11 +- tizen_src/ewk/efl_integration/BUILD.gn | 9 -- .../browser/geolocation/location_provider_efl.cc | 116 ++++++++++++--------- .../browser/geolocation/location_provider_efl.h | 53 ++++++---- .../efl_integration/content_browser_client_efl.cc | 3 - .../private/ewk_geolocation_private.cc | 9 +- .../private/ewk_geolocation_private.h | 2 +- 8 files changed, 130 insertions(+), 90 deletions(-) diff --git a/services/device/geolocation/location_arbitrator.cc b/services/device/geolocation/location_arbitrator.cc index 723328e..f875edf 100644 --- a/services/device/geolocation/location_arbitrator.cc +++ b/services/device/geolocation/location_arbitrator.cc @@ -17,6 +17,11 @@ #include "services/device/public/cpp/geolocation/geoposition.h" #include "services/network/public/cpp/shared_url_loader_factory.h" +#if BUILDFLAG(IS_TIZEN) +#include "base/base_switches.h" +#include "base/command_line.h" +#endif + namespace device { // To avoid oscillations, set this to twice the expected update interval of a @@ -149,8 +154,8 @@ LocationArbitrator::NewNetworkLocationProvider( scoped_refptr url_loader_factory, const std::string& api_key) { DCHECK(url_loader_factory); -#if BUILDFLAG(IS_ANDROID) - // Android uses its own SystemLocationProvider. +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_TIZEN) + // Android/Tizen uses its own SystemLocationProvider. return nullptr; #else return std::make_unique( @@ -161,6 +166,14 @@ LocationArbitrator::NewNetworkLocationProvider( std::unique_ptr LocationArbitrator::NewSystemLocationProvider() { +#if BUILDFLAG(IS_TIZEN) + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableOffscreenRendering)) { + return device::NewSystemLocationProvider(main_task_runner_, + geolocation_manager_); + } +#endif + #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) return nullptr; #else diff --git a/third_party/blink/renderer/modules/geolocation/geolocation_coordinates.cc b/third_party/blink/renderer/modules/geolocation/geolocation_coordinates.cc index fb01ad3..54930be 100644 --- a/third_party/blink/renderer/modules/geolocation/geolocation_coordinates.cc +++ b/third_party/blink/renderer/modules/geolocation/geolocation_coordinates.cc @@ -25,6 +25,10 @@ #include "third_party/blink/renderer/modules/geolocation/geolocation_coordinates.h" +#if BUILDFLAG(IS_TIZEN) +#include +#endif + namespace blink { absl::optional GeolocationCoordinates::altitude() const { @@ -40,8 +44,13 @@ absl::optional GeolocationCoordinates::altitudeAccuracy() const { } absl::optional GeolocationCoordinates::heading() const { - if (can_provide_heading_) + if (can_provide_heading_) { +#if BUILDFLAG(IS_TIZEN) + if (can_provide_speed_ && speed_ == 0.0) + return std::numeric_limits::quiet_NaN(); +#endif return heading_; + } return absl::nullopt; } diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index e9d015b..da0da3390 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -143,13 +143,6 @@ shared_library("chromium-ewk") { "browser/geolocation/location_provider_efl.cc", "browser/geolocation/location_provider_efl.h", ] - if (ewk_bringup) { - # FIXME: EWK_BRINGUP - exclude_source_set -= [ - "browser/geolocation/location_provider_efl.cc", - "browser/geolocation/location_provider_efl.h", - ] - } } # TODO : Below dependency is set in chromium/device/battery_tizen.gypi, @@ -605,8 +598,6 @@ shared_library("chromium-ewk") { # FIXME: Followings are guarded just for bringup. if (ewk_bringup) { sources -= [ - "browser/geolocation/location_provider_efl.cc", - "browser/geolocation/location_provider_efl.h", "browser/vibration/vibration_provider_client.cc", "browser/vibration/vibration_provider_client.h", "permission_popup_manager.cc", diff --git a/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.cc b/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.cc index 13bb051..2b8b815 100644 --- a/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.cc @@ -3,74 +3,98 @@ // found in the LICENSE file. #include "browser/geolocation/location_provider_efl.h" - #include "base/bind.h" #include "base/logging.h" #include "base/time/time.h" -#include "base/message_loop/message_loop.h" -#include "content/public/common/geoposition.h" -namespace content { +#include "services/device/public/cpp/geolocation/geolocation_manager.h" -LocationProviderEfl::LocationProviderEfl() - : LocationProviderBase() - , location_manager_(NULL) - , geolocation_message_loop_(base::MessageLoop::current()) { +namespace device { + +static double KilometerPerHourToMeterPerSecond(double kilometer_per_hour) { + return kilometer_per_hour * 5 / 18; } +LocationProviderEfl::LocationProviderEfl() + : location_manager_(nullptr), + task_runner_(base::ThreadTaskRunnerHandle::Get()) {} + LocationProviderEfl::~LocationProviderEfl() { StopProvider(); } // static -void LocationProviderEfl::GeoPositionChangedCb( - double latitude, double longitude, double altitude, - time_t timestamp, void* user_data) { +void LocationProviderEfl::GeoPositionChangedCb(double latitude, + double longitude, + double altitude, + double speed, + double direction, + double horizontal_accuracy, + time_t timestamp, + void* user_data) { LocationProviderEfl* location_provider = static_cast(user_data); DCHECK(location_provider); - location_provider->NotifyPositionChanged( - latitude, longitude, altitude, timestamp); + location_provider->NotifyPositionChanged(latitude, longitude, altitude, speed, + direction, horizontal_accuracy, + timestamp); +} +void LocationProviderEfl::NotifyCallback(const mojom::Geoposition& position) { + if (!callback_.is_null()) + callback_.Run(this, position); } -void LocationProviderEfl::NotifyPositionChanged( - double latitude, double longitude, double altitude, time_t timestamp) { - location_accuracy_level_e level; +void LocationProviderEfl::SetUpdateCallback( + const LocationProviderUpdateCallback& callback) { + callback_ = callback; +} +void LocationProviderEfl::NotifyPositionChanged(double latitude, + double longitude, + double altitude, + double speed, + double direction, + double horizontal_accuracy, + time_t timestamp) { DCHECK(location_manager_); - DCHECK(geolocation_message_loop_); + DCHECK(task_runner_); last_position_.latitude = latitude; last_position_.longitude = longitude; + last_position_.altitude = altitude; last_position_.timestamp = base::Time::FromTimeT(timestamp); + last_position_.speed = KilometerPerHourToMeterPerSecond(speed); + last_position_.heading = direction; + location_accuracy_level_e level; location_manager_get_last_accuracy(location_manager_, &level, &last_position_.accuracy, &last_position_.altitude_accuracy); - base::Closure task = base::BindOnce(&LocationProviderEfl::NotifyCallback, - base::Unretained(this), last_position_); - geolocation_message_loop_->PostTask(FROM_HERE, task); + base::OnceClosure task = + base::BindOnce(&LocationProviderEfl::NotifyCallback, + base::Unretained(this), last_position_); + task_runner_->PostTask(FROM_HERE, std::move(task)); } -bool LocationProviderEfl::StartProvider(bool high_accuracy) { +void LocationProviderEfl::StartProvider(bool high_accuracy) { if (location_manager_) { // already started! - return false; + return; } int ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &location_manager_); if (ret != LOCATIONS_ERROR_NONE) { LOG(ERROR) << "Failed to create location manager!"; - return false; + return; } - ret = location_manager_set_position_updated_cb( - location_manager_, GeoPositionChangedCb, 1, this); + ret = location_manager_set_location_changed_cb(location_manager_, + GeoPositionChangedCb, 1, this); if (ret != LOCATIONS_ERROR_NONE) { LOG(ERROR) << "Failed to register position changed callback!"; location_manager_destroy(location_manager_); - location_manager_ = NULL; - return false; + location_manager_ = nullptr; + return; } ret = static_cast(location_manager_start(location_manager_)); @@ -78,40 +102,34 @@ bool LocationProviderEfl::StartProvider(bool high_accuracy) { LOG(ERROR) << "Failed to start location manager: " << ret; location_manager_unset_position_updated_cb(location_manager_); location_manager_destroy(location_manager_); - location_manager_ = NULL; - return false; + location_manager_ = nullptr; } - - return true; } void LocationProviderEfl::StopProvider() { - if (location_manager_) { - int ret = location_manager_stop(location_manager_); - if (ret == LOCATIONS_ERROR_NONE) { - location_manager_unset_position_updated_cb(location_manager_); - } + if (!location_manager_) + return; - // TODO: didn't stop but destroy? - location_manager_destroy(location_manager_); - location_manager_ = NULL; - } -} + int ret = location_manager_stop(location_manager_); + if (ret == LOCATIONS_ERROR_NONE) + location_manager_unset_position_updated_cb(location_manager_); -void LocationProviderEfl::GetPosition(Geoposition* position) { - DCHECK(position); - *position = last_position_; + // TODO: didn't stop but destroy? + location_manager_destroy(location_manager_); + location_manager_ = nullptr; } -void LocationProviderEfl::RequestRefresh() { +const mojom::Geoposition& LocationProviderEfl::GetPosition() { + return last_position_; } void LocationProviderEfl::OnPermissionGranted() { } -//static -LocationProvider* LocationProviderEfl::Create() { - return new LocationProviderEfl(); +std::unique_ptr NewSystemLocationProvider( + scoped_refptr main_task_runner, + GeolocationManager* geolocation_manager) { + return base::WrapUnique(new LocationProviderEfl()); } -} // namespace content +} // namespace device diff --git a/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.h b/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.h index b47d447..5616c1b 100644 --- a/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.h +++ b/tizen_src/ewk/efl_integration/browser/geolocation/location_provider_efl.h @@ -6,43 +6,50 @@ #define LOCATION_PROVIDER_EFL_H_ #include "base/compiler_specific.h" -#include "content/browser/geolocation/location_provider_base.h" -#include "content/public/common/geoposition.h" +#include "base/memory/ptr_util.h" +#include "services/device/geolocation/geolocation_provider.h" +#include "services/device/public/cpp/geolocation/geoposition.h" +#include "services/device/public/cpp/geolocation/location_provider.h" #include -namespace base { -class MessageLoop; -} +namespace device { -namespace content { - -class LocationProviderEfl : public LocationProviderBase { +class LocationProviderEfl : public LocationProvider { public: - virtual ~LocationProviderEfl(); + LocationProviderEfl(); + ~LocationProviderEfl() override; - static LocationProvider* Create(); + void SetUpdateCallback( + const LocationProviderUpdateCallback& callback) override; + void StartProvider(bool high_accuracy) override; + void StopProvider() override; + const mojom::Geoposition& GetPosition() override; - virtual bool StartProvider(bool high_accuracy) override; - virtual void StopProvider() override; - virtual void GetPosition(Geoposition* position) override; - virtual void RequestRefresh() override; - virtual void OnPermissionGranted() override; + void OnPermissionGranted() override; private: - LocationProviderEfl(); - LocationProviderEfl(const LocationProviderEfl&) = delete; LocationProviderEfl& operator=(const LocationProviderEfl&) = delete; - static void GeoPositionChangedCb(double, double, double, time_t, void*); - void NotifyPositionChanged(double, double, double, time_t); - - Geoposition last_position_; + static void GeoPositionChangedCb(double, + double, + double, + double, + double, + double, + time_t, + void*); + void + NotifyPositionChanged(double, double, double, double, double, double, time_t); + void NotifyCallback(const mojom::Geoposition&); + + mojom::Geoposition last_position_; location_manager_h location_manager_; - base::MessageLoop* geolocation_message_loop_; + scoped_refptr task_runner_; + LocationProviderUpdateCallback callback_; }; -} // namespace content +} // namespace device #endif // LOCATION_PROVIDER_EFL_H_ diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc index 878d02a..7b36d0f 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc @@ -35,9 +35,6 @@ #include "web_contents_view_delegate_ewk.h" #if BUILDFLAG(IS_TIZEN) -#if !defined(EWK_BRINGUP) -#include "browser/geolocation/location_provider_efl.h" -#endif #include #include "content/browser/speech/tts_message_filter_efl.h" #endif diff --git a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc index a705b07..4091a6d 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "ewk_geolocation_private.h" +#include "content/public/browser/browser_thread.h" #include "private/ewk_security_origin_private.h" - -#include +#include "services/device/geolocation/geolocation_provider_impl.h" using content::BrowserThread; using namespace blink::mojom; @@ -22,6 +22,11 @@ _Ewk_Geolocation_Permission_Request::~_Ewk_Geolocation_Permission_Request() { } void _Ewk_Geolocation_Permission_Request::runCallback(bool allowed) { + if (allowed) { + device::GeolocationProviderImpl::GetInstance() + ->UserDidOptIntoLocationServices(); + } + std::move(callback_).Run(allowed ? PermissionStatus::GRANTED : PermissionStatus::DENIED); } diff --git a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h index e3619d0..ab83c11 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h @@ -20,7 +20,7 @@ class _Ewk_Geolocation_Permission_Request : public Ewk_Suspendable_Object{ _Ewk_Geolocation_Permission_Request( const GURL& origin_url, base::OnceCallback callback); - ~_Ewk_Geolocation_Permission_Request(); + ~_Ewk_Geolocation_Permission_Request() override; _Ewk_Security_Origin* GetOrigin() const { return origin_; } -- 2.7.4