diff --git a/base/ohos/sys_info_utils.cc b/base/ohos/sys_info_utils.cc index 6ca1c3c82ae24703e02d22381f0a34a03b48341a..710a7ccc92ab5fed7294bcdf59ff1a4c9545b506 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 1b53a581bdf856f5cbc12287f6c751b62d4a00e7..a691700eed9998eea13485e01970ff199e4410cf 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 fefbe37563fd5d85bef0d8bbeb8bf351e9f65331..1f6a55cd1f892963653388e4ad84ee7016e38e11 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";