From 765fd885ce7115436121792b05f55494276d9959 Mon Sep 17 00:00:00 2001 From: liuchuang65 Date: Thu, 19 Dec 2024 11:20:01 +0800 Subject: [PATCH] =?UTF-8?q?WebUA=E9=80=82=E9=85=8D=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/ohos/sys_info_utils.cc | 13 +++++++++++-- base/ohos/sys_info_utils.h | 1 + content/common/user_agent.cc | 9 ++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/base/ohos/sys_info_utils.cc b/base/ohos/sys_info_utils.cc index 6ca1c3c82a..710a7ccc92 100644 --- a/base/ohos/sys_info_utils.cc +++ b/base/ohos/sys_info_utils.cc @@ -53,6 +53,8 @@ class SystemProperties { std::string base_os_name() { return base_os_name_; } + std::string compatible_device_type() { return compatible_device_type_; } + #ifdef OHOS_SCROLLBAR float get_pixel_ratio() { return virtual_pixel_ratio_;} void set_pixel_ratio(float ratio) { virtual_pixel_ratio_ = ratio;} @@ -69,6 +71,7 @@ class SystemProperties { std::string os_name_; std::string os_version_; std::string base_os_name_; + std::string compatible_device_type_; #ifdef OHOS_SCROLLBAR float virtual_pixel_ratio_ = 2.0; #endif @@ -92,8 +95,10 @@ SystemProperties::SystemProperties() .GetUserAgentOSVersion()), base_os_name_(OhosAdapterHelper::GetInstance() .GetSystemPropertiesInstance() - .GetUserAgentBaseOSName()) {} - + .GetUserAgentBaseOSName()), + compatible_device_type_(OhosAdapterHelper::GetInstance() + .GetSystemPropertiesInstance() + .GetCompatibleDeviceType()) {} } // namespace #ifdef OHOS_SCROLLBAR @@ -139,6 +144,10 @@ BASE_EXPORT std::string BaseOsName() { return SystemProperties::Instance()->base_os_name(); } +BASE_EXPORT std::string CompatibleDeviceType() { + return SystemProperties::Instance()->compatible_device_type(); +} + } // namespace ohos } // namespace base \ No newline at end of file diff --git a/base/ohos/sys_info_utils.h b/base/ohos/sys_info_utils.h index 1b53a581bd..a691700eed 100644 --- a/base/ohos/sys_info_utils.h +++ b/base/ohos/sys_info_utils.h @@ -46,6 +46,7 @@ BASE_EXPORT std::string OsVersion(); BASE_EXPORT std::string BaseOsName(); +BASE_EXPORT std::string CompatibleDeviceType(); } // namespace ohos } // namespace base diff --git a/content/common/user_agent.cc b/content/common/user_agent.cc index fefbe37563..1f6a55cd1f 100644 --- a/content/common/user_agent.cc +++ b/content/common/user_agent.cc @@ -14,7 +14,6 @@ #include "base/system/sys_info.h" #include "build/build_config.h" #include "build/util/chromium_git_revision.h" -#include "ohos_adapter_helper.h" #if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" @@ -272,9 +271,7 @@ std::string GetOSVersion(IncludeAndroidBuildNumber include_android_build_number, device_type_string = command_line->GetSwitchValueASCII(::switches::kUserAgentValue); } - std::string compatible_device_type = OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetSystemPropertiesInstance() - .GetCompatibleDeviceType(); + std::string compatible_device_type = base::ohos::CompatibleDeviceType(); if (!compatible_device_type.empty()) { if (compatible_device_type == "Phone" || compatible_device_type == "PC" || @@ -494,10 +491,8 @@ std::string BuildUserAgentFromOSAndProduct(const std::string& os_info, #if BUILDFLAG(IS_OHOS) && defined(OHOS_USERAGENT) std::string product_string = ""; + std::string compatible_device_type = base::ohos::CompatibleDeviceType(); - std::string compatible_device_type = OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetSystemPropertiesInstance() - .GetCompatibleDeviceType(); base::StringAppendF(&product_string, " ArkWeb/%s", ARKWEB_VERSION); if (base::ohos::IsMobileDevice()) { product_string += " Mobile"; -- Gitee