1diff --git a/BUILD.gn b/BUILD.gn 2index 2c674a5784..e1f11bc6e2 100644 3--- a/BUILD.gn 4+++ b/BUILD.gn 5@@ -33,7 +33,7 @@ import("//ui/gl/features.gni") 6 import("//v8/gni/snapshot_toolchain.gni") 7 import("//v8/gni/v8.gni") 8 9-if (is_android) { 10+if (is_android || is_ohos) { 11 import("//build/config/android/config.gni") 12 } 13 14@@ -100,7 +100,7 @@ group("gn_all") { 15 deps += [ "//third_party/abseil-cpp:absl_tests" ] 16 } 17 18- if (!is_android && !is_chromecast) { 19+ if (!is_android && !is_chromecast && !is_ohos) { 20 deps += [ 21 "//crypto:crypto_unittests", 22 "//google_apis/gcm:gcm_unit_tests", 23@@ -111,7 +111,7 @@ group("gn_all") { 24 deps += [ ":webui_closure_compile" ] 25 } 26 27- if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) { 28+ if (!is_ios && !is_android && !is_chromecast && !is_fuchsia && !is_ohos) { 29 deps += [ 30 "//chrome", 31 "//chrome/browser/ui/color:dump_colors", 32@@ -172,7 +172,7 @@ group("gn_all") { 33 ] 34 } 35 36- if (!is_ios) { 37+ if (!is_ios && !is_ohos) { 38 deps += [ 39 "//cc:cc_unittests", 40 "//components/policy:policy_templates", 41@@ -225,7 +225,7 @@ group("gn_all") { 42 } 43 } 44 45- if (!is_ios && !is_android) { 46+ if (!is_ios && !is_android && !is_ohos) { 47 deps += [ 48 "//components/cronet:cronet_tests", 49 "//components/cronet:cronet_unittests", 50@@ -238,16 +238,18 @@ group("gn_all") { 51 } 52 53 if (!is_ios && !is_fuchsia) { 54- deps += [ 55- "//chrome/test:telemetry_perf_unittests", 56- "//chrome/test:unit_tests", 57- "//components:components_browsertests", 58- "//device:device_unittests", 59- "//google_apis/gcm:mcs_probe", 60- "//media/capture:capture_unittests", 61- "//media/cast:cast_unittests", 62- "//third_party/catapult/telemetry:bitmaptools($host_toolchain)", 63- ] 64+ if (!is_ohos) { 65+ deps += [ 66+ "//chrome/test:telemetry_perf_unittests", 67+ "//chrome/test:unit_tests", 68+ "//components:components_browsertests", 69+ "//device:device_unittests", 70+ "//google_apis/gcm:mcs_probe", 71+ "//media/capture:capture_unittests", 72+ "//media/cast:cast_unittests", 73+ "//third_party/catapult/telemetry:bitmaptools($host_toolchain)", 74+ ] 75+ } 76 if (enable_cef) { 77 deps += [ "//cef" ] 78 } 79@@ -507,7 +509,7 @@ group("gn_all") { 80 81 # TODO(GYP): Figure out which of these should (and can) build 82 # for chromeos/ios. 83- if (!is_chromeos_ash && !is_ios && !is_fuchsia) { 84+ if (!is_chromeos_ash && !is_ios && !is_fuchsia && !is_ohos) { 85 deps += [ 86 "//base:build_utf8_validator_tables", 87 "//base:check_example", 88@@ -526,7 +528,7 @@ group("gn_all") { 89 "//ui/compositor:compositor_unittests", 90 ] 91 92- if (!is_android) { 93+ if (!is_android && !is_ohos) { 94 deps += [ 95 "//chrome/test:load_library_perf_tests", 96 "//chrome/test:sync_performance_tests", 97@@ -586,7 +588,7 @@ group("gn_all") { 98 deps += [ "//chrome/test/chromedriver:chromedriver($host_toolchain)" ] 99 } 100 101- if (is_android || (is_linux || is_chromeos_lacros)) { 102+ if (is_android || (is_linux || is_chromeos_lacros) || is_ohos) { 103 deps += [ 104 "//components/network_hints/browser", 105 "//content/public/app", 106@@ -599,7 +601,7 @@ group("gn_all") { 107 "//third_party/breakpad:minidump_stackwalk($host_toolchain)", 108 ] 109 110- if (!is_android) { 111+ if (!is_android && !is_ohos) { 112 deps += [ 113 "//chrome/test:chrome_app_unittests", 114 "//gpu/khronos_glcts_support:khronos_glcts_test", 115@@ -689,7 +691,7 @@ group("gn_all") { 116 } 117 } 118 119- if (is_mac || is_win || is_android || is_linux || is_chromeos) { 120+ if (is_mac || is_win || is_android || is_linux || is_chromeos || is_ohos) { 121 deps += [ 122 "//third_party/crashpad/crashpad:crashpad_tests", 123 "//third_party/crashpad/crashpad/handler:crashpad_handler", 124@@ -1013,7 +1015,7 @@ if (!is_ios) { 125 deps = [ ":blink_web_tests" ] 126 } 127 128- if (!is_chromeos_ash && !is_ios && !is_fuchsia && !is_android) { 129+ if (!is_chromeos_ash && !is_ios && !is_fuchsia && !is_android && !is_ohos) { 130 # WPT Webdriver tests runner 131 # chrome/test/chromedriver/test/run_webdriver_tests.py 132 script_test("webdriver_wpt_tests") { 133@@ -1310,7 +1312,7 @@ if (!is_ios) { 134 group("chromium_builder_perf") { 135 testonly = true 136 137- if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) { 138+ if (!is_ios && !is_android && !is_chromecast && !is_fuchsia && !is_ohos) { 139 data_deps = [ 140 "//cc:cc_perftests", 141 "//chrome/test:load_library_perf_tests", 142@@ -1355,7 +1357,7 @@ group("chromium_builder_perf") { 143 } 144 } 145 146-if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) { 147+if (!is_ios && !is_android && !is_chromecast && !is_fuchsia && !is_ohos) { 148 group("chromium_builder_asan") { 149 testonly = true 150 151@@ -1387,7 +1389,7 @@ if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) { 152 } 153 } 154 155-if (is_android) { 156+if (is_android || is_ohos) { 157 group("optimize_gn_gen") { 158 deps = [ 159 # These run expensive scripts in non-default toolchains. Generally, host 160diff --git a/android_webview/browser/lifecycle/aw_contents_lifecycle_notifier.h b/android_webview/browser/lifecycle/aw_contents_lifecycle_notifier.h 161index ec69d719a5..9039b189dd 100644 162--- a/android_webview/browser/lifecycle/aw_contents_lifecycle_notifier.h 163+++ b/android_webview/browser/lifecycle/aw_contents_lifecycle_notifier.h 164@@ -68,7 +68,7 @@ class AwContentsLifecycleNotifier { 165 AwContentsState aw_content_state = AwContentsState::kDetached; 166 167 private: 168- DISALLOW_COPY(AwContentsData); 169+ DISALLOW_COPY_BASE(AwContentsData); 170 }; 171 172 friend class TestAwContentsLifecycleNotifier; 173diff --git a/base/BUILD.gn b/base/BUILD.gn 174index c7bed2c7ea..9d9900844e 100644 175--- a/base/BUILD.gn 176+++ b/base/BUILD.gn 177@@ -90,6 +90,9 @@ declare_args() { 178 # Ensure that a non-GigaCage memory region can't be reused for GigaCage while 179 # there are associated CheckedPtr instances left. 180 use_gigacage_blocklist = false 181+ 182+ # Dump symbols for stack trace, default disable, add gn file to enable it 183+ use_symbolize = false 184 } 185 186 # Mutex priority inheritance is disabled by default due to security 187@@ -182,6 +185,20 @@ if (is_android) { 188 } 189 } 190 191+if (is_ohos) { 192+ import("//build/config/ohos/config.gni") 193+ config("ohos_system_libs") { 194+ libs = [ 195+ "hilog", 196+ "utils.z", 197+ "eventhandler.z", 198+ ] 199+ 200+ include_dirs = ohos_src_includes 201+ lib_dirs = ohos_libs_dir 202+ } 203+} 204+ 205 config("perfetto_config") { 206 if (use_perfetto_client_library) { 207 defines = [ 208@@ -1265,7 +1282,16 @@ component("base") { 209 ] 210 } 211 212- if (is_linux || is_chromeos) { 213+ if (is_ohos) { 214+ sources += [ 215+ "debug/stack_trace_ohos.cc", 216+ "profiler/stack_sampler_android.cc", 217+ "message_loop/message_pump_ohos.cc", 218+ ] 219+ public_configs = [ ":ohos_system_libs" ] 220+ } 221+ 222+ if (is_linux || is_chromeos || is_ohos) { 223 sources += [ 224 "debug/proc_maps_linux.cc", 225 "debug/proc_maps_linux.h", 226@@ -1313,6 +1339,13 @@ component("base") { 227 ] 228 } 229 230+ if (is_ohos) { 231+ sources += [ 232+ "base_paths_ohos.cc", 233+ "base_paths_ohos.h", 234+ ] 235+ } 236+ 237 if (is_posix) { 238 sources += [ "base_paths_posix.h" ] 239 } 240@@ -1391,7 +1424,7 @@ component("base") { 241 "allocator/allocator_shim_default_dispatch_to_partition_alloc.h", 242 "allocator/allocator_shim_internals.h", 243 ] 244- if (is_android) { 245+ if (is_android || is_ohos) { 246 sources += [ 247 "allocator/allocator_shim_override_cpp_symbols.h", 248 "allocator/allocator_shim_override_linker_wrapped_symbols.h", 249@@ -1420,7 +1453,7 @@ component("base") { 250 sources += [ "allocator/allocator_shim_default_dispatch_to_tcmalloc.cc" ] 251 deps += [ "//base/allocator:tcmalloc" ] 252 } else if (use_allocator == "none") { 253- if (is_android) { 254+ if (is_android || is_ohos) { 255 sources += [ "allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc" ] 256 } 257 if (is_apple) { 258@@ -1452,6 +1485,36 @@ component("base") { 259 defines += [ "SYSTEM_NATIVE_UTF8" ] 260 } 261 262+ if (is_ohos) { 263+ sources -= [ 264+ "debug/stack_trace_posix.cc", 265+ "profiler/stack_sampler_posix.cc", 266+ ] 267+ sources += [ 268+ "android/build_info.cc", 269+ "android/build_info.h", 270+ "debug/elf_reader.cc", 271+ "debug/elf_reader.h", 272+ "nix/mime_util_xdg.cc", 273+ "nix/mime_util_xdg.h", 274+ "nix/xdg_util.cc", 275+ "nix/xdg_util.h", 276+ "system/sys_info_linux.cc", 277+ ] 278+ deps += [ 279+ "//base/third_party/symbolize", 280+ "//base/third_party/xdg_mime", 281+ "//base/third_party/xdg_user_dirs", 282+ ] 283+ # Add this build flag in gn file to enable stack trace dump 284+ if (use_symbolize) { 285+ defines += [ "USE_SYMBOLIZE" ] 286+ deps += [ 287+ "//base/third_party/symbolize", 288+ ] 289+ } 290+ } 291+ 292 # Android. 293 if (is_android) { 294 sources -= [ 295@@ -2062,7 +2125,7 @@ component("base") { 296 "//base/third_party/xdg_user_dirs", 297 ] 298 } else { 299- if (!is_android) { 300+ if (!is_android && !is_ohos) { 301 sources -= [ 302 "linux_util.cc", 303 "linux_util.h", 304diff --git a/base/allocator/BUILD.gn b/base/allocator/BUILD.gn 305index 9348e2dc7c..6fb5b05699 100644 306--- a/base/allocator/BUILD.gn 307+++ b/base/allocator/BUILD.gn 308@@ -63,7 +63,7 @@ config("tcmalloc_flags") { 309 cflags = [] 310 } 311 312- if (is_linux || is_chromeos || is_android) { 313+ if (is_linux || is_chromeos || is_android || is_ohos) { 314 # We enable all warnings by default, but upstream disables a few. 315 # Keep "-Wno-*" flags in sync with upstream by comparing against: 316 # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.am 317@@ -176,7 +176,7 @@ if (use_allocator == "tcmalloc") { 318 #"win_allocator.cc", 319 ] 320 321- if (is_android) { 322+ if (is_android || is_ohos) { 323 sources += [ "$tcmalloc_dir/src/config_android.h" ] 324 } 325 326@@ -244,7 +244,7 @@ if (use_allocator == "tcmalloc") { 327 defines += [ "ENABLE_PROFILING=1" ] 328 } 329 330- if (is_linux || is_chromeos || is_android) { 331+ if (is_linux || is_chromeos || is_android || is_ohos) { 332 sources -= [ 333 "$tcmalloc_dir/src/system-alloc.h", 334 "$tcmalloc_dir/src/windows/port.cc", 335diff --git a/base/allocator/allocator.gni b/base/allocator/allocator.gni 336index 1b8150c150..3f355de134 100644 337--- a/base/allocator/allocator.gni 338+++ b/base/allocator/allocator.gni 339@@ -15,13 +15,13 @@ _is_using_sanitizers = is_asan || is_hwasan || is_lsan || is_tsan || is_msan 340 _disable_partition_alloc = 341 (is_win && (is_component_build || is_debug)) || 342 (is_android && is_component_build) || (is_android && is_chromecast) || 343- (is_linux && is_component_build) 344-_is_partition_alloc_platform = is_android || is_win || is_linux 345+ (is_linux && is_component_build) || (is_ohos && is_component_build) 346+_is_partition_alloc_platform = is_android || is_win || is_linux || is_ohos 347 348 # The debug CRT on Windows has some debug features that are incompatible with 349 # the shim. NaCl in particular does seem to link some binaries statically 350 # against the debug CRT with "is_nacl=false". 351-if ((is_linux || is_chromeos || is_android || is_apple || 352+if ((is_linux || is_chromeos || is_android || is_apple || is_ohos || 353 (is_win && !is_component_build && !is_debug)) && !_is_using_sanitizers) { 354 _default_use_allocator_shim = true 355 } else { 356@@ -31,7 +31,7 @@ if ((is_linux || is_chromeos || is_android || is_apple || 357 if (_default_use_allocator_shim && _is_partition_alloc_platform && 358 !_disable_partition_alloc) { 359 _default_allocator = "partition" 360-} else if (is_android || is_apple || _is_using_sanitizers || is_win || 361+} else if (is_android || is_apple || _is_using_sanitizers || is_win || is_ohos || 362 is_fuchsia || ((is_linux || is_chromeos) && target_cpu == "arm64") || 363 (is_cast_audio_only && target_cpu == "arm")) { 364 # Temporarily disable tcmalloc on arm64 linux to get rid of compilation 365@@ -79,7 +79,7 @@ assert(!is_mac || use_allocator != "tcmalloc", 366 assert(!is_ios || use_allocator != "tcmalloc", "Tcmalloc doesn't work on iOS.") 367 368 assert( 369- !use_allocator_shim || is_linux || is_chromeos || is_android || is_win || 370+ !use_allocator_shim || is_linux || is_chromeos || is_android || is_win || is_ohos || 371 is_apple, 372 "use_allocator_shim works only on Android, iOS, Linux, macOS, and Windows.") 373 374diff --git a/base/allocator/allocator_shim.cc b/base/allocator/allocator_shim.cc 375index e085adfe59..6a56b75b72 100644 376--- a/base/allocator/allocator_shim.cc 377+++ b/base/allocator/allocator_shim.cc 378@@ -330,7 +330,7 @@ ALWAYS_INLINE void ShimAlignedFree(void* address, void* context) { 379 #include "base/allocator/allocator_shim_override_cpp_symbols.h" 380 #endif 381 382-#if defined(OS_ANDROID) 383+#if defined(OS_ANDROID) || defined(OS_OHOS) 384 // Android does not support symbol interposition. The way malloc symbols are 385 // intercepted on Android is by using link-time -wrap flags. 386 #include "base/allocator/allocator_shim_override_linker_wrapped_symbols.h" 387diff --git a/base/allocator/allocator_shim_internals.h b/base/allocator/allocator_shim_internals.h 388index da1e5a6f92..d5b9945273 100644 389--- a/base/allocator/allocator_shim_internals.h 390+++ b/base/allocator/allocator_shim_internals.h 391@@ -9,7 +9,9 @@ 392 393 #if defined(__GNUC__) 394 395+#if !defined(__MUSL__) 396 #include <sys/cdefs.h> // for __THROW 397+#endif 398 399 #ifndef __THROW // Not a glibc system 400 #ifdef _NOEXCEPT // LLVM libc++ uses noexcept instead 401diff --git a/base/android/build_info.cc b/base/android/build_info.cc 402index 12597e6908..2672b63839 100644 403--- a/base/android/build_info.cc 404+++ b/base/android/build_info.cc 405@@ -5,11 +5,12 @@ 406 #include "base/android/build_info.h" 407 408 #include <string> 409- 410+#if !defined(OS_OHOS) 411 #include "base/android/jni_android.h" 412 #include "base/android/jni_array.h" 413 #include "base/android/scoped_java_ref.h" 414 #include "base/base_jni_headers/BuildInfo_jni.h" 415+#endif 416 #include "base/check_op.h" 417 #include "base/memory/singleton.h" 418 #include "base/notreached.h" 419@@ -36,11 +37,17 @@ int GetIntParam(const std::vector<std::string>& params, int index) { 420 421 struct BuildInfoSingletonTraits { 422 static BuildInfo* New() { 423+ #if !defined(OS_OHOS) 424 JNIEnv* env = AttachCurrentThread(); 425 ScopedJavaLocalRef<jobjectArray> params_objs = Java_BuildInfo_getAll(env); 426 std::vector<std::string> params; 427 AppendJavaStringArrayToStringVector(env, params_objs, ¶ms); 428 return new BuildInfo(params); 429+ #else 430+ std::vector<std::string> params; 431+ return new BuildInfo(params); 432+ #endif 433+ 434 } 435 436 static void Delete(BuildInfo* x) { 437diff --git a/base/android/build_info.h b/base/android/build_info.h 438index cb9f2fe790..a431773650 100644 439--- a/base/android/build_info.h 440+++ b/base/android/build_info.h 441@@ -5,7 +5,9 @@ 442 #ifndef BASE_ANDROID_BUILD_INFO_H_ 443 #define BASE_ANDROID_BUILD_INFO_H_ 444 445+#if !defined(OSOHOS) 446 #include <jni.h> 447+#endif 448 449 #include <string> 450 #include <vector> 451diff --git a/base/base_paths.h b/base/base_paths.h 452index 5504336182..b0ad12dcc9 100644 453--- a/base/base_paths.h 454+++ b/base/base_paths.h 455@@ -16,6 +16,8 @@ 456 #include "base/base_paths_mac.h" 457 #elif defined(OS_ANDROID) 458 #include "base/base_paths_android.h" 459+#elif defined(OS_OHOS) 460+#include "base/base_paths_ohos.h" 461 #endif 462 463 #if defined(OS_POSIX) || defined(OS_FUCHSIA) 464diff --git a/base/base_paths_ohos.cc b/base/base_paths_ohos.cc 465new file mode 100644 466index 0000000000..2e507f8c9d 467--- /dev/null 468+++ b/base/base_paths_ohos.cc 469@@ -0,0 +1,66 @@ 470+// Copyright (c) 2022 The Chromium Authors. All rights reserved. 471+// Use of this source code is governed by a BSD-style license that can be 472+// found in the LICENSE file. 473+ 474+// Defines base::PathProviderOHOS which replaces base::PathProviderPosix for 475+// OHOS in base/path_service.cc. 476+#include "base/base_paths_ohos.h" 477+ 478+#include <limits.h> 479+#include <unistd.h> 480+ 481+#include "base/base_paths.h" 482+#include "base/files/file_path.h" 483+#include "base/files/file_util.h" 484+#include "base/notreached.h" 485+#include "base/process/process_metrics.h" 486+ 487+namespace base { 488+ 489+bool PathProviderOHOS(int key, FilePath* result) { 490+ FilePath bin_dir; 491+ switch (key) { 492+ case base::FILE_EXE: { 493+ if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { 494+ NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; 495+ return false; 496+ } 497+ *result = bin_dir; 498+ return true; 499+ } 500+ case base::FILE_MODULE: 501+ NOTIMPLEMENTED(); 502+ return false; 503+ case base::DIR_MODULE: { 504+ if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { 505+ NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; 506+ return false; 507+ } 508+ *result = bin_dir.DirName(); 509+ return true; 510+ } 511+ case base::DIR_SOURCE_ROOT: 512+ NOTIMPLEMENTED(); 513+ return false; 514+ case base::DIR_USER_DESKTOP: 515+ NOTIMPLEMENTED(); 516+ return false; 517+ case base::DIR_CACHE: 518+ // set to /data/local directory for W|X permission. 519+ *result = FilePath("/data/local"); 520+ return true; 521+ case base::DIR_ASSETS: 522+ // resource file packed to system images 523+ *result = FilePath("/system/etc/webview"); 524+ return true; 525+ case base::DIR_OHOS_APP_DATA: 526+ *result = FilePath("/data/local"); 527+ return true; 528+ case base::DIR_OHOS_EXTERNAL_STORAGE: 529+ return false; 530+ default: 531+ return false; 532+ } 533+} 534+ 535+} // namespace base 536diff --git a/base/base_paths_ohos.h b/base/base_paths_ohos.h 537new file mode 100644 538index 0000000000..b85158a319 539--- /dev/null 540+++ b/base/base_paths_ohos.h 541@@ -0,0 +1,21 @@ 542+// Copyright (c) 2022 The Chromium Authors. All rights reserved. 543+// Use of this source code is governed by a BSD-style license that can be 544+// found in the LICENSE file. 545+ 546+#ifndef BASE_BASE_PATHS_OHOS_H_ 547+#define BASE_BASE_PATHS_OHOS_H_ 548+ 549+namespace base { 550+ 551+enum { 552+ PATH_OHOS_START = 500, 553+ 554+ DIR_OHOS_APP_DATA, 555+ DIR_OHOS_EXTERNAL_STORAGE, 556+ 557+ PATH_OHOS_END 558+}; 559+ 560+} // namespace base 561+ 562+#endif // BASE_BASE_PATHS_OHOS_H_ 563diff --git a/base/base_switches.cc b/base/base_switches.cc 564index 9bc2bb3356..8afdcb7e76 100644 565--- a/base/base_switches.cc 566+++ b/base/base_switches.cc 567@@ -125,8 +125,8 @@ const char kDisableUsbKeyboardDetect[] = "disable-usb-keyboard-detect"; 568 569 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 570 // of lacros-chrome is complete. 571-#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ 572- !BUILDFLAG(IS_CHROMEOS_LACROS) 573+#if (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ 574+ !BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 575 // The /dev/shm partition is too small in certain VM environments, causing 576 // Chrome to fail or crash (see http://crbug.com/715363). Use this flag to 577 // work-around this issue (a temporary directory will always be used to create 578@@ -161,7 +161,7 @@ const char kForceFieldTrialParams[] = "force-fieldtrial-params"; 579 580 #endif 581 582-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 583+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 584 // Controls whether or not retired instruction counts are surfaced for threads 585 // in trace events on Linux. 586 // 587diff --git a/base/base_switches.h b/base/base_switches.h 588index 2a71415f0a..1a026ec51a 100644 589--- a/base/base_switches.h 590+++ b/base/base_switches.h 591@@ -42,8 +42,8 @@ extern const char kDisableUsbKeyboardDetect[]; 592 593 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 594 // of lacros-chrome is complete. 595-#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ 596- !BUILDFLAG(IS_CHROMEOS_LACROS) 597+#if (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ 598+ !BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 599 extern const char kDisableDevShmUsage[]; 600 #endif 601 602@@ -59,7 +59,7 @@ extern const char kEnableIdleTracing[]; 603 extern const char kForceFieldTrialParams[]; 604 #endif 605 606-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 607+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 608 extern const char kEnableThreadInstructionCount[]; 609 610 // TODO(crbug.com/1176772): Remove kEnableCrashpad and IsCrashpadEnabled() when 611diff --git a/base/containers/checked_iterators.h b/base/containers/checked_iterators.h 612index 89a0d10b55..0a6113793e 100644 613--- a/base/containers/checked_iterators.h 614+++ b/base/containers/checked_iterators.h 615@@ -237,6 +237,17 @@ using CheckedContiguousConstIterator = CheckedContiguousIterator<const T>; 616 // [3] https://wg21.link/pointer.traits.optmem 617 namespace std { 618 619+// OHOS build toolchain use c++ 17 620+#if defined(OS_OHOS) && !defined(__MUSL__) 621+#if _LIBCPP_STD_VER > 17 622+template <class _Tp> 623+struct __is_cpp17_contiguous_iterator : public __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag> {}; 624+#else 625+template <class _Tp> 626+struct __is_cpp17_contiguous_iterator : public false_type {}; 627+#endif 628+#endif 629+ 630 template <typename T> 631 struct __is_cpp17_contiguous_iterator<::base::CheckedContiguousIterator<T>> 632 : true_type {}; 633diff --git a/base/cpu.cc b/base/cpu.cc 634index 5a084660f2..2f18425157 100644 635--- a/base/cpu.cc 636+++ b/base/cpu.cc 637@@ -17,7 +17,7 @@ 638 #include "base/stl_util.h" 639 640 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 641- defined(OS_AIX) 642+ defined(OS_AIX) || defined(OS_OHOS) 643 #include "base/containers/flat_set.h" 644 #include "base/files/file_util.h" 645 #include "base/no_destructor.h" 646@@ -31,7 +31,7 @@ 647 #endif 648 649 #if defined(ARCH_CPU_ARM_FAMILY) && \ 650- (defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)) 651+ (defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS)) 652 #include <asm/hwcap.h> 653 #include <sys/auxv.h> 654 #include "base/files/file_util.h" 655@@ -150,7 +150,7 @@ uint64_t xgetbv(uint32_t xcr) { 656 #endif // ARCH_CPU_X86_FAMILY 657 658 #if defined(ARCH_CPU_ARM_FAMILY) && \ 659- (defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)) 660+ (defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS)) 661 StringPairs::const_iterator FindFirstProcCpuKey(const StringPairs& pairs, 662 StringPiece key) { 663 return ranges::find_if(pairs, [key](const StringPairs::value_type& pair) { 664@@ -337,7 +337,7 @@ void CPU::Initialize(bool require_branding) { 665 } 666 } 667 #elif defined(ARCH_CPU_ARM_FAMILY) 668-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 669+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 670 if (require_branding) { 671 const ProcCpuInfo& info = ParseProcCpu(); 672 cpu_brand_ = info.brand; 673@@ -373,7 +373,7 @@ CPU::IntelMicroArchitecture CPU::GetIntelMicroArchitecture() const { 674 } 675 676 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 677- defined(OS_AIX) 678+ defined(OS_AIX) || defined(OS_OHOS) 679 namespace { 680 681 constexpr char kTimeInStatePath[] = 682diff --git a/base/cpu.h b/base/cpu.h 683index dbc92dddde..2d514bc698 100644 684--- a/base/cpu.h 685+++ b/base/cpu.h 686@@ -93,7 +93,7 @@ class BASE_EXPORT CPU final { 687 const std::string& cpu_brand() const { return cpu_brand_; } 688 689 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 690- defined(OS_AIX) 691+ defined(OS_AIX) || defined(OS_OHOS) 692 enum class CoreType { 693 kUnknown = 0, 694 kOther, 695diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc 696index b2e8ae3ba6..68aefddde6 100644 697--- a/base/debug/debugger_posix.cc 698+++ b/base/debug/debugger_posix.cc 699@@ -154,7 +154,7 @@ void VerifyDebugger() { 700 } 701 702 #elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 703- defined(OS_AIX) 704+ defined(OS_AIX) || defined(OS_OHOS) 705 706 // We can look in /proc/self/status for TracerPid. We are likely used in crash 707 // handling, so we are careful not to use the heap or have side effects. 708diff --git a/base/debug/proc_maps_linux.cc b/base/debug/proc_maps_linux.cc 709index ed47c58f08..588394ac46 100644 710--- a/base/debug/proc_maps_linux.cc 711+++ b/base/debug/proc_maps_linux.cc 712@@ -13,7 +13,7 @@ 713 #include "base/strings/string_split.h" 714 #include "build/build_config.h" 715 716-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 717+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 718 #include <inttypes.h> 719 #endif 720 721diff --git a/base/debug/stack_trace_ohos.cc b/base/debug/stack_trace_ohos.cc 722new file mode 100644 723index 0000000000..199b6d679a 724--- /dev/null 725+++ b/base/debug/stack_trace_ohos.cc 726@@ -0,0 +1,323 @@ 727+// Copyright (c) 2022 The Chromium Authors. All rights reserved. 728+// Use of this source code is governed by a BSD-style license that can be 729+// found in the LICENSE file. 730+ 731+#include "base/debug/stack_trace.h" 732+ 733+#include <stddef.h> 734+#include <unwind.h> 735+ 736+#include <algorithm> 737+#include <ostream> 738+ 739+#include "base/debug/proc_maps_linux.h" 740+#include "base/stl_util.h" 741+#include "base/strings/stringprintf.h" 742+#include "base/threading/thread_restrictions.h" 743+ 744+#if defined(USE_SYMBOLIZE) 745+#include "base/posix/eintr_wrapper.h" 746+#include "base/third_party/symbolize/symbolize.h" 747+#endif 748+ 749+#ifdef __LP64__ 750+#define FMT_ADDR "0x%016lx" 751+#else 752+#define FMT_ADDR "0x%08x" 753+#endif 754+ 755+namespace { 756+ 757+struct StackCrawlState { 758+ StackCrawlState(uintptr_t* frames, size_t max_depth) 759+ : frames(frames), 760+ frame_count(0), 761+ max_depth(max_depth), 762+ have_skipped_self(false) {} 763+ 764+ uintptr_t* frames; 765+ size_t frame_count; 766+ size_t max_depth; 767+ bool have_skipped_self; 768+}; 769+ 770+_Unwind_Reason_Code TraceStackFrame(_Unwind_Context* context, void* arg) { 771+ StackCrawlState* state = static_cast<StackCrawlState*>(arg); 772+ uintptr_t ip = _Unwind_GetIP(context); 773+ 774+ // The first stack frame is this function itself. Skip it. 775+ if (ip != 0 && !state->have_skipped_self) { 776+ state->have_skipped_self = true; 777+ return _URC_NO_REASON; 778+ } 779+ 780+ state->frames[state->frame_count++] = ip; 781+ if (state->frame_count >= state->max_depth) 782+ return _URC_END_OF_STACK; 783+ return _URC_NO_REASON; 784+} 785+ 786+#if !defined(USE_SYMBOLIZE) 787+bool EndsWith(const std::string& s, const std::string& suffix) { 788+ return s.size() >= suffix.size() && 789+ s.substr(s.size() - suffix.size(), suffix.size()) == suffix; 790+} 791+#endif 792+ 793+} // namespace 794+ 795+namespace base { 796+namespace debug { 797+ 798+#if defined(USE_SYMBOLIZE) 799+namespace internal { 800+char* itoa_r(intptr_t i, char* buf, size_t sz, int base, size_t padding) { 801+ // Make sure we can write at least one NUL byte. 802+ size_t n = 1; 803+ if (n > sz) 804+ return nullptr; 805+ 806+ if (base < 2 || base > 16) { 807+ buf[0] = '\000'; 808+ return nullptr; 809+ } 810+ 811+ char* start = buf; 812+ 813+ uintptr_t j = i; 814+ 815+ // Handle negative numbers (only for base 10). 816+ if (i < 0 && base == 10) { 817+ // This does "j = -i" while avoiding integer overflow. 818+ j = static_cast<uintptr_t>(-(i + 1)) + 1; 819+ 820+ // Make sure we can write the '-' character. 821+ if (++n > sz) { 822+ buf[0] = '\000'; 823+ return nullptr; 824+ } 825+ *start++ = '-'; 826+ } 827+ 828+ // Loop until we have converted the entire number. Output at least one 829+ // character (i.e. '0'). 830+ char* ptr = start; 831+ do { 832+ // Make sure there is still enough space left in our output buffer. 833+ if (++n > sz) { 834+ buf[0] = '\000'; 835+ return nullptr; 836+ } 837+ 838+ // Output the next digit. 839+ *ptr++ = "0123456789abcdef"[j % base]; 840+ j /= base; 841+ 842+ if (padding > 0) 843+ padding--; 844+ } while (j > 0 || padding > 0); 845+ 846+ // Terminate the output with a NUL character. 847+ *ptr = '\000'; 848+ 849+ // Conversion to ASCII actually resulted in the digits being in reverse 850+ // order. We can't easily generate them in forward order, as we can't tell 851+ // the number of characters needed until we are done converting. 852+ // So, now, we reverse the string (except for the possible "-" sign). 853+ while (--ptr > start) { 854+ char ch = *ptr; 855+ *ptr = *start; 856+ *start++ = ch; 857+ } 858+ return buf; 859+} 860+} //namespace internal 861+ 862+class BacktraceOutputHandler { 863+ public: 864+ virtual void HandleOutput(const char* output) = 0; 865+ 866+ protected: 867+ virtual ~BacktraceOutputHandler() = default; 868+}; 869+ 870+void OutputPointer(void* pointer, BacktraceOutputHandler* handler) { 871+ // This should be more than enough to store a 64-bit number in hex: 872+ // 16 hex digits + 1 for null-terminator. 873+ char buf[17] = { '\0' }; 874+ handler->HandleOutput("0x"); 875+ internal::itoa_r(reinterpret_cast<intptr_t>(pointer), 876+ buf, sizeof(buf), 16, 12); 877+ handler->HandleOutput(buf); 878+} 879+ 880+void OutputFrameId(intptr_t frame_id, BacktraceOutputHandler* handler) { 881+ // Max unsigned 64-bit number in decimal has 20 digits (18446744073709551615). 882+ // Hence, 30 digits should be more than enough to represent it in decimal 883+ // (including the null-terminator). 884+ char buf[30] = { '\0' }; 885+ handler->HandleOutput("#"); 886+ internal::itoa_r(frame_id, buf, sizeof(buf), 10, 1); 887+ handler->HandleOutput(buf); 888+} 889+ 890+void PrintToStderr(const char* output) { 891+ // NOTE: This code MUST be async-signal safe (it's used by in-process 892+ // stack dumping signal handler). NO malloc or stdio is allowed here. 893+ ignore_result(HANDLE_EINTR(write(STDERR_FILENO, output, strlen(output)))); 894+ //LOG(ERROR) << output; 895+} 896+ 897+class PrintBacktraceOutputHandler : public BacktraceOutputHandler { 898+ public: 899+ PrintBacktraceOutputHandler() = default; 900+ 901+ void HandleOutput(const char* output) override { 902+ // NOTE: This code MUST be async-signal safe (it's used by in-process 903+ // stack dumping signal handler). NO malloc or stdio is allowed here. 904+ PrintToStderr(output); 905+ } 906+ 907+ private: 908+ DISALLOW_COPY_AND_ASSIGN(PrintBacktraceOutputHandler); 909+}; 910+ 911+class StreamBacktraceOutputHandler : public BacktraceOutputHandler { 912+ public: 913+ explicit StreamBacktraceOutputHandler(std::ostream* os) : os_(os) { 914+ } 915+ 916+ void HandleOutput(const char* output) override { (*os_) << output; } 917+ 918+ private: 919+ std::ostream* os_; 920+ 921+ DISALLOW_COPY_AND_ASSIGN(StreamBacktraceOutputHandler); 922+}; 923+ 924+void ProcessBacktrace(void* const* trace, 925+ size_t size, 926+ const char* prefix_string, 927+ BacktraceOutputHandler* handler) { 928+// NOTE: This code MUST be async-signal safe (it's used by in-process 929+// stack dumping signal handler). NO malloc or stdio is allowed here. 930+ 931+ for (size_t i = 0; i < size; ++i) { 932+ if (prefix_string) 933+ handler->HandleOutput(prefix_string); 934+ 935+ OutputFrameId(i, handler); 936+ handler->HandleOutput(" "); 937+ OutputPointer(trace[i], handler); 938+ handler->HandleOutput(" "); 939+ 940+ char buf[1024] = { '\0' }; 941+ 942+ // Subtract by one as return address of function may be in the next 943+ // function when a function is annotated as noreturn. 944+ void* address = static_cast<char*>(trace[i]) - 1; 945+ if (google::Symbolize(address, buf, sizeof(buf))) 946+ handler->HandleOutput(buf); 947+ else 948+ handler->HandleOutput("<unknown>"); 949+ 950+ handler->HandleOutput("\n"); 951+ } 952+} 953+ 954+#endif // defined (USE_SYMBOLIZE) 955+ 956+bool EnableInProcessStackDumping() { 957+ // When running in an application, our code typically expects SIGPIPE 958+ // to be ignored. Therefore, when testing that same code, it should run 959+ // with SIGPIPE ignored as well. 960+ // TODO(phajdan.jr): De-duplicate this SIGPIPE code. 961+ struct sigaction action; 962+ memset(&action, 0, sizeof(action)); 963+ action.sa_handler = SIG_IGN; 964+ sigemptyset(&action.sa_mask); 965+ return (sigaction(SIGPIPE, &action, NULL) == 0); 966+} 967+ 968+size_t CollectStackTrace(void** trace, size_t count) { 969+ StackCrawlState state(reinterpret_cast<uintptr_t*>(trace), count); 970+ _Unwind_Backtrace(&TraceStackFrame, &state); 971+ return state.frame_count; 972+} 973+ 974+void StackTrace::PrintWithPrefix(const char* prefix_string) const { 975+#if !defined(USE_SYMBOLIZE) 976+ std::string backtrace = ToStringWithPrefix(prefix_string); 977+ LOG(WARNING) << "backtrace:\n" << backtrace.c_str(); 978+#else 979+ PrintBacktraceOutputHandler handler; 980+ ProcessBacktrace(trace_, count_, prefix_string, &handler); 981+#endif // !defined(USE_SYMBOLIZE) 982+} 983+ 984+// NOTE: Native libraries in APKs are stripped before installing. Print out the 985+// relocatable address and library names so host computers can use tools to 986+// symbolize and demangle (e.g., addr2line, c++filt). 987+void StackTrace::OutputToStreamWithPrefix(std::ostream* os, 988+ const char* prefix_string) const { 989+ std::string proc_maps; 990+ std::vector<MappedMemoryRegion> regions; 991+#if defined(USE_SYMBOLIZE) 992+ StreamBacktraceOutputHandler handler(os); 993+ ProcessBacktrace(trace_, count_, prefix_string, &handler); 994+#else 995+ // Allow IO to read /proc/self/maps. Reading this file doesn't hit the disk 996+ // since it lives in procfs, and this is currently used to print a stack trace 997+ // on fatal log messages in debug builds only. If the restriction is enabled 998+ // then it will recursively trigger fatal failures when this enters on the 999+ // UI thread. 1000+ base::ThreadRestrictions::ScopedAllowIO allow_io; 1001+ if (!ReadProcMaps(&proc_maps)) { 1002+ LOG(ERROR) << "Failed to read /proc/self/maps"; 1003+ } else if (!ParseProcMaps(proc_maps, ®ions)) { 1004+ LOG(ERROR) << "Failed to parse /proc/self/maps"; 1005+ } 1006+ 1007+ for (size_t i = 0; i < count_; ++i) { 1008+ // Subtract one as return address of function may be in the next 1009+ // function when a function is annotated as noreturn. 1010+ uintptr_t address = reinterpret_cast<uintptr_t>(trace_[i]) - 1; 1011+ 1012+ std::vector<MappedMemoryRegion>::iterator iter = regions.begin(); 1013+ while (iter != regions.end()) { 1014+ if (address >= iter->start && address < iter->end && 1015+ !iter->path.empty()) { 1016+ break; 1017+ } 1018+ ++iter; 1019+ } 1020+ 1021+ if (prefix_string) 1022+ *os << prefix_string; 1023+ 1024+ // Adjust absolute address to be an offset within the mapped region, to 1025+ // match the format dumped by Android's crash output. 1026+ if (iter != regions.end()) { 1027+ address -= iter->start; 1028+ } 1029+ 1030+ // The format below intentionally matches that of Android's debuggerd 1031+ // output. This simplifies decoding by scripts such as stack.py. 1032+ *os << base::StringPrintf("#%02zd pc " FMT_ADDR " ", i, address); 1033+ 1034+ if (iter != regions.end()) { 1035+ *os << base::StringPrintf("%s", iter->path.c_str()); 1036+ if (EndsWith(iter->path, ".apk")) { 1037+ *os << base::StringPrintf(" (offset 0x%llx)", iter->offset); 1038+ } 1039+ } else { 1040+ *os << "<unknown>"; 1041+ } 1042+ 1043+ *os << "\n"; 1044+ } 1045+#endif // defined(USE_SYMBOLIZE) 1046+} 1047+ 1048+} // namespace debug 1049+} // namespace base 1050diff --git a/base/files/file.h b/base/files/file.h 1051index 79fd844ee5..b29a0eb5b8 100644 1052--- a/base/files/file.h 1053+++ b/base/files/file.h 1054@@ -25,7 +25,7 @@ 1055 namespace base { 1056 1057 #if defined(OS_BSD) || defined(OS_APPLE) || defined(OS_NACL) || \ 1058- defined(OS_FUCHSIA) || (defined(OS_ANDROID) && __ANDROID_API__ < 21) 1059+ defined(OS_FUCHSIA) || (defined(OS_ANDROID) && __ANDROID_API__ < 21) || defined(OS_OHOS) 1060 typedef struct stat stat_wrapper_t; 1061 #elif defined(OS_POSIX) 1062 typedef struct stat64 stat_wrapper_t; 1063diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc 1064index 85603986db..2637e42119 100644 1065--- a/base/files/file_posix.cc 1066+++ b/base/files/file_posix.cc 1067@@ -18,7 +18,7 @@ 1068 #include "build/build_config.h" 1069 #include "build/chromeos_buildflags.h" 1070 1071-#if defined(OS_ANDROID) 1072+#if defined(OS_ANDROID) || defined(OS_OHOS) 1073 #include "base/os_compat_android.h" 1074 #endif 1075 1076@@ -125,14 +125,14 @@ void File::Info::FromStat(const stat_wrapper_t& stat_info) { 1077 // creation time. However, other than on Mac & iOS where the actual file 1078 // creation time is included as st_birthtime, the rest of POSIX platforms have 1079 // no portable way to get the creation time. 1080-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) 1081+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(__MUSL__) 1082 time_t last_modified_sec = stat_info.st_mtim.tv_sec; 1083 int64_t last_modified_nsec = stat_info.st_mtim.tv_nsec; 1084 time_t last_accessed_sec = stat_info.st_atim.tv_sec; 1085 int64_t last_accessed_nsec = stat_info.st_atim.tv_nsec; 1086 time_t creation_time_sec = stat_info.st_ctim.tv_sec; 1087 int64_t creation_time_nsec = stat_info.st_ctim.tv_nsec; 1088-#elif defined(OS_ANDROID) 1089+#elif defined(OS_ANDROID) || defined(OS_OHOS) 1090 time_t last_modified_sec = stat_info.st_mtime; 1091 int64_t last_modified_nsec = stat_info.st_mtime_nsec; 1092 time_t last_accessed_sec = stat_info.st_atime; 1093@@ -205,7 +205,7 @@ int64_t File::Seek(Whence whence, int64_t offset) { 1094 1095 SCOPED_FILE_TRACE_WITH_SIZE("Seek", offset); 1096 1097-#if defined(OS_ANDROID) 1098+#if defined(OS_ANDROID) || defined(OS_OHOS) 1099 static_assert(sizeof(int64_t) == sizeof(off64_t), "off64_t must be 64 bits"); 1100 return lseek64(file_.get(), static_cast<off64_t>(offset), 1101 static_cast<int>(whence)); 1102@@ -291,7 +291,7 @@ int File::Write(int64_t offset, const char* data, int size) { 1103 int bytes_written = 0; 1104 int rv; 1105 do { 1106-#if defined(OS_ANDROID) 1107+#if defined(OS_ANDROID) || defined(OS_OHOS) 1108 // In case __USE_FILE_OFFSET64 is not used, we need to call pwrite64() 1109 // instead of pwrite(). 1110 static_assert(sizeof(int64_t) == sizeof(off64_t), 1111@@ -550,7 +550,7 @@ bool File::Flush() { 1112 NOTIMPLEMENTED(); // NaCl doesn't implement fsync. 1113 return true; 1114 #elif defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || \ 1115- defined(OS_LINUX) 1116+ defined(OS_LINUX) || defined(OS_OHOS) 1117 return !HANDLE_EINTR(fdatasync(file_.get())); 1118 #elif defined(OS_APPLE) 1119 // On macOS and iOS, fsync() is guaranteed to send the file's data to the 1120@@ -585,7 +585,7 @@ File::Error File::GetLastFileError() { 1121 } 1122 1123 #if defined(OS_BSD) || defined(OS_APPLE) || defined(OS_NACL) || \ 1124- defined(OS_FUCHSIA) || (defined(OS_ANDROID) && __ANDROID_API__ < 21) 1125+ defined(OS_FUCHSIA) || (defined(OS_ANDROID) && __ANDROID_API__ < 21) || defined(OS_OHOS) 1126 int File::Stat(const char* path, stat_wrapper_t* sb) { 1127 ScopedBlockingCall scoped_blocking_call(FROM_HERE, BlockingType::MAY_BLOCK); 1128 return stat(path, sb); 1129diff --git a/base/files/file_util.h b/base/files/file_util.h 1130index 5983de2191..0ec2e1819a 100644 1131--- a/base/files/file_util.h 1132+++ b/base/files/file_util.h 1133@@ -283,7 +283,7 @@ BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode); 1134 BASE_EXPORT bool ExecutableExistsInPath(Environment* env, 1135 const FilePath::StringType& executable); 1136 1137-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) 1138+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) || defined(OS_OHOS) 1139 // Determine if files under a given |path| can be mapped and then mprotect'd 1140 // PROT_EXEC. This depends on the mount options used for |path|, which vary 1141 // among different Linux distributions and possibly local configuration. It also 1142@@ -602,7 +602,7 @@ BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path); 1143 // the directory |path|, in the number of FilePath::CharType, or -1 on failure. 1144 BASE_EXPORT int GetMaximumPathComponentLength(const base::FilePath& path); 1145 1146-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) 1147+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) || defined(OS_OHOS) 1148 // Broad categories of file systems as returned by statfs() on Linux. 1149 enum FileSystemType { 1150 FILE_SYSTEM_UNKNOWN, // statfs failed. 1151diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc 1152index 57c3cb8e68..b5fb3d620d 100644 1153--- a/base/files/file_util_posix.cc 1154+++ b/base/files/file_util_posix.cc 1155@@ -586,7 +586,7 @@ bool GetTempDir(FilePath* path) { 1156 return true; 1157 } 1158 1159-#if defined(OS_ANDROID) 1160+#if defined(OS_ANDROID) || defined(OS_OHOS) 1161 return PathService::Get(DIR_CACHE, path); 1162 #else 1163 *path = FilePath("/tmp"); 1164@@ -1224,7 +1224,7 @@ bool MoveUnsafe(const FilePath& from_path, const FilePath& to_path) { 1165 1166 #endif // !defined(OS_NACL_NONSFI) 1167 1168-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) 1169+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) || defined(OS_OHOS) 1170 BASE_EXPORT bool IsPathExecutable(const FilePath& path) { 1171 bool result = false; 1172 FilePath tmp_file_path; 1173diff --git a/base/linux_util.cc b/base/linux_util.cc 1174index c1512b8418..7c87dee6ec 100644 1175--- a/base/linux_util.cc 1176+++ b/base/linux_util.cc 1177@@ -19,6 +19,7 @@ 1178 #include "base/files/dir_reader_posix.h" 1179 #include "base/files/file_util.h" 1180 #include "base/files/scoped_file.h" 1181+#include "base/logging.h" 1182 #include "base/no_destructor.h" 1183 #include "base/strings/safe_sprintf.h" 1184 #include "base/strings/string_number_conversions.h" 1185@@ -100,6 +101,8 @@ char g_linux_distro[kDistroSize] = 1186 "CrOS"; 1187 #elif defined(OS_ANDROID) 1188 "Android"; 1189+#elif defined(OS_OHOS) 1190+ "OhOS"; 1191 #else 1192 "Unknown"; 1193 #endif 1194diff --git a/base/logging.cc b/base/logging.cc 1195index 7722d37296..8326bc2c63 100644 1196--- a/base/logging.cc 1197+++ b/base/logging.cc 1198@@ -80,6 +80,10 @@ typedef HANDLE FileHandle; 1199 #include <android/log.h> 1200 #endif 1201 1202+#if defined(OS_OHOS) 1203+#include "hilog/log.h" 1204+#endif 1205+ 1206 #if defined(OS_POSIX) || defined(OS_FUCHSIA) 1207 #include <errno.h> 1208 #include <paths.h> 1209@@ -556,6 +560,22 @@ LogMessage::LogMessage(const char* file, int line, const char* condition) 1210 stream_ << "Check failed: " << condition << ". "; 1211 } 1212 1213+#if defined(OS_OHOS) 1214+extern "C" { 1215+ int HiLogPrintArgs(LogType type, LogLevel level, unsigned int domain, const char* tag, const char* fmt, va_list ap); 1216+} 1217+ 1218+int HiLogPrintOHOS(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) 1219+{ 1220+ int ret; 1221+ va_list ap; 1222+ va_start(ap, fmt); 1223+ ret = HiLogPrintArgs(type, level, domain, tag, fmt, ap); 1224+ va_end(ap); 1225+ return ret; 1226+} 1227+#endif 1228+ 1229 LogMessage::~LogMessage() { 1230 size_t stack_start = stream_.tellp(); 1231 #if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__) && \ 1232@@ -777,6 +797,25 @@ LogMessage::~LogMessage() { 1233 // The Android system may truncate the string if it's too long. 1234 __android_log_write(priority, kAndroidLogTag, str_newline.c_str()); 1235 #endif 1236+#elif defined(OS_OHOS) 1237+ LogLevel priority = 1238+ (severity_ < 0) ? LogLevel::LOG_DEBUG : LogLevel::LOG_LEVEL_MAX; 1239+ switch (severity_) { 1240+ case LOGGING_INFO: 1241+ priority = LogLevel::LOG_INFO; 1242+ break; 1243+ case LOGGING_WARNING: 1244+ priority = LogLevel::LOG_WARN; 1245+ break; 1246+ case LOGGING_ERROR: 1247+ priority = LogLevel::LOG_ERROR; 1248+ break; 1249+ case LOGGING_FATAL: 1250+ priority = LogLevel::LOG_FATAL; 1251+ break; 1252+ } 1253+ const char kOHOSLogTag[] = "chromium"; 1254+ HiLogPrintOHOS(LOG_APP, priority, 0, kOHOSLogTag, str_newline.c_str()); 1255 #elif defined(OS_FUCHSIA) 1256 fx_log_severity_t severity = FX_LOG_INFO; 1257 switch (severity_) { 1258diff --git a/base/macros.h b/base/macros.h 1259index 19d15ca713..2eee1ae626 100644 1260--- a/base/macros.h 1261+++ b/base/macros.h 1262@@ -15,7 +15,8 @@ 1263 // //styleguide/c++/c++-dos-and-donts.md for more information. 1264 1265 // DEPRECATED: See above. Makes a class uncopyable. 1266-#define DISALLOW_COPY(TypeName) \ 1267+// Add BASE for confliction with ohos base library 1268+#define DISALLOW_COPY_BASE(TypeName) \ 1269 TypeName(const TypeName&) = delete 1270 1271 // DEPRECATED: See above. Makes a class unassignable. 1272@@ -23,7 +24,7 @@ 1273 1274 // DEPRECATED: See above. Makes a class uncopyable and unassignable. 1275 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 1276- DISALLOW_COPY(TypeName); \ 1277+ DISALLOW_COPY_BASE(TypeName); \ 1278 DISALLOW_ASSIGN(TypeName) 1279 1280 // DEPRECATED: See above. Disallow all implicit constructors, namely the 1281diff --git a/base/memory/platform_shared_memory_region.h b/base/memory/platform_shared_memory_region.h 1282index 9b67c0e929..b2f7be4048 100644 1283--- a/base/memory/platform_shared_memory_region.h 1284+++ b/base/memory/platform_shared_memory_region.h 1285@@ -27,7 +27,7 @@ 1286 #include "base/files/scoped_file.h" 1287 #endif 1288 1289-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1290+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1291 namespace content { 1292 class SandboxIPCHandler; 1293 } 1294@@ -120,7 +120,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion { 1295 kMaxValue = GET_SHMEM_TEMP_DIR_FAILURE 1296 }; 1297 1298-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1299+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1300 // Structure to limit access to executable region creation. 1301 struct ExecutableRegion { 1302 private: 1303@@ -264,7 +264,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion { 1304 CheckPlatformHandlePermissionsCorrespondToMode); 1305 static PlatformSharedMemoryRegion Create(Mode mode, 1306 size_t size 1307-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1308+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1309 , 1310 bool executable = false 1311 #endif 1312diff --git a/base/memory/platform_shared_memory_region_posix.cc b/base/memory/platform_shared_memory_region_posix.cc 1313index f62a7d6a9c..c8e488667b 100644 1314--- a/base/memory/platform_shared_memory_region_posix.cc 1315+++ b/base/memory/platform_shared_memory_region_posix.cc 1316@@ -70,7 +70,7 @@ FDPair ScopedFDPair::get() const { 1317 return {fd.get(), readonly_fd.get()}; 1318 } 1319 1320-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1321+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1322 // static 1323 ScopedFD PlatformSharedMemoryRegion::ExecutableRegion::CreateFD(size_t size) { 1324 PlatformSharedMemoryRegion region = 1325@@ -204,7 +204,7 @@ bool PlatformSharedMemoryRegion::MapAtInternal(off_t offset, 1326 // static 1327 PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Create(Mode mode, 1328 size_t size 1329-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1330+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1331 , 1332 bool executable 1333 #endif 1334@@ -233,7 +233,7 @@ PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Create(Mode mode, 1335 // flag. 1336 FilePath directory; 1337 if (!GetShmemTempDir( 1338-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1339+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1340 executable, 1341 #else 1342 false /* executable */, 1343diff --git a/base/message_loop/message_pump_for_ui.h b/base/message_loop/message_pump_for_ui.h 1344index 1eb7da02ee..12b22e5ba7 100644 1345--- a/base/message_loop/message_pump_for_ui.h 1346+++ b/base/message_loop/message_pump_for_ui.h 1347@@ -14,6 +14,8 @@ 1348 #include "base/message_loop/message_pump_win.h" 1349 #elif defined(OS_ANDROID) 1350 #include "base/message_loop/message_pump_android.h" 1351+#elif defined(OS_OHOS) 1352+#include "base/message_loop/message_pump_ohos.h" 1353 #elif defined(OS_APPLE) 1354 #include "base/message_loop/message_pump.h" 1355 #elif defined(OS_NACL) || defined(OS_AIX) 1356@@ -34,6 +36,8 @@ using MessagePumpForUI = MessagePumpForUI; 1357 #elif defined(OS_ANDROID) 1358 // Android defines it as-is. 1359 using MessagePumpForUI = MessagePumpForUI; 1360+#elif defined(OS_OHOS) 1361+using MessagePumpForUI = MessagePumpForUI; 1362 #elif defined(OS_APPLE) 1363 // MessagePumpForUI isn't bound to a specific impl on Mac. While each impl can 1364 // be represented by a plain MessagePump: MessagePumpMac::Create() must be used 1365diff --git a/base/message_loop/message_pump_ohos.cc b/base/message_loop/message_pump_ohos.cc 1366new file mode 100644 1367index 0000000000..b705919891 1368--- /dev/null 1369+++ b/base/message_loop/message_pump_ohos.cc 1370@@ -0,0 +1,300 @@ 1371+// Copyright (c) 2012 The Chromium Authors. All rights reserved. 1372+// Use of this source code is governed by a BSD-style license that can be 1373+// found in the LICENSE file. 1374+ 1375+#include "base/message_loop/message_pump_ohos.h" 1376+ 1377+#include <errno.h> 1378+#include <fcntl.h> 1379+#include <sys/eventfd.h> 1380+#include <sys/syscall.h> 1381+#include <sys/types.h> 1382+#include <unistd.h> 1383+#include <utility> 1384+ 1385+#include <event_handler.h> 1386+#include <file_descriptor_listener.h> 1387+ 1388+#include "base/callback_helpers.h" 1389+#include "base/check_op.h" 1390+#include "base/lazy_instance.h" 1391+#include "base/logging.h" 1392+#include "base/notreached.h" 1393+#include "base/run_loop.h" 1394+#include "build/build_config.h" 1395+ 1396+#ifndef __NR_timerfd_create 1397+#error "Unable to find syscall for __NR_timerfd_create" 1398+#endif 1399+ 1400+#ifndef TFD_TIMER_ABSTIME 1401+#define TFD_TIMER_ABSTIME (1 << 0) 1402+#endif 1403+ 1404+namespace base { 1405+ 1406+namespace { 1407+ 1408+class EventHandlerFileDescriptorListener : public OHOS::AppExecFwk::FileDescriptorListener { 1409+ public: 1410+ explicit EventHandlerFileDescriptorListener(MessagePumpForUI* pump, 1411+ int non_delay_fd, int delay_fd) 1412+ : message_pump_(pump), non_delayed_fd_(non_delay_fd), delayed_fd_(delay_fd) { 1413+ } 1414+ 1415+ ~EventHandlerFileDescriptorListener() { 1416+ message_pump_ = nullptr; 1417+ non_delayed_fd_ = -1; 1418+ delayed_fd_ = -1; 1419+ } 1420+ 1421+ void OnReadable(int32_t fileDescriptor) override { 1422+ if (fileDescriptor < 0) { 1423+ LOG(ERROR) << "EventHandlerFileDescriptorListener error fd"; 1424+ return; 1425+ } 1426+ 1427+ if (fileDescriptor == non_delayed_fd_) { 1428+ message_pump_->OnNonDelayedLooperCallback(); 1429+ } else if (fileDescriptor == delayed_fd_) { 1430+ message_pump_->OnDelayedLooperCallback(); 1431+ } else { 1432+ LOG(ERROR) << "EventHandlerFileDescriptorListener invalid fd: " << fileDescriptor; 1433+ } 1434+ } 1435+ 1436+ private: 1437+ MessagePumpForUI* message_pump_; 1438+ int non_delayed_fd_; 1439+ int delayed_fd_; 1440+}; 1441+ 1442+// See sys/timerfd.h 1443+int timerfd_create(int clockid, int flags) { 1444+ return syscall(__NR_timerfd_create, clockid, flags); 1445+} 1446+ 1447+// See sys/timerfd.h 1448+int timerfd_settime(int ufc, 1449+ int flags, 1450+ const struct itimerspec* utmr, 1451+ struct itimerspec* otmr) { 1452+#if defined(__MUSL__) 1453+ return syscall(__NR_timerfd_settime32, ufc, flags, utmr, otmr); 1454+#else 1455+ return syscall(__NR_timerfd_settime, ufc, flags, utmr, otmr); 1456+#endif 1457+} 1458+ 1459+// A bit added to the |non_delayed_fd_| to keep it signaled when we yield to 1460+// native tasks below. 1461+constexpr uint64_t kTryNativeTasksBeforeIdleBit = uint64_t(1) << 32; 1462+} // namespace 1463+ 1464+MessagePumpForUI::MessagePumpForUI() { 1465+ non_delayed_fd_ = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); 1466+ CHECK_NE(non_delayed_fd_, -1); 1467+ DCHECK_EQ(TimeTicks::GetClock(), TimeTicks::Clock::LINUX_CLOCK_MONOTONIC); 1468+ 1469+ // We can't create the timerfd with TFD_NONBLOCK | TFD_CLOEXEC as we can't 1470+ // include timerfd.h. See comments above on __NR_timerfd_create. It looks like 1471+ // they're just aliases to O_NONBLOCK and O_CLOEXEC anyways, so this should be 1472+ // fine. 1473+ delayed_fd_ = timerfd_create(CLOCK_MONOTONIC, O_NONBLOCK | O_CLOEXEC); 1474+ CHECK_NE(delayed_fd_, -1); 1475+ 1476+ ohos_event_handler_ = OHOS::AppExecFwk::EventHandler::Current(); 1477+ DCHECK(ohos_event_handler_); 1478+ ohos_listener = std::make_shared<EventHandlerFileDescriptorListener>( 1479+ this, non_delayed_fd_, delayed_fd_); 1480+ ohos_event_handler_->AddFileDescriptorListener( 1481+ non_delayed_fd_, OHOS::AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, ohos_listener); 1482+ ohos_event_handler_->AddFileDescriptorListener( 1483+ delayed_fd_, OHOS::AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, ohos_listener); 1484+} 1485+ 1486+MessagePumpForUI::~MessagePumpForUI() { 1487+ ohos_event_handler_->RemoveFileDescriptorListener(non_delayed_fd_); 1488+ ohos_event_handler_->RemoveFileDescriptorListener(delayed_fd_); 1489+ 1490+ close(non_delayed_fd_); 1491+ close(delayed_fd_); 1492+} 1493+ 1494+void MessagePumpForUI::OnDelayedLooperCallback() { 1495+ if (ShouldQuit()) { 1496+ return; 1497+ } 1498+ 1499+ // Clear the fd. 1500+ uint64_t value; 1501+ int ret = read(delayed_fd_, &value, sizeof(value)); 1502+ 1503+ DPCHECK(ret >= 0 || errno == EAGAIN); 1504+ DoDelayedLooperWork(); 1505+} 1506+ 1507+void MessagePumpForUI::DoDelayedLooperWork() { 1508+ delayed_scheduled_time_.reset(); 1509+ 1510+ Delegate::NextWorkInfo next_work_info = delegate_->DoWork(); 1511+ 1512+ if (ShouldQuit()) { 1513+ return; 1514+ } 1515+ 1516+ if (next_work_info.is_immediate()) { 1517+ ScheduleWork(); 1518+ return; 1519+ } 1520+ 1521+ DoIdleWork(); 1522+ if (!next_work_info.delayed_run_time.is_max()) { 1523+ ScheduleDelayedWork(next_work_info.delayed_run_time); 1524+ } 1525+} 1526+ 1527+void MessagePumpForUI::OnNonDelayedLooperCallback() { 1528+ if (ShouldQuit()) { 1529+ return; 1530+ } 1531+ 1532+ uint64_t value = 0; 1533+ int ret = read(non_delayed_fd_, &value, sizeof(value)); 1534+ DPCHECK(ret >= 0); 1535+ DCHECK_GT(value, 0U); 1536+ bool do_idle_work = value == kTryNativeTasksBeforeIdleBit; 1537+ DoNonDelayedLooperWork(do_idle_work); 1538+} 1539+ 1540+void MessagePumpForUI::DoNonDelayedLooperWork(bool do_idle_work) { 1541+ // Runs all application tasks scheduled to run. 1542+ Delegate::NextWorkInfo next_work_info; 1543+ do { 1544+ if (ShouldQuit()) { 1545+ return; 1546+ } 1547+ 1548+ next_work_info = delegate_->DoWork(); 1549+ } while (next_work_info.is_immediate()); 1550+ 1551+ // Do not resignal |non_delayed_fd_| if we're quitting (this pump doesn't 1552+ // allow nesting so needing to resume in an outer loop is not an issue 1553+ // either). 1554+ if (ShouldQuit()) { 1555+ return; 1556+ } 1557+ 1558+ // Before declaring this loop idle, yield to native tasks and arrange to be 1559+ // called again (unless we're already in that second call). 1560+ if (!do_idle_work) { 1561+ ScheduleWorkInternal(/*do_idle_work=*/true); 1562+ return; 1563+ } 1564+ 1565+ DCHECK(do_idle_work); 1566+ 1567+ if (ShouldQuit()) { 1568+ return; 1569+ } 1570+ 1571+ DoIdleWork(); 1572+ if (!next_work_info.delayed_run_time.is_max()) { 1573+ ScheduleDelayedWork(next_work_info.delayed_run_time); 1574+ } 1575+} 1576+ 1577+void MessagePumpForUI::DoIdleWork() { 1578+ if (delegate_->DoIdleWork()) { 1579+ // If DoIdleWork() resulted in any work, we're not idle yet. We need to pump 1580+ // the loop here because we may in fact be idle after doing idle work 1581+ // without any new tasks being queued. 1582+ ScheduleWork(); 1583+ } 1584+} 1585+ 1586+void MessagePumpForUI::Run(Delegate* delegate) { 1587+ CHECK(false) << "Unexpected call to Run()"; 1588+} 1589+ 1590+void MessagePumpForUI::Attach(Delegate* delegate) { 1591+ DCHECK(!quit_); 1592+ SetDelegate(delegate); 1593+ run_loop_ = std::make_unique<RunLoop>(); 1594+ if (!run_loop_->BeforeRun()) { 1595+ NOTREACHED(); 1596+ } 1597+} 1598+ 1599+void MessagePumpForUI::Quit() { 1600+ if (quit_) { 1601+ return; 1602+ } 1603+ 1604+ quit_ = true; 1605+ 1606+ int64_t value; 1607+ // Clear any pending timer. 1608+ read(delayed_fd_, &value, sizeof(value)); 1609+ // Clear the eventfd. 1610+ read(non_delayed_fd_, &value, sizeof(value)); 1611+ 1612+ if (run_loop_) { 1613+ run_loop_->AfterRun(); 1614+ run_loop_ = nullptr; 1615+ } 1616+ if (on_quit_callback_) { 1617+ std::move(on_quit_callback_).Run(); 1618+ } 1619+} 1620+ 1621+void MessagePumpForUI::ScheduleWork() { 1622+ ScheduleWorkInternal(/*do_idle_work=*/false); 1623+} 1624+ 1625+void MessagePumpForUI::ScheduleWorkInternal(bool do_idle_work) { 1626+ uint64_t value = do_idle_work ? kTryNativeTasksBeforeIdleBit : 1; 1627+ int ret = write(non_delayed_fd_, &value, sizeof(value)); 1628+ DPCHECK(ret >= 0); 1629+} 1630+ 1631+void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) { 1632+ if (ShouldQuit()) { 1633+ return; 1634+ } 1635+ 1636+ if (delayed_scheduled_time_ && *delayed_scheduled_time_ == delayed_work_time) { 1637+ return; 1638+ } 1639+ 1640+ DCHECK(!delayed_work_time.is_null()); 1641+ delayed_scheduled_time_ = delayed_work_time; 1642+ int64_t nanos = delayed_work_time.since_origin().InNanoseconds(); 1643+ struct itimerspec ts; 1644+ ts.it_interval.tv_sec = 0; // Don't repeat. 1645+ ts.it_interval.tv_nsec = 0; 1646+ ts.it_value.tv_sec = nanos / TimeTicks::kNanosecondsPerSecond; 1647+ ts.it_value.tv_nsec = nanos % TimeTicks::kNanosecondsPerSecond; 1648+ 1649+ int ret = timerfd_settime(delayed_fd_, TFD_TIMER_ABSTIME, &ts, nullptr); 1650+ DPCHECK(ret >= 0); 1651+} 1652+ 1653+void MessagePumpForUI::QuitWhenIdle(base::OnceClosure callback) { 1654+ DCHECK(!on_quit_callback_); 1655+ DCHECK(run_loop_); 1656+ on_quit_callback_ = std::move(callback); 1657+ run_loop_->QuitWhenIdle(); 1658+ // Pump the loop in case we're already idle. 1659+ ScheduleWork(); 1660+} 1661+ 1662+MessagePump::Delegate* MessagePumpForUI::SetDelegate(Delegate* delegate) { 1663+ return std::exchange(delegate_, delegate); 1664+} 1665+ 1666+bool MessagePumpForUI::SetQuit(bool quit) { 1667+ return std::exchange(quit_, quit); 1668+} 1669+ 1670+} // namespace base 1671diff --git a/base/message_loop/message_pump_ohos.h b/base/message_loop/message_pump_ohos.h 1672new file mode 100644 1673index 0000000000..e1a1c70c73 1674--- /dev/null 1675+++ b/base/message_loop/message_pump_ohos.h 1676@@ -0,0 +1,95 @@ 1677+// Copyright (c) 2022 The Chromium Authors. All rights reserved. 1678+// Use of this source code is governed by a BSD-style license that can be 1679+// found in the LICENSE file. 1680+ 1681+#ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_OHOS_H_ 1682+#define BASE_MESSAGE_LOOP_MESSAGE_PUMP_OHOS_H_ 1683+ 1684+#include <memory> 1685+#include <event_handler.h> 1686+ 1687+#include "base/base_export.h" 1688+#include "base/callback.h" 1689+#include "base/compiler_specific.h" 1690+#include "base/message_loop/message_pump.h" 1691+#include "base/time/time.h" 1692+#include "third_party/abseil-cpp/absl/types/optional.h" 1693+ 1694+namespace base { 1695+ 1696+class RunLoop; 1697+ 1698+class BASE_EXPORT MessagePumpForUI : public MessagePump { 1699+ public: 1700+ MessagePumpForUI(); 1701+ 1702+ MessagePumpForUI(const MessagePumpForUI&) = delete; 1703+ MessagePumpForUI& operator=(const MessagePumpForUI&) = delete; 1704+ 1705+ ~MessagePumpForUI() override; 1706+ 1707+ void Run(Delegate* delegate) override; 1708+ void Quit() override; 1709+ void ScheduleWork() override; 1710+ void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override; 1711+ 1712+ // Attaches |delegate| to this native MessagePump. |delegate| will from then 1713+ // on be invoked by the native loop to process application tasks. 1714+ void Attach(Delegate* delegate); 1715+ 1716+ void Abort() { should_abort_ = true; } 1717+ bool IsAborted() { return should_abort_; } 1718+ bool ShouldQuit() const { return should_abort_ || quit_; } 1719+ 1720+ // Tells the RunLoop to quit when idle, calling the callback when it's safe 1721+ // for the Thread to stop. 1722+ void QuitWhenIdle(base::OnceClosure callback); 1723+ 1724+ // These functions are only public so that the looper callbacks can call them, 1725+ // and should not be called from outside this class. 1726+ void OnDelayedLooperCallback(); 1727+ void OnNonDelayedLooperCallback(); 1728+ 1729+ protected: 1730+ Delegate* SetDelegate(Delegate* delegate); 1731+ bool SetQuit(bool quit); 1732+ void DoDelayedLooperWork(); 1733+ void DoNonDelayedLooperWork(bool do_idle_work); 1734+ 1735+ private: 1736+ void ScheduleWorkInternal(bool do_idle_work); 1737+ void DoIdleWork(); 1738+ 1739+ std::unique_ptr<RunLoop> run_loop_; 1740+ 1741+ // See Abort(). 1742+ bool should_abort_ = false; 1743+ 1744+ // Whether this message pump is quitting, or has quit. 1745+ bool quit_ = false; 1746+ 1747+ // The MessageLoop::Delegate for this pump. 1748+ Delegate* delegate_ = nullptr; 1749+ 1750+ // The time at which we are currently scheduled to wake up and perform a 1751+ // delayed task. This avoids redundantly scheduling |delayed_fd_| with the 1752+ // same timeout when subsequent work phases all go idle on the same pending 1753+ // delayed task; nullopt if no wakeup is currently scheduled. 1754+ absl::optional<TimeTicks> delayed_scheduled_time_; 1755+ 1756+ // If set, a callback to fire when the message pump is quit. 1757+ base::OnceClosure on_quit_callback_; 1758+ 1759+ // The file descriptor used to signal that non-delayed work is available. 1760+ int non_delayed_fd_; 1761+ 1762+ // The file descriptor used to signal that delayed work is available. 1763+ int delayed_fd_; 1764+ 1765+ std::shared_ptr<OHOS::AppExecFwk::EventHandler> ohos_event_handler_; 1766+ std::shared_ptr<OHOS::AppExecFwk::FileDescriptorListener> ohos_listener; 1767+}; 1768+ 1769+} // namespace base 1770+ 1771+#endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_OHOS_H_ 1772diff --git a/base/path_service.cc b/base/path_service.cc 1773index d1c9bb1045..44aa032ef2 100644 1774--- a/base/path_service.cc 1775+++ b/base/path_service.cc 1776@@ -31,6 +31,8 @@ bool PathProviderMac(int key, FilePath* result); 1777 bool PathProviderAndroid(int key, FilePath* result); 1778 #elif defined(OS_FUCHSIA) 1779 bool PathProviderFuchsia(int key, FilePath* result); 1780+#elif defined(OS_OHOS) 1781+bool PathProviderOHOS(int key, FilePath* result); 1782 #elif defined(OS_POSIX) 1783 // PathProviderPosix is the default path provider on POSIX OSes other than 1784 // Mac and Android. 1785@@ -95,6 +97,18 @@ Provider base_provider_android = { 1786 }; 1787 #endif 1788 1789+#if defined(OS_OHOS) 1790+Provider base_provider_ohos = { 1791+ PathProviderOHOS, 1792+ &base_provider, 1793+#ifndef NDEBUG 1794+ PATH_OHOS_START, 1795+ PATH_OHOS_END, 1796+#endif 1797+ true 1798+}; 1799+#endif 1800+ 1801 #if defined(OS_FUCHSIA) 1802 Provider base_provider_fuchsia = {PathProviderFuchsia, &base_provider, 1803 #ifndef NDEBUG 1804@@ -104,7 +118,7 @@ Provider base_provider_fuchsia = {PathProviderFuchsia, &base_provider, 1805 #endif 1806 1807 #if defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_ANDROID) && \ 1808- !defined(OS_FUCHSIA) 1809+ !defined(OS_FUCHSIA) && !defined(OS_OHOS) 1810 Provider base_provider_posix = { 1811 PathProviderPosix, 1812 &base_provider, 1813@@ -133,6 +147,8 @@ struct PathData { 1814 providers = &base_provider_android; 1815 #elif defined(OS_FUCHSIA) 1816 providers = &base_provider_fuchsia; 1817+#elif defined(OS_OHOS) 1818+ providers = &base_provider_ohos; 1819 #elif defined(OS_POSIX) 1820 providers = &base_provider_posix; 1821 #endif 1822diff --git a/base/process/kill.h b/base/process/kill.h 1823index d66a0a994f..9da1826f0a 100644 1824--- a/base/process/kill.h 1825+++ b/base/process/kill.h 1826@@ -113,7 +113,7 @@ BASE_EXPORT TerminationStatus GetTerminationStatus(ProcessHandle handle, 1827 BASE_EXPORT TerminationStatus GetKnownDeadTerminationStatus( 1828 ProcessHandle handle, int* exit_code); 1829 1830-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1831+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1832 // Spawns a thread to wait asynchronously for the child |process| to exit 1833 // and then reaps it. 1834 BASE_EXPORT void EnsureProcessGetsReaped(Process process); 1835diff --git a/base/process/kill_posix.cc b/base/process/kill_posix.cc 1836index fc2bf5cac5..4b7d68236a 100644 1837--- a/base/process/kill_posix.cc 1838+++ b/base/process/kill_posix.cc 1839@@ -160,7 +160,7 @@ void EnsureProcessTerminated(Process process) { 1840 0, new BackgroundReaper(std::move(process), TimeDelta::FromSeconds(2))); 1841 } 1842 1843-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1844+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1845 void EnsureProcessGetsReaped(Process process) { 1846 DCHECK(!process.is_current()); 1847 1848diff --git a/base/process/launch.h b/base/process/launch.h 1849index 2d7425f56e..f5438e89ee 100644 1850--- a/base/process/launch.h 1851+++ b/base/process/launch.h 1852@@ -190,7 +190,7 @@ struct BASE_EXPORT LaunchOptions { 1853 bool clear_environment = false; 1854 #endif // OS_WIN || OS_POSIX || OS_FUCHSIA 1855 1856-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1857+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1858 // If non-zero, start the process using clone(), using flags as provided. 1859 // Unlike in clone, clone_flags may not contain a custom termination signal 1860 // that is sent to the parent when the child dies. The termination signal will 1861@@ -422,7 +422,7 @@ BASE_EXPORT void RaiseProcessToHighPriority(); 1862 // binary. This should not be called in production/released code. 1863 BASE_EXPORT LaunchOptions LaunchOptionsForTest(); 1864 1865-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_NACL_NONSFI) 1866+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_NACL_NONSFI) || defined(OS_OHOS) 1867 // A wrapper for clone with fork-like behavior, meaning that it returns the 1868 // child's pid in the parent and 0 in the child. |flags|, |ptid|, and |ctid| are 1869 // as in the clone system call (the CLONE_VM flag is not supported). 1870diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc 1871index 77d15c3953..321edd183f 100644 1872--- a/base/process/launch_posix.cc 1873+++ b/base/process/launch_posix.cc 1874@@ -89,7 +89,7 @@ void SetEnvironment(char** env) { 1875 // the previous signal mask. 1876 sigset_t SetSignalMask(const sigset_t& new_sigmask) { 1877 sigset_t old_sigmask; 1878-#if defined(OS_ANDROID) 1879+#if defined(OS_ANDROID) || defined(OS_OHOS) 1880 // POSIX says pthread_sigmask() must be used in multi-threaded processes, 1881 // but Android's pthread_sigmask() was broken until 4.1: 1882 // https://code.google.com/p/android/issues/detail?id=15337 1883@@ -199,7 +199,7 @@ struct ScopedDIRClose { 1884 // Automatically closes |DIR*|s. 1885 typedef std::unique_ptr<DIR, ScopedDIRClose> ScopedDIR; 1886 1887-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) 1888+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) || defined(OS_OHOS) 1889 static const char kFDDir[] = "/proc/self/fd"; 1890 #elif defined(OS_SOLARIS) 1891 static const char kFDDir[] = "/dev/fd"; 1892@@ -310,7 +310,7 @@ Process LaunchProcess(const std::vector<std::string>& argv, 1893 1894 pid_t pid; 1895 base::TimeTicks before_fork = TimeTicks::Now(); 1896-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) 1897+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) || defined(OS_OHOS) 1898 if (options.clone_flags) { 1899 // Signal handling in this function assumes the creation of a new 1900 // process, so we check that a thread is not being created by mistake 1901@@ -662,7 +662,7 @@ bool GetAppOutputWithExitCode(const CommandLine& cl, 1902 #endif // !defined(OS_NACL_NONSFI) 1903 1904 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_NACL_NONSFI) || \ 1905- defined(OS_AIX) 1906+ defined(OS_AIX) || defined(OS_OHOS) 1907 namespace { 1908 1909 // This function runs on the stack specified on the clone call. It uses longjmp 1910diff --git a/base/process/memory.h b/base/process/memory.h 1911index fb6f3a54ec..b0d18921e4 100644 1912--- a/base/process/memory.h 1913+++ b/base/process/memory.h 1914@@ -32,7 +32,7 @@ BASE_EXPORT void TerminateBecauseOutOfMemory(size_t size); 1915 BASE_EXPORT extern size_t g_oom_size; 1916 1917 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 1918- defined(OS_AIX) 1919+ defined(OS_AIX) || defined(OS_OHOS) 1920 // The maximum allowed value for the OOM score. 1921 const int kMaxOomScore = 1000; 1922 1923diff --git a/base/process/process_handle.cc b/base/process/process_handle.cc 1924index 7212a49cb3..13d19b98ff 100644 1925--- a/base/process/process_handle.cc 1926+++ b/base/process/process_handle.cc 1927@@ -30,7 +30,7 @@ UniqueProcId GetUniqueIdForProcess() { 1928 : UniqueProcId(GetCurrentProcId()); 1929 } 1930 1931-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) 1932+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_AIX) || defined(OS_OHOS) 1933 1934 void InitUniqueIdForProcessInPidNamespace(ProcessId pid_outside_of_namespace) { 1935 DCHECK(pid_outside_of_namespace != kNullProcessId); 1936diff --git a/base/process/process_handle.h b/base/process/process_handle.h 1937index 3640351398..e610b5e6fb 100644 1938--- a/base/process/process_handle.h 1939+++ b/base/process/process_handle.h 1940@@ -103,7 +103,7 @@ BASE_EXPORT ProcessId GetCurrentProcId(); 1941 // processes may be reused. 1942 BASE_EXPORT UniqueProcId GetUniqueIdForProcess(); 1943 1944-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 1945+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 1946 // When a process is started in a different PID namespace from the browser 1947 // process, this function must be called with the process's PID in the browser's 1948 // PID namespace in order to initialize its unique ID. Not thread safe. 1949diff --git a/base/process/process_metrics.cc b/base/process/process_metrics.cc 1950index 34ee8add80..875b0f1c00 100644 1951--- a/base/process/process_metrics.cc 1952+++ b/base/process/process_metrics.cc 1953@@ -50,7 +50,7 @@ SystemMetrics SystemMetrics::Sample() { 1954 SystemMetrics system_metrics; 1955 1956 system_metrics.committed_memory_ = GetSystemCommitCharge(); 1957-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 1958+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 1959 GetSystemMemoryInfo(&system_metrics.memory_info_); 1960 GetVmStatInfo(&system_metrics.vmstat_info_); 1961 GetSystemDiskInfo(&system_metrics.disk_info_); 1962@@ -69,7 +69,7 @@ std::unique_ptr<Value> SystemMetrics::ToValue() const { 1963 std::unique_ptr<DictionaryValue> res(new DictionaryValue()); 1964 1965 res->SetIntKey("committed_memory", static_cast<int>(committed_memory_)); 1966-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 1967+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 1968 std::unique_ptr<DictionaryValue> meminfo = memory_info_.ToValue(); 1969 std::unique_ptr<DictionaryValue> vmstat = vmstat_info_.ToValue(); 1970 meminfo->MergeDictionary(vmstat.get()); 1971diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h 1972index b291915645..3219922ab9 100644 1973--- a/base/process/process_metrics.h 1974+++ b/base/process/process_metrics.h 1975@@ -47,7 +47,7 @@ namespace base { 1976 // Full declaration is in process_metrics_iocounters.h. 1977 struct IoCounters; 1978 1979-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 1980+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 1981 // Minor and major page fault counts since the process creation. 1982 // Both counts are process-wide, and exclude child processes. 1983 // 1984@@ -98,7 +98,7 @@ class BASE_EXPORT ProcessMetrics { 1985 // convenience wrapper for CreateProcessMetrics(). 1986 static std::unique_ptr<ProcessMetrics> CreateCurrentProcessMetrics(); 1987 1988-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 1989+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 1990 // Resident Set Size is a Linux/Android specific memory concept. Do not 1991 // attempt to extend this to other platforms. 1992 BASE_EXPORT size_t GetResidentSetSize() const; 1993@@ -125,7 +125,7 @@ class BASE_EXPORT ProcessMetrics { 1994 TimeDelta GetCumulativeCPUUsage(); 1995 1996 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 1997- defined(OS_AIX) 1998+ defined(OS_AIX) || defined(OS_OHOS) 1999 // Emits the cumulative CPU usage for all currently active threads since they 2000 // were started into the output parameter (replacing its current contents). 2001 // Threads that have already terminated will not be reported. Thus, the sum of 2002@@ -216,7 +216,7 @@ class BASE_EXPORT ProcessMetrics { 2003 int GetOpenFdSoftLimit() const; 2004 #endif // defined(OS_POSIX) 2005 2006-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 2007+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2008 // Bytes of swap as reported by /proc/[pid]/status. 2009 uint64_t GetVmSwapBytes() const; 2010 2011@@ -236,7 +236,7 @@ class BASE_EXPORT ProcessMetrics { 2012 #endif // !defined(OS_MAC) 2013 2014 #if defined(OS_APPLE) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 2015- defined(OS_AIX) 2016+ defined(OS_AIX) || defined(OS_OHOS) 2017 int CalculateIdleWakeupsPerSecond(uint64_t absolute_idle_wakeups); 2018 #endif 2019 #if defined(OS_APPLE) 2020@@ -247,7 +247,7 @@ class BASE_EXPORT ProcessMetrics { 2021 #endif 2022 2023 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 2024- defined(OS_AIX) 2025+ defined(OS_AIX) || defined(OS_OHOS) 2026 CPU::CoreType GetCoreType(int core_index); 2027 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || 2028 // defined(OS_AIX) 2029@@ -272,7 +272,7 @@ class BASE_EXPORT ProcessMetrics { 2030 uint64_t last_cumulative_disk_usage_ = 0; 2031 2032 #if defined(OS_APPLE) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 2033- defined(OS_AIX) 2034+ defined(OS_AIX) || defined(OS_OHOS) 2035 // Same thing for idle wakeups. 2036 TimeTicks last_idle_wakeups_time_; 2037 uint64_t last_absolute_idle_wakeups_; 2038@@ -325,7 +325,7 @@ BASE_EXPORT void IncreaseFdLimitTo(unsigned int max_descriptors); 2039 2040 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 2041 defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_AIX) || \ 2042- defined(OS_FUCHSIA) 2043+ defined(OS_FUCHSIA) || defined(OS_OHOS) 2044 // Data about system-wide memory consumption. Values are in KB. Available on 2045 // Windows, Mac, Linux, Android and Chrome OS. 2046 // 2047@@ -359,7 +359,7 @@ struct BASE_EXPORT SystemMemoryInfoKB { 2048 #endif 2049 2050 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 2051- defined(OS_AIX) 2052+ defined(OS_AIX) || defined(OS_OHOS) 2053 // This provides an estimate of available memory as described here: 2054 // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 2055 // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always 2056@@ -374,7 +374,7 @@ struct BASE_EXPORT SystemMemoryInfoKB { 2057 #endif 2058 2059 #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 2060- defined(OS_AIX) || defined(OS_FUCHSIA) 2061+ defined(OS_AIX) || defined(OS_FUCHSIA) || defined(OS_OHOS) 2062 int buffers = 0; 2063 int cached = 0; 2064 int active_anon = 0; 2065@@ -411,7 +411,7 @@ BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); 2066 // defined(OS_FUCHSIA) 2067 2068 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 2069- defined(OS_AIX) 2070+ defined(OS_AIX) || defined(OS_OHOS) 2071 // Parse the data found in /proc/<pid>/stat and return the sum of the 2072 // CPU-related ticks. Returns -1 on parse error. 2073 // Exposed for testing. 2074@@ -597,7 +597,7 @@ class BASE_EXPORT SystemMetrics { 2075 FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics); 2076 2077 size_t committed_memory_; 2078-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 2079+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2080 SystemMemoryInfoKB memory_info_; 2081 VmStatInfo vmstat_info_; 2082 SystemDiskInfo disk_info_; 2083diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc 2084index 07b0ceb965..1b6202cd4c 100644 2085--- a/base/process/process_metrics_linux.cc 2086+++ b/base/process/process_metrics_linux.cc 2087@@ -262,7 +262,7 @@ bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { 2088 return true; 2089 } 2090 2091-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 2092+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2093 uint64_t ProcessMetrics::GetVmSwapBytes() const { 2094 return ReadProcStatusAndGetFieldAsSizeT(process_, "VmSwap") * 1024; 2095 } 2096diff --git a/base/process/process_metrics_posix.cc b/base/process/process_metrics_posix.cc 2097index 9d12c427bb..824f4b3aba 100644 2098--- a/base/process/process_metrics_posix.cc 2099+++ b/base/process/process_metrics_posix.cc 2100@@ -49,7 +49,7 @@ static const rlim_t kSystemDefaultMaxFds = 8192; 2101 static const rlim_t kSystemDefaultMaxFds = 1024; 2102 #elif defined(OS_OPENBSD) 2103 static const rlim_t kSystemDefaultMaxFds = 256; 2104-#elif defined(OS_ANDROID) 2105+#elif defined(OS_ANDROID) || defined(OS_OHOS) 2106 static const rlim_t kSystemDefaultMaxFds = 1024; 2107 #elif defined(OS_AIX) 2108 static const rlim_t kSystemDefaultMaxFds = 8192; 2109@@ -119,7 +119,10 @@ size_t ProcessMetrics::GetMallocUsage() { 2110 malloc_statistics_t stats = {0}; 2111 malloc_zone_statistics(nullptr, &stats); 2112 return stats.size_in_use; 2113-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 2114+#elif defined(__MUSL__) 2115+ // TODO: same as https://crbug.com/735087, no mallinfo for musl 2116+ return 0; 2117+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2118 struct mallinfo minfo = mallinfo(); 2119 #if BUILDFLAG(USE_TCMALLOC) 2120 return minfo.uordblks; 2121diff --git a/base/profiler/register_context.h b/base/profiler/register_context.h 2122index 36b2ca24da..fbe66bfe40 100644 2123--- a/base/profiler/register_context.h 2124+++ b/base/profiler/register_context.h 2125@@ -17,7 +17,7 @@ 2126 #include <windows.h> 2127 #elif defined(OS_APPLE) 2128 #include <mach/machine/thread_status.h> 2129-#elif defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 2130+#elif defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 2131 #include <sys/ucontext.h> 2132 #endif 2133 2134@@ -111,7 +111,7 @@ inline uintptr_t& RegisterContextInstructionPointer( 2135 #endif 2136 2137 #elif defined(OS_ANDROID) || defined(OS_LINUX) || \ 2138- defined(OS_CHROMEOS) // #if defined(OS_WIN) 2139+ defined(OS_CHROMEOS) || defined(OS_OHOS) // #if defined(OS_WIN) 2140 2141 using RegisterContext = mcontext_t; 2142 2143diff --git a/base/profiler/sampling_profiler_thread_token.h b/base/profiler/sampling_profiler_thread_token.h 2144index 8a2d23f18f..1cbbb17a60 100644 2145--- a/base/profiler/sampling_profiler_thread_token.h 2146+++ b/base/profiler/sampling_profiler_thread_token.h 2147@@ -9,7 +9,7 @@ 2148 #include "base/threading/platform_thread.h" 2149 #include "build/build_config.h" 2150 2151-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 2152+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 2153 #include <pthread.h> 2154 #endif 2155 2156@@ -21,7 +21,7 @@ namespace base { 2157 // functions used to obtain the stack base address. 2158 struct SamplingProfilerThreadToken { 2159 PlatformThreadId id; 2160-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 2161+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 2162 pthread_t pthread_id; 2163 #endif 2164 }; 2165diff --git a/base/run_loop.h b/base/run_loop.h 2166index 730bf19819..177dc88c77 100644 2167--- a/base/run_loop.h 2168+++ b/base/run_loop.h 2169@@ -289,7 +289,7 @@ class BASE_EXPORT RunLoop { 2170 FRIEND_TEST_ALL_PREFIXES(SingleThreadTaskExecutorTypedTest, 2171 RunLoopQuitOrderAfter); 2172 2173-#if defined(OS_ANDROID) 2174+#if defined(OS_ANDROID) || defined(OS_OHOS) 2175 // Android doesn't support the blocking RunLoop::Run, so it calls 2176 // BeforeRun and AfterRun directly. 2177 friend class MessagePumpForUI; 2178diff --git a/base/synchronization/lock_impl_posix.cc b/base/synchronization/lock_impl_posix.cc 2179index 0793661d62..0bbcf2ff8f 100644 2180--- a/base/synchronization/lock_impl_posix.cc 2181+++ b/base/synchronization/lock_impl_posix.cc 2182@@ -48,7 +48,7 @@ std::string SystemErrorCodeToString(int error_code) { 2183 // Lock::PriorityInheritanceAvailable still must be checked as the code may 2184 // compile but the underlying platform still may not correctly support priority 2185 // inheritance locks. 2186-#if defined(OS_NACL) || defined(OS_ANDROID) || defined(OS_FUCHSIA) 2187+#if defined(OS_NACL) || defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(OS_OHOS) 2188 #define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 0 2189 #else 2190 #define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 1 2191diff --git a/base/system/sys_info.h b/base/system/sys_info.h 2192index 46d49ccdf1..a2af75b6a0 100644 2193--- a/base/system/sys_info.h 2194+++ b/base/system/sys_info.h 2195@@ -219,7 +219,7 @@ class BASE_EXPORT SysInfo { 2196 static HardwareInfo GetHardwareInfoSync(); 2197 2198 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 2199- defined(OS_AIX) 2200+ defined(OS_AIX) || defined(OS_OHOS) 2201 static int64_t AmountOfAvailablePhysicalMemory( 2202 const SystemMemoryInfoKB& meminfo); 2203 #endif 2204diff --git a/base/task/current_thread.cc b/base/task/current_thread.cc 2205index 51cc852fcc..e4fcbefb26 100644 2206--- a/base/task/current_thread.cc 2207+++ b/base/task/current_thread.cc 2208@@ -153,7 +153,7 @@ MessagePumpForUI* CurrentUIThread::GetMessagePumpForUI() const { 2209 return static_cast<MessagePumpForUI*>(current_->GetMessagePump()); 2210 } 2211 2212-#if defined(USE_OZONE) && !defined(OS_FUCHSIA) && !defined(OS_WIN) 2213+#if defined(USE_OZONE) && !defined(OS_FUCHSIA) && !defined(OS_WIN) && !defined(OS_OHOS) 2214 bool CurrentUIThread::WatchFileDescriptor( 2215 int fd, 2216 bool persistent, 2217diff --git a/base/task/current_thread.h b/base/task/current_thread.h 2218index 823a1d02ca..f5a21a624e 100644 2219--- a/base/task/current_thread.h 2220+++ b/base/task/current_thread.h 2221@@ -221,7 +221,7 @@ class BASE_EXPORT CurrentUIThread : public CurrentThread { 2222 2223 CurrentUIThread* operator->() { return this; } 2224 2225-#if defined(USE_OZONE) && !defined(OS_FUCHSIA) && !defined(OS_WIN) 2226+#if defined(USE_OZONE) && !defined(OS_FUCHSIA) && !defined(OS_WIN) && !defined(OS_OHOS) 2227 static_assert( 2228 std::is_base_of<WatchableIOMessagePumpPosix, MessagePumpForUI>::value, 2229 "CurrentThreadForUI::WatchFileDescriptor is supported only" 2230diff --git a/base/task/sequence_manager/sequence_manager_impl.cc b/base/task/sequence_manager/sequence_manager_impl.cc 2231index 228489157e..d34064c3a8 100644 2232--- a/base/task/sequence_manager/sequence_manager_impl.cc 2233+++ b/base/task/sequence_manager/sequence_manager_impl.cc 2234@@ -308,6 +308,10 @@ void SequenceManagerImpl::BindToMessagePump(std::unique_ptr<MessagePump> pump) { 2235 settings_.message_loop_type == MessagePumpType::JAVA) { 2236 controller_->AttachToMessagePump(); 2237 } 2238+#elif defined(OS_OHOS) 2239+ if (settings_.message_loop_type == MessagePumpType::UI) { 2240+ controller_->AttachToMessagePump(); 2241+ } 2242 #endif 2243 2244 // On iOS attach to the native loop when there is one. 2245diff --git a/base/task/sequence_manager/thread_controller.h b/base/task/sequence_manager/thread_controller.h 2246index 229bf222de..4e01e5370f 100644 2247--- a/base/task/sequence_manager/thread_controller.h 2248+++ b/base/task/sequence_manager/thread_controller.h 2249@@ -93,7 +93,7 @@ class ThreadController { 2250 // Returns true if the current run loop should quit when idle. 2251 virtual bool ShouldQuitRunLoopWhenIdle() = 0; 2252 2253-#if defined(OS_IOS) || defined(OS_ANDROID) 2254+#if defined(OS_IOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2255 // On iOS, the main message loop cannot be Run(). Instead call 2256 // AttachToMessagePump(), which connects this ThreadController to the 2257 // UI thread's CFRunLoop and allows PostTask() to work. 2258diff --git a/base/task/sequence_manager/thread_controller_impl.cc b/base/task/sequence_manager/thread_controller_impl.cc 2259index bfc66bd8be..13cdad6672 100644 2260--- a/base/task/sequence_manager/thread_controller_impl.cc 2261+++ b/base/task/sequence_manager/thread_controller_impl.cc 2262@@ -332,7 +332,7 @@ MessagePump* ThreadControllerImpl::GetBoundMessagePump() const { 2263 return nullptr; 2264 } 2265 2266-#if defined(OS_IOS) || defined(OS_ANDROID) 2267+#if defined(OS_IOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2268 void ThreadControllerImpl::AttachToMessagePump() { 2269 NOTREACHED(); 2270 } 2271diff --git a/base/task/sequence_manager/thread_controller_impl.h b/base/task/sequence_manager/thread_controller_impl.h 2272index 0276b039ed..c491e9095e 100644 2273--- a/base/task/sequence_manager/thread_controller_impl.h 2274+++ b/base/task/sequence_manager/thread_controller_impl.h 2275@@ -61,7 +61,7 @@ class BASE_EXPORT ThreadControllerImpl : public ThreadController, 2276 void SetTaskExecutionAllowed(bool allowed) override; 2277 bool IsTaskExecutionAllowed() const override; 2278 MessagePump* GetBoundMessagePump() const override; 2279-#if defined(OS_IOS) || defined(OS_ANDROID) 2280+#if defined(OS_IOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2281 void AttachToMessagePump() override; 2282 #endif 2283 #if defined(OS_IOS) 2284diff --git a/base/task/sequence_manager/thread_controller_with_message_pump_impl.cc b/base/task/sequence_manager/thread_controller_with_message_pump_impl.cc 2285index e2322c8cf0..1bda48dd13 100644 2286--- a/base/task/sequence_manager/thread_controller_with_message_pump_impl.cc 2287+++ b/base/task/sequence_manager/thread_controller_with_message_pump_impl.cc 2288@@ -532,7 +532,7 @@ void ThreadControllerWithMessagePumpImpl::AttachToMessagePump() { 2289 void ThreadControllerWithMessagePumpImpl::DetachFromMessagePump() { 2290 static_cast<MessagePumpCFRunLoopBase*>(pump_.get())->Detach(); 2291 } 2292-#elif defined(OS_ANDROID) 2293+#elif defined(OS_ANDROID) || defined(OS_OHOS) 2294 void ThreadControllerWithMessagePumpImpl::AttachToMessagePump() { 2295 static_cast<MessagePumpForUI*>(pump_.get())->Attach(this); 2296 } 2297diff --git a/base/task/sequence_manager/thread_controller_with_message_pump_impl.h b/base/task/sequence_manager/thread_controller_with_message_pump_impl.h 2298index 8ef4a51437..f7254eb61a 100644 2299--- a/base/task/sequence_manager/thread_controller_with_message_pump_impl.h 2300+++ b/base/task/sequence_manager/thread_controller_with_message_pump_impl.h 2301@@ -72,7 +72,7 @@ class BASE_EXPORT ThreadControllerWithMessagePumpImpl 2302 void SetTaskExecutionAllowed(bool allowed) override; 2303 bool IsTaskExecutionAllowed() const override; 2304 MessagePump* GetBoundMessagePump() const override; 2305-#if defined(OS_IOS) || defined(OS_ANDROID) 2306+#if defined(OS_IOS) || defined(OS_ANDROID) || defined(OS_OHOS) 2307 void AttachToMessagePump() override; 2308 #endif 2309 #if defined(OS_IOS) 2310diff --git a/base/third_party/libevent/BUILD.gn b/base/third_party/libevent/BUILD.gn 2311index abd3901d15..5ae9fd1768 100644 2312--- a/base/third_party/libevent/BUILD.gn 2313+++ b/base/third_party/libevent/BUILD.gn 2314@@ -73,6 +73,17 @@ static_library("libevent") { 2315 "nacl_nonsfi/signal_stub.c", 2316 ] 2317 include_dirs = [ "nacl_nonsfi" ] 2318+ } else if (is_ohos) { 2319+ sources += [ 2320+ "epoll.c", 2321+ "ohos/config.h", 2322+ "ohos/event-config.h", 2323+ ] 2324+ include_dirs = [ "ohos" ] 2325+ if (use_musl) { 2326+ defines += [ "USE_MUSL" ] 2327+ include_dirs += [ "compat" ] 2328+ } 2329 } 2330 2331 if (!is_debug) { 2332diff --git a/base/third_party/libevent/event_tagging.c b/base/third_party/libevent/event_tagging.c 2333index d436e3fd65..6dcc8c2fa0 100644 2334--- a/base/third_party/libevent/event_tagging.c 2335+++ b/base/third_party/libevent/event_tagging.c 2336@@ -45,7 +45,9 @@ 2337 #include <sys/ioctl.h> 2338 #endif 2339 2340+#ifdef HAVE_SYS_QUEUE_H 2341 #include <sys/queue.h> 2342+#endif 2343 #ifdef HAVE_SYS_TIME_H 2344 #include <sys/time.h> 2345 #endif 2346diff --git a/base/third_party/libevent/ohos/config.h b/base/third_party/libevent/ohos/config.h 2347new file mode 100644 2348index 0000000000..8c540883ef 2349--- /dev/null 2350+++ b/base/third_party/libevent/ohos/config.h 2351@@ -0,0 +1,268 @@ 2352+/* Copied from Linux version and changed the features according Android, which 2353+ * is close to Linux */ 2354+ 2355+/* Define if clock_gettime is available in libc */ 2356+#define DNS_USE_CPU_CLOCK_FOR_ID 1 2357+ 2358+/* Define is no secure id variant is available */ 2359+/* #undef DNS_USE_GETTIMEOFDAY_FOR_ID */ 2360+ 2361+/* Define to 1 if you have the `clock_gettime' function. */ 2362+#define HAVE_CLOCK_GETTIME 1 2363+ 2364+/* Define if /dev/poll is available */ 2365+/* #undef HAVE_DEVPOLL */ 2366+ 2367+/* Define to 1 if you have the <dlfcn.h> header file. */ 2368+#define HAVE_DLFCN_H 1 2369+ 2370+/* Define if your system supports the epoll system calls */ 2371+#define HAVE_EPOLL 1 2372+ 2373+/* Define to 1 if you have the `epoll_ctl' function. */ 2374+#define HAVE_EPOLL_CTL 1 2375+ 2376+/* Define if your system supports event ports */ 2377+/* #undef HAVE_EVENT_PORTS */ 2378+ 2379+/* Define to 1 if you have the `fcntl' function. */ 2380+#define HAVE_FCNTL 1 2381+ 2382+/* Define to 1 if you have the <fcntl.h> header file. */ 2383+#define HAVE_FCNTL_H 1 2384+ 2385+/* Define to 1 if the system has the type `fd_mask'. */ 2386+/* #undef HAVE_FD_MASK */ 2387+ 2388+/* Define to 1 if you have the `getaddrinfo' function. */ 2389+#define HAVE_GETADDRINFO 1 2390+ 2391+/* Define to 1 if you have the `getegid' function. */ 2392+#define HAVE_GETEGID 1 2393+ 2394+/* Define to 1 if you have the `geteuid' function. */ 2395+#define HAVE_GETEUID 1 2396+ 2397+/* Define to 1 if you have the `getnameinfo' function. */ 2398+#define HAVE_GETNAMEINFO 1 2399+ 2400+/* Define to 1 if you have the `gettimeofday' function. */ 2401+#define HAVE_GETTIMEOFDAY 1 2402+ 2403+/* Define to 1 if you have the `inet_ntop' function. */ 2404+#define HAVE_INET_NTOP 1 2405+ 2406+/* Define to 1 if you have the <inttypes.h> header file. */ 2407+#define HAVE_INTTYPES_H 1 2408+ 2409+/* Define to 1 if you have the `issetugid' function. */ 2410+/* #undef HAVE_ISSETUGID */ 2411+ 2412+/* Define to 1 if you have the `kqueue' function. */ 2413+/* #undef HAVE_KQUEUE */ 2414+ 2415+/* Define to 1 if you have the `nsl' library (-lnsl). */ 2416+#define HAVE_LIBNSL 1 2417+ 2418+/* Define to 1 if you have the `resolv' library (-lresolv). */ 2419+#define HAVE_LIBRESOLV 1 2420+ 2421+/* Define to 1 if you have the `rt' library (-lrt). */ 2422+#define HAVE_LIBRT 1 2423+ 2424+/* Define to 1 if you have the `socket' library (-lsocket). */ 2425+/* #undef HAVE_LIBSOCKET */ 2426+ 2427+/* Define to 1 if you have the <memory.h> header file. */ 2428+#define HAVE_MEMORY_H 1 2429+ 2430+/* Define to 1 if you have the <netinet/in6.h> header file. */ 2431+/* #undef HAVE_NETINET_IN6_H */ 2432+ 2433+/* Define to 1 if you have the `poll' function. */ 2434+#define HAVE_POLL 1 2435+ 2436+/* Define to 1 if you have the <poll.h> header file. */ 2437+#define HAVE_POLL_H 1 2438+ 2439+/* Define to 1 if you have the `port_create' function. */ 2440+/* #undef HAVE_PORT_CREATE */ 2441+ 2442+/* Define to 1 if you have the <port.h> header file. */ 2443+/* #undef HAVE_PORT_H */ 2444+ 2445+/* Define to 1 if you have the `select' function. */ 2446+#define HAVE_SELECT 1 2447+ 2448+/* Define if F_SETFD is defined in <fcntl.h> */ 2449+#define HAVE_SETFD 1 2450+ 2451+/* Define to 1 if you have the `sigaction' function. */ 2452+#define HAVE_SIGACTION 1 2453+ 2454+/* Define to 1 if you have the `signal' function. */ 2455+#define HAVE_SIGNAL 1 2456+ 2457+/* Define to 1 if you have the <signal.h> header file. */ 2458+#define HAVE_SIGNAL_H 1 2459+ 2460+/* Define to 1 if you have the <stdarg.h> header file. */ 2461+#define HAVE_STDARG_H 1 2462+ 2463+/* Define to 1 if you have the <stdint.h> header file. */ 2464+#define HAVE_STDINT_H 1 2465+ 2466+/* Define to 1 if you have the <stdlib.h> header file. */ 2467+#define HAVE_STDLIB_H 1 2468+ 2469+/* Define to 1 if you have the <strings.h> header file. */ 2470+#define HAVE_STRINGS_H 1 2471+ 2472+/* Define to 1 if you have the <string.h> header file. */ 2473+#define HAVE_STRING_H 1 2474+ 2475+/* Define to 1 if you have the `strlcpy' function. */ 2476+#define HAVE_STRLCPY 1 2477+ 2478+/* Define to 1 if you have the `strsep' function. */ 2479+#define HAVE_STRSEP 1 2480+ 2481+/* Define to 1 if you have the `strtok_r' function. */ 2482+#define HAVE_STRTOK_R 1 2483+ 2484+/* Define to 1 if you have the `strtoll' function. */ 2485+#define HAVE_STRTOLL 1 2486+ 2487+/* Define to 1 if the system has the type `struct in6_addr'. */ 2488+#define HAVE_STRUCT_IN6_ADDR 1 2489+ 2490+/* Define to 1 if you have the <sys/devpoll.h> header file. */ 2491+/* #undef HAVE_SYS_DEVPOLL_H */ 2492+ 2493+/* Define to 1 if you have the <sys/epoll.h> header file. */ 2494+#define HAVE_SYS_EPOLL_H 1 2495+ 2496+/* Define to 1 if you have the <sys/event.h> header file. */ 2497+/* #undef HAVE_SYS_EVENT_H */ 2498+ 2499+/* Define to 1 if you have the <sys/ioctl.h> header file. */ 2500+#define HAVE_SYS_IOCTL_H 1 2501+ 2502+/* Define to 1 if you have the <sys/param.h> header file. */ 2503+#define HAVE_SYS_PARAM_H 1 2504+ 2505+/* Define to 1 if you have the <sys/queue.h> header file. */ 2506+#if !defined(USE_MUSL) 2507+#define HAVE_SYS_QUEUE_H 1 2508+#endif 2509+ 2510+/* Define to 1 if you have the <sys/select.h> header file. */ 2511+#define HAVE_SYS_SELECT_H 1 2512+ 2513+/* Define to 1 if you have the <sys/socket.h> header file. */ 2514+#define HAVE_SYS_SOCKET_H 1 2515+ 2516+/* Define to 1 if you have the <sys/stat.h> header file. */ 2517+#define HAVE_SYS_STAT_H 1 2518+ 2519+/* Define to 1 if you have the <sys/time.h> header file. */ 2520+#define HAVE_SYS_TIME_H 1 2521+ 2522+/* Define to 1 if you have the <sys/types.h> header file. */ 2523+#define HAVE_SYS_TYPES_H 1 2524+ 2525+/* Define if TAILQ_FOREACH is defined in <sys/queue.h> */ 2526+#define HAVE_TAILQFOREACH 1 2527+ 2528+/* Define if timeradd is defined in <sys/time.h> */ 2529+#define HAVE_TIMERADD 1 2530+ 2531+/* Define if timerclear is defined in <sys/time.h> */ 2532+#define HAVE_TIMERCLEAR 1 2533+ 2534+/* Define if timercmp is defined in <sys/time.h> */ 2535+#define HAVE_TIMERCMP 1 2536+ 2537+/* Define if timerisset is defined in <sys/time.h> */ 2538+#define HAVE_TIMERISSET 1 2539+ 2540+/* Define to 1 if the system has the type `uint16_t'. */ 2541+#define HAVE_UINT16_T 1 2542+ 2543+/* Define to 1 if the system has the type `uint32_t'. */ 2544+#define HAVE_UINT32_T 1 2545+ 2546+/* Define to 1 if the system has the type `uint64_t'. */ 2547+#define HAVE_UINT64_T 1 2548+ 2549+/* Define to 1 if the system has the type `uint8_t'. */ 2550+#define HAVE_UINT8_T 1 2551+ 2552+/* Define to 1 if you have the <unistd.h> header file. */ 2553+#define HAVE_UNISTD_H 1 2554+ 2555+/* Define to 1 if you have the `vasprintf' function. */ 2556+#define HAVE_VASPRINTF 1 2557+ 2558+/* Define if kqueue works correctly with pipes */ 2559+/* #undef HAVE_WORKING_KQUEUE */ 2560+ 2561+/* Name of package */ 2562+#define PACKAGE "libevent" 2563+ 2564+/* Define to the address where bug reports for this package should be sent. */ 2565+#define PACKAGE_BUGREPORT "" 2566+ 2567+/* Define to the full name of this package. */ 2568+#define PACKAGE_NAME "" 2569+ 2570+/* Define to the full name and version of this package. */ 2571+#define PACKAGE_STRING "" 2572+ 2573+/* Define to the one symbol short name of this package. */ 2574+#define PACKAGE_TARNAME "" 2575+ 2576+/* Define to the version of this package. */ 2577+#define PACKAGE_VERSION "" 2578+ 2579+/* The size of `int', as computed by sizeof. */ 2580+#define SIZEOF_INT 4 2581+ 2582+/* The size of `long', as computed by sizeof. */ 2583+#define SIZEOF_LONG 8 2584+ 2585+/* The size of `long long', as computed by sizeof. */ 2586+#define SIZEOF_LONG_LONG 8 2587+ 2588+/* The size of `short', as computed by sizeof. */ 2589+#define SIZEOF_SHORT 2 2590+ 2591+/* Define to 1 if you have the ANSI C header files. */ 2592+#define STDC_HEADERS 1 2593+ 2594+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ 2595+#define TIME_WITH_SYS_TIME 1 2596+ 2597+/* Version number of package */ 2598+#define VERSION "1.4.13-stable" 2599+ 2600+/* Define to appropriate substitue if compiler doesnt have __func__ */ 2601+/* #undef __func__ */ 2602+ 2603+/* Define to empty if `const' does not conform to ANSI C. */ 2604+/* #undef const */ 2605+ 2606+/* Define to `__inline__' or `__inline' if that's what the C compiler 2607+ calls it, or to nothing if 'inline' is not supported under any name. */ 2608+#ifndef __cplusplus 2609+/* #undef inline */ 2610+#endif 2611+ 2612+/* Define to `int' if <sys/types.h> does not define. */ 2613+/* #undef pid_t */ 2614+ 2615+/* Define to `unsigned int' if <sys/types.h> does not define. */ 2616+/* #undef size_t */ 2617+ 2618+/* Define to unsigned int if you dont have it */ 2619+/* #undef socklen_t */ 2620diff --git a/base/third_party/libevent/ohos/event-config.h b/base/third_party/libevent/ohos/event-config.h 2621new file mode 100644 2622index 0000000000..6563cb78d8 2623--- /dev/null 2624+++ b/base/third_party/libevent/ohos/event-config.h 2625@@ -0,0 +1,281 @@ 2626+/* Copied from Linux version and changed the features according Android, which 2627+ * is close to Linux */ 2628+#ifndef _EVENT_CONFIG_H_ 2629+#define _EVENT_CONFIG_H_ 2630+/* config.h. Generated from config.h.in by configure. */ 2631+/* config.h.in. Generated from configure.in by autoheader. */ 2632+ 2633+/* Define if clock_gettime is available in libc */ 2634+#define _EVENT_DNS_USE_CPU_CLOCK_FOR_ID 1 2635+ 2636+/* Define is no secure id variant is available */ 2637+/* #undef _EVENT_DNS_USE_GETTIMEOFDAY_FOR_ID */ 2638+ 2639+/* Define to 1 if you have the `clock_gettime' function. */ 2640+#define _EVENT_HAVE_CLOCK_GETTIME 1 2641+ 2642+/* Define if /dev/poll is available */ 2643+/* #undef _EVENT_HAVE_DEVPOLL */ 2644+ 2645+/* Define to 1 if you have the <dlfcn.h> header file. */ 2646+#define _EVENT_HAVE_DLFCN_H 1 2647+ 2648+/* Define if your system supports the epoll system calls */ 2649+#define _EVENT_HAVE_EPOLL 1 2650+ 2651+/* Define to 1 if you have the `epoll_ctl' function. */ 2652+#define _EVENT_HAVE_EPOLL_CTL 1 2653+ 2654+/* Define if your system supports event ports */ 2655+/* #undef _EVENT_HAVE_EVENT_PORTS */ 2656+ 2657+/* Define to 1 if you have the `fcntl' function. */ 2658+#define _EVENT_HAVE_FCNTL 1 2659+ 2660+/* Define to 1 if you have the <fcntl.h> header file. */ 2661+#define _EVENT_HAVE_FCNTL_H 1 2662+ 2663+/* Define to 1 if the system has the type `fd_mask'. */ 2664+/* #undef _EVENT_HAVE_FD_MASK 1 */ 2665+ 2666+/* Define to 1 if you have the `getaddrinfo' function. */ 2667+#define _EVENT_HAVE_GETADDRINFO 1 2668+ 2669+/* Define to 1 if you have the `getegid' function. */ 2670+#define _EVENT_HAVE_GETEGID 1 2671+ 2672+/* Define to 1 if you have the `geteuid' function. */ 2673+#define _EVENT_HAVE_GETEUID 1 2674+ 2675+/* Define to 1 if you have the `getnameinfo' function. */ 2676+#define _EVENT_HAVE_GETNAMEINFO 1 2677+ 2678+/* Define to 1 if you have the `gettimeofday' function. */ 2679+#define _EVENT_HAVE_GETTIMEOFDAY 1 2680+ 2681+/* Define to 1 if you have the `inet_ntop' function. */ 2682+#define _EVENT_HAVE_INET_NTOP 1 2683+ 2684+/* Define to 1 if you have the <inttypes.h> header file. */ 2685+#define _EVENT_HAVE_INTTYPES_H 1 2686+ 2687+/* Define to 1 if you have the `issetugid' function. */ 2688+/* #undef _EVENT_HAVE_ISSETUGID */ 2689+ 2690+/* Define to 1 if you have the `kqueue' function. */ 2691+/* #undef _EVENT_HAVE_KQUEUE */ 2692+ 2693+/* Define to 1 if you have the `nsl' library (-lnsl). */ 2694+#define _EVENT_HAVE_LIBNSL 1 2695+ 2696+/* Define to 1 if you have the `resolv' library (-lresolv). */ 2697+#define _EVENT_HAVE_LIBRESOLV 1 2698+ 2699+/* Define to 1 if you have the `rt' library (-lrt). */ 2700+#define _EVENT_HAVE_LIBRT 1 2701+ 2702+/* Define to 1 if you have the `socket' library (-lsocket). */ 2703+/* #undef _EVENT_HAVE_LIBSOCKET */ 2704+ 2705+/* Define to 1 if you have the <memory.h> header file. */ 2706+#define _EVENT_HAVE_MEMORY_H 1 2707+ 2708+/* Define to 1 if you have the <netinet/in6.h> header file. */ 2709+/* #undef _EVENT_HAVE_NETINET_IN6_H */ 2710+ 2711+/* Define to 1 if you have the `poll' function. */ 2712+#define _EVENT_HAVE_POLL 1 2713+ 2714+/* Define to 1 if you have the <poll.h> header file. */ 2715+#define _EVENT_HAVE_POLL_H 1 2716+ 2717+/* Define to 1 if you have the `port_create' function. */ 2718+/* #undef _EVENT_HAVE_PORT_CREATE */ 2719+ 2720+/* Define to 1 if you have the <port.h> header file. */ 2721+/* #undef _EVENT_HAVE_PORT_H */ 2722+ 2723+/* Define to 1 if you have the `select' function. */ 2724+#define _EVENT_HAVE_SELECT 1 2725+ 2726+/* Define if F_SETFD is defined in <fcntl.h> */ 2727+#define _EVENT_HAVE_SETFD 1 2728+ 2729+/* Define to 1 if you have the `sigaction' function. */ 2730+#define _EVENT_HAVE_SIGACTION 1 2731+ 2732+/* Define to 1 if you have the `signal' function. */ 2733+#define _EVENT_HAVE_SIGNAL 1 2734+ 2735+/* Define to 1 if you have the <signal.h> header file. */ 2736+#define _EVENT_HAVE_SIGNAL_H 1 2737+ 2738+/* Define to 1 if you have the <stdarg.h> header file. */ 2739+#define _EVENT_HAVE_STDARG_H 1 2740+ 2741+/* Define to 1 if you have the <stdint.h> header file. */ 2742+#define _EVENT_HAVE_STDINT_H 1 2743+ 2744+/* Define to 1 if you have the <stdlib.h> header file. */ 2745+#define _EVENT_HAVE_STDLIB_H 1 2746+ 2747+/* Define to 1 if you have the <strings.h> header file. */ 2748+#define _EVENT_HAVE_STRINGS_H 1 2749+ 2750+/* Define to 1 if you have the <string.h> header file. */ 2751+#define _EVENT_HAVE_STRING_H 1 2752+ 2753+/* Define to 1 if you have the `strlcpy' function. */ 2754+#define _EVENT_HAVE_STRLCPY 1 2755+ 2756+/* Define to 1 if you have the `strsep' function. */ 2757+#define _EVENT_HAVE_STRSEP 1 2758+ 2759+/* Define to 1 if you have the `strtok_r' function. */ 2760+#define _EVENT_HAVE_STRTOK_R 1 2761+ 2762+/* Define to 1 if you have the `strtoll' function. */ 2763+#define _EVENT_HAVE_STRTOLL 1 2764+ 2765+/* Define to 1 if the system has the type `struct in6_addr'. */ 2766+#define _EVENT_HAVE_STRUCT_IN6_ADDR 1 2767+ 2768+/* Define to 1 if you have the <sys/devpoll.h> header file. */ 2769+/* #undef _EVENT_HAVE_SYS_DEVPOLL_H */ 2770+ 2771+/* Define to 1 if you have the <sys/epoll.h> header file. */ 2772+#define _EVENT_HAVE_SYS_EPOLL_H 1 2773+ 2774+/* Define to 1 if you have the <sys/event.h> header file. */ 2775+/* #undef _EVENT_HAVE_SYS_EVENT_H */ 2776+ 2777+/* Define to 1 if you have the <sys/ioctl.h> header file. */ 2778+#define _EVENT_HAVE_SYS_IOCTL_H 1 2779+ 2780+/* Define to 1 if you have the <sys/param.h> header file. */ 2781+#define _EVENT_HAVE_SYS_PARAM_H 1 2782+ 2783+/* Define to 1 if you have the <sys/queue.h> header file. */ 2784+#define _EVENT_HAVE_SYS_QUEUE_H 1 2785+ 2786+/* Define to 1 if you have the <sys/select.h> header file. */ 2787+#define _EVENT_HAVE_SYS_SELECT_H 1 2788+ 2789+/* Define to 1 if you have the <sys/socket.h> header file. */ 2790+#define _EVENT_HAVE_SYS_SOCKET_H 1 2791+ 2792+/* Define to 1 if you have the <sys/stat.h> header file. */ 2793+#define _EVENT_HAVE_SYS_STAT_H 1 2794+ 2795+/* Define to 1 if you have the <sys/time.h> header file. */ 2796+#define _EVENT_HAVE_SYS_TIME_H 1 2797+ 2798+/* Define to 1 if you have the <sys/types.h> header file. */ 2799+#define _EVENT_HAVE_SYS_TYPES_H 1 2800+ 2801+/* Define if TAILQ_FOREACH is defined in <sys/queue.h> */ 2802+#define _EVENT_HAVE_TAILQFOREACH 1 2803+ 2804+/* Define if timeradd is defined in <sys/time.h> */ 2805+#define _EVENT_HAVE_TIMERADD 1 2806+ 2807+/* Define if timerclear is defined in <sys/time.h> */ 2808+#define _EVENT_HAVE_TIMERCLEAR 1 2809+ 2810+/* Define if timercmp is defined in <sys/time.h> */ 2811+#define _EVENT_HAVE_TIMERCMP 1 2812+ 2813+/* Define if timerisset is defined in <sys/time.h> */ 2814+#define _EVENT_HAVE_TIMERISSET 1 2815+ 2816+/* Define to 1 if the system has the type `uint16_t'. */ 2817+#define _EVENT_HAVE_UINT16_T 1 2818+ 2819+/* Define to 1 if the system has the type `uint32_t'. */ 2820+#define _EVENT_HAVE_UINT32_T 1 2821+ 2822+/* Define to 1 if the system has the type `uint64_t'. */ 2823+#define _EVENT_HAVE_UINT64_T 1 2824+ 2825+/* Define to 1 if the system has the type `uint8_t'. */ 2826+#define _EVENT_HAVE_UINT8_T 1 2827+ 2828+/* Define to 1 if you have the <unistd.h> header file. */ 2829+#define _EVENT_HAVE_UNISTD_H 1 2830+ 2831+/* Define to 1 if you have the `vasprintf' function. */ 2832+#define _EVENT_HAVE_VASPRINTF 1 2833+ 2834+/* Define if kqueue works correctly with pipes */ 2835+/* #undef _EVENT_HAVE_WORKING_KQUEUE */ 2836+ 2837+/* Define to the sub-directory in which libtool stores uninstalled libraries. 2838+ */ 2839+#define _EVENT_LT_OBJDIR ".libs/" 2840+ 2841+/* Numeric representation of the version */ 2842+#define _EVENT_NUMERIC_VERSION 0x01040f00 2843+ 2844+/* Name of package */ 2845+#define _EVENT_PACKAGE "libevent" 2846+ 2847+/* Define to the address where bug reports for this package should be sent. */ 2848+#define _EVENT_PACKAGE_BUGREPORT "" 2849+ 2850+/* Define to the full name of this package. */ 2851+#define _EVENT_PACKAGE_NAME "" 2852+ 2853+/* Define to the full name and version of this package. */ 2854+#define _EVENT_PACKAGE_STRING "" 2855+ 2856+/* Define to the one symbol short name of this package. */ 2857+#define _EVENT_PACKAGE_TARNAME "" 2858+ 2859+/* Define to the home page for this package. */ 2860+#define _EVENT_PACKAGE_URL "" 2861+ 2862+/* Define to the version of this package. */ 2863+#define _EVENT_PACKAGE_VERSION "" 2864+ 2865+/* The size of `int', as computed by sizeof. */ 2866+#define _EVENT_SIZEOF_INT 4 2867+ 2868+/* The size of `long', as computed by sizeof. */ 2869+#define _EVENT_SIZEOF_LONG 8 2870+ 2871+/* The size of `long long', as computed by sizeof. */ 2872+#define _EVENT_SIZEOF_LONG_LONG 8 2873+ 2874+/* The size of `short', as computed by sizeof. */ 2875+#define _EVENT_SIZEOF_SHORT 2 2876+ 2877+/* Define to 1 if you have the ANSI C header files. */ 2878+#define _EVENT_STDC_HEADERS 1 2879+ 2880+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ 2881+#define _EVENT_TIME_WITH_SYS_TIME 1 2882+ 2883+/* Version number of package */ 2884+#define _EVENT_VERSION "1.4.15" 2885+ 2886+/* Define to appropriate substitue if compiler doesnt have __func__ */ 2887+/* #undef _EVENT___func__ */ 2888+ 2889+/* Define to empty if `const' does not conform to ANSI C. */ 2890+/* #undef _EVENT_const */ 2891+ 2892+/* Define to `__inline__' or `__inline' if that's what the C compiler 2893+ calls it, or to nothing if 'inline' is not supported under any name. */ 2894+#ifndef _EVENT___cplusplus 2895+/* #undef _EVENT_inline */ 2896+#endif 2897+ 2898+/* Define to `int' if <sys/types.h> does not define. */ 2899+/* #undef _EVENT_pid_t */ 2900+ 2901+/* Define to `unsigned int' if <sys/types.h> does not define. */ 2902+/* #undef _EVENT_size_t */ 2903+ 2904+/* Define to unsigned int if you dont have it */ 2905+/* #undef _EVENT_socklen_t */ 2906+#endif 2907diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h 2908index eb0428f64d..8f74bf35b1 100644 2909--- a/base/threading/platform_thread.h 2910+++ b/base/threading/platform_thread.h 2911@@ -231,7 +231,7 @@ class BASE_EXPORT PlatformThread { 2912 // Returns a realtime period provided by |delegate|. 2913 static TimeDelta GetRealtimePeriod(Delegate* delegate); 2914 2915-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 2916+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 2917 // Toggles a specific thread's priority at runtime. This can be used to 2918 // change the priority of a thread in a different process and will fail 2919 // if the calling process does not have proper permissions. The 2920diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc 2921index f704249f79..7afbd6adc9 100644 2922--- a/base/threading/platform_thread_posix.cc 2923+++ b/base/threading/platform_thread_posix.cc 2924@@ -192,7 +192,7 @@ PlatformThreadId PlatformThread::CurrentId() { 2925 "through fork()."; 2926 } 2927 return g_thread_id; 2928-#elif defined(OS_ANDROID) 2929+#elif defined(OS_ANDROID) || defined(OS_OHOS) 2930 return gettid(); 2931 #elif defined(OS_FUCHSIA) 2932 return zx_thread_self(); 2933diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc 2934index 38811b03f9..22109b6ee9 100644 2935--- a/base/trace_event/malloc_dump_provider.cc 2936+++ b/base/trace_event/malloc_dump_provider.cc 2937@@ -199,6 +199,9 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, 2938 } 2939 #elif defined(OS_FUCHSIA) 2940 // TODO(fuchsia): Port, see https://crbug.com/706592. 2941+#elif defined(__MUSL__) 2942+// TODO(OS_OHOS for musl): 2943+// same as https://crbug.com/706592, no mallinfo for musl 2944 #else 2945 struct mallinfo info = mallinfo(); 2946 // In case of Android's jemalloc |arena| is 0 and the outer pages size is 2947diff --git a/base/trace_event/tracing.gni b/base/trace_event/tracing.gni 2948index b452b02b5f..b62dbc570b 100644 2949--- a/base/trace_event/tracing.gni 2950+++ b/base/trace_event/tracing.gni 2951@@ -17,5 +17,5 @@ declare_args() { 2952 # Disabled by default on Android and ChromeOS due to binary size impact, 2953 # enabled everywhere else. 2954 optional_trace_events_enabled = 2955- (!is_android && !is_chromeos_ash) || extended_tracing_enabled 2956+ (!is_android && !is_chromeos_ash && !is_ohos) || extended_tracing_enabled 2957 } 2958diff --git a/build/build_config.h b/build/build_config.h 2959index 0f1cd5706c..87972c893c 100644 2960--- a/build/build_config.h 2961+++ b/build/build_config.h 2962@@ -50,6 +50,8 @@ 2963 #endif 2964 #elif defined(ANDROID) 2965 #define OS_ANDROID 1 2966+#elif defined(OSOHOS) 2967+#define OS_OHOS 1 2968 #elif defined(__APPLE__) 2969 // Only include TargetConditionals after testing ANDROID as some Android builds 2970 // on the Mac have this header available and it's not needed unless the target 2971@@ -112,7 +114,7 @@ 2972 defined(OS_FREEBSD) || defined(OS_IOS) || defined(OS_LINUX) || \ 2973 defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_NACL) || \ 2974 defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_QNX) || \ 2975- defined(OS_SOLARIS) 2976+ defined(OS_SOLARIS) || defined(OS_OHOS) 2977 #define OS_POSIX 1 2978 #endif 2979 2980@@ -220,7 +222,7 @@ 2981 #error Please add support for your compiler in build/build_config.h 2982 #endif 2983 2984-#if defined(OS_ANDROID) 2985+#if defined(OS_ANDROID) || defined(OS_OHOS) 2986 // The compiler thinks std::string::const_iterator and "const char*" are 2987 // equivalent types. 2988 #define STD_STRING_ITERATOR_IS_CHAR_POINTER 2989diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn 2990index aa530a249d..631caef2db 100644 2991--- a/build/config/BUILD.gn 2992+++ b/build/config/BUILD.gn 2993@@ -20,7 +20,7 @@ import("//build/config/pch.gni") 2994 import("//build/config/sanitizers/sanitizers.gni") 2995 import("//build/config/ui.gni") 2996 import("//build/toolchain/goma.gni") 2997-if (is_android) { 2998+if (is_android || is_ohos) { 2999 import("//build/config/android/abi.gni") 3000 } 3001 3002@@ -212,7 +212,7 @@ config("default_libs") { 3003 "ole32.lib", 3004 ] 3005 } 3006- } else if (is_android) { 3007+ } else if (is_android || is_ohos) { 3008 libs = [ 3009 "dl", 3010 "m", 3011@@ -313,7 +313,7 @@ config("executable_config") { 3012 "//build/config/ios:ios_dynamic_flags", 3013 "//build/config/ios:ios_executable_flags", 3014 ] 3015- } else if (is_linux || is_chromeos || is_android || current_os == "aix") { 3016+ } else if (is_linux || is_chromeos || is_android || current_os == "aix" || is_ohos) { 3017 configs += [ "//build/config/gcc:executable_config" ] 3018 if (is_chromecast) { 3019 configs += [ "//build/config/chromecast:executable_config" ] 3020diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn 3021index 0ef73ab2b2..f4f9d9bf46 100644 3022--- a/build/config/BUILDCONFIG.gn 3023+++ b/build/config/BUILDCONFIG.gn 3024@@ -148,6 +148,10 @@ declare_args() { 3025 # DON'T ADD MORE FLAGS HERE. Read the comment above. 3026 } 3027 3028+declare_args() { 3029+ use_musl = false 3030+} 3031+ 3032 declare_args() { 3033 # Debug build. Enabling official builds automatically sets is_debug to false. 3034 is_debug = !is_official_build 3035@@ -222,6 +226,8 @@ if (target_os == "android") { 3036 assert(host_os == "linux" || host_os == "mac", 3037 "Android builds are only supported on Linux and Mac hosts.") 3038 _default_toolchain = "//build/toolchain/android:android_clang_$target_cpu" 3039+} else if (target_os == "ohos") { 3040+ _default_toolchain = "//build/toolchain/ohos:ohos_clang_$target_cpu" 3041 } else if (target_os == "chromeos" || target_os == "linux") { 3042 # See comments in build/toolchain/cros/BUILD.gn about board compiles. 3043 if (is_clang) { 3044@@ -291,6 +297,7 @@ is_linux = current_os == "linux" 3045 is_mac = current_os == "mac" 3046 is_nacl = current_os == "nacl" 3047 is_win = current_os == "win" || current_os == "winuwp" 3048+is_ohos = current_os == "ohos" 3049 3050 is_apple = is_ios || is_mac 3051 is_posix = !is_win && !is_fuchsia 3052@@ -360,7 +367,7 @@ if (is_fuchsia) { 3053 default_compiler_configs += [ "//build/config/gcc:symbol_visibility_hidden" ] 3054 } 3055 3056-if (is_android) { 3057+if (is_android || is_ohos) { 3058 default_compiler_configs += 3059 [ "//build/config/android:default_orderfile_instrumentation" ] 3060 } 3061@@ -499,7 +506,7 @@ foreach(_target_type, 3062 # On Android, write shared library output file to metadata. We will use 3063 # this information to, for instance, collect all shared libraries that 3064 # should be packaged into an APK. 3065- if (!defined(invoker.metadata) && is_android && 3066+ if (!defined(invoker.metadata) && (is_android || is_ohos) && 3067 (_target_type == "shared_library" || 3068 _target_type == "loadable_module")) { 3069 _output_name = _target_name 3070diff --git a/build/config/android/BUILD.gn b/build/config/android/BUILD.gn 3071index 8cfe7a0c34..98991d82eb 100644 3072--- a/build/config/android/BUILD.gn 3073+++ b/build/config/android/BUILD.gn 3074@@ -11,7 +11,7 @@ if (current_toolchain == default_toolchain) { 3075 import("//build/toolchain/concurrent_links.gni") 3076 } 3077 3078-assert(is_android) 3079+assert(is_android || is_ohos) 3080 3081 # This is included by reference in the //build/config/compiler config that 3082 # is applied to all targets. It is here to separate out the logic that is 3083diff --git a/build/config/android/abi.gni b/build/config/android/abi.gni 3084index ed7c2ffc8b..680086bd86 100644 3085--- a/build/config/android/abi.gni 3086+++ b/build/config/android/abi.gni 3087@@ -8,7 +8,11 @@ 3088 # NOTE: Because Chrome OS builds may depend on targets built with the Android 3089 # toolchain, this GNI file may be read and processed from within Chrome OS 3090 # toolchains. Checking |is_android| here would therefore be too restrictive. 3091-assert(is_android || is_chromeos) 3092+assert(is_android || is_chromeos ||is_ohos) 3093+ 3094+if (is_ohos) { 3095+ import("//build/config/ohos/abi.gni") 3096+} 3097 3098 declare_args() { 3099 # Adds intrumentation to each function. Writes a file with the order that 3100diff --git a/build/config/android/config.gni b/build/config/android/config.gni 3101index 652ea7429a..2c8561c79f 100644 3102--- a/build/config/android/config.gni 3103+++ b/build/config/android/config.gni 3104@@ -7,7 +7,7 @@ 3105 # NOTE: Because Chrome OS builds may depend on targets built with the Android 3106 # toolchain, this GNI file may be read and processed from within Chrome OS 3107 # toolchains. Checking |is_android| here would therefore be too restrictive. 3108-if (is_android || is_chromeos) { 3109+if (is_android || is_chromeos || is_ohos) { 3110 import("//build/config/chromecast_build.gni") 3111 import("//build/config/dcheck_always_on.gni") 3112 import("//build_overrides/build.gni") 3113diff --git a/build/config/arm.gni b/build/config/arm.gni 3114index ddd1c5df82..04b3341d8b 100644 3115--- a/build/config/arm.gni 3116+++ b/build/config/arm.gni 3117@@ -38,7 +38,7 @@ if (current_cpu == "arm" || v8_current_cpu == "arm") { 3118 arm_use_thumb = true 3119 } 3120 3121- if (current_os == "android" || target_os == "android") { 3122+ if (current_os == "android" || target_os == "android" || target_os == "ohos") { 3123 arm_float_abi = "softfp" 3124 } else { 3125 declare_args() { 3126diff --git a/build/config/c++/c++.gni b/build/config/c++/c++.gni 3127index a7448f3a0a..53f8d3f19c 100644 3128--- a/build/config/c++/c++.gni 3129+++ b/build/config/c++/c++.gni 3130@@ -46,6 +46,11 @@ use_custom_libcxx = 3131 use_custom_libcxx || (use_custom_libcxx_for_host && !is_a_target_toolchain) 3132 use_custom_libcxx = use_custom_libcxx && !is_nacl 3133 3134+if (is_ohos) { 3135+ use_custom_libcxx = false 3136+ use_custom_libcxx_for_host = false 3137+} 3138+ 3139 declare_args() { 3140 # WARNING: Setting this to a non-default value is highly discouraged. 3141 # If true, libc++ will be built as a shared library; otherwise libc++ will be 3142diff --git a/build/config/clang/BUILD.gn b/build/config/clang/BUILD.gn 3143index 180e2e626b..8d0904545d 100644 3144--- a/build/config/clang/BUILD.gn 3145+++ b/build/config/clang/BUILD.gn 3146@@ -21,7 +21,7 @@ config("find_bad_constructs") { 3147 "checked-ptr-as-trivial-member", 3148 ] 3149 3150- if (is_linux || is_chromeos || is_android || is_fuchsia) { 3151+ if (is_linux || is_chromeos || is_android || is_fuchsia || is_ohos) { 3152 cflags += [ 3153 "-Xclang", 3154 "-plugin-arg-find-bad-constructs", 3155diff --git a/build/config/clang/clang.gni b/build/config/clang/clang.gni 3156index 588864586d..153c5930a1 100644 3157--- a/build/config/clang/clang.gni 3158+++ b/build/config/clang/clang.gni 3159@@ -4,7 +4,15 @@ 3160 3161 import("//build/toolchain/toolchain.gni") 3162 3163-default_clang_base_path = "//third_party/llvm-build/Release+Asserts" 3164+if (is_ohos) { 3165+ import("//build/config/ohos/config.gni") 3166+} 3167+ 3168+if (!is_ohos) { 3169+ default_clang_base_path = "//third_party/llvm-build/Release+Asserts" 3170+} else { 3171+ default_clang_base_path = ohos_toolchain_root 3172+} 3173 3174 declare_args() { 3175 # Indicates if the build should use the Chrome-specific plugins for enforcing 3176diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn 3177index 3a54227ed4..af07fe8066 100644 3178--- a/build/config/compiler/BUILD.gn 3179+++ b/build/config/compiler/BUILD.gn 3180@@ -94,7 +94,7 @@ declare_args() { 3181 # nonsensical for said projects. 3182 clang_use_default_sample_profile = 3183 chrome_pgo_phase == 0 && build_with_chromium && is_official_build && 3184- (is_android || chromeos_is_browser_only || is_chromecast) 3185+ (is_android || chromeos_is_browser_only || is_chromecast || is_ohos) 3186 3187 # This configuration is used to select a default profile in Chrome OS based on 3188 # the microarchitectures we are using. This is only used if 3189@@ -120,7 +120,7 @@ declare_args() { 3190 # the space overhead is too great. We should use some mixture of profiles and 3191 # optimization settings to better tune the size increase. 3192 thin_lto_enable_optimizations = 3193- (is_chromeos_ash || is_android || is_win || is_linux) && is_official_build 3194+ (is_chromeos_ash || is_android || is_win || is_linux || is_ohos) && is_official_build 3195 3196 # Initialize all local variables with a pattern. This flag will fill 3197 # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the 3198@@ -133,7 +133,7 @@ declare_args() { 3199 # 3200 # TODO(crbug.com/977230): Enabling this when 'use_xcode_clang' is true may 3201 # call an old clang that doesn't support auto-init. 3202- init_stack_vars = !is_android && !use_xcode_clang 3203+ init_stack_vars = !is_android && !use_xcode_clang && !is_ohos 3204 3205 # This argument is to control whether enabling text section splitting in the 3206 # final binary. When enabled, the separated text sections with prefix 3207@@ -151,8 +151,8 @@ declare_args() { 3208 ((is_mac && target_cpu == "x64" && !use_system_xcode) || 3209 ((is_linux || is_chromeos_lacros) && target_cpu == "x64") || 3210 (is_win && target_cpu == "x86") || (is_win && target_cpu == "x64") || 3211- (is_android && target_cpu == "arm") || 3212- (is_android && target_cpu == "arm64")) 3213+ ((is_android || is_ohos) && target_cpu == "arm") || 3214+ ((is_android || is_ohos) && target_cpu == "arm64")) 3215 3216 # Turn off the --call-graph-profile-sort flag for lld by default. Enable 3217 # selectively for targets where it's beneficial. 3218@@ -187,12 +187,12 @@ declare_args() { 3219 # lld doesn't have the bug. 3220 use_icf = 3221 (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && 3222- !use_clang_coverage && !(is_android && use_order_profiling) && 3223+ !use_clang_coverage && !((is_android || is_ohos) && use_order_profiling) && 3224 (use_lld || (use_gold && (is_chromeos_ash || !(current_cpu == "x86" || 3225 current_cpu == "x64")))) 3226 } 3227 3228-if (is_android || (is_chromeos_ash && is_chromeos_device)) { 3229+if (is_android || is_ohos || (is_chromeos_ash && is_chromeos_device)) { 3230 # Set the path to use orderfile for linking Chrome 3231 # Note that this is for using only one orderfile for linking 3232 # the Chrome binary/library. 3233@@ -251,6 +251,8 @@ config("compiler") { 3234 configs += [ "//build/config/win:compiler" ] 3235 } else if (is_android) { 3236 configs += [ "//build/config/android:compiler" ] 3237+ } else if (is_ohos) { 3238+ configs += [ "//build/config/ohos:compiler" ] 3239 } else if (is_linux || is_chromeos) { 3240 configs += [ "//build/config/linux:compiler" ] 3241 if (is_chromeos_ash) { 3242@@ -317,7 +319,7 @@ config("compiler") { 3243 cflags += [ "--param=ssp-buffer-size=4" ] 3244 3245 # The x86 toolchain currently has problems with stack-protector. 3246- if (is_android && current_cpu == "x86") { 3247+ if ((is_android || is_ohos) && current_cpu == "x86") { 3248 cflags += [ "-fno-stack-protector" ] 3249 } else if (current_os != "aix") { 3250 # Not available on aix. 3251@@ -377,7 +379,7 @@ config("compiler") { 3252 ldflags += [ "-Wl,--build-id" ] 3253 } 3254 3255- if (!is_android) { 3256+ if (!is_android && !is_ohos) { 3257 defines += [ 3258 # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain 3259 # the behavior of the Android NDK from earlier versions. 3260@@ -403,7 +405,7 @@ config("compiler") { 3261 3262 # Linux/Android/Fuchsia common flags setup. 3263 # --------------------------------- 3264- if (is_linux || is_chromeos || is_android || is_fuchsia) { 3265+ if (is_linux || is_chromeos || is_android || is_fuchsia || is_ohos) { 3266 asmflags += [ "-fPIC" ] 3267 cflags += [ "-fPIC" ] 3268 ldflags += [ "-fPIC" ] 3269@@ -444,7 +446,7 @@ config("compiler") { 3270 } 3271 } else if (use_gold) { 3272 ldflags += [ "-fuse-ld=gold" ] 3273- if (!is_android) { 3274+ if (!is_android && !is_ohos) { 3275 # On Android, this isn't needed. gcc in the NDK knows to look next to 3276 # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed 3277 # above. 3278@@ -528,9 +530,9 @@ config("compiler") { 3279 3280 # C11/C++11 compiler flags setup. 3281 # --------------------------- 3282- if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) || 3283+ if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) || is_ohos || 3284 current_os == "aix") { 3285- if (target_os == "android") { 3286+ if (target_os == "android" || target_os == "ohos") { 3287 cxx11_override = use_cxx11_on_android 3288 } else { 3289 cxx11_override = use_cxx11 3290@@ -563,10 +565,10 @@ config("compiler") { 3291 # Override Chromium's default for projects that wish to stay on C++11. 3292 cflags_cc += [ "-std=${standard_prefix}++11" ] 3293 } else { 3294- cflags_cc += [ "-std=${standard_prefix}++14" ] 3295+ cflags_cc += [ "-std=${standard_prefix}++17" ] 3296 } 3297 } else if (!is_win && !is_nacl) { 3298- if (target_os == "android") { 3299+ if (target_os == "android" || target_os == "ohos") { 3300 cxx11_override = use_cxx11_on_android 3301 } else { 3302 cxx11_override = use_cxx11 3303@@ -580,7 +582,7 @@ config("compiler") { 3304 if (cxx11_override) { 3305 cflags_cc += [ "-std=c++11" ] 3306 } else { 3307- cflags_cc += [ "-std=c++14" ] 3308+ cflags_cc += [ "-std=c++17" ] 3309 } 3310 } 3311 3312@@ -677,7 +679,7 @@ config("compiler") { 3313 # Whole-program devirtualization increases android libchrome.so size 3314 # by ~100kb on arm32 and reduces it by ~108kb on arm64 instead. 3315 # Tracked by llvm bug: https://bugs.llvm.org/show_bug.cgi?id=48245 3316- if (!is_android || current_cpu == "arm64") { 3317+ if ((!is_android && !is_ohos) || current_cpu == "arm64") { 3318 cflags += [ "-fwhole-program-vtables" ] 3319 if (!is_win) { 3320 ldflags += [ "-fwhole-program-vtables" ] 3321@@ -708,7 +710,7 @@ config("compiler") { 3322 3323 # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize 3324 # stack crashes (http://crbug.com/919499). 3325- if (use_lld && is_android) { 3326+ if (use_lld && (is_android || is_ohos)) { 3327 ldflags += [ "-Wl,--no-rosegment" ] 3328 } 3329 3330@@ -817,7 +819,7 @@ config("compiler_cpu_abi") { 3331 ] 3332 } 3333 } else if (current_cpu == "arm") { 3334- if (is_clang && !is_android && !is_nacl) { 3335+ if (is_clang && !is_android && !is_nacl && !is_ohos) { 3336 cflags += [ "--target=arm-linux-gnueabihf" ] 3337 ldflags += [ "--target=arm-linux-gnueabihf" ] 3338 } 3339@@ -831,7 +833,7 @@ config("compiler_cpu_abi") { 3340 cflags += [ "-mtune=$arm_tune" ] 3341 } 3342 } else if (current_cpu == "arm64") { 3343- if (is_clang && !is_android && !is_nacl && !is_fuchsia) { 3344+ if (is_clang && !is_android && !is_nacl && !is_fuchsia && !is_ohos) { 3345 cflags += [ "--target=aarch64-linux-gnu" ] 3346 ldflags += [ "--target=aarch64-linux-gnu" ] 3347 } 3348@@ -1123,7 +1125,7 @@ config("compiler_codegen") { 3349 configs += [ "//build/config/nacl:compiler_codegen" ] 3350 } 3351 3352- if (current_cpu == "arm64" && is_android) { 3353+ if (current_cpu == "arm64" && (is_android || is_ohos)) { 3354 # On arm64 disable outlining for Android. See crbug.com/931297 for more 3355 # information. 3356 cflags += [ "-mno-outline" ] 3357@@ -1294,6 +1296,8 @@ config("runtime_library") { 3358 configs += [ "//build/config/mac:runtime_library" ] 3359 } else if (is_android) { 3360 configs += [ "//build/config/android:runtime_library" ] 3361+ } else if (is_ohos) { 3362+ configs += [ "//build/config/ohos:runtime_library" ] 3363 } 3364 3365 if (is_component_build) { 3366@@ -1491,6 +1495,45 @@ config("default_warnings") { 3367 cflags += [ "-Wno-psabi" ] 3368 } 3369 3370+ if (use_musl) { 3371+ cflags += [ 3372+ "-Wno-psabi", 3373+ "-Wno-unknown-pragmas", 3374+ "-Wno-thread-safety-attributes", 3375+ "-Wno-cpp", 3376+ "-Wno-extra-tokens", 3377+ "-Wno-error=c99-designator", 3378+ "-Wno-error=anon-enum-enum-conversion", 3379+ "-Wno-error=implicit-fallthrough", 3380+ "-Wno-error=sizeof-array-div", 3381+ "-Wno-error=reorder-init-list", 3382+ "-Wno-error=range-loop-construct", 3383+ "-Wno-error=deprecated-copy", 3384+ "-Wno-error=implicit-int-float-conversion", 3385+ "-Wno-error=inconsistent-dllimport", 3386+ "-Wno-error=unknown-warning-option", 3387+ "-Wno-error=abstract-final-class", 3388+ "-Wno-error=sign-compare", 3389+ "-Wno-error=int-in-bool-context", 3390+ "-Wno-error=xor-used-as-pow", 3391+ "-Wno-error=return-stack-address", 3392+ "-Wno-error=dangling-gsl", 3393+ "-Wno-error=macro-redefined", 3394+ "-Wno-error=implicit-function-declaration", 3395+ "-Wno-error=misleading-indentation", 3396+ ] 3397+ } else { 3398+ cflags += [ 3399+ "-Wno-psabi", 3400+ "-Wno-error=sign-compare", 3401+ "-Wno-error=unknown-warning-option", 3402+ "-Wno-error=unused-variable", 3403+ "-Wno-unknown-attributes", 3404+ "-Wno-thread-safety-attributes", 3405+ "-Wno-unknown-pragmas", 3406+ ] 3407+ } 3408+ 3409 if (!is_clang) { 3410 cflags_cc += [ 3411 # See comment for -Wno-c++11-narrowing. 3412@@ -1593,16 +1636,34 @@ config("default_warnings") { 3413 "-Wno-non-c-typedef-for-linkage", 3414 ] 3415 3416+ if (use_musl) { 3417+ cflags -= [ 3418+ "-Wno-psabi", 3419+ "-Wno-non-c-typedef-for-linkage", 3420+ ] 3421+ } else { 3422+ cflags -= [ 3423+ "-Wno-psabi", 3424+ "-Wno-implicit-int-float-conversion", 3425+ "-Wno-final-dtor-non-final-class", 3426+ "-Wno-builtin-assume-aligned-alignment", 3427+ "-Wno-deprecated-copy", 3428+ "-Wno-non-c-typedef-for-linkage", 3429+ ] 3430+ } 3431+ 3432 cflags_c += [ 3433 # TODO(https://crbug.com/995993): Clean up and enable. 3434 "-Wno-implicit-fallthrough", 3435 ] 3436 3437- if (enable_wmax_tokens) { 3438- cflags += [ "-Wmax-tokens" ] 3439- } else { 3440- # TODO(https://crbug.com/1049569): Remove after Clang 87b235db. 3441- cflags += [ "-Wno-max-tokens" ] 3442+ if (!is_ohos) { 3443+ if (enable_wmax_tokens) { 3444+ cflags += [ "-Wmax-tokens" ] 3445+ } else { 3446+ # TODO(https://crbug.com/1049569): Remove after Clang 87b235db. 3447+ cflags += [ "-Wno-max-tokens" ] 3448+ } 3449 } 3450 } 3451 } 3452@@ -1690,7 +1751,7 @@ config("chromium_code") { 3453 # Temporarily disable -Wextra-semi for Chrome on Chrome OS. 3454 } else if (is_chromecast && chromecast_branding != "public") { 3455 # Temporarily disable -Wextra-semi for Chromecast. 3456- } else { 3457+ } else if (!is_ohos) { 3458 cflags += [ "-Wextra-semi" ] 3459 } 3460 } 3461@@ -1734,7 +1795,7 @@ config("no_chromium_code") { 3462 # suppressing them individually, we just blanket suppress them here. 3463 "-Wno-unused-variable", 3464 ] 3465- if (!is_nacl && (current_toolchain == host_toolchain || !use_xcode_clang)) { 3466+ if (!is_nacl && (current_toolchain == host_toolchain || !use_xcode_clang) && !is_ohos) { 3467 cflags += [ 3468 # TODO(https://crbug.com/1031169): Clean up and enable. 3469 "-Wno-misleading-indentation", 3470@@ -1858,7 +1919,7 @@ config("no_exceptions") { 3471 # See: //docs/static_initializers.md 3472 # See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion 3473 config("wglobal_constructors") { 3474- if (is_clang) { 3475+ if (is_clang && !is_ohos) { 3476 cflags = [ "-Wglobal-constructors" ] 3477 } 3478 } 3479@@ -1867,7 +1928,7 @@ config("wglobal_constructors") { 3480 # destructors, which will slow down closing the program. 3481 # TODO(thakis): Make this a blocklist instead, http://crbug.com/101600 3482 config("wexit_time_destructors") { 3483- if (is_clang) { 3484+ if (is_clang && !is_ohos) { 3485 cflags = [ "-Wexit-time-destructors" ] 3486 } 3487 } 3488@@ -1978,7 +2039,7 @@ if (is_win) { 3489 common_optimize_on_cflags = [] 3490 common_optimize_on_ldflags = [] 3491 3492- if (is_android) { 3493+ if (is_android || is_ohos) { 3494 # TODO(jdduke) Re-enable on mips after resolving linking 3495 # issues with libc++ (crbug.com/456380). 3496 if (current_cpu != "mipsel" && current_cpu != "mips64el") { 3497@@ -2094,7 +2155,7 @@ config("no_optimize") { 3498 # traces on Windows ARM64 rely on it. 3499 cflags += [ "/Oy-" ] 3500 } 3501- } else if (is_android && !android_full_debug) { 3502+ } else if ((is_android || is_ohos) && !android_full_debug) { 3503 # On Android we kind of optimize some things that don't affect debugging 3504 # much even when optimization is disabled to get the binary size down. 3505 if (is_clang) { 3506@@ -2214,9 +2275,9 @@ if (is_clang && is_a_target_toolchain) { 3507 } else if (clang_use_default_sample_profile) { 3508 assert(build_with_chromium, 3509 "Our default profiles currently only apply to Chromium") 3510- assert(is_android || is_chromeos_lacros || is_chromeos_ash || is_chromecast, 3511+ assert(is_android || is_chromeos_lacros || is_chromeos_ash || is_chromecast || is_ohos, 3512 "The current platform has no default profile") 3513- if (is_android || is_chromecast) { 3514+ if (is_android || is_chromecast || is_ohos) { 3515 _clang_sample_profile = "//chrome/android/profiles/afdo.prof" 3516 } else { 3517 assert(chromeos_afdo_platform == "atom" || 3518@@ -2438,7 +2499,7 @@ config("minimal_symbols") { 3519 cflags += [ "-g1" ] 3520 } 3521 ldflags = [] 3522- if (is_android && is_clang) { 3523+ if ((is_android || is_ohos) && is_clang) { 3524 # Android defaults to symbol_level=1 builds in production builds 3525 # (https://crbug.com/648948), but clang, unlike gcc, doesn't emit 3526 # DW_AT_linkage_name in -g1 builds. -fdebug-info-for-profiling enables 3527@@ -2484,7 +2545,7 @@ config("default_symbols") { 3528 } 3529 3530 # This config is removed by base unittests apk. 3531- if (is_android && is_clang && strip_debug_info) { 3532+ if ((is_android || is_ohos) && is_clang && strip_debug_info) { 3533 configs += [ ":strip_debug" ] 3534 } 3535 } 3536@@ -2518,7 +2579,7 @@ if (is_chromeos_ash && is_chromeos_device) { 3537 } 3538 } 3539 3540-if (is_android || (is_chromeos_ash && is_chromeos_device)) { 3541+if (is_android || is_ohos || (is_chromeos_ash && is_chromeos_device)) { 3542 # Use orderfile for linking Chrome on Android and Chrome OS. 3543 # This config enables using an orderfile for linking in LLD. 3544 # TODO: Consider using call graph sort instead, at least on Android. 3545diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni 3546index 96a18d91a3..77ec200817 100644 3547--- a/build/config/compiler/compiler.gni 3548+++ b/build/config/compiler/compiler.gni 3549@@ -13,7 +13,7 @@ import("//build/toolchain/goma.gni") 3550 import("//build/toolchain/toolchain.gni") 3551 import("//build_overrides/build.gni") 3552 3553-if (is_android) { 3554+if (is_android || is_ohos) { 3555 import("//build/config/android/abi.gni") 3556 } 3557 if (current_cpu == "arm" || current_cpu == "arm64") { 3558@@ -115,7 +115,7 @@ assert(!is_cfi || use_thin_lto, "CFI requires ThinLTO") 3559 # Linux & Mac favor speed over size. 3560 # TODO(brettw) it's weird that Mac and desktop Linux are different. We should 3561 # explore favoring size over speed in this case as well. 3562-optimize_for_size = is_android || is_chromecast || is_fuchsia || is_ios 3563+optimize_for_size = is_android || is_chromecast || is_fuchsia || is_ios || is_ohos 3564 3565 declare_args() { 3566 # Whether we should consider the profile we're using to be accurate. Accurate 3567@@ -144,7 +144,7 @@ if (is_chromeos_ash) { 3568 } else { 3569 enable_frame_pointers = true 3570 } 3571-} else if (is_android) { 3572+} else if (is_android || is_ohos) { 3573 enable_frame_pointers = 3574 enable_profiling || 3575 # Ensure that stacks from arm64 crash dumps are usable (crbug.com/391706). 3576@@ -190,7 +190,7 @@ can_unwind_with_cfi_table = is_android && !is_component_build && 3577 # Whether or not cfi table should be enabled on arm. 3578 # TODO(crbug.com/1090409): Replace can_unwind_with_cfi_table with this once 3579 # sampling profiler is enabled on android. 3580-enable_arm_cfi_table = is_android && !is_component_build && current_cpu == "arm" 3581+enable_arm_cfi_table = (is_android || is_ohos) && !is_component_build && current_cpu == "arm" 3582 3583 declare_args() { 3584 # Set to true to use lld, the LLVM linker. 3585@@ -208,7 +208,7 @@ declare_args() { 3586 (current_cpu == "x64" || current_cpu == "x86" || 3587 current_cpu == "arm" || current_cpu == "arm64" || 3588 current_cpu == "mipsel" || current_cpu == "mips64el")) || 3589- (is_android && (current_cpu == "x86" || current_cpu == "x64" || 3590+ ((is_android || is_ohos) && (current_cpu == "x86" || current_cpu == "x64" || 3591 current_cpu == "arm" || current_cpu == "arm64"))) 3592 } 3593 3594@@ -225,7 +225,7 @@ strip_absolute_paths_from_debug_symbols_default = 3595 # TODO(crbug.com/1010267): remove '!use_clang_coverage', coverage build has 3596 # dependency to absolute path of source files. 3597 !use_clang_coverage && 3598- (is_android || is_fuchsia || is_nacl || (is_win && use_lld) || is_linux || 3599+ (is_android || is_fuchsia || is_nacl || (is_win && use_lld) || is_linux || is_ohos || 3600 is_chromeos || (is_apple && !enable_dsyms)) 3601 3602 # If the platform uses stripped absolute paths by default, then we don't expose 3603@@ -243,14 +243,14 @@ assert( 3604 use_debug_fission == "default" || use_debug_fission || !use_debug_fission, 3605 "Invalid use_debug_fission.") 3606 if (use_debug_fission == "default") { 3607- use_debug_fission = is_debug && !is_android && !is_fuchsia && !is_apple && 3608+ use_debug_fission = is_debug && !is_android && !is_fuchsia && !is_apple && !is_ohos && 3609 !is_win && (use_gold || use_lld) && cc_wrapper == "" 3610 } 3611 3612 # If it wasn't manually set, set to an appropriate default. 3613 assert(symbol_level >= -1 && symbol_level <= 2, "Invalid symbol_level") 3614 if (symbol_level == -1) { 3615- if (is_android && !is_component_build && !use_debug_fission) { 3616+ if ((is_android || is_ohos) && !is_component_build && !use_debug_fission) { 3617 # Reduce symbol level when it will cause invalid elf files to be created 3618 # (due to file size). https://crbug.com/648948. 3619 symbol_level = 1 3620diff --git a/build/config/gcc/BUILD.gn b/build/config/gcc/BUILD.gn 3621index 154b259b5f..184c4e1f3b 100644 3622--- a/build/config/gcc/BUILD.gn 3623+++ b/build/config/gcc/BUILD.gn 3624@@ -63,7 +63,7 @@ config("symbol_visibility_default") { 3625 # configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] 3626 # } 3627 config("rpath_for_built_shared_libraries") { 3628- if (!is_android) { 3629+ if (!is_android && !is_ohos) { 3630 # Note: Android doesn't support rpath. 3631 if (current_toolchain != default_toolchain || gcc_target_rpath == "") { 3632 ldflags = [ 3633@@ -79,7 +79,7 @@ config("rpath_for_built_shared_libraries") { 3634 } 3635 } 3636 3637-if (is_component_build && !is_android) { 3638+if (is_component_build && !(is_android || is_ohos)) { 3639 # See the rpath_for... config above for why this is necessary for component 3640 # builds. 3641 executable_and_shared_library_configs_ = 3642@@ -92,14 +92,14 @@ if (is_component_build && !is_android) { 3643 config("executable_config") { 3644 configs = executable_and_shared_library_configs_ 3645 ldflags = [ "-pie" ] 3646- if (is_android) { 3647+ if (is_android || is_ohos) { 3648 ldflags += [ 3649 "-Bdynamic", 3650 "-Wl,-z,nocopyreloc", 3651 ] 3652 } 3653 3654- if (!is_android && current_os != "aix") { 3655+ if (!is_android && current_os != "aix" && !is_ohos) { 3656 ldflags += [ 3657 # TODO(GYP): Do we need a check on the binutils version here? 3658 # 3659diff --git a/build/config/ohos/BUILD.gn b/build/config/ohos/BUILD.gn 3660new file mode 100644 3661index 0000000000..3e9b09269d 3662--- /dev/null 3663+++ b/build/config/ohos/BUILD.gn 3664@@ -0,0 +1,201 @@ 3665+# Copyright 2022 The Chromium Authors. All rights reserved. 3666+# Use of this source code is governed by a BSD-style license that can be 3667+# found in the LICENSE file. 3668+ 3669+import("//build/config/c++/c++.gni") 3670+import("//build/config/compiler/compiler.gni") 3671+import("//build/config/ohos/config.gni") 3672+import("//build/config/sanitizers/sanitizers.gni") 3673+ 3674+assert(is_ohos) 3675+ 3676+# This is included by reference in the //build/config/compiler config that 3677+# is applied to all targets. It is here to separate out the logic that is 3678+# ohos-only. 3679+config("compiler") { 3680+ cflags = [ 3681+ "-ffunction-sections", 3682+ "-fno-short-enums", 3683+ ] 3684+ defines = [ 3685+ "OSOHOS", 3686+ 3687+ # The NDK has these things, but doesn't define the constants to say that it 3688+ # does. Define them here instead. 3689+ "HAVE_SYS_UIO_H", 3690+ ] 3691+ 3692+ if (use_musl) { 3693+ defines += [ 3694+ "__MUSL__", 3695+ "_LIBCPP_HAS_MUSL_LIBC", 3696+ "__BUILD_LINUX_WITH_CLANG", 3697+ ] 3698+ } else { 3699+ defines += [ 3700+ "__BUILD_LINUX_WITH_CLANG", 3701+ ] 3702+ } 3703+ 3704+ ldflags = [ 3705+ "-Wl,--exclude-libs=libgcc.a", 3706+ "-Wl,--no-undefined", 3707+ "-Wl,--exclude-libs=libunwind_llvm.a", 3708+ "-Wl,--exclude-libs=libc++_static.a", 3709+ 3710+ # Don't allow visible symbols from libraries that contain 3711+ # assembly code with symbols that aren't hidden properly. 3712+ # http://crbug.com/448386 3713+ "-Wl,--exclude-libs=libvpx_assembly_arm.a", 3714+ ] 3715+ 3716+ # TODO(crbug.com/1184398): Move to compiler-rt when we are ready. 3717+ if (use_musl) { 3718+ if (current_cpu == "arm") { 3719+ } else { 3720+ ldflags += [ "--rtlib=libgcc" ] 3721+ } 3722+ } 3723+ 3724+ if (current_cpu == "arm64") { 3725+ # For outline atomics on AArch64 (can't pass this unconditionally 3726+ # due to unused flag warning on other targets). 3727+ cflags += [ "--rtlib=libgcc" ] 3728+ } 3729+ 3730+ # $compile_api_level corresponds to the API level used for the sysroot path 3731+ # calculation in //build/config/ohos/config.gni 3732+ if (current_cpu == "arm") { 3733+ abi_target = "arm-linux-androideabi" 3734+ if (use_musl) { 3735+ abi_target = "arm-linux-ohosmusl" 3736+ } else { 3737+ compile_api_level = arm32_ndk_api_level 3738+ } 3739+ } else if (current_cpu == "x86") { 3740+ abi_target = "" 3741+ compile_api_level = "" 3742+ } else if (current_cpu == "arm64") { 3743+ if (!use_musl) { 3744+ abi_target = "aarch64-linux-android" 3745+ compile_api_level = arm64_ndk_api_level 3746+ } 3747+ } else if (current_cpu == "x64") { 3748+ abi_target = "" 3749+ compile_api_level = "" 3750+ } else { 3751+ assert(false, "Architecture not supported") 3752+ } 3753+ 3754+ if (use_musl) { 3755+ cflags += [ "--target=$abi_target" ] 3756+ include_dirs = [ 3757+ "$ohos_toolchain_root/include/c++/v1", 3758+ ] 3759+ ldflags += [ "--target=$abi_target" ] 3760+ } else { 3761+ cflags += [ 3762+ "--target=$abi_target", 3763+ "-D__ANDROID_API__=$compile_api_level", 3764+ ] 3765+ ldflags += [ "--target=$abi_target" ] 3766+ include_dirs = [ 3767+ "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/sysroot/usr/include", 3768+ "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/sysroot/usr/include/$abi_target", 3769+ ] 3770+ } 3771+ 3772+ # Assign any flags set for the C compiler to asmflags so that they are sent 3773+ # to the assembler. 3774+ asmflags = cflags 3775+} 3776+ 3777+# This is included by reference in the //build/config/compiler:runtime_library 3778+# config that is applied to all targets. It is here to separate out the logic 3779+# that is Android-only. Please see that target for advice on what should go in 3780+# :runtime_library vs. :compiler. 3781+config("runtime_library") { 3782+ libs = [] 3783+ ldflags = [] 3784+ 3785+ if (use_musl) { 3786+ defines = [ 3787+ "__MUSL__", 3788+ "_LIBCPP_HAS_MUSL_LIBC", 3789+ "__BUILD_LINUX_WITH_CLANG", 3790+ ] 3791+ } else { 3792+ defines = [ 3793+ "__BUILD_LINUX_WITH_CLANG", 3794+ ] 3795+ } 3796+ if (use_musl) { 3797+ ldflags += [ 3798+ "-L" + rebase_path("$ohos_sysroot/usr/lib/arm-linux-ohosmusl", root_build_dir), 3799+ "-L" + rebase_path("$ohos_toolchain_root/lib/arm-linux-ohosmusl/c++", root_build_dir), 3800+ "-L" + rebase_path("$ohos_toolchain_root/lib/clang/10.0.1/lib/arm-linux-ohosmusl", root_build_dir), 3801+ ] 3802+ ldflags += [ "-Wl,--dynamic-linker,/system/bin/ld-musl-arm.so.1" ] 3803+ libclang_rt_file = "$ohos_toolchain_root/lib/clang/10.0.1/lib/arm-linux-ohosmusl/libclang_rt.builtins.a" 3804+ 3805+ libs += [ 3806+ rebase_path(libclang_rt_file), 3807+ "c", 3808+ "c++", 3809+ "c++abi" 3810+ ] 3811+ } else { 3812+ cflags = [ 3813+ "-isystem" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/libcxx/include", root_build_dir), 3814+ "-isystem" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/libcxxabi/include", root_build_dir), 3815+ "-isystem" + rebase_path("$ohos_toolchain_root/lib64/clang/9.0.3/include", root_build_dir), 3816+ "-isystem" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/sysroot/usr/include", root_build_dir), 3817+ "-isystem" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/sysroot/usr/include/arm-linux-androideabi", root_build_dir), 3818+ ] 3819+ 3820+ cflags_cc = [ 3821+ "-isystem" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/libcxx/include", root_build_dir), 3822+ "-isystem" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/libcxxabi/include", root_build_dir), 3823+ ] 3824+ 3825+ if (current_cpu == "arm") { 3826+ ldflags += [ "-L" + rebase_path("$ohos_ndk_root/gcc/linux-x86/arm/gcc-linaro-7.5.0-arm-linux-gnueabi/arm-linux-gnueabi/lib", root_build_dir) ] 3827+ ldflags += [ "-L" + rebase_path("$ohos_ndk_root/gcc/linux-x86/arm/gcc-linaro-7.5.0-arm-linux-gnueabi/lib/gcc/arm-linux-gnueabi/7.5.0", root_build_dir) ] 3828+ ldflags += [ "-l:libgcc.a" ] 3829+ ldflags += [ "-L" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/libcxx/arm", root_build_dir) ] 3830+ ldflags += [ "-l:libc++_static.a" ] 3831+ ldflags += [ "-L" + rebase_path("$ohos_toolchain_root/lib64/clang/9.0.3/lib/linux", root_build_dir) ] 3832+ ldflags += [ "-l:libclang_rt.builtins-arm-android.a" ] 3833+ ldflags += [ "-L" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/sdk/shared_library/arm", root_build_dir) ] 3834+ ldflags += [ "-l:liblog.so" ] 3835+ ldflags += [ "-L" + rebase_path("$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/platforms/current/arch-arm/usr/lib", root_build_dir) ] 3836+ } 3837+ 3838+ libs += [ "unwind_llvm" ] 3839+ } 3840+ 3841+ # arm builds of libc++ starting in NDK r12 depend on unwind. 3842+ if (current_cpu == "arm") { 3843+ libs += [ "unwind" ] 3844+ } 3845+ 3846+ # TODO(jdduke) Re-enable on mips after resolving linking 3847+ # issues with libc++ (crbug.com/456380). 3848+ if (current_cpu != "mipsel" && current_cpu != "mips64el") { 3849+ ldflags += [ "-Wl,--warn-shared-textrel" ] 3850+ } 3851+} 3852+ 3853+config("lld_pack_relocations") { 3854+ ldflags = [ "-Wl,--pack-dyn-relocs=android" ] 3855+} 3856+ 3857+# Used for instrumented build to generate the orderfile. 3858+config("default_orderfile_instrumentation") { 3859+ if (use_order_profiling) { 3860+ cflags = [ "-finstrument-function-entry-bare" ] 3861+ if (use_thin_lto) { 3862+ ldflags = [ "-Wl,-u,__cyg_profile_func_enter_bare" ] 3863+ } 3864+ } 3865+} 3866diff --git a/build/config/ohos/abi.gni b/build/config/ohos/abi.gni 3867new file mode 100644 3868index 0000000000..71cfb23ccc 3869--- /dev/null 3870+++ b/build/config/ohos/abi.gni 3871@@ -0,0 +1,48 @@ 3872+# Copyright 2022 The Chromium Authors. All rights reserved. 3873+# Use of this source code is governed by a BSD-style license that can be 3874+# found in the LICENSE file. 3875+ 3876+# Logic separated out from config.gni so that it can be used by compiler.gni 3877+# without introducing a circular dependency. 3878+ 3879+assert(is_ohos) 3880+ 3881+if (current_cpu == "x86") { 3882+ ohos_app_abi = "x86" 3883+} else if (current_cpu == "arm") { 3884+ import("//build/config/arm.gni") 3885+ if (arm_version < 7) { 3886+ ohos_app_abi = "armeabi" 3887+ } else { 3888+ ohos_app_abi = "armeabi-v7a" 3889+ } 3890+} else if (current_cpu == "x64") { 3891+ ohos_app_abi = "x86_64" 3892+} else if (current_cpu == "arm64") { 3893+ ohos_app_abi = "arm64-v8a" 3894+} else { 3895+ assert(false, "Unknown ABI: " + current_cpu) 3896+} 3897+ 3898+if (target_cpu == "arm64" || target_cpu == "x64") { 3899+ ohos_64bit_target_cpu = true 3900+} else if (target_cpu == "arm" || target_cpu == "x86") { 3901+ ohos_64bit_target_cpu = false 3902+} else { 3903+ assert(false, "Unknown target CPU: $target_cpu") 3904+} 3905+ 3906+# Intentionally do not define ohos_app_secondary_abi_cpu and 3907+# ohos_app_secondary_abi for 32-bit target_cpu, since they are not used. 3908+if (target_cpu == "arm64") { 3909+ ohos_secondary_abi_cpu = "arm" 3910+ ohos_app_secondary_abi = "armeabi-v7a" 3911+} else if (target_cpu == "x64") { 3912+ ohos_secondary_abi_cpu = "x86" 3913+ ohos_app_secondary_abi = "x86" 3914+} 3915+ 3916+if (defined(ohos_secondary_abi_cpu)) { 3917+ ohos_secondary_abi_cpu = 3918+ "//build/toolchain/ohos:ohos_clang_${ohos_secondary_abi_cpu}" 3919+} 3920diff --git a/build/config/ohos/config.gni b/build/config/ohos/config.gni 3921new file mode 100644 3922index 0000000000..951d4a7f26 3923--- /dev/null 3924+++ b/build/config/ohos/config.gni 3925@@ -0,0 +1,116 @@ 3926+# Copyright 2022 The Chromium Authors. All rights reserved. 3927+# Use of this source code is governed by a BSD-style license that can be 3928+# found in the LICENSE file. 3929+ 3930+if (is_ohos) { 3931+ import("//build/config/dcheck_always_on.gni") 3932+ import("//build_overrides/build.gni") 3933+ import("abi.gni") 3934+ 3935+ declare_args() { 3936+ arm32_ndk_api_level = 21 3937+ arm64_ndk_api_level = 21 3938+ } 3939+ 3940+ declare_args() { 3941+ build_chromium_with_ohos_src = false 3942+ } 3943+ 3944+ # Defines the name the ohos build gives to the current host CPU 3945+ # architecture, which is different than the names GN uses. 3946+ if (host_cpu == "x64") { 3947+ ohos_host_arch = "x86_64" 3948+ } else if (host_cpu == "x86") { 3949+ ohos_host_arch = "x86" 3950+ } else { 3951+ assert(false, "Need ohos toolchain support for your build CPU arch.") 3952+ } 3953+ 3954+ # Defines the name the ohos build gives to the current host CPU 3955+ # architecture, which is different than the names GN uses. 3956+ if (host_os == "linux") { 3957+ ohos_host_os = "linux" 3958+ } else if (host_os == "mac") { 3959+ ohos_host_os = "darwin" 3960+ } else { 3961+ assert(false, "Need ohos toolchain support for your build OS.") 3962+ } 3963+ 3964+ # config dependent paths 3965+ if (build_chromium_with_ohos_src) { 3966+ ohos_ndk_root = "//../../../prebuilts" 3967+ ohos_build_root = "//../../.." 3968+ if (use_musl) { 3969+ ohos_toolchain_root = "$ohos_ndk_root/clang/ohos/linux-x86_64/llvm" 3970+ ohos_sysroot = "$ohos_build_root/out/ohos-arm-release/obj/third_party/musl" 3971+ } else { 3972+ ohos_toolchain_root = "$ohos_ndk_root/clang/host/linux-x86/clang-r353983c" 3973+ ohos_sysroot = "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/platforms/current/arch-arm" 3974+ } 3975+ 3976+ # ohos include and libs dependencies 3977+ ohos_src_includes = [ 3978+ "$ohos_build_root/foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", 3979+ "$ohos_build_root/utils/native/base/include", 3980+ "$ohos_build_root/base/hiviewdfx/hilog/interfaces/native/innerkits/include", 3981+ "$ohos_build_root/foundation/graphic/standard/interfaces/innerkits/common", 3982+ "$ohos_build_root/drivers/peripheral/display/interfaces/include", 3983+ "$ohos_build_root/foundation/graphic/standard/utils/buffer_handle/export", 3984+ "$ohos_build_root/foundation/multimedia/media_standard/interfaces/innerkits/native/media/include", 3985+ "$ohos_build_root/drivers/peripheral/base", 3986+ "$ohos_build_root/foundation/graphic/standard/interfaces/innerkits/surface", 3987+ "$ohos_build_root/foundation/communication/ipc/interfaces/innerkits/ipc_core/include", 3988+ "$ohos_build_root/base/miscservices/inputmethod/frameworks/inputmethod_controller/include", 3989+ "$ohos_build_root/base/miscservices/inputmethod/services/include", 3990+ "$ohos_build_root/base/miscservices/inputmethod/frameworks/inputmethod_ability/include", 3991+ "$ohos_build_root/utils/native/base/include", 3992+ "$ohos_build_root/foundation/multimodalinput/input/interfaces/native/innerkits/event/include", 3993+ "$ohos_build_root/base/location/location_locator/callback/include", 3994+ "$ohos_build_root/base/location/utils/include", 3995+ "$ohos_build_root/base/location/interfaces/innerkits/locator_standard/include", 3996+ "$ohos_build_root/base/location/location_common/common/include", 3997+ "$ohos_build_root/utils/system/safwk/native/include", 3998+ ] 3999+ ohos_libs_dir = [ 4000+ "$ohos_build_root/out/ohos-arm-release/packages/phone/system/lib", 4001+ ] 4002+ } else { 4003+ if (use_musl) { 4004+ ohos_build_root = "//ohos_ndk" 4005+ ohos_ndk_root = "//ohos_ndk" 4006+ ohos_toolchain_root = "$ohos_ndk_root/toolchains/llvm" 4007+ ohos_sysroot = "$ohos_ndk_root/sysroot" 4008+ } else { 4009+ ohos_build_root = "//ohos_ndk_aosp" 4010+ ohos_ndk_root = "//ohos_ndk_aosp" 4011+ ohos_toolchain_root = "$ohos_ndk_root/toolchains/clang-r353983c" 4012+ ohos_sysroot = "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/platforms/current/arch-arm" 4013+ } 4014+ 4015+ # ohos include and libs dependencies, corresponding to gen_ohos_ndk.sh 4016+ ohos_src_includes = [ 4017+ "$ohos_build_root/includes/libeventhandler", 4018+ "$ohos_build_root/includes/utils", 4019+ "$ohos_build_root/includes/common", 4020+ "$ohos_build_root/includes/display", 4021+ "$ohos_build_root/includes/graphic_util", 4022+ "$ohos_build_root/includes/media", 4023+ "$ohos_build_root/includes/peripheral", 4024+ "$ohos_build_root/includes/surface", 4025+ "$ohos_build_root/includes/ipc_core", 4026+ "$ohos_build_root/includes/inputmethod_controller", 4027+ "$ohos_build_root/includes", 4028+ "$ohos_build_root/includes/inputmethod_services", 4029+ "$ohos_build_root/includes/inputmethod_ability", 4030+ "$ohos_build_root/includes/multimodalinput", 4031+ "$ohos_build_root/includes/location", 4032+ "$ohos_build_root/includes/location_utils", 4033+ "$ohos_build_root/includes/location_callback", 4034+ "$ohos_build_root/includes/location_request_config", 4035+ "$ohos_build_root/includes/system_ability", 4036+ ] 4037+ ohos_libs_dir = [ 4038+ "$ohos_build_root/libs", 4039+ ] 4040+ } 4041+} 4042diff --git a/build/config/ozone.gni b/build/config/ozone.gni 4043index a14eb93cec..187d05846b 100644 4044--- a/build/config/ozone.gni 4045+++ b/build/config/ozone.gni 4046@@ -89,6 +89,8 @@ declare_args() { 4047 } else if (is_fuchsia) { 4048 ozone_platform = "scenic" 4049 ozone_platform_scenic = true 4050+ } else if (is_ohos) { 4051+ ozone_platform_wayland = true 4052 } 4053 } 4054 4055diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni 4056index 18d2d57362..359776d661 100644 4057--- a/build/config/sysroot.gni 4058+++ b/build/config/sysroot.gni 4059@@ -35,6 +35,9 @@ if (sysroot == "") { 4060 4061 # Android uses unified headers, and thus a single compile time sysroot 4062 sysroot = "$android_toolchain_root/sysroot" 4063+ } else if (is_ohos) { 4064+ import("//build/config/ohos/config.gni") 4065+ sysroot = "$ohos_sysroot" 4066 } else if ((is_linux || is_chromeos) && use_sysroot) { 4067 # By default build against a sysroot image downloaded from Cloud Storage 4068 # during gclient runhooks. 4069diff --git a/build/config/ui.gni b/build/config/ui.gni 4070index 022f008ab1..ec0b388f3d 100644 4071--- a/build/config/ui.gni 4072+++ b/build/config/ui.gni 4073@@ -24,7 +24,7 @@ declare_args() { 4074 # Indicates if Ozone is enabled. Ozone is a low-level library layer for Linux 4075 # that does not require X11. 4076 use_ozone = 4077- is_chromeos || (is_chromecast && !is_android) || is_fuchsia || is_linux 4078+ is_chromeos || (is_chromecast && !is_android) || is_fuchsia || is_linux || is_ohos 4079 4080 # Indicates if the UI toolkit depends on X11. 4081 # Enabled by default. Can be disabled if Ozone only build is required and 4082diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn 4083index 65be9970c2..e8b2f872b2 100644 4084--- a/build/toolchain/android/BUILD.gn 4085+++ b/build/toolchain/android/BUILD.gn 4086@@ -32,11 +32,11 @@ template("android_clang_toolchain") { 4087 # toolchain definitions are evaluated under the default toolchain. 4088 # Rather than computing the value under current_os="android", just disable 4089 # it if target_os != "android". 4090- _use_debug_fission = use_debug_fission && target_os == "android" 4091+ _use_debug_fission = use_debug_fission && (target_os == "android" || target_os == "ohos") 4092 4093 toolchain_args = { 4094 forward_variables_from(invoker.toolchain_args, "*") 4095- current_os = "android" 4096+ current_os = target_os 4097 use_debug_fission = _use_debug_fission 4098 } 4099 4100diff --git a/build/toolchain/concurrent_links.gni b/build/toolchain/concurrent_links.gni 4101index f1a42c9101..20068b6470 100644 4102--- a/build/toolchain/concurrent_links.gni 4103+++ b/build/toolchain/concurrent_links.gni 4104@@ -58,10 +58,10 @@ if (concurrent_links == -1) { 4105 } else { 4106 _args = [ "--mem_per_link_gb=4" ] 4107 } 4108- } else if (is_android && !is_component_build && symbol_level == 2) { 4109+ } else if ((is_android || is_ohos) && !is_component_build && symbol_level == 2) { 4110 # Full debug symbols require large memory for link. 4111 _args = [ "--mem_per_link_gb=25" ] 4112- } else if (is_android && !is_debug && !using_sanitizer && is_java_debug && 4113+ } else if ((is_android || is_ohos) && !is_debug && !using_sanitizer && is_java_debug && 4114 disable_android_lint && symbol_level < 2) { 4115 if (symbol_level == 1) { 4116 _args = [ "--mem_per_link_gb=6" ] 4117@@ -81,7 +81,7 @@ if (concurrent_links == -1) { 4118 # These both have a peak usage of < 2GB, but that is still large enough for 4119 # them to need to use a pool since they both typically happen at the 4120 # same time as linking. 4121- if (is_android) { 4122+ if (is_android || is_ohos) { 4123 _args += [ "--secondary_mem_per_link=2" ] 4124 } 4125 4126diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni 4127index 650784bb54..029cdc857d 100644 4128--- a/build/toolchain/gcc_toolchain.gni 4129+++ b/build/toolchain/gcc_toolchain.gni 4130@@ -27,12 +27,12 @@ declare_args() { 4131 is_official_build && 4132 # Don't enable for Android-on-Chrome OS so that they can build with 4133 # symbol_level=0 without this failing (crbug.com/891164). 4134- (target_os == "android" || target_os == "win") 4135+ (target_os == "android" || target_os == "win" || target_os == "ohos") 4136 } 4137 4138 # When the arg is set via args.gn, it applies to all toolchains. In order to not 4139 # hit the assert in grit_rule.gni, explicitly disable for host toolchains. 4140-if ((is_linux || is_chromeos) && target_os == "android") { 4141+if ((is_linux || is_chromeos) && (target_os == "android" || target_os == "ohos")) { 4142 enable_resource_allowlist_generation = false 4143 } 4144 4145@@ -47,7 +47,7 @@ if (enable_resource_allowlist_generation) { 4146 !is_component_build, 4147 "enable_resource_allowlist_generation=true requires is_component_build=false") 4148 assert( 4149- target_os == "android" || target_os == "win", 4150+ target_os == "android" || target_os == "win" || target_os == "ohos", 4151 "enable_resource_allowlist_generation=true does not work for target_os=$target_os") 4152 } 4153 4154diff --git a/build/toolchain/ohos/BUILD.gn b/build/toolchain/ohos/BUILD.gn 4155new file mode 100644 4156index 0000000000..c8540c7b3a 4157--- /dev/null 4158+++ b/build/toolchain/ohos/BUILD.gn 4159@@ -0,0 +1,63 @@ 4160+# Copyright 2022 The Chromium Authors. All rights reserved. 4161+# Use of this source code is governed by a BSD-style license that can be 4162+# found in the LICENSE file. 4163+ 4164+import("//build/config/clang/clang.gni") 4165+import("//build/config/compiler/compiler.gni") 4166+import("//build/config/ohos/config.gni") 4167+import("//build/config/ozone.gni") 4168+import("//build/config/sysroot.gni") 4169+import("//build/toolchain/gcc_toolchain.gni") 4170+ 4171+declare_args() { 4172+ # Whether unstripped binaries, i.e. compiled with debug symbols, should be 4173+ # considered runtime_deps rather than stripped ones. 4174+ ohos_unstripped_runtime_outputs = true 4175+} 4176+ 4177+# The ohos clang toolchains share most of the same parameters, so we have this 4178+# wrapper around gcc_toolchain to avoid duplication of logic. 4179+# 4180+# Parameters: 4181+# - binary_prefix 4182+# Prefix of compiler executables. 4183+template("ohos_clang_toolchain") { 4184+ gcc_toolchain(target_name) { 4185+ assert(defined(invoker.toolchain_args), 4186+ "toolchain_args must be defined for ohos_clang_toolchain()") 4187+ 4188+ toolchain_args = { 4189+ forward_variables_from(invoker.toolchain_args, "*") 4190+ current_os = target_os 4191+ } 4192+ 4193+ # Output linker map files for binary size analysis. 4194+ enable_linker_map = true 4195+ 4196+ _prefix = rebase_path("$clang_base_path/bin", root_build_dir) 4197+ cc = "$_prefix/clang" 4198+ cxx = "$_prefix/clang++" 4199+ ar = "$_prefix/llvm-ar" 4200+ ld = cxx 4201+ readelf = "$_prefix/llvm-readobj" 4202+ nm = "$_prefix/llvm-nm" 4203+ strip = rebase_path("$clang_base_path/bin/llvm-strip", root_build_dir) 4204+ use_unstripped_as_runtime_outputs = ohos_unstripped_runtime_outputs 4205+ 4206+ # Don't use .cr.so for loadable_modules since they are always loaded via 4207+ # absolute path. 4208+ loadable_module_extension = ".so" 4209+ } 4210+} 4211+ 4212+ohos_clang_toolchain("ohos_clang_arm") { 4213+ toolchain_args = { 4214+ current_cpu = "arm" 4215+ } 4216+} 4217+ 4218+ohos_clang_toolchain("ohos_clang_arm64") { 4219+ toolchain_args = { 4220+ current_cpu = "arm64" 4221+ } 4222+} 4223diff --git a/build/toolchain/toolchain.gni b/build/toolchain/toolchain.gni 4224index 94ecbbb13e..92a0e4ea4a 100644 4225--- a/build/toolchain/toolchain.gni 4226+++ b/build/toolchain/toolchain.gni 4227@@ -23,7 +23,7 @@ declare_args() { 4228 use_xcode_clang = false 4229 4230 # Used for binary size analysis. 4231- generate_linker_map = is_android && is_official_build 4232+ generate_linker_map = (is_android || is_ohos) && is_official_build 4233 } 4234 4235 if (generate_linker_map) { 4236@@ -32,7 +32,7 @@ if (generate_linker_map) { 4237 "true or is_chromecast = true") 4238 assert(current_os == "android" || current_os == "linux" || 4239 target_os == "android" || target_os == "linux" || 4240- target_os == "chromeos", 4241+ target_os == "chromeos" || target_os == "ohos", 4242 "Linker map files should only be generated for Android, Linux, " + 4243 "or ChromeOS.") 4244 } 4245@@ -50,7 +50,7 @@ assert(!use_xcode_clang || target_os == "ios", 4246 # Extension for shared library files (including leading dot). 4247 if (is_apple) { 4248 shlib_extension = ".dylib" 4249-} else if (is_android && is_component_build) { 4250+} else if ((is_android || is_ohos) && is_component_build) { 4251 # By appending .cr, we prevent name collisions with libraries already 4252 # loaded by the Android zygote. 4253 shlib_extension = ".cr.so" 4254diff --git a/build/util/version.gni b/build/util/version.gni 4255index fb8715d32d..9e76b887c7 100644 4256--- a/build/util/version.gni 4257+++ b/build/util/version.gni 4258@@ -35,7 +35,7 @@ if (is_mac) { 4259 "-e", 4260 "PATCH_LO=int(PATCH)%256", 4261 ] 4262-} else if (target_os == "android") { 4263+} else if (target_os == "android" || target_os == "ohos") { 4264 import("//build/config/android/config.gni") 4265 4266 _version_dictionary_template += 4267@@ -93,7 +93,7 @@ if (is_mac) { 4268 4269 chrome_dylib_version = "$chrome_version_build.$chrome_version_patch_hi" + 4270 ".$chrome_version_patch_lo" 4271-} else if (target_os == "android") { 4272+} else if (target_os == "android" || target_os == "ohos") { 4273 forward_variables_from(_result, 4274 [ 4275 "chrome_modern_version_code", 4276diff --git a/cc/mojom/BUILD.gn b/cc/mojom/BUILD.gn 4277index fc4ab95cb5..e1392a9ec2 100644 4278--- a/cc/mojom/BUILD.gn 4279+++ b/cc/mojom/BUILD.gn 4280@@ -21,6 +21,9 @@ component("shared_mojom_traits") { 4281 4282 mojom("mojom") { 4283 generate_java = true 4284+ if (is_android) { 4285+ enabled_features = [ "is_android" ] 4286+ } 4287 sources = [ 4288 "browser_controls_params.mojom", 4289 "browser_controls_state.mojom", 4290diff --git a/cef/BUILD.gn b/cef/BUILD.gn 4291index 1a5a0a93d0..776db090a5 100644 4292--- a/cef/BUILD.gn 4293+++ b/cef/BUILD.gn 4294@@ -254,7 +254,7 @@ assert(enable_basic_printing) 4295 assert(enable_print_preview) 4296 4297 # Enable support for Widevine CDM. 4298-assert(enable_widevine) 4299+assert(enable_widevine || is_ohos) 4300 4301 if (is_clang) { 4302 # Don't use the chrome style plugin. 4303@@ -872,7 +872,7 @@ static_library("libcef_static") { 4304 "//components/printing/common", 4305 "//components/printing/renderer", 4306 "//components/proxy_config", 4307- "//components/safe_browsing/core/db:test_database_manager", 4308+ # "//components/safe_browsing/core/db:test_database_manager", 4309 "//components/services/print_compositor/public/cpp", 4310 "//components/services/print_compositor/public/mojom", 4311 "//components/update_client", 4312@@ -935,6 +935,12 @@ static_library("libcef_static") { 4313 "//v8", 4314 ] 4315 4316+ if (safe_browsing_mode != 0) { 4317+ deps += [ 4318+ "//components/safe_browsing/core/db:test_database_manager" 4319+ ] 4320+ } 4321+ 4322 if (is_win) { 4323 sources += includes_win + [ 4324 "libcef/browser/alloy/alloy_browser_main_win.cc", 4325@@ -980,6 +986,18 @@ static_library("libcef_static") { 4326 ] 4327 } 4328 4329+ if (is_ohos) { 4330+ sources += includes_linux + [ 4331+ "libcef/browser/native/browser_platform_delegate_native_linux.cc", 4332+ "libcef/browser/native/browser_platform_delegate_native_linux.h", 4333+ "libcef/browser/native/cursor_util_linux.cc", 4334+ "libcef/browser/native/menu_runner_linux.cc", 4335+ "libcef/browser/native/menu_runner_linux.h", 4336+ "libcef/browser/osr/browser_platform_delegate_osr_linux.cc", 4337+ "libcef/browser/osr/browser_platform_delegate_osr_linux.h", 4338+ ] 4339+ } 4340+ 4341 if (is_linux) { 4342 sources += includes_linux + [ 4343 "libcef/browser/native/browser_platform_delegate_native_linux.cc", 4344@@ -1057,7 +1075,7 @@ static_library("libcef_static") { 4345 deps += [ "//tools/v8_context_snapshot" ] 4346 } 4347 4348- if (toolkit_views) { 4349+ if (toolkit_views || is_ohos) { 4350 sources += [ 4351 "libcef/browser/chrome/views/browser_platform_delegate_chrome_views.cc", 4352 "libcef/browser/chrome/views/browser_platform_delegate_chrome_views.h", 4353@@ -1214,6 +1232,14 @@ static_library("libcef_static") { 4354 ] 4355 } 4356 } 4357+ if (is_ohos) { 4358+ sources += [ 4359+ # Support for UI input events. 4360+ # Part of //ui/aura:test_support which is testingonly. 4361+ "//ui/aura/test/aura_test_utils.cc", 4362+ "//ui/aura/test/aura_test_utils.h", 4363+ ] 4364+ } 4365 } 4366 4367 if (is_mac) { 4368@@ -1406,7 +1432,7 @@ make_pack_header("resources") { 4369 "//ui/resources:webui_resources_grd", 4370 ] 4371 4372- if (toolkit_views) { 4373+ if (toolkit_views || is_ohos) { 4374 inputs += [ "$root_gen_dir/ui/views/resources/grit/views_resources.h" ] 4375 deps += [ "//ui/views/resources:resources_grd" ] 4376 } 4377diff --git a/cef/include/capi/cef_base_capi.h b/cef/include/capi/cef_base_capi.h 4378index dbd0b9f339..09c397421a 100644 4379--- a/cef/include/capi/cef_base_capi.h 4380+++ b/cef/include/capi/cef_base_capi.h 4381@@ -38,6 +38,7 @@ 4382 #include "include/internal/cef_string_map.h" 4383 #include "include/internal/cef_string_multimap.h" 4384 #include "include/internal/cef_types.h" 4385+#include "include/internal/cef_types_wrappers.h" 4386 4387 #ifdef __cplusplus 4388 extern "C" { 4389diff --git a/cef/include/cef_api_hash.h b/cef/include/cef_api_hash.h 4390index 1bbed1b2e5..c09e0c63ce 100644 4391--- a/cef/include/cef_api_hash.h 4392+++ b/cef/include/cef_api_hash.h 4393@@ -49,6 +49,8 @@ 4394 #define CEF_API_HASH_PLATFORM "5cc32f88bd134410eff86b21095138b339d572f2" 4395 #elif defined(OS_LINUX) 4396 #define CEF_API_HASH_PLATFORM "b227b3fdd6142a9d8ff0f2252a71425f15960800" 4397+#elif defined(OS_OHOS) 4398+#define CEF_API_HASH_PLATFORM "b227b3fdd6142a9d8ff0f2252a71425f15960800" 4399 #endif 4400 4401 #ifdef __cplusplus 4402diff --git a/cef/include/cef_base.h b/cef/include/cef_base.h 4403index 89e9c7a1e0..8dadcf45e0 100644 4404--- a/cef/include/cef_base.h 4405+++ b/cef/include/cef_base.h 4406@@ -42,7 +42,7 @@ 4407 #include "include/internal/cef_win.h" 4408 #elif defined(OS_MAC) 4409 #include "include/internal/cef_mac.h" 4410-#elif defined(OS_LINUX) 4411+#elif defined(OS_LINUX) || defined(OS_OHOS) 4412 #include "include/internal/cef_linux.h" 4413 #endif 4414 4415diff --git a/cef/include/cef_config.h b/cef/include/cef_config.h 4416index 9938c4019d..e90ae957b4 100644 4417--- a/cef/include/cef_config.h 4418+++ b/cef/include/cef_config.h 4419@@ -35,7 +35,7 @@ 4420 #ifndef CEF_INCLUDE_CEF_CONFIG_H_ 4421 #define CEF_INCLUDE_CEF_CONFIG_H_ 4422 4423-#if defined(OS_LINUX) 4424+#if defined(OS_LINUX) && !defined(OS_OHOS) 4425 4426 #define CEF_X11 1 4427 4428diff --git a/cef/include/internal/cef_types.h b/cef/include/internal/cef_types.h 4429index 0ec9fcb5cf..db67632877 100644 4430--- a/cef/include/internal/cef_types.h 4431+++ b/cef/include/internal/cef_types.h 4432@@ -41,7 +41,7 @@ 4433 #include "include/internal/cef_types_win.h" 4434 #elif defined(OS_MAC) 4435 #include "include/internal/cef_types_mac.h" 4436-#elif defined(OS_LINUX) 4437+#elif defined(OS_LINUX) || defined(OS_OHOS) 4438 #include "include/internal/cef_types_linux.h" 4439 #endif 4440 4441diff --git a/cef/include/internal/cef_types_linux.h b/cef/include/internal/cef_types_linux.h 4442index b21d6551e1..94c85dea40 100644 4443--- a/cef/include/internal/cef_types_linux.h 4444+++ b/cef/include/internal/cef_types_linux.h 4445@@ -34,7 +34,7 @@ 4446 #include "include/base/cef_build.h" 4447 #include "include/cef_config.h" 4448 4449-#if defined(OS_LINUX) 4450+#if defined(OS_LINUX) || defined(OS_OHOS) 4451 4452 #if defined(CEF_X11) 4453 typedef union _XEvent XEvent; 4454diff --git a/cef/libcef/browser/alloy/alloy_browser_main.cc b/cef/libcef/browser/alloy/alloy_browser_main.cc 4455index ffcde42815..433272c61c 100644 4456--- a/cef/libcef/browser/alloy/alloy_browser_main.cc 4457+++ b/cef/libcef/browser/alloy/alloy_browser_main.cc 4458@@ -148,7 +148,11 @@ int AlloyBrowserMainParts::PreCreateThreads() { 4459 // Initialize these objects before IO access restrictions are applied and 4460 // before the IO thread is started. 4461 content::GpuDataManager::GetInstance(); 4462+#if !defined(OS_OHOS) 4463 SystemNetworkContextManager::CreateInstance(g_browser_process->local_state()); 4464+#else 4465+ LOG(INFO) << "SystemNetworkContextManager::CreateInstance UNIMPLEMENT for OS_OHOS"; 4466+#endif 4467 4468 return 0; 4469 } 4470diff --git a/cef/libcef/browser/alloy/alloy_content_browser_client.cc b/cef/libcef/browser/alloy/alloy_content_browser_client.cc 4471index 48f567f9be..33be06def0 100644 4472--- a/cef/libcef/browser/alloy/alloy_content_browser_client.cc 4473+++ b/cef/libcef/browser/alloy/alloy_content_browser_client.cc 4474@@ -383,7 +383,7 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext { 4475 DISALLOW_COPY_AND_ASSIGN(CefQuotaPermissionContext); 4476 }; 4477 4478-#if defined(OS_POSIX) && !defined(OS_MAC) 4479+#if defined(OS_POSIX) && !defined(OS_MAC) && !defined(OS_OHOS) 4480 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( 4481 const std::string& process_type) { 4482 base::FilePath dumps_path; 4483@@ -693,7 +693,6 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( 4484 switches::kMainBundlePath, 4485 #endif 4486 switches::kLocalesDirPath, 4487- switches::kLogFile, 4488 switches::kLogSeverity, 4489 switches::kResourcesDirPath, 4490 embedder_support::kUserAgent, 4491@@ -705,6 +704,16 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( 4492 4493 const std::string& process_type = 4494 command_line->GetSwitchValueASCII(switches::kProcessType); 4495+ if (process_type == switches::kZygoteProcess || 4496+ (browser_cmd->HasSwitch(switches::kNoZygote) && 4497+ process_type == switches::kRendererProcess)) { 4498+ static const char* const kSwitchNames[] = { 4499+ switches::kUserDataDir, 4500+ }; 4501+ command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames, 4502+ base::size(kSwitchNames)); 4503+ } 4504+ 4505 if (process_type == switches::kRendererProcess) { 4506 // Propagate the following switches to the renderer command line (along with 4507 // any associated values) if present in the browser command line. 4508@@ -718,6 +727,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( 4509 switches::kEnableSpeechInput, 4510 switches::kUncaughtExceptionStackSize, 4511 network::switches::kUnsafelyTreatInsecureOriginAsSecure, 4512+ switches::kUserDataDir, 4513 }; 4514 command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames, 4515 base::size(kSwitchNames)); 4516@@ -1046,6 +1056,7 @@ void AlloyContentBrowserClient::ExposeInterfacesToRenderer( 4517 base::BindRepeating(&BindPluginInfoHost, host->GetID())); 4518 } 4519 4520+#if !defined(OS_OHOS) 4521 std::unique_ptr<net::ClientCertStore> 4522 AlloyContentBrowserClient::CreateClientCertStore( 4523 content::BrowserContext* browser_context) { 4524@@ -1058,10 +1069,14 @@ AlloyContentBrowserClient::CreateClientCertStore( 4525 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin()); 4526 #elif defined(OS_MAC) 4527 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac()); 4528+#elif defined(OS_OHOS) 4529+ LOG(INFO) << "ClientCertStore UNIMPLEMENT for OS_OHOS"; 4530+ return nullptr; 4531 #else 4532 #error Unknown platform. 4533 #endif 4534 } 4535+#endif 4536 4537 std::unique_ptr<content::LoginDelegate> 4538 AlloyContentBrowserClient::CreateLoginDelegate( 4539@@ -1176,10 +1191,15 @@ void AlloyContentBrowserClient::OnNetworkServiceCreated( 4540 PrefService* local_state = g_browser_process->local_state(); 4541 DCHECK(local_state); 4542 4543+#if !defined(OS_OHOS) 4544 // Need to set up global NetworkService state before anything else uses it. 4545 DCHECK(SystemNetworkContextManager::GetInstance()); 4546 SystemNetworkContextManager::GetInstance()->OnNetworkServiceCreated( 4547 network_service); 4548+#else 4549+ LOG(INFO) << "AlloyContentBrowserClient::OnNetworkServiceCreated UNIMPLEMENT " 4550+ "for OS_OHOS"; 4551+#endif 4552 } 4553 4554 void AlloyContentBrowserClient::ConfigureNetworkContextParams( 4555@@ -1261,6 +1281,7 @@ bool AlloyContentBrowserClient::HandleExternalProtocol( 4556 content::NavigationUIData* navigation_data, 4557 const network::ResourceRequest& resource_request, 4558 mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) { 4559+#if !defined(OS_OHOS) 4560 mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver = 4561 out_factory->InitWithNewPipeAndPassReceiver(); 4562 4563@@ -1274,6 +1295,11 @@ bool AlloyContentBrowserClient::HandleExternalProtocol( 4564 net_service::ProxyURLLoaderFactory::CreateProxy( 4565 web_contents_getter, std::move(receiver), std::move(request_handler)); 4566 return true; 4567+#else 4568+ LOG(INFO) << "AlloyContentBrowserClient::HandleExternalProtocol UNIMPLEMENT " 4569+ "for OS_OHOS"; 4570+ return false; 4571+#endif 4572 } 4573 4574 std::unique_ptr<content::OverlayWindow> 4575@@ -1285,7 +1311,11 @@ AlloyContentBrowserClient::CreateWindowForPictureInPicture( 4576 // dependency constraints that disallow directly calling 4577 // chrome/browser/ui/views code either from here or from other code in 4578 // chrome/browser. 4579+#if !defined(OS_OHOS) 4580 return content::OverlayWindow::Create(controller); 4581+#else 4582+ return nullptr; 4583+#endif 4584 } 4585 4586 void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame( 4587@@ -1395,6 +1425,23 @@ bool AlloyContentBrowserClient::ShouldAllowPluginCreation( 4588 return true; 4589 } 4590 4591+#if defined(OS_OHOS) 4592+bool AlloyContentBrowserClient::ShouldTryToUseExistingProcessHost( 4593+ content::BrowserContext* browser_context, 4594+ const GURL& url) { 4595+ const base::CommandLine* command_line = 4596+ base::CommandLine::ForCurrentProcess(); 4597+ if (!command_line) 4598+ return false; 4599+ return command_line->HasSwitch(switches::kEnableMultiRendererProcess) ? false 4600+ : true; 4601+} 4602+ 4603+bool AlloyContentBrowserClient::ShouldDisableSiteIsolation() { 4604+ return true; 4605+} 4606+#endif 4607+ 4608 CefRefPtr<CefRequestContextImpl> AlloyContentBrowserClient::request_context() 4609 const { 4610 return browser_main_parts_->request_context(); 4611diff --git a/cef/libcef/browser/alloy/alloy_content_browser_client.h b/cef/libcef/browser/alloy/alloy_content_browser_client.h 4612index 9b4a842b08..35b45c4f89 100644 4613--- a/cef/libcef/browser/alloy/alloy_content_browser_client.h 4614+++ b/cef/libcef/browser/alloy/alloy_content_browser_client.h 4615@@ -133,8 +133,10 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient { 4616 service_manager::BinderRegistry* registry, 4617 blink::AssociatedInterfaceRegistry* associated_registry, 4618 content::RenderProcessHost* render_process_host) override; 4619+#if !defined(OS_OHOS) 4620 std::unique_ptr<net::ClientCertStore> CreateClientCertStore( 4621 content::BrowserContext* browser_context) override; 4622+#endif 4623 std::unique_ptr<content::LoginDelegate> CreateLoginDelegate( 4624 const net::AuthChallengeInfo& auth_info, 4625 content::WebContents* web_contents, 4626@@ -216,6 +218,13 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient { 4627 const url::Origin& embedder_origin, 4628 const content::PepperPluginInfo& plugin_info) override; 4629 4630+#if defined(OS_OHOS) 4631+ bool ShouldTryToUseExistingProcessHost( 4632+ content::BrowserContext* browser_context, 4633+ const GURL& url) override; 4634+ bool ShouldDisableSiteIsolation() override; 4635+#endif 4636+ 4637 CefRefPtr<CefRequestContextImpl> request_context() const; 4638 CefDevToolsDelegate* devtools_delegate() const; 4639 4640diff --git a/cef/libcef/browser/alloy/chrome_browser_process_alloy.cc b/cef/libcef/browser/alloy/chrome_browser_process_alloy.cc 4641index d0630ee159..eb37471ece 100644 4642--- a/cef/libcef/browser/alloy/chrome_browser_process_alloy.cc 4643+++ b/cef/libcef/browser/alloy/chrome_browser_process_alloy.cc 4644@@ -303,10 +303,12 @@ StatusTray* ChromeBrowserProcessAlloy::status_tray() { 4645 return nullptr; 4646 } 4647 4648+#if BUILDFLAG(FULL_SAFE_BROWSING) 4649 safe_browsing::SafeBrowsingService* 4650 ChromeBrowserProcessAlloy::safe_browsing_service() { 4651 return nullptr; 4652 } 4653+#endif 4654 4655 subresource_filter::RulesetService* 4656 ChromeBrowserProcessAlloy::subresource_filter_ruleset_service() { 4657diff --git a/cef/libcef/browser/alloy/chrome_browser_process_alloy.h b/cef/libcef/browser/alloy/chrome_browser_process_alloy.h 4658index 01460594b7..6e9e2d03f8 100644 4659--- a/cef/libcef/browser/alloy/chrome_browser_process_alloy.h 4660+++ b/cef/libcef/browser/alloy/chrome_browser_process_alloy.h 4661@@ -78,7 +78,9 @@ class ChromeBrowserProcessAlloy : public BrowserProcess { 4662 std::unique_ptr<BackgroundModeManager> manager) override; 4663 #endif 4664 StatusTray* status_tray() override; 4665+#if BUILDFLAG(FULL_SAFE_BROWSING) 4666 safe_browsing::SafeBrowsingService* safe_browsing_service() override; 4667+#endif 4668 subresource_filter::RulesetService* subresource_filter_ruleset_service() 4669 override; 4670 federated_learning::FlocSortingLshClustersService* 4671diff --git a/cef/libcef/browser/browser_host_base.h b/cef/libcef/browser/browser_host_base.h 4672index 48331e81e3..d30f0b43d0 100644 4673--- a/cef/libcef/browser/browser_host_base.h 4674+++ b/cef/libcef/browser/browser_host_base.h 4675@@ -39,7 +39,7 @@ struct CefBrowserCreateParams { 4676 settings = that.settings; 4677 request_context = that.request_context; 4678 extra_info = that.extra_info; 4679-#if defined(TOOLKIT_VIEWS) 4680+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 4681 browser_view = that.browser_view; 4682 #endif 4683 return *this; 4684@@ -49,7 +49,7 @@ struct CefBrowserCreateParams { 4685 // views-hosted browser. Currently used with the alloy runtime only. 4686 std::unique_ptr<CefWindowInfo> window_info; 4687 4688-#if defined(TOOLKIT_VIEWS) 4689+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 4690 // The BrowserView that will own a Views-hosted browser. Will be nullptr for 4691 // popup browsers. 4692 CefRefPtr<CefBrowserView> browser_view; 4693@@ -262,7 +262,7 @@ class CefBrowserHostBase : public CefBrowserHost, 4694 return contents_delegate_.get(); 4695 } 4696 4697-#if defined(TOOLKIT_VIEWS) 4698+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 4699 // Returns the Widget owner for the browser window. Only used with windowed 4700 // rendering. 4701 views::Widget* GetWindowWidget() const; 4702diff --git a/cef/libcef/browser/browser_info_manager.cc b/cef/libcef/browser/browser_info_manager.cc 4703index 4193972c9c..6482a7cee7 100644 4704--- a/cef/libcef/browser/browser_info_manager.cc 4705+++ b/cef/libcef/browser/browser_info_manager.cc 4706@@ -182,7 +182,9 @@ bool CefBrowserInfoManager::CanCreateWindow( 4707 CefBrowserCreateParams create_params; 4708 4709 if (browser->HasView()) { 4710+#if defined(TOOLKIT_VIEWS) 4711 create_params.popup_with_views_hosted_opener = true; 4712+#endif 4713 } else { 4714 create_params.window_info = std::move(window_info); 4715 } 4716diff --git a/cef/libcef/browser/browser_platform_delegate.cc b/cef/libcef/browser/browser_platform_delegate.cc 4717index 31f3a811a1..646614c126 100644 4718--- a/cef/libcef/browser/browser_platform_delegate.cc 4719+++ b/cef/libcef/browser/browser_platform_delegate.cc 4720@@ -112,7 +112,7 @@ CefWindowHandle CefBrowserPlatformDelegate::GetHostWindowHandle() const { 4721 return kNullWindowHandle; 4722 } 4723 4724-#if defined(TOOLKIT_VIEWS) 4725+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 4726 views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const { 4727 NOTREACHED(); 4728 return nullptr; 4729diff --git a/cef/libcef/browser/browser_platform_delegate.h b/cef/libcef/browser/browser_platform_delegate.h 4730index 501a778f68..938f40840e 100644 4731--- a/cef/libcef/browser/browser_platform_delegate.h 4732+++ b/cef/libcef/browser/browser_platform_delegate.h 4733@@ -57,7 +57,7 @@ class Size; 4734 class Vector2d; 4735 } // namespace gfx 4736 4737-#if defined(TOOLKIT_VIEWS) 4738+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 4739 namespace views { 4740 class Widget; 4741 } 4742@@ -168,7 +168,7 @@ class CefBrowserPlatformDelegate { 4743 // the client, which may be NULL. May be called on multiple threads. 4744 virtual CefWindowHandle GetHostWindowHandle() const; 4745 4746-#if defined(TOOLKIT_VIEWS) 4747+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 4748 // Returns the Widget owner for the browser window. Only used with windowed 4749 // rendering. 4750 virtual views::Widget* GetWindowWidget() const; 4751diff --git a/cef/libcef/browser/browser_platform_delegate_create.cc b/cef/libcef/browser/browser_platform_delegate_create.cc 4752index e8da240f0b..2409bf5767 100644 4753--- a/cef/libcef/browser/browser_platform_delegate_create.cc 4754+++ b/cef/libcef/browser/browser_platform_delegate_create.cc 4755@@ -22,7 +22,7 @@ 4756 #elif defined(OS_MAC) 4757 #include "libcef/browser/native/browser_platform_delegate_native_mac.h" 4758 #include "libcef/browser/osr/browser_platform_delegate_osr_mac.h" 4759-#elif defined(OS_LINUX) 4760+#elif defined(OS_LINUX) || defined(OS_OHOS) 4761 #include "libcef/browser/native/browser_platform_delegate_native_linux.h" 4762 #include "libcef/browser/osr/browser_platform_delegate_osr_linux.h" 4763 #else 4764@@ -45,7 +45,7 @@ std::unique_ptr<CefBrowserPlatformDelegateNative> CreateNativeDelegate( 4765 #elif defined(OS_MAC) 4766 return std::make_unique<CefBrowserPlatformDelegateNativeMac>( 4767 window_info, background_color); 4768-#elif defined(OS_LINUX) 4769+#elif defined(OS_LINUX) || defined(OS_OHOS) 4770 return std::make_unique<CefBrowserPlatformDelegateNativeLinux>( 4771 window_info, background_color); 4772 #endif 4773@@ -61,7 +61,7 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate( 4774 #elif defined(OS_MAC) 4775 return std::make_unique<CefBrowserPlatformDelegateOsrMac>( 4776 std::move(native_delegate)); 4777-#elif defined(OS_LINUX) 4778+#elif defined(OS_LINUX) || defined(OS_OHOS) 4779 return std::make_unique<CefBrowserPlatformDelegateOsrLinux>( 4780 std::move(native_delegate), use_external_begin_frame); 4781 #endif 4782diff --git a/cef/libcef/browser/extensions/extension_system.cc b/cef/libcef/browser/extensions/extension_system.cc 4783index 22da03fea5..fddfc70a9a 100644 4784--- a/cef/libcef/browser/extensions/extension_system.cc 4785+++ b/cef/libcef/browser/extensions/extension_system.cc 4786@@ -126,6 +126,7 @@ void LoadExtensionWithManifest(base::WeakPtr<CefExtensionSystem> context, 4787 internal, loader_context, handler); 4788 } 4789 4790+#if !defined(OS_OHOS) 4791 void LoadExtensionFromDisk(base::WeakPtr<CefExtensionSystem> context, 4792 const base::FilePath& root_directory, 4793 bool internal, 4794@@ -145,6 +146,7 @@ void LoadExtensionFromDisk(base::WeakPtr<CefExtensionSystem> context, 4795 LoadExtensionWithManifest(context, manifest_contents, root_directory, 4796 internal, loader_context, handler); 4797 } 4798+#endif 4799 4800 } // namespace 4801 4802@@ -265,10 +267,14 @@ void CefExtensionSystem::LoadExtension( 4803 bool internal, 4804 CefRefPtr<CefRequestContext> loader_context, 4805 CefRefPtr<CefExtensionHandler> handler) { 4806+#if !defined(OS_OHOS) 4807 CEF_REQUIRE_UIT(); 4808 CEF_POST_USER_VISIBLE_TASK( 4809 base::BindOnce(LoadExtensionFromDisk, weak_ptr_factory_.GetWeakPtr(), 4810 root_directory, internal, loader_context, handler)); 4811+#else 4812+ LOG(INFO) << "CefExtensionSystem::LoadExtension UNIMPLEMENT for OS_OHOS"; 4813+#endif 4814 } 4815 4816 void CefExtensionSystem::LoadExtension( 4817diff --git a/cef/libcef/browser/views/window_impl.cc b/cef/libcef/browser/views/window_impl.cc 4818index eeb1fcced7..a90011f029 100644 4819--- a/cef/libcef/browser/views/window_impl.cc 4820+++ b/cef/libcef/browser/views/window_impl.cc 4821@@ -38,6 +38,7 @@ void InitializeUITesting() { 4822 if (!initialized) { 4823 ui_controls::EnableUIControls(); 4824 4825+#if !defined(OS_OHOS) 4826 #if defined(USE_AURA) 4827 #if defined(OS_LINUX) && defined(USE_X11) 4828 ui_controls::InstallUIControlsAura( 4829@@ -46,6 +47,7 @@ void InitializeUITesting() { 4830 ui_controls::InstallUIControlsAura( 4831 aura::test::CreateUIControlsAura(nullptr)); 4832 #endif 4833+#endif 4834 #endif 4835 4836 initialized = true; 4837diff --git a/cef/libcef/common/alloy/alloy_main_delegate.cc b/cef/libcef/common/alloy/alloy_main_delegate.cc 4838index ba5b08cd78..ccbd621288 100644 4839--- a/cef/libcef/common/alloy/alloy_main_delegate.cc 4840+++ b/cef/libcef/common/alloy/alloy_main_delegate.cc 4841@@ -211,6 +211,11 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) { 4842 CefString(&settings_->javascript_flags)); 4843 } 4844 4845+ if (settings_->user_data_path.length > 0) { 4846+ command_line->AppendSwitchPath(switches::kUserDataDir, 4847+ CefString(&settings_->user_data_path)); 4848+ } 4849+ 4850 if (settings_->pack_loading_disabled) { 4851 command_line->AppendSwitch(switches::kDisablePackLoading); 4852 } else { 4853@@ -521,7 +526,22 @@ void AlloyMainDelegate::InitializeResourceBundle() { 4854 base::PathService::Override(ui::DIR_LOCALES, locales_dir); 4855 } 4856 4857+#if defined(OS_OHOS) 4858+ base::FilePath userdata_dir; 4859+ if (command_line->HasSwitch(switches::kUserDataDir)) { 4860+ userdata_dir = command_line->GetSwitchValuePath(switches::kUserDataDir); 4861+ } 4862+ if (!userdata_dir.empty()) { 4863+ base::PathService::Override(base::DIR_OHOS_APP_DATA, userdata_dir); 4864+ base::PathService::Override(base::DIR_CACHE, userdata_dir.Append("cache")); 4865+ } 4866+#endif 4867+ 4868+#if !defined(OS_OHOS) 4869 std::string locale = command_line->GetSwitchValueASCII(switches::kLang); 4870+#else 4871+ std::string locale = "zh-CN"; 4872+#endif 4873 DCHECK(!locale.empty()); 4874 4875 const std::string loaded_locale = 4876diff --git a/cef/libcef/common/extensions/extensions_util.cc b/cef/libcef/common/extensions/extensions_util.cc 4877index 4780f5bbfc..7da19e691d 100644 4878--- a/cef/libcef/common/extensions/extensions_util.cc 4879+++ b/cef/libcef/common/extensions/extensions_util.cc 4880@@ -18,10 +18,14 @@ bool ExtensionsEnabled() { 4881 } 4882 4883 bool PdfExtensionEnabled() { 4884+#if !defined(OS_OHOS) 4885 static bool enabled = 4886 ExtensionsEnabled() && !base::CommandLine::ForCurrentProcess()->HasSwitch( 4887 switches::kDisablePdfExtension); 4888 return enabled; 4889+#else 4890+ return false; 4891+#endif 4892 } 4893 4894 bool PrintPreviewEnabled() { 4895diff --git a/cef/libcef/common/resource_util.cc b/cef/libcef/common/resource_util.cc 4896index 7e8e49f38d..cd608ab345 100644 4897--- a/cef/libcef/common/resource_util.cc 4898+++ b/cef/libcef/common/resource_util.cc 4899@@ -15,6 +15,7 @@ 4900 #include "base/files/file_util.h" 4901 #include "base/notreached.h" 4902 #include "base/path_service.h" 4903+#include "base/logging.h" 4904 #include "chrome/common/chrome_constants.h" 4905 #include "chrome/common/chrome_paths.h" 4906 #include "chrome/common/chrome_paths_internal.h" 4907@@ -26,7 +27,7 @@ 4908 #include "libcef/common/util_mac.h" 4909 #endif 4910 4911-#if defined(OS_LINUX) 4912+#if defined(OS_LINUX) || defined(OS_OHOS) 4913 #include "base/environment.h" 4914 #include "base/nix/xdg_util.h" 4915 #endif 4916@@ -77,6 +78,16 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) { 4917 return true; 4918 } 4919 4920+#elif defined(OS_OHOS) 4921+ 4922+bool GetDefaultUserDataDirectory(base::FilePath* result) { 4923+ if (!base::PathService::Get(base::DIR_OHOS_APP_DATA, result)) 4924+ return false; 4925+ *result = result->Append(FILE_PATH_LITERAL("cef")); 4926+ *result = result->Append(FILE_PATH_LITERAL("cef_user_data")); 4927+ return true; 4928+} 4929+ 4930 #endif 4931 4932 base::FilePath GetUserDataPath(CefSettings* settings, 4933@@ -118,6 +129,7 @@ base::FilePath GetUserDataPath(CefSettings* settings, 4934 // to the desktop on any platform. 4935 // From chrome/browser/download/download_prefs.cc. 4936 bool DownloadPathIsDangerous(const base::FilePath& download_path) { 4937+#if !defined(OS_OHOS) 4938 #if defined(OS_LINUX) 4939 base::FilePath home_dir = base::GetHomeDir(); 4940 if (download_path == home_dir) { 4941@@ -131,6 +143,10 @@ bool DownloadPathIsDangerous(const base::FilePath& download_path) { 4942 return false; 4943 } 4944 return (download_path == desktop_dir); 4945+#else 4946+ // chrome/browser/download/download_prefs.cc: DownloadPathIsDangerous, have no destop dir 4947+ return false; 4948+#endif 4949 } 4950 4951 bool GetDefaultDownloadDirectory(base::FilePath* result) { 4952@@ -184,7 +200,11 @@ base::FilePath GetResourcesDir() { 4953 // Use a "debug.log" file in the running executable's directory. 4954 base::FilePath GetDefaultLogFilePath() { 4955 base::FilePath log_path; 4956+#if defined(OS_OHOS) 4957+ base::PathService::Get(base::DIR_OHOS_APP_DATA, &log_path); 4958+#else 4959 base::PathService::Get(base::DIR_EXE, &log_path); 4960+#endif 4961 return log_path.Append(FILE_PATH_LITERAL("debug.log")); 4962 } 4963 4964@@ -207,6 +227,11 @@ void OverrideUserDataDir(CefSettings* settings, 4965 const base::CommandLine* command_line) { 4966 const base::FilePath& user_data_path = 4967 GetUserDataPath(settings, command_line); 4968+ 4969+#if defined(OS_OHOS) 4970+ base::PathService::Override(base::DIR_CACHE, user_data_path.Append("cache")); 4971+ base::PathService::Override(base::DIR_OHOS_APP_DATA, user_data_path); 4972+#else 4973 base::PathService::Override(chrome::DIR_USER_DATA, user_data_path); 4974 4975 // Path used for crash dumps. 4976@@ -217,6 +242,8 @@ void OverrideUserDataDir(CefSettings* settings, 4977 chrome::DIR_APP_DICTIONARIES, user_data_path.AppendASCII("Dictionaries"), 4978 false, // May not be an absolute path. 4979 true); // Create if necessary. 4980+ 4981+#endif 4982 } 4983 4984 // Same as ui::ResourceBundle::IsScaleFactorSupported. 4985diff --git a/cef/libcef_dll/base/cef_logging.cc b/cef/libcef_dll/base/cef_logging.cc 4986index 35602911bf..1b4833fa68 100644 4987--- a/cef/libcef_dll/base/cef_logging.cc 4988+++ b/cef/libcef_dll/base/cef_logging.cc 4989@@ -67,6 +67,7 @@ wrap_posix_strerror_r(char* (*strerror_r_ptr)(int, char*, size_t), 4990 // guarantee that they are handled. This is compiled on all POSIX platforms, but 4991 // it will only be used on Linux if the POSIX strerror_r implementation is 4992 // being used (see below). 4993+#ifndef COMPILE_WITH_OHOS 4994 static void POSSIBLY_UNUSED wrap_posix_strerror_r(int (*strerror_r_ptr)(int, 4995 char*, 4996 size_t), 4997@@ -109,6 +110,7 @@ static void POSSIBLY_UNUSED wrap_posix_strerror_r(int (*strerror_r_ptr)(int, 4998 } 4999 errno = old_errno; 5000 } 5001+#endif 5002 5003 void safe_strerror_r(int err, char* buf, size_t len) { 5004 if (buf == NULL || len <= 0) { 5005@@ -118,7 +120,9 @@ void safe_strerror_r(int err, char* buf, size_t len) { 5006 // appropriate overloaded function based on the function type of strerror_r. 5007 // The other one will be elided from the translation unit since both are 5008 // static. 5009+#ifndef COMPILE_WITH_OHOS 5010 wrap_posix_strerror_r(&strerror_r, err, buf, len); 5011+#endif 5012 } 5013 5014 std::string safe_strerror(int err) { 5015diff --git a/cef/tools/cef_api_hash.py b/cef/tools/cef_api_hash.py 5016index 6dbecf5dbc..229f219bf3 100644 5017--- a/cef/tools/cef_api_hash.py 5018+++ b/cef/tools/cef_api_hash.py 5019@@ -35,7 +35,7 @@ class cef_api_hash: 5020 self.__debug_enabled = not (self.__debugdir is 5021 None) and len(self.__debugdir) > 0 5022 5023- self.platforms = ["windows", "mac", "linux"] 5024+ self.platforms = ["windows", "mac", "linux", "ohos"] 5025 5026 self.platform_files = { 5027 # List of includes_win_capi from cef_paths2.gypi. 5028@@ -49,6 +49,9 @@ class cef_api_hash: 5029 # List of includes_linux_capi from cef_paths2.gypi. 5030 "linux": [ 5031 "internal/cef_types_linux.h", 5032+ ], 5033+ "ohos": [ 5034+ "internal/cef_types_linux.h", 5035 ] 5036 } 5037 5038diff --git a/cef/tools/make_api_hash_header.py b/cef/tools/make_api_hash_header.py 5039index 6c79efcdba..8901749c7d 100644 5040--- a/cef/tools/make_api_hash_header.py 5041+++ b/cef/tools/make_api_hash_header.py 5042@@ -39,6 +39,8 @@ def make_api_hash_header(cpp_header_dir): 5043 #define CEF_API_HASH_PLATFORM "$MAC$" 5044 #elif defined(OS_LINUX) 5045 #define CEF_API_HASH_PLATFORM "$LINUX$" 5046+#elif defined(OS_OHOS) 5047+#define CEF_API_HASH_PLATFORM "$OHOS$" 5048 #endif 5049 5050 #ifdef __cplusplus 5051diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn 5052index f80853980d..210e5654c9 100644 5053--- a/chrome/BUILD.gn 5054+++ b/chrome/BUILD.gn 5055@@ -1611,13 +1611,21 @@ if (is_android) { 5056 "//components/gwp_asan/buildflags", 5057 "//components/heap_profiling/in_process", 5058 "//components/minidump_uploader", 5059- "//components/safe_browsing:buildflags", 5060- "//components/safe_browsing/android:safe_browsing_api_handler", 5061- "//components/safe_browsing/android:safe_browsing_mobile", 5062+ # "//components/safe_browsing:buildflags", 5063+ # "//components/safe_browsing/android:safe_browsing_api_handler", 5064+ # "//components/safe_browsing/android:safe_browsing_mobile", 5065 "//components/services/heap_profiling", 5066 "//content/public/app", 5067 ] 5068 5069+ if (safe_browsing_mode != 0) { 5070+ deps += [ 5071+ "//components/safe_browsing:buildflags", 5072+ "//components/safe_browsing/android:safe_browsing_api_handler", 5073+ "//components/safe_browsing/android:safe_browsing_mobile", 5074+ ] 5075+ } 5076+ 5077 # Explicit dependency required for JNI registration to be able to 5078 # find the native side functions. 5079 if (is_android && is_component_build) { 5080diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc 5081index 0673d955b5..2215e0f08f 100644 5082--- a/chrome/app/chrome_main_delegate.cc 5083+++ b/chrome/app/chrome_main_delegate.cc 5084@@ -156,7 +156,7 @@ 5085 #endif 5086 5087 #if defined(OS_MAC) || defined(OS_WIN) || defined(OS_ANDROID) || \ 5088- defined(OS_LINUX) || defined(OS_CHROMEOS) 5089+ defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 5090 #include "chrome/browser/policy/policy_path_parser.h" 5091 #include "components/crash/core/app/crashpad.h" 5092 #endif 5093@@ -353,7 +353,7 @@ void HandleHelpSwitches(const base::CommandLine& command_line) { 5094 } 5095 #endif // defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 5096 5097-#if !defined(OS_MAC) && !defined(OS_ANDROID) 5098+#if !defined(OS_MAC) && !defined(OS_ANDROID) && !defined(OS_OHOS) 5099 void SIGTERMProfilingShutdown(int signal) { 5100 content::Profiling::Stop(); 5101 struct sigaction sigact; 5102@@ -1105,8 +1105,10 @@ void ChromeMainDelegate::PreSandboxStartup() { 5103 #else // !defined(OS_ANDROID) 5104 if (crash_reporter::IsCrashpadEnabled()) { 5105 crash_reporter::InitializeCrashpad(process_type.empty(), process_type); 5106+#if !defined(__MUSL__) 5107 crash_reporter::SetFirstChanceExceptionHandler( 5108 v8::TryHandleWebAssemblyTrapPosix); 5109+#endif 5110 } else { 5111 breakpad::InitCrashReporter(process_type); 5112 } 5113diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd 5114index b0a9f00730..d7a65ff5c5 100644 5115--- a/chrome/app/chromium_strings.grd 5116+++ b/chrome/app/chromium_strings.grd 5117@@ -681,7 +681,7 @@ Chromium is unable to recover your settings. 5118 </if> 5119 5120 <!-- Enterprise sign-in dialog --> 5121- <if expr="toolkit_views"> 5122+ <if expr="toolkit_views or is_ohos"> 5123 <message name="IDS_ENTERPRISE_SIGNIN_TITLE" desc="The title of the dialog to confirm linking the browser profile with the signed-in enterprise account"> 5124 Link your Chromium data to this account? 5125 </message> 5126diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd 5127index d3c77c82a8..1ef5193794 100644 5128--- a/chrome/app/generated_resources.grd 5129+++ b/chrome/app/generated_resources.grd 5130@@ -383,7 +383,7 @@ are declared in tools/grit/grit_rule.gni. 5131 Permission requested, press ⌘ + Option + Down arrow to respond 5132 </message> 5133 </if> 5134- <if expr="is_win or desktop_linux"> 5135+ <if expr="is_win or desktop_linux or is_ohos"> 5136 <message name="IDS_PERMISSIONS_REQUESTED_SCREENREADER_ANNOUNCEMENT" desc="Announcement to screen readers on Windows or Linux when permission is requested to inform users of how to focus the permission UI."> 5137 Permission requested, press F6 to respond 5138 </message> 5139@@ -2832,7 +2832,7 @@ are declared in tools/grit/grit_rule.gni. 5140 </message> 5141 5142 <!-- Win certificate selector dialog strings. --> 5143- <if expr="toolkit_views"> 5144+ <if expr="toolkit_views or is_ohos"> 5145 <message name="IDS_CERT_SELECTOR_SUBJECT_COLUMN" desc="The text of the header for the certificate subject column in the certificate selector dialog."> 5146 Subject 5147 </message> 5148@@ -7572,7 +7572,7 @@ Keep your key file in a safe place. You will need it to create new versions of y 5149 </message> 5150 5151 <!-- Accessiblility strings for Infobars in Views --> 5152- <if expr="toolkit_views"> 5153+ <if expr="toolkit_views or is_ohos"> 5154 <message name="IDS_ACCNAME_INFOBAR_CONTAINER" desc="The accessible name for the infobar container."> 5155 Infobar Container 5156 </message> 5157@@ -8566,7 +8566,7 @@ Please help our engineers fix this problem. Tell us what happened right before y 5158 </if> 5159 5160 <!-- Translate Bubble --> 5161- <if expr="toolkit_views"> 5162+ <if expr="toolkit_views or is_ohos"> 5163 <message name="IDS_TRANSLATE_BUBBLE_BEFORE_TRANSLATE_TITLE" desc="Title text for the translate bubble when asking to translate a page."> 5164 Translate this page? 5165 </message> 5166@@ -9646,7 +9646,7 @@ Please help our engineers fix this problem. Tell us what happened right before y 5167 Live Caption visible, press ⌘ + Option + Up arrow or Down arrow to cycle focus 5168 </message> 5169 </if> 5170- <if expr="is_win or desktop_linux"> 5171+ <if expr="is_win or desktop_linux or is_ohos"> 5172 <message name="IDS_LIVE_CAPTION_BUBBLE_APPEAR_SCREENREADER_ANNOUNCEMENT" desc="Announcement to screen readers on Windows or Linux when the Live Caption bubble appears to inform users of how to focus the bubble."> 5173 Live Caption visible, press F6 to cycle focus 5174 </message> 5175@@ -9834,7 +9834,7 @@ Please help our engineers fix this problem. Tell us what happened right before y 5176 <message name="IDS_DESKTOP_MEDIA_PRESENTER_TOOLS" desc="Text for the checkbox on window picker dialog, when checked the presenter tools will be shown."> 5177 Presenter Tools 5178 </message> 5179- <if expr="toolkit_views"> 5180+ <if expr="toolkit_views or is_ohos"> 5181 <message name="IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_THIS_TAB" desc="Text for one of the dialog-tabs on the media picker dialog. This dialog-tab controls sharing the current tab."> 5182 This Tab 5183 </message> 5184@@ -9984,7 +9984,7 @@ Please help our engineers fix this problem. Tell us what happened right before y 5185 <ph name="WINDOW_TITLE">$1<ex>Google Search</ex></ph> - Permission requested, press ⌘ + Option + Up arrow to respond 5186 </message> 5187 </if> 5188- <if expr="is_win or desktop_linux"> 5189+ <if expr="is_win or desktop_linux or is_ohos"> 5190 <message name="IDS_TAB_AX_LABEL_PERMISSION_REQUESTED_FORMAT" desc="Accessibility label text for Windows or Linux, when a tab has a pending request. Example: 'Google Search - Permission requested, press F6 to respond'."> 5191 <ph name="WINDOW_TITLE">$1<ex>Google Search</ex></ph> - Permission requested, press F6 to respond 5192 </message> 5193@@ -10652,7 +10652,7 @@ Please help our engineers fix this problem. Tell us what happened right before y 5194 </if> 5195 5196 <!-- Web-modal dialog shown during Web Authenticaton API requests. --> 5197- <if expr="is_win or is_macosx or desktop_linux or chromeos"> 5198+ <if expr="is_win or is_macosx or desktop_linux or chromeos or is_ohos"> 5199 <message name="IDS_WEBAUTHN_GENERIC_TITLE" desc="Title of most dialogs shown while the user is authenticating on a web site using a security key."> 5200 Use your security key with <ph name="APP_NAME">$1<ex>google.com</ex></ph> 5201 </message> 5202diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd 5203index 6e262a2562..ab8064c7d0 100644 5204--- a/chrome/app/google_chrome_strings.grd 5205+++ b/chrome/app/google_chrome_strings.grd 5206@@ -689,7 +689,7 @@ Google Chrome is unable to recover your settings. 5207 </if> 5208 5209 <!-- Enterprise sign-in dialog --> 5210- <if expr="toolkit_views"> 5211+ <if expr="toolkit_views or is_ohos"> 5212 <message name="IDS_ENTERPRISE_SIGNIN_TITLE" desc="The title of the dialog to confirm linking the browser profile with the signed-in enterprise account"> 5213 Link your Chrome data to this account? 5214 </message> 5215diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp 5216index 70fa4da663..cf925eb113 100644 5217--- a/chrome/app/settings_strings.grdp 5218+++ b/chrome/app/settings_strings.grdp 5219@@ -142,6 +142,11 @@ 5220 Reset to default 5221 </message> 5222 </if> 5223+ <if expr="is_ohos"> 5224+ <message name="IDS_SETTINGS_RESET_TO_DEFAULT_THEME" desc="Name of the control which resets the browser theme back to the default theme."> 5225+ Reset to default 5226+ </message> 5227+ </if> 5228 <message name="IDS_SETTINGS_CHROME_COLORS" desc="Text of the label describing 'Chrome Colors' theme."> 5229 Chrome Colors 5230 </message> 5231diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd 5232index f26b92c575..ad4fcca0e9 100644 5233--- a/chrome/app/theme/theme_resources.grd 5234+++ b/chrome/app/theme/theme_resources.grd 5235@@ -28,7 +28,7 @@ 5236 <if expr="is_linux or is_win or chromeos"> 5237 <structure type="chrome_scaled_image" name="IDR_ACCESSIBILITY_CAPTIONS_PREVIEW_BACKGROUND" file="common/captions-preview-bg.png" /> 5238 </if> 5239- <if expr="toolkit_views and not is_macosx"> 5240+ <if expr="toolkit_views and not is_macosx or is_ohos"> 5241 <structure type="chrome_scaled_image" name="IDR_APP_WINDOW_CLOSE" file="common/app_window_close.png" /> 5242 <structure type="chrome_scaled_image" name="IDR_APP_WINDOW_CLOSE_H" file="common/app_window_close_hover.png" /> 5243 <structure type="chrome_scaled_image" name="IDR_APP_WINDOW_CLOSE_P" file="common/app_window_close_active.png" /> 5244diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn 5245index e2872b0c85..054746e8cb 100644 5246--- a/chrome/browser/BUILD.gn 5247+++ b/chrome/browser/BUILD.gn 5248@@ -1119,8 +1119,8 @@ static_library("browser") { 5249 "permissions/contextual_notification_permission_ui_selector.h", 5250 "permissions/crowd_deny_preload_data.cc", 5251 "permissions/crowd_deny_preload_data.h", 5252- "permissions/crowd_deny_safe_browsing_request.cc", 5253- "permissions/crowd_deny_safe_browsing_request.h", 5254+ # "permissions/crowd_deny_safe_browsing_request.cc", 5255+ # "permissions/crowd_deny_safe_browsing_request.h", 5256 "permissions/last_tab_standing_tracker.cc", 5257 "permissions/last_tab_standing_tracker.h", 5258 "permissions/last_tab_standing_tracker_factory.cc", 5259@@ -1844,6 +1844,13 @@ static_library("browser") { 5260 "window_placement/window_placement_permission_context.h", 5261 ] 5262 5263+ if (safe_browsing_mode != 0) { 5264+ sources += [ 5265+ "permissions/crowd_deny_safe_browsing_request.cc", 5266+ "permissions/crowd_deny_safe_browsing_request.h", 5267+ ] 5268+ } 5269+ 5270 configs += [ 5271 "//build/config/compiler:wexit_time_destructors", 5272 "//build/config:precompiled_headers", 5273@@ -1862,15 +1869,24 @@ static_library("browser") { 5274 "//chrome/browser/profiling_host", 5275 "//chrome/browser/ui", 5276 "//chrome/browser/ui/webui/bluetooth_internals", 5277- "//chrome/browser/safe_browsing", 5278- "//chrome/browser/safe_browsing:verdict_cache_manager_factory", 5279- "//chrome/browser/safe_browsing:advanced_protection", 5280- "//chrome/browser/safe_browsing:metrics_collector", 5281+ # "//chrome/browser/safe_browsing", 5282+ # "//chrome/browser/safe_browsing:verdict_cache_manager_factory", 5283+ # "//chrome/browser/safe_browsing:advanced_protection", 5284+ # "//chrome/browser/safe_browsing:metrics_collector", 5285 5286 # TODO(crbug.com/1030821): Eliminate usages of browser.h from Media Router. 5287 "//chrome/browser/media/router", 5288 ] 5289 5290+ if (safe_browsing_mode != 0) { 5291+ allow_circular_includes_from += [ 5292+ "//chrome/browser/safe_browsing", 5293+ "//chrome/browser/safe_browsing:verdict_cache_manager_factory", 5294+ "//chrome/browser/safe_browsing:advanced_protection", 5295+ "//chrome/browser/safe_browsing:metrics_collector", 5296+ ] 5297+ } 5298+ 5299 public_deps = [ 5300 "//base", 5301 "//chrome/common", 5302@@ -1946,10 +1962,10 @@ static_library("browser") { 5303 "//chrome/browser/push_messaging:budget_proto", 5304 "//chrome/browser/resource_coordinator:mojo_bindings", 5305 "//chrome/browser/resource_coordinator:tab_manager_features", 5306- "//chrome/browser/safe_browsing", 5307- "//chrome/browser/safe_browsing:advanced_protection", 5308- "//chrome/browser/safe_browsing:metrics_collector", 5309- "//chrome/browser/safe_browsing:verdict_cache_manager_factory", 5310+ # "//chrome/browser/safe_browsing", 5311+ # "//chrome/browser/safe_browsing:advanced_protection", 5312+ # "//chrome/browser/safe_browsing:metrics_collector", 5313+ # "//chrome/browser/safe_browsing:verdict_cache_manager_factory", 5314 "//chrome/browser/search/drive:mojo_bindings", 5315 "//chrome/browser/search/task_module:mojo_bindings", 5316 "//chrome/browser/sharing:buildflags", 5317@@ -2152,19 +2168,19 @@ static_library("browser") { 5318 "//components/reputation/core", 5319 "//components/reputation/core:proto", 5320 "//components/resources", 5321- "//components/safe_browsing/content/browser", 5322- "//components/safe_browsing/content/password_protection", 5323- "//components/safe_browsing/core:download_file_types_proto", 5324- "//components/safe_browsing/core:features", 5325+ # "//components/safe_browsing/content/browser", 5326+ # "//components/safe_browsing/content/password_protection", 5327+ # "//components/safe_browsing/core:download_file_types_proto", 5328+ # "//components/safe_browsing/core:features", 5329 "//components/safe_browsing/core:file_type_policies", 5330- "//components/safe_browsing/core:public", 5331- "//components/safe_browsing/core/browser", 5332- "//components/safe_browsing/core/browser/sync", 5333- "//components/safe_browsing/core/common", 5334- "//components/safe_browsing/core/common:safe_browsing_policy_handler", 5335- "//components/safe_browsing/core/db:database_manager", 5336- "//components/safe_browsing/core/realtime:policy_engine", 5337- "//components/safe_browsing/core/realtime:url_lookup_service", 5338+ # "//components/safe_browsing/core:public", 5339+ # "//components/safe_browsing/core/browser", 5340+ # "//components/safe_browsing/core/browser/sync", 5341+ # "//components/safe_browsing/core/common", 5342+ # "//components/safe_browsing/core/common:safe_browsing_policy_handler", 5343+ # "//components/safe_browsing/core/db:database_manager", 5344+ # "//components/safe_browsing/core/realtime:policy_engine", 5345+ # "//components/safe_browsing/core/realtime:url_lookup_service", 5346 "//components/safe_search_api", 5347 "//components/safe_search_api:safe_search_client", 5348 "//components/schema_org/common:improved_mojom", 5349@@ -2357,6 +2373,29 @@ static_library("browser") { 5350 "//ui/webui", 5351 "//ui/webui/resources/cr_components/customize_themes:mojom", 5352 ] 5353+ 5354+ if (safe_browsing_mode != 0) { 5355+ deps += [ 5356+ "//chrome/browser/safe_browsing", 5357+ "//chrome/browser/safe_browsing:advanced_protection", 5358+ "//chrome/browser/safe_browsing:metrics_collector", 5359+ "//chrome/browser/safe_browsing:verdict_cache_manager_factory", 5360+ "//components/safe_browsing/content/browser", 5361+ "//components/safe_browsing/content/password_protection", 5362+ "//components/safe_browsing/core:download_file_types_proto", 5363+ "//components/safe_browsing/core:features", 5364+ #"//components/safe_browsing/core:file_type_policies", 5365+ "//components/safe_browsing/core:public", 5366+ "//components/safe_browsing/core/browser", 5367+ "//components/safe_browsing/core/browser/sync", 5368+ "//components/safe_browsing/core/common", 5369+ "//components/safe_browsing/core/common:safe_browsing_policy_handler", 5370+ "//components/safe_browsing/core/db:database_manager", 5371+ "//components/safe_browsing/core/realtime:policy_engine", 5372+ "//components/safe_browsing/core/realtime:url_lookup_service", 5373+ ] 5374+ } 5375+ 5376 if (is_chromeos_ash) { 5377 sources += [ 5378 "apps/digital_goods/digital_goods_factory_impl.cc", 5379@@ -3138,12 +3177,12 @@ static_library("browser") { 5380 "reputation/safety_tip_infobar.h", 5381 "reputation/safety_tip_infobar_delegate.cc", 5382 "reputation/safety_tip_infobar_delegate.h", 5383- "safe_browsing/android/password_reuse_controller_android.cc", 5384- "safe_browsing/android/password_reuse_controller_android.h", 5385- "safe_browsing/android/safe_browsing_referring_app_bridge_android.cc", 5386- "safe_browsing/android/safe_browsing_referring_app_bridge_android.h", 5387- "safe_browsing/android/safe_browsing_settings_launcher_android.cc", 5388- "safe_browsing/android/safe_browsing_settings_launcher_android.h", 5389+ # "safe_browsing/android/password_reuse_controller_android.cc", 5390+ # "safe_browsing/android/password_reuse_controller_android.h", 5391+ # "safe_browsing/android/safe_browsing_referring_app_bridge_android.cc", 5392+ # "safe_browsing/android/safe_browsing_referring_app_bridge_android.h", 5393+ # "safe_browsing/android/safe_browsing_settings_launcher_android.cc", 5394+ # "safe_browsing/android/safe_browsing_settings_launcher_android.h", 5395 "search/contextual_search_policy_handler_android.cc", 5396 "search/contextual_search_policy_handler_android.h", 5397 "search_engines/template_url_service_factory_android.cc", 5398@@ -3195,6 +3234,18 @@ static_library("browser") { 5399 "video_tutorials/internal/android/video_tutorial_service_bridge_factory.cc", 5400 "webauthn/android/cable_module_android.cc", 5401 ] 5402+ 5403+ if (safe_browsing_mode != 0) { 5404+ sources += [ 5405+ "safe_browsing/android/password_reuse_controller_android.cc", 5406+ "safe_browsing/android/password_reuse_controller_android.h", 5407+ "safe_browsing/android/safe_browsing_referring_app_bridge_android.cc", 5408+ "safe_browsing/android/safe_browsing_referring_app_bridge_android.h", 5409+ "safe_browsing/android/safe_browsing_settings_launcher_android.cc", 5410+ "safe_browsing/android/safe_browsing_settings_launcher_android.h", 5411+ ] 5412+ } 5413+ 5414 public_deps += [ 5415 "//chrome/android/features/dev_ui:buildflags", 5416 "//components/image_fetcher/core", 5417@@ -3302,7 +3353,7 @@ static_library("browser") { 5418 "//components/reading_list/features:flags", 5419 "//components/resources:android_resources", 5420 "//components/resources:components_resources", 5421- "//components/safe_browsing/core/password_protection:password_protection_metrics_util", 5422+ # "//components/safe_browsing/core/password_protection:password_protection_metrics_util", 5423 "//components/security_state/content/android", 5424 "//components/send_tab_to_self", 5425 "//components/signin/internal/identity_manager", # cf android / signin / 5426@@ -3334,6 +3385,13 @@ static_library("browser") { 5427 "//url:gurl_android", 5428 "//url:origin_android", 5429 ] 5430+ 5431+ if (safe_browsing_mode != 0) { 5432+ deps += [ 5433+ "//components/safe_browsing/core/password_protection:password_protection_metrics_util" 5434+ ] 5435+ } 5436+ 5437 allow_circular_includes_from += [ 5438 # chrome/browser depends on webapps, but that module needs 5439 # app_banner_manager_android.h from chrome. However, the .h file will soon 5440@@ -3869,8 +3927,8 @@ static_library("browser") { 5441 "resource_coordinator/tab_metrics_logger.h", 5442 "resource_coordinator/usage_clock.cc", 5443 "resource_coordinator/usage_clock.h", 5444- "safe_browsing/generated_safe_browsing_pref.cc", 5445- "safe_browsing/generated_safe_browsing_pref.h", 5446+ # "safe_browsing/generated_safe_browsing_pref.cc", 5447+ # "safe_browsing/generated_safe_browsing_pref.h", 5448 "search/background/ntp_background_data.cc", 5449 "search/background/ntp_background_data.h", 5450 "search/background/ntp_background_service.cc", 5451@@ -4158,6 +4216,14 @@ static_library("browser") { 5452 "webauthn/observable_authenticator_list.cc", 5453 "webauthn/observable_authenticator_list.h", 5454 ] 5455+ 5456+ if (safe_browsing_mode != 0) { 5457+ deps += [ 5458+ "safe_browsing/generated_safe_browsing_pref.cc", 5459+ "safe_browsing/generated_safe_browsing_pref.h", 5460+ ] 5461+ } 5462+ 5463 deps += [ 5464 ":cart_db_content_proto", 5465 ":theme_properties", 5466@@ -4855,8 +4921,8 @@ static_library("browser") { 5467 ":chrome_process_finder", 5468 "//base/win:base_win_buildflags", 5469 "//chrome/app/theme:chrome_unscaled_resources_grit", 5470- "//chrome/browser/safe_browsing/chrome_cleaner", 5471- "//chrome/browser/safe_browsing/chrome_cleaner:public", 5472+ # "//chrome/browser/safe_browsing/chrome_cleaner", 5473+ # "//chrome/browser/safe_browsing/chrome_cleaner:public", 5474 "//chrome/browser/web_applications/chrome_pwa_launcher:util", 5475 "//chrome/browser/win/conflicts:module_info", 5476 "//chrome/chrome_elf:constants", 5477@@ -4885,8 +4951,16 @@ static_library("browser") { 5478 "//ui/base:fullscreen_win", 5479 "//ui/base/cursor", 5480 ] 5481- allow_circular_includes_from += 5482+ 5483+ if (safe_browsing_mode != 0) { 5484+ deps += [ 5485+ "//chrome/browser/safe_browsing/chrome_cleaner", 5486+ "//chrome/browser/safe_browsing/chrome_cleaner:public" 5487+ ] 5488+ 5489+ allow_circular_includes_from += 5490 [ "//chrome/browser/safe_browsing/chrome_cleaner" ] 5491+ } 5492 5493 all_dependent_configs = [ ":browser_win_linker_flags" ] 5494 5495@@ -5100,6 +5174,20 @@ static_library("browser") { 5496 } 5497 } 5498 5499+ 5500+ if (is_ohos) { 5501+ sources += [ 5502+ "chrome_browser_main_linux.cc", 5503+ "chrome_browser_main_linux.h", 5504+ "enterprise/signals/device_info_fetcher_linux.cc", 5505+ "enterprise/signals/device_info_fetcher_linux.h", 5506+ "first_run/first_run_internal_linux.cc", 5507+ "memory_details_linux.cc", 5508+ "obsolete_system/obsolete_system_linux.cc", 5509+ "policy/browser_dm_token_storage_linux.cc", 5510+ "policy/browser_dm_token_storage_linux.h", 5511+ ] 5512+ } 5513 if (is_linux || is_chromeos) { 5514 sources += [ 5515 "chrome_browser_main_linux.cc", 5516@@ -5134,7 +5222,7 @@ static_library("browser") { 5517 } 5518 } 5519 5520- if (is_linux || is_chromeos_lacros) { 5521+ if (is_linux || is_chromeos_lacros || is_ohos) { 5522 # Desktop linux, doesn't count ChromeOS. 5523 sources += [ 5524 "download/download_status_updater_linux.cc", 5525@@ -5209,7 +5297,7 @@ static_library("browser") { 5526 sources += [ "hang_monitor/hang_crash_dump.cc" ] 5527 } 5528 5529- if (is_win || is_linux || is_chromeos) { 5530+ if (is_win || is_linux || is_chromeos || is_ohos) { 5531 sources += [ 5532 "renderer_context_menu/spelling_options_submenu_observer.cc", 5533 "renderer_context_menu/spelling_options_submenu_observer.h", 5534@@ -5231,7 +5319,7 @@ static_library("browser") { 5535 deps += [ "//chrome/browser/webshare:storage" ] 5536 } 5537 5538- if (is_win || is_mac || (is_linux || is_chromeos_lacros)) { 5539+ if (is_win || is_mac || (is_linux || is_chromeos_lacros) || is_ohos) { 5540 sources += [ 5541 "browser_switcher/alternative_browser_driver.h", 5542 "browser_switcher/browser_switcher_navigation_throttle.cc", 5543@@ -5250,7 +5338,7 @@ static_library("browser") { 5544 if (is_win) { 5545 sources += [ "browser_switcher/alternative_browser_driver_win.cc" ] 5546 } 5547- if (is_mac || (is_linux || is_chromeos_lacros)) { 5548+ if (is_mac || (is_linux || is_chromeos_lacros) || is_ohos) { 5549 sources += [ "browser_switcher/alternative_browser_driver_posix.cc" ] 5550 } 5551 } 5552@@ -5367,7 +5455,7 @@ static_library("browser") { 5553 ] 5554 } 5555 5556- if (is_win || is_mac || is_linux || is_chromeos) { 5557+ if (is_win || is_mac || is_linux || is_chromeos || is_ohos) { 5558 sources += [ 5559 "media/cast_mirroring_service_host.cc", 5560 "media/cast_mirroring_service_host.h", 5561@@ -5517,10 +5605,10 @@ static_library("browser") { 5562 if (is_mac) { 5563 sources += [ "printing/printer_manager_dialog_mac.mm" ] 5564 } 5565- if (is_linux || is_chromeos) { 5566+ if (is_linux || is_chromeos || is_ohos) { 5567 sources += [ "printing/printer_manager_dialog_linux.cc" ] 5568 } 5569- if (is_win || is_mac || is_linux || is_chromeos) { 5570+ if (is_win || is_mac || is_linux || is_chromeos || is_ohos) { 5571 sources += [ 5572 "printing/print_backend_service.cc", 5573 "printing/print_backend_service.h", 5574@@ -6417,7 +6505,7 @@ static_library("browser") { 5575 "net/nss_service_chromeos_factory.h", 5576 ] 5577 } 5578- if (is_linux || is_chromeos_lacros) { 5579+ if (is_linux || is_chromeos_lacros || is_ohos) { 5580 sources += [ "net/nss_context_linux.cc" ] 5581 } 5582 } 5583@@ -6557,7 +6645,7 @@ grit("resources") { 5584 if (is_chromeos_ash) { 5585 inputs = [ "resources/plugin_metadata/plugins_chromeos.json" ] 5586 } 5587- if (is_linux || is_chromeos_lacros) { 5588+ if (is_linux || is_chromeos_lacros || is_ohos) { 5589 inputs = [ "resources/plugin_metadata/plugins_linux.json" ] 5590 } 5591 if (is_mac) { 5592@@ -6568,7 +6656,7 @@ grit("resources") { 5593 } 5594 } 5595 5596- if (is_win || is_mac || is_linux || is_chromeos) { 5597+ if (is_win || is_mac || is_linux || is_chromeos || is_ohos) { 5598 deps += [ 5599 "//chrome/browser/resources/discards:discards_resources_gen", 5600 "//chrome/browser/resources/gaia_auth_host:modulize", 5601@@ -6757,15 +6845,22 @@ static_library("test_support") { 5602 public_deps = [ 5603 ":browser", 5604 "//chrome/browser/profiles:profile", 5605- "//chrome/browser/safe_browsing:test_support", 5606+ # "//chrome/browser/safe_browsing:test_support", 5607 "//chrome/browser/ui:test_support", 5608 ] 5609+ 5610+ if (safe_browsing_mode != 0) { 5611+ public_deps += [ 5612+ "//chrome/browser/safe_browsing:test_support" 5613+ ] 5614+ } 5615+ 5616 deps = [ 5617 "//build:chromeos_buildflags", 5618 "//chrome/app/theme:theme_resources", 5619 "//chrome/browser:browser_process", 5620 "//chrome/common", 5621- "//chrome/common/safe_browsing:proto", 5622+ # "//chrome/common/safe_browsing:proto", 5623 "//components/consent_auditor:test_support", 5624 "//components/invalidation/impl", 5625 "//components/invalidation/impl:test_support", 5626@@ -6782,7 +6877,7 @@ static_library("test_support") { 5627 "//components/reporting/util:task_runner_context", 5628 "//components/reputation/core", 5629 "//components/reputation/core:proto", 5630- "//components/safe_browsing/core:csd_proto", 5631+ # "//components/safe_browsing/core:csd_proto", 5632 "//components/search_engines:test_support", 5633 "//components/security_interstitials/content:security_interstitial_page", 5634 "//components/services/unzip/content", 5635@@ -6804,6 +6899,13 @@ static_library("test_support") { 5636 "//ui/gfx", 5637 ] 5638 5639+ if (safe_browsing_mode != 0) { 5640+ deps += [ 5641+ "//chrome/common/safe_browsing:proto", 5642+ "//components/safe_browsing/core:csd_proto" 5643+ ] 5644+ } 5645+ 5646 if (!is_android && !is_fuchsia) { 5647 deps += [ "//components/policy/test_support" ] 5648 } 5649@@ -6951,7 +7053,7 @@ static_library("test_support") { 5650 deps += [ 5651 "//components/crx_file", 5652 "//components/drive:test_support", 5653- "//components/safe_browsing/core/db:v4_test_util", 5654+ # "//components/safe_browsing/core/db:v4_test_util", 5655 "//components/services/unzip:in_process", 5656 "//components/storage_monitor:test_support", 5657 "//extensions:test_support", 5658@@ -6961,6 +7063,11 @@ static_library("test_support") { 5659 "//google_apis:test_support", 5660 "//services/data_decoder/public/cpp:test_support", 5661 ] 5662+ if (safe_browsing_mode != 0) { 5663+ deps += [ 5664+ "//components/safe_browsing/core/db:v4_test_util", 5665+ ] 5666+ } 5667 if (is_chromeos_ash) { 5668 deps += [ "//chrome/browser/chromeos" ] 5669 } 5670diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc 5671index 6821bb60ca..b934165fda 100644 5672--- a/chrome/browser/about_flags.cc 5673+++ b/chrome/browser/about_flags.cc 5674@@ -6589,7 +6589,7 @@ const FeatureEntry kFeatureEntries[] = { 5675 flag_descriptions::kEnableTranslateSubFramesDescription, kOsAll, 5676 FEATURE_VALUE_TYPE(translate::kTranslateSubFrames)}, 5677 5678-#if !defined(OS_ANDROID) 5679+#if !defined(OS_ANDROID) && !defined(OS_OHOS) 5680 {"enable-media-feeds", flag_descriptions::kEnableMediaFeedsName, 5681 flag_descriptions::kEnableMediaFeedsDescription, kOsDesktop, 5682 FEATURE_VALUE_TYPE(media::kMediaFeeds)}, 5683@@ -6892,7 +6892,7 @@ const FeatureEntry kFeatureEntries[] = { 5684 flag_descriptions::kPrivacyAdvisorDescription, kOsDesktop, 5685 FEATURE_VALUE_TYPE(features::kPrivacyAdvisor)}, 5686 5687-#if defined(TOOLKIT_VIEWS) 5688+#if defined(TOOLKIT_VIEWS) && !defined(OS_OHOS) 5689 {"desktop-in-product-help-snooze", 5690 flag_descriptions::kDesktopInProductHelpSnoozeName, 5691 flag_descriptions::kDesktopInProductHelpSnoozeDescription, kOsDesktop, 5692diff --git a/chrome/browser/apps/platform_apps/api/music_manager_private/BUILD.gn b/chrome/browser/apps/platform_apps/api/music_manager_private/BUILD.gn 5693index 2b63f2831c..213e1889bd 100644 5694--- a/chrome/browser/apps/platform_apps/api/music_manager_private/BUILD.gn 5695+++ b/chrome/browser/apps/platform_apps/api/music_manager_private/BUILD.gn 5696@@ -33,7 +33,7 @@ source_set("music_manager_private") { 5697 5698 if (is_chromeos_ash) { 5699 sources += [ "device_id_chromeos.cc" ] 5700- } else if (is_linux || is_chromeos_lacros) { 5701+ } else if (is_linux || is_chromeos_lacros || is_ohos) { 5702 sources += [ "device_id_linux.cc" ] 5703 } else if (is_mac) { 5704 sources += [ "device_id_mac.cc" ] 5705diff --git a/chrome/browser/apps/platform_apps/api/music_manager_private/device_id_linux.cc b/chrome/browser/apps/platform_apps/api/music_manager_private/device_id_linux.cc 5706index 0cb7a5f1d0..6177058513 100644 5707--- a/chrome/browser/apps/platform_apps/api/music_manager_private/device_id_linux.cc 5708+++ b/chrome/browser/apps/platform_apps/api/music_manager_private/device_id_linux.cc 5709@@ -40,9 +40,11 @@ const char* const kDeviceNames[] = { 5710 // Fedora 15 uses biosdevname feature where Embedded ethernet uses the 5711 // "em" prefix and PCI cards use the p[0-9]c[0-9] format based on PCI 5712 // slot and card information. 5713+#if !defined(OS_OHOS) 5714 const char* const kNetDeviceNamePrefixes[] = { 5715 "eth", "em", "en", "wl", "ww", "p0", "p1", "p2", 5716 "p3", "p4", "p5", "p6", "p7", "p8", "p9", "wlan"}; 5717+#endif 5718 5719 // Map from device name to disk uuid 5720 typedef std::map<base::FilePath, base::FilePath> DiskEntries; 5721@@ -151,7 +153,7 @@ class MacAddressProcessor { 5722 std::string GetMacAddress(IsValidMacAddressCallback is_valid_mac_address) { 5723 base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, 5724 base::BlockingType::MAY_BLOCK); 5725- 5726+#if !defined(OS_OHOS) 5727 struct ifaddrs* ifaddrs; 5728 int rv = getifaddrs(&ifaddrs); 5729 if (rv < 0) { 5730@@ -168,6 +170,10 @@ std::string GetMacAddress(IsValidMacAddressCallback is_valid_mac_address) { 5731 } 5732 freeifaddrs(ifaddrs); 5733 return processor.mac_address(); 5734+#else 5735+ LOG(INFO) << "GetMacAddress TODO for OS_OHOS"; 5736+ return ""; 5737+#endif 5738 } 5739 5740 void GetRawDeviceIdImpl(IsValidMacAddressCallback is_valid_mac_address, 5741diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h 5742index 96e44ad48e..99af2a8af6 100644 5743--- a/chrome/browser/browser_process.h 5744+++ b/chrome/browser/browser_process.h 5745@@ -22,6 +22,7 @@ 5746 #include "build/chromeos_buildflags.h" 5747 #include "chrome/common/buildflags.h" 5748 #include "media/media_buildflags.h" 5749+#include "components/safe_browsing/buildflags.h" 5750 5751 class BackgroundModeManager; 5752 class BrowserProcessPlatformPart; 5753@@ -209,8 +210,10 @@ class BrowserProcess { 5754 // on this platform (or this is a unit test). 5755 virtual StatusTray* status_tray() = 0; 5756 5757+#if BUILDFLAG(FULL_SAFE_BROWSING) 5758 // Returns the SafeBrowsing service. 5759 virtual safe_browsing::SafeBrowsingService* safe_browsing_service() = 0; 5760+#endif 5761 5762 // Returns the service providing versioned storage for rules used by the Safe 5763 // Browsing subresource filter. 5764diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc 5765index 946ccbda58..f7ef428ec8 100644 5766--- a/chrome/browser/browser_process_impl.cc 5767+++ b/chrome/browser/browser_process_impl.cc 5768@@ -367,8 +367,10 @@ void BrowserProcessImpl::StartTearDown() { 5769 5770 metrics_services_manager_.reset(); 5771 intranet_redirect_detector_.reset(); 5772+#if BUILDFLAG(FULL_SAFE_BROWSING) 5773 if (safe_browsing_service_.get()) 5774 safe_browsing_service()->ShutDown(); 5775+#endif 5776 network_time_tracker_.reset(); 5777 #if BUILDFLAG(ENABLE_PLUGINS) 5778 plugins_resource_service_.reset(); 5779@@ -968,6 +970,7 @@ StatusTray* BrowserProcessImpl::status_tray() { 5780 return status_tray_.get(); 5781 } 5782 5783+#if BUILDFLAG(FULL_SAFE_BROWSING) 5784 safe_browsing::SafeBrowsingService* 5785 BrowserProcessImpl::safe_browsing_service() { 5786 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 5787@@ -975,6 +978,7 @@ BrowserProcessImpl::safe_browsing_service() { 5788 CreateSafeBrowsingService(); 5789 return safe_browsing_service_.get(); 5790 } 5791+#endif 5792 5793 subresource_filter::RulesetService* 5794 BrowserProcessImpl::subresource_filter_ruleset_service() { 5795@@ -1225,6 +1229,7 @@ void BrowserProcessImpl::CreateBackgroundPrintingManager() { 5796 #endif 5797 } 5798 5799+#if BUILDFLAG(FULL_SAFE_BROWSING) 5800 void BrowserProcessImpl::CreateSafeBrowsingService() { 5801 DCHECK(!safe_browsing_service_); 5802 // Set this flag to true so that we don't retry indefinitely to 5803@@ -1244,6 +1249,7 @@ void BrowserProcessImpl::CreateSafeBrowsingService() { 5804 if (safe_browsing_service_) 5805 safe_browsing_service_->Initialize(); 5806 } 5807+#endif 5808 5809 void BrowserProcessImpl::CreateSubresourceFilterRulesetService() { 5810 DCHECK(!subresource_filter_ruleset_service_); 5811diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h 5812index 7d60206c83..1fa86f19b3 100644 5813--- a/chrome/browser/browser_process_impl.h 5814+++ b/chrome/browser/browser_process_impl.h 5815@@ -28,6 +28,7 @@ 5816 #include "components/nacl/common/buildflags.h" 5817 #include "components/prefs/persistent_pref_store.h" 5818 #include "components/prefs/pref_change_registrar.h" 5819+#include "components/safe_browsing/buildflags.h" 5820 #include "extensions/buildflags/buildflags.h" 5821 #include "media/media_buildflags.h" 5822 #include "ppapi/buildflags/buildflags.h" 5823@@ -175,7 +176,9 @@ class BrowserProcessImpl : public BrowserProcess, 5824 std::unique_ptr<BackgroundModeManager> manager) override; 5825 #endif 5826 StatusTray* status_tray() override; 5827+#if BUILDFLAG(FULL_SAFE_BROWSING) 5828 safe_browsing::SafeBrowsingService* safe_browsing_service() override; 5829+#endif 5830 subresource_filter::RulesetService* subresource_filter_ruleset_service() 5831 override; 5832 federated_learning::FlocSortingLshClustersService* 5833@@ -222,7 +225,9 @@ class BrowserProcessImpl : public BrowserProcess, 5834 void CreateNotificationUIManager(); 5835 void CreatePrintPreviewDialogController(); 5836 void CreateBackgroundPrintingManager(); 5837+#if BUILDFLAG(FULL_SAFE_BROWSING) 5838 void CreateSafeBrowsingService(); 5839+#endif 5840 void CreateSubresourceFilterRulesetService(); 5841 void CreateFlocBlocklistService(); 5842 void CreateFlocSortingLshClustersService(); 5843@@ -322,9 +327,10 @@ class BrowserProcessImpl : public BrowserProcess, 5844 // itself as a profile attributes storage observer on destruction. 5845 std::unique_ptr<BackgroundModeManager> background_mode_manager_; 5846 #endif 5847- 5848+#if BUILDFLAG(FULL_SAFE_BROWSING) 5849 bool created_safe_browsing_service_ = false; 5850 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service_; 5851+#endif 5852 5853 bool created_subresource_filter_ruleset_service_ = false; 5854 std::unique_ptr<subresource_filter::RulesetService> 5855diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd 5856index 41702ce803..b8e10ad4a2 100644 5857--- a/chrome/browser/browser_resources.grd 5858+++ b/chrome/browser/browser_resources.grd 5859@@ -8,7 +8,7 @@ 5860 </outputs> 5861 <release seq="1"> 5862 <structures> 5863- <if expr="is_win or is_macosx or desktop_linux or chromeos"> 5864+ <if expr="is_win or is_macosx or desktop_linux or chromeos or is_ohos"> 5865 <structure name="IDR_SIGNIN_SHARED_CSS_JS" file="${root_gen_dir}\chrome\browser\resources\signin\signin_shared_css.js" use_base_dir="false" preprocess="true" type="chrome_html" /> 5866 <structure name="IDR_SIGNIN_VARS_CSS_JS" file="${root_gen_dir}\chrome\browser\resources\signin\signin_vars_css.js" use_base_dir="false" type="chrome_html" /> 5867 </if> 5868@@ -29,7 +29,7 @@ 5869 </if> 5870 </structures> 5871 <includes> 5872- <if expr="is_win or is_macosx or desktop_linux or chromeos"> 5873+ <if expr="is_win or is_macosx or desktop_linux or chromeos or is_ohos"> 5874 <include name="IDR_DISCARDS_DATABASE_TAB_JS" file="${root_gen_dir}\chrome\browser\resources\discards\database_tab.js" use_base_dir="false" type="BINDATA" /> 5875 <include name="IDR_DISCARDS_DISCARDS_MAIN_JS" file="${root_gen_dir}\chrome\browser\resources\discards\discards_main.js" use_base_dir="false" type="BINDATA" /> 5876 <include name="IDR_DISCARDS_DISCARDS_TAB_JS" file="${root_gen_dir}\chrome\browser\resources\discards\discards_tab.js" use_base_dir="false" type="BINDATA" /> 5877@@ -144,7 +144,7 @@ 5878 <if expr="chromeos"> 5879 <include name="IDR_PLUGIN_DB_JSON" file="resources\plugin_metadata\plugins_chromeos.json" type="BINDATA" /> 5880 </if> 5881- <if expr="desktop_linux"> 5882+ <if expr="desktop_linux or is_ohos"> 5883 <include name="IDR_PLUGIN_DB_JSON" file="resources\plugin_metadata\plugins_linux.json" type="BINDATA" /> 5884 </if> 5885 <if expr="not is_android"> 5886@@ -154,7 +154,7 @@ 5887 <include name="IDR_MANAGEMENT_ICONS_JS" file="${root_gen_dir}/chrome/browser/resources/management/icons.js" use_base_dir="false" type="BINDATA" preprocess="true" /> 5888 </if> 5889 <include name="IDR_URL_MOJOM_LITE_JS" file="${root_gen_dir}\url\mojom\url.mojom-lite.js" use_base_dir="false" type="BINDATA" /> 5890- <if expr="is_win or is_macosx or desktop_linux or chromeos"> 5891+ <if expr="is_win or is_macosx or desktop_linux or chromeos or is_ohos"> 5892 <include name="IDR_SYNC_DISABLED_CONFIRMATION_HTML" file="resources\signin\sync_confirmation\sync_disabled_confirmation.html" type="BINDATA" /> 5893 <include name="IDR_SYNC_DISABLED_CONFIRMATION_APP_JS" file="${root_gen_dir}\chrome\browser\resources\signin\sync_confirmation\sync_disabled_confirmation_app.js" use_base_dir="false" preprocess="true" type="BINDATA" /> 5894 <include name="IDR_SYNC_CONFIRMATION_HTML" file="resources\signin\sync_confirmation\sync_confirmation.html" type="BINDATA" /> 5895@@ -166,7 +166,7 @@ 5896 <include name="IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_REFRESHED_ILLUSTRATION_SVG" file="resources\signin\sync_confirmation\images\sync_confirmation_refreshed_illustration.svg" type="BINDATA" /> 5897 <include name="IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_REFRESHED_ILLUSTRATION_DARK_SVG" file="resources\signin\sync_confirmation\images\sync_confirmation_refreshed_illustration_dark.svg" type="BINDATA" /> 5898 </if> 5899- <if expr="is_win or is_macosx or desktop_linux"> 5900+ <if expr="is_win or is_macosx or desktop_linux or is_ohos"> 5901 <include name="IDR_SIGNIN_DICE_WEB_INTERCEPT_HTML" file="resources\signin\dice_web_signin_intercept\dice_web_signin_intercept.html" type="BINDATA" /> 5902 <include name="IDR_SIGNIN_DICE_WEB_INTERCEPT_APP_JS" file="${root_gen_dir}\chrome\browser\resources\signin\dice_web_signin_intercept\dice_web_signin_intercept_app.js" use_base_dir="false" type="BINDATA" /> 5903 <include name="IDR_SIGNIN_DICE_WEB_INTERCEPT_BROWSER_PROXY_JS" file="resources/signin/dice_web_signin_intercept/dice_web_signin_intercept_browser_proxy.js" type="BINDATA" /> 5904diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc 5905index dec02fc1fc..2edbadc772 100644 5906--- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc 5907+++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc 5908@@ -656,6 +656,7 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( 5909 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB)) { 5910 base::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); 5911 5912+#if BUILDFLAG(FULL_SAFE_BROWSING) 5913 network::mojom::NetworkContext* safe_browsing_context = nullptr; 5914 safe_browsing::SafeBrowsingService* sb_service = 5915 g_browser_process->safe_browsing_service(); 5916@@ -668,7 +669,7 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( 5917 base::BindOnce( 5918 &ChromeBrowsingDataRemoverDelegate::CreateTaskCompletionClosure, 5919 base::Unretained(this), TracingDataType::kCookies)); 5920- 5921+#endif 5922 if (filter_builder->GetMode() == 5923 BrowsingDataFilterBuilder::Mode::kPreserve) { 5924 PrivacySandboxSettings* privacy_sandbox_settings = 5925diff --git a/chrome/browser/chrome_browser_main_linux.cc b/chrome/browser/chrome_browser_main_linux.cc 5926index a9e15135f9..aff941f13c 100644 5927--- a/chrome/browser/chrome_browser_main_linux.cc 5928+++ b/chrome/browser/chrome_browser_main_linux.cc 5929@@ -79,7 +79,7 @@ void ChromeBrowserMainPartsLinux::PreProfileInit() { 5930 5931 5932 void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() { 5933-#if !BUILDFLAG(IS_CHROMEOS_ASH) 5934+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_OHOS) 5935 bluez::BluezDBusManager::Initialize(nullptr /* system_bus */); 5936 #endif 5937 5938@@ -87,7 +87,7 @@ void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() { 5939 } 5940 5941 void ChromeBrowserMainPartsLinux::PostDestroyThreads() { 5942-#if !BUILDFLAG(IS_CHROMEOS_ASH) 5943+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_OHOS) 5944 bluez::BluezDBusManager::Shutdown(); 5945 bluez::BluezDBusThreadManager::Shutdown(); 5946 #endif 5947diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc 5948index 3c69c7da0f..a99bc28830 100644 5949--- a/chrome/browser/chrome_content_browser_client.cc 5950+++ b/chrome/browser/chrome_content_browser_client.cc 5951@@ -506,7 +506,7 @@ 5952 #include "chrome/browser/browser_switcher/browser_switcher_navigation_throttle.h" 5953 #endif 5954 5955-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 5956+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 5957 #include "components/crash/core/app/crash_switches.h" 5958 #include "components/crash/core/app/crashpad.h" 5959 #endif 5960@@ -999,18 +999,26 @@ class CertificateReportingServiceCertReporter : public SSLCertReporter { 5961 public: 5962 explicit CertificateReportingServiceCertReporter( 5963 content::WebContents* web_contents) 5964+ #if BUILDFLAG(FULL_SAFE_BROWSING) 5965 : service_(CertificateReportingServiceFactory::GetForBrowserContext( 5966 web_contents->GetBrowserContext())) {} 5967+ #else 5968+ {} 5969+ #endif 5970 ~CertificateReportingServiceCertReporter() override {} 5971 5972 // SSLCertReporter implementation 5973 void ReportInvalidCertificateChain( 5974 const std::string& serialized_report) override { 5975+#if BUILDFLAG(FULL_SAFE_BROWSING) 5976 service_->Send(serialized_report); 5977+#endif 5978 } 5979 5980 private: 5981+#if BUILDFLAG(FULL_SAFE_BROWSING) 5982 CertificateReportingService* service_; 5983+#endif 5984 5985 DISALLOW_COPY_AND_ASSIGN(CertificateReportingServiceCertReporter); 5986 }; 5987@@ -1440,7 +1448,9 @@ void ChromeContentBrowserClient::PostAfterStartupTask( 5988 InitNetworkContextsParentDirectory(); 5989 5990 DCHECK_CURRENTLY_ON(BrowserThread::UI); 5991+#if BUILDFLAG(FULL_SAFE_BROWSING) 5992 safe_browsing_service_ = g_browser_process->safe_browsing_service(); 5993+#endif 5994 } 5995 5996 bool ChromeContentBrowserClient::IsBrowserStartupComplete() { 5997@@ -4154,6 +4164,7 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( 5998 &throttles); 5999 #endif 6000 6001+#if BUILDFLAG(FULL_SAFE_BROWSING) 6002 throttles.push_back( 6003 std::make_unique<safe_browsing::SafeBrowsingNavigationThrottle>(handle)); 6004 6005@@ -4162,6 +4173,7 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( 6006 std::make_unique<safe_browsing::DelayedWarningNavigationThrottle>( 6007 handle)); 6008 } 6009+#endif 6010 6011 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 6012 // of lacros-chrome is complete. 6013@@ -5368,6 +5380,7 @@ ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate( 6014 const std::vector<std::string>& allowlist_domains) { 6015 DCHECK_CURRENTLY_ON(BrowserThread::IO); 6016 6017+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6018 // Should not bypass safe browsing check if the check is for enterprise 6019 // lookup. 6020 if (!safe_browsing_enabled_for_profile && !should_check_on_sb_disabled) 6021@@ -5388,6 +5401,10 @@ ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate( 6022 } 6023 6024 return safe_browsing_url_checker_delegate_; 6025+#else 6026+ return nullptr; 6027+#endif 6028+ 6029 } 6030 6031 safe_browsing::RealTimeUrlLookupServiceBase* 6032@@ -5399,7 +5416,7 @@ ChromeContentBrowserClient::GetUrlLookupService( 6033 if (!safe_browsing_service_) { 6034 return nullptr; 6035 } 6036- 6037+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6038 Profile* profile = Profile::FromBrowserContext(browser_context); 6039 6040 #if BUILDFLAG(SAFE_BROWSING_DB_LOCAL) 6041@@ -5407,12 +5424,14 @@ ChromeContentBrowserClient::GetUrlLookupService( 6042 return safe_browsing::ChromeEnterpriseRealTimeUrlLookupServiceFactory:: 6043 GetForProfile(profile); 6044 } 6045-#endif 6046+#endif // BUILDFLAG(SAFE_BROWSING_DB_LOCAL) 6047 6048 if (is_consumer_lookup_enabled) { 6049 return safe_browsing::RealTimeUrlLookupServiceFactory::GetForProfile( 6050 profile); 6051 } 6052+#endif // BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6053+ 6054 return nullptr; 6055 } 6056 6057diff --git a/chrome/browser/chrome_content_browser_client_receiver_bindings.cc b/chrome/browser/chrome_content_browser_client_receiver_bindings.cc 6058index a406da288f..005625bb1c 100644 6059--- a/chrome/browser/chrome_content_browser_client_receiver_bindings.cc 6060+++ b/chrome/browser/chrome_content_browser_client_receiver_bindings.cc 6061@@ -75,6 +75,7 @@ 6062 6063 namespace { 6064 6065+#if BUILDFLAG(FULL_SAFE_BROWSING) 6066 // Helper method for ExposeInterfacesToRenderer() that checks the latest 6067 // SafeBrowsing pref value on the UI thread before hopping over to the IO 6068 // thread. 6069@@ -87,6 +88,8 @@ void MaybeCreateSafeBrowsingForRenderer( 6070 const std::vector<std::string>& allowlist_domains)> 6071 get_checker_delegate, 6072 mojo::PendingReceiver<safe_browsing::mojom::SafeBrowsing> receiver) { 6073+ 6074+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6075 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 6076 6077 content::RenderProcessHost* render_process_host = 6078@@ -126,7 +129,10 @@ void MaybeCreateSafeBrowsingForRenderer( 6079 /*should_check_on_sb_disabled=*/false, 6080 allowlist_domains), 6081 std::move(receiver))); 6082+#endif 6083+ 6084 } 6085+#endif 6086 6087 } // namespace 6088 6089@@ -164,6 +170,7 @@ void ChromeContentBrowserClient::ExposeInterfacesToRenderer( 6090 if (safe_browsing_service_) { 6091 content::ResourceContext* resource_context = 6092 render_process_host->GetBrowserContext()->GetResourceContext(); 6093+ #if BUILDFLAG(FULL_SAFE_BROWSING) 6094 registry->AddInterface( 6095 base::BindRepeating( 6096 &MaybeCreateSafeBrowsingForRenderer, render_process_host->GetID(), 6097@@ -172,6 +179,7 @@ void ChromeContentBrowserClient::ExposeInterfacesToRenderer( 6098 &ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate, 6099 base::Unretained(this))), 6100 ui_task_runner); 6101+ #endif 6102 } 6103 #endif 6104 6105diff --git a/chrome/browser/chrome_notification_types.h b/chrome/browser/chrome_notification_types.h 6106index 858b7d94eb..0bfb0098f8 100644 6107--- a/chrome/browser/chrome_notification_types.h 6108+++ b/chrome/browser/chrome_notification_types.h 6109@@ -170,7 +170,7 @@ enum NotificationType { 6110 NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 6111 #endif 6112 6113-#if defined(TOOLKIT_VIEWS) 6114+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 6115 // Notification that the nested loop using during tab dragging has returned. 6116 // Used for testing. 6117 // TODO(https://crbug.com/1174797): Remove. 6118diff --git a/chrome/browser/component_updater/file_type_policies_component_installer.cc b/chrome/browser/component_updater/file_type_policies_component_installer.cc 6119index f47bb82a97..16968830f7 100644 6120--- a/chrome/browser/component_updater/file_type_policies_component_installer.cc 6121+++ b/chrome/browser/component_updater/file_type_policies_component_installer.cc 6122@@ -51,8 +51,11 @@ void LoadFileTypesFromDisk(const base::FilePath& pb_path) { 6123 return; 6124 } 6125 6126+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6127 safe_browsing::FileTypePolicies::GetInstance()->PopulateFromDynamicUpdate( 6128 binary_pb); 6129+#endif 6130+ 6131 } 6132 6133 } // namespace 6134diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc 6135index 78f6754375..0efa47f797 100644 6136--- a/chrome/browser/devtools/devtools_window.cc 6137+++ b/chrome/browser/devtools/devtools_window.cc 6138@@ -1563,8 +1563,10 @@ void DevToolsWindow::ShowCertificateViewer(const std::string& cert_chain) { 6139 int tab = 0; 6140 if (!FindInspectedBrowserAndTabIndex(inspected_contents, &browser, &tab)) 6141 return; 6142+#if !defined(OS_OHOS) 6143 gfx::NativeWindow parent = browser->window()->GetNativeWindow(); 6144 ::ShowCertificateViewer(inspected_contents, parent, cert.get()); 6145+#endif 6146 } 6147 6148 void DevToolsWindow::OnLoadCompleted() { 6149diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc 6150index cebed2a6c0..61adceb5ba 100644 6151--- a/chrome/browser/download/chrome_download_manager_delegate.cc 6152+++ b/chrome/browser/download/chrome_download_manager_delegate.cc 6153@@ -72,6 +72,7 @@ 6154 #include "components/prefs/pref_service.h" 6155 #include "components/safe_browsing/buildflags.h" 6156 #include "components/safe_browsing/core/file_type_policies.h" 6157+#include "components/safe_browsing/buildflags.h" 6158 #include "components/services/quarantine/public/mojom/quarantine.mojom.h" 6159 #include "components/services/quarantine/quarantine_impl.h" 6160 #include "content/public/browser/browser_task_traits.h" 6161@@ -92,6 +93,10 @@ 6162 #include "services/network/public/cpp/network_connection_tracker.h" 6163 #include "ui/base/l10n/l10n_util.h" 6164 6165+#if defined(OS_OHOS) 6166+#include "net/http/http_content_disposition.h" 6167+#endif 6168+ 6169 #if defined(OS_ANDROID) 6170 #include "base/android/path_utils.h" 6171 #include "chrome/browser/download/android/chrome_duplicate_download_infobar_delegate.h" 6172@@ -131,7 +136,11 @@ using content::DownloadManager; 6173 using download::DownloadItem; 6174 using download::DownloadPathReservationTracker; 6175 using download::PathValidationResult; 6176+ 6177+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6178 using safe_browsing::DownloadFileType; 6179+#endif 6180+ 6181 using safe_browsing::DownloadProtectionService; 6182 6183 namespace { 6184@@ -394,13 +403,14 @@ ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { 6185 6186 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { 6187 download_manager_ = dm; 6188- 6189+#if BUILDFLAG(FULL_SAFE_BROWSING) 6190 safe_browsing::SafeBrowsingService* sb_service = 6191 g_browser_process->safe_browsing_service(); 6192 if (sb_service && !profile_->IsOffTheRecord()) { 6193 // Include this download manager in the set monitored by safe browsing. 6194 sb_service->AddDownloadManager(dm); 6195 } 6196+#endif 6197 } 6198 6199 #if defined(OS_ANDROID) 6200@@ -741,13 +751,14 @@ void ChromeDownloadManagerDelegate::ChooseSavePath( 6201 6202 void ChromeDownloadManagerDelegate::SanitizeSavePackageResourceName( 6203 base::FilePath* filename) { 6204+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6205 safe_browsing::FileTypePolicies* file_type_policies = 6206 safe_browsing::FileTypePolicies::GetInstance(); 6207 6208 if (file_type_policies->GetFileDangerLevel(*filename) == 6209 safe_browsing::DownloadFileType::NOT_DANGEROUS) 6210 return; 6211- 6212+#endif 6213 base::FilePath default_filename = base::FilePath::FromUTF8Unsafe( 6214 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 6215 *filename = filename->AddExtension(default_filename.BaseName().value()); 6216@@ -1449,7 +1460,10 @@ void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined( 6217 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); 6218 #endif 6219 6220+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6221 DownloadItemModel(item).SetDangerLevel(target_info->danger_level); 6222+#endif 6223+ 6224 } 6225 if (ShouldBlockFile(target_info->danger_type, item)) { 6226 MaybeReportDangerousDownloadBlocked( 6227diff --git a/chrome/browser/download/download_commands.cc b/chrome/browser/download/download_commands.cc 6228index fe0e3b6bed..e254f35a33 100644 6229--- a/chrome/browser/download/download_commands.cc 6230+++ b/chrome/browser/download/download_commands.cc 6231@@ -28,7 +28,7 @@ 6232 #include "ui/base/clipboard/scoped_clipboard_writer.h" 6233 6234 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 6235- defined(OS_MAC) 6236+ defined(OS_MAC) || defined(OS_OHOS) 6237 #include "chrome/browser/ui/browser.h" 6238 #include "chrome/browser/ui/browser_finder.h" 6239 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 6240@@ -156,7 +156,7 @@ void DownloadCommands::ExecuteCommand(Command command) { 6241 } 6242 6243 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 6244- defined(OS_CHROMEOS) 6245+ defined(OS_CHROMEOS) || defined(OS_OHOS) 6246 6247 Browser* DownloadCommands::GetBrowser() const { 6248 chrome::ScopedTabbedBrowserDisplayer browser_displayer(model_->profile()); 6249@@ -179,7 +179,7 @@ bool DownloadCommands::CanOpenPdfInSystemViewer() const { 6250 return IsDownloadPdf() && 6251 (IsAdobeReaderDefaultPDFViewer() ? is_adobe_pdf_reader_up_to_date 6252 : true); 6253-#elif defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS) 6254+#elif defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 6255 return IsDownloadPdf(); 6256 #endif 6257 } 6258diff --git a/chrome/browser/download/download_commands.h b/chrome/browser/download/download_commands.h 6259index 82d66ff175..f8f7737856 100644 6260--- a/chrome/browser/download/download_commands.h 6261+++ b/chrome/browser/download/download_commands.h 6262@@ -50,7 +50,7 @@ class DownloadCommands { 6263 void ExecuteCommand(Command command); 6264 6265 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 6266- defined(OS_MAC) 6267+ defined(OS_MAC) || defined(OS_OHOS) 6268 bool IsDownloadPdf() const; 6269 bool CanOpenPdfInSystemViewer() const; 6270 Browser* GetBrowser() const; 6271diff --git a/chrome/browser/download/download_danger_prompt.cc b/chrome/browser/download/download_danger_prompt.cc 6272index 3643ca2131..44d34d2829 100644 6273--- a/chrome/browser/download/download_danger_prompt.cc 6274+++ b/chrome/browser/download/download_danger_prompt.cc 6275@@ -19,7 +19,7 @@ using safe_browsing::ClientDownloadResponse; 6276 using safe_browsing::ClientSafeBrowsingReportRequest; 6277 6278 namespace { 6279- 6280+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6281 const char kDownloadDangerPromptPrefix[] = "Download.DownloadDangerPrompt"; 6282 6283 // Converts DownloadDangerType into their corresponding string. 6284@@ -66,9 +66,11 @@ const char* GetDangerTypeString( 6285 NOTREACHED(); 6286 return nullptr; 6287 } 6288+#endif 6289 6290 } // namespace 6291 6292+#if BUILDFLAG(FULL_SAFE_BROWSING) 6293 void DownloadDangerPrompt::SendSafeBrowsingDownloadReport( 6294 ClientSafeBrowsingReportRequest::ReportType report_type, 6295 bool did_proceed, 6296@@ -109,10 +111,12 @@ void DownloadDangerPrompt::SendSafeBrowsingDownloadReport( 6297 else 6298 DLOG(ERROR) << "Unable to serialize the threat report."; 6299 } 6300+#endif 6301 6302 void DownloadDangerPrompt::RecordDownloadDangerPrompt( 6303 bool did_proceed, 6304 const download::DownloadItem& download) { 6305+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6306 int64_t file_type_uma_value = 6307 safe_browsing::FileTypePolicies::GetInstance()->UmaValueForFile( 6308 download.GetTargetFilePath()); 6309@@ -128,4 +132,5 @@ void DownloadDangerPrompt::RecordDownloadDangerPrompt( 6310 GetDangerTypeString(danger_type)), 6311 file_type_uma_value); 6312 } 6313+#endif 6314 } 6315diff --git a/chrome/browser/download/download_danger_prompt.h b/chrome/browser/download/download_danger_prompt.h 6316index 274d59d136..c2574b525a 100644 6317--- a/chrome/browser/download/download_danger_prompt.h 6318+++ b/chrome/browser/download/download_danger_prompt.h 6319@@ -7,6 +7,7 @@ 6320 6321 #include "base/callback_forward.h" 6322 #include "components/safe_browsing/core/proto/csd.pb.h" 6323+#include "components/safe_browsing/buildflags.h" 6324 6325 namespace content { 6326 class WebContents; 6327@@ -53,6 +54,7 @@ class DownloadDangerPrompt { 6328 // respective button click handler. 6329 virtual void InvokeActionForTesting(Action action) = 0; 6330 6331+#if BUILDFLAG(FULL_SAFE_BROWSING) 6332 // Sends download recovery report to safe browsing backend. 6333 // Since it only records download url (DownloadItem::GetURL()), user's 6334 // action (click through or not) and its download danger type, it isn't gated 6335@@ -63,6 +65,7 @@ class DownloadDangerPrompt { 6336 safe_browsing::ClientSafeBrowsingReportRequest::ReportType report_type, 6337 bool did_proceed, 6338 const download::DownloadItem& download); 6339+#endif 6340 6341 protected: 6342 // Records UMA stats for a download danger prompt event. 6343diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc 6344index c83a001251..f45dc63ecf 100644 6345--- a/chrome/browser/download/download_item_model.cc 6346+++ b/chrome/browser/download/download_item_model.cc 6347@@ -535,6 +535,7 @@ bool DownloadItemModel::IsCommandEnabled( 6348 return download_->CanOpenDownload() && 6349 !download_crx_util::IsExtensionDownload(*download_); 6350 case DownloadCommands::ALWAYS_OPEN_TYPE: 6351+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6352 // For temporary downloads, the target filename might be a temporary 6353 // filename. Don't base an "Always open" decision based on it. Also 6354 // exclude extensions. 6355@@ -543,6 +544,10 @@ bool DownloadItemModel::IsCommandEnabled( 6356 ->IsAllowedToOpenAutomatically( 6357 download_->GetTargetFilePath()) && 6358 !download_crx_util::IsExtensionDownload(*download_); 6359+#else 6360+ return download_->CanOpenDownload() && 6361+ !download_crx_util::IsExtensionDownload(*download_); 6362+#endif 6363 case DownloadCommands::PAUSE: 6364 return !download_->IsSavePackageDownload() && 6365 DownloadUIModel::IsCommandEnabled(download_commands, command); 6366@@ -702,6 +707,7 @@ void DownloadItemModel::ExecuteCommand(DownloadCommands* download_commands, 6367 DownloadUIModel::ExecuteCommand(download_commands, command); 6368 break; 6369 case DownloadCommands::DEEP_SCAN: 6370+#if BUILDFLAG(FULL_SAFE_BROWSING) 6371 safe_browsing::SafeBrowsingService* sb_service = 6372 g_browser_process->safe_browsing_service(); 6373 if (!sb_service) 6374@@ -727,6 +733,7 @@ void DownloadItemModel::ExecuteCommand(DownloadCommands* download_commands, 6375 safe_browsing::DeepScanningRequest::DeepScanTrigger:: 6376 TRIGGER_APP_PROMPT, 6377 std::move(settings)); 6378+#endif 6379 break; 6380 } 6381 } 6382diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc 6383index 6d82d55acd..1e5e4f9d72 100644 6384--- a/chrome/browser/download/download_prefs.cc 6385+++ b/chrome/browser/download/download_prefs.cc 6386@@ -73,14 +73,14 @@ namespace { 6387 // Consider downloads 'dangerous' if they go to the home directory on Linux and 6388 // to the desktop on any platform. 6389 bool DownloadPathIsDangerous(const base::FilePath& download_path) { 6390-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 6391+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 6392 base::FilePath home_dir = base::GetHomeDir(); 6393 if (download_path == home_dir) { 6394 return true; 6395 } 6396 #endif 6397 6398-#if defined(OS_ANDROID) 6399+#if defined(OS_ANDROID) || defined(OS_OHOS) 6400 // Android does not have a desktop dir. 6401 return false; 6402 #else 6403@@ -271,6 +271,7 @@ DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) { 6404 base::FilePath::StringType(1, base::FilePath::kExtensionSeparator) + 6405 extension); 6406 6407+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6408 // Note that the list of file types that are not allowed to open 6409 // automatically can change in the future. When the list is tightened, it is 6410 // expected that some entries in the users' auto open list will get dropped 6411@@ -279,6 +280,7 @@ DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) { 6412 filename_with_extension)) { 6413 auto_open_by_user_.insert(extension); 6414 } 6415+#endif 6416 } 6417 } 6418 6419@@ -483,11 +485,12 @@ bool DownloadPrefs::IsAutoOpenByPolicy(const GURL& url, 6420 bool DownloadPrefs::EnableAutoOpenByUserBasedOnExtension( 6421 const base::FilePath& file_name) { 6422 base::FilePath::StringType extension = file_name.Extension(); 6423+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6424 if (!FileTypePolicies::GetInstance()->IsAllowedToOpenAutomatically( 6425 file_name)) { 6426 return false; 6427 } 6428- 6429+#endif 6430 DCHECK(extension[0] == base::FilePath::kExtensionSeparator); 6431 extension.erase(0, 1); 6432 6433diff --git a/chrome/browser/download/download_shelf_context_menu.cc b/chrome/browser/download/download_shelf_context_menu.cc 6434index 7efa464116..711893472d 100644 6435--- a/chrome/browser/download/download_shelf_context_menu.cc 6436+++ b/chrome/browser/download/download_shelf_context_menu.cc 6437@@ -146,7 +146,7 @@ std::u16string DownloadShelfContextMenu::GetLabelForCommandId( 6438 : IDS_DOWNLOAD_MENU_PLATFORM_OPEN_ALWAYS; 6439 break; 6440 } 6441-#elif defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS) 6442+#elif defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 6443 if (can_open_pdf_in_system_viewer) { 6444 id = IDS_DOWNLOAD_MENU_PLATFORM_OPEN_ALWAYS; 6445 break; 6446diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc 6447index b5f4616ff8..c1ce60db1b 100644 6448--- a/chrome/browser/download/download_target_determiner.cc 6449+++ b/chrome/browser/download/download_target_determiner.cc 6450@@ -291,14 +291,14 @@ base::FilePath DownloadTargetDeterminer::GenerateFileName() const { 6451 base::FilePath generated_filename = net::GenerateFileName( 6452 download_->GetURL(), download_->GetContentDisposition(), referrer_charset, 6453 suggested_filename, sniffed_mime_type, default_filename); 6454- 6455+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6456 // We don't replace the file extension if sfafe browsing consider the file 6457 // extension to be unsafe. Just let safe browsing scan the generated file. 6458 if (safe_browsing::FileTypePolicies::GetInstance()->IsCheckedBinaryFile( 6459 generated_filename)) { 6460 return generated_filename; 6461 } 6462- 6463+#endif 6464 // If no mime type or explicitly specified a name, don't replace file 6465 // extension. 6466 if (sniffed_mime_type.empty() || !suggested_filename.empty()) 6467@@ -1097,9 +1097,12 @@ DownloadFileType::DangerLevel DownloadTargetDeterminer::GetDangerLevel( 6468 download_->HasUserGesture()) 6469 return DownloadFileType::NOT_DANGEROUS; 6470 6471- DownloadFileType::DangerLevel danger_level = 6472+ DownloadFileType::DangerLevel danger_level = DownloadFileType::NOT_DANGEROUS; 6473+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6474+ danger_level = 6475 safe_browsing::FileTypePolicies::GetInstance()->GetFileDangerLevel( 6476 virtual_path_.BaseName()); 6477+#endif 6478 6479 // A danger level of ALLOW_ON_USER_GESTURE is used to label potentially 6480 // dangerous file types that have a high frequency of legitimate use. We would 6481diff --git a/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc b/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc 6482index d4da2eadd6..8edbefeebb 100644 6483--- a/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc 6484+++ b/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc 6485@@ -37,13 +37,21 @@ 6486 #include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service_factory.h" 6487 #include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h" 6488 #include "chrome/browser/safe_browsing/cloud_content_scanning/file_analysis_request.h" 6489+ 6490+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6491 #include "chrome/browser/safe_browsing/download_protection/check_client_download_request.h" 6492+#endif 6493+ 6494 #include "chrome/grit/generated_resources.h" 6495 #include "components/enterprise/common/proto/connectors.pb.h" 6496 #include "components/policy/core/browser/url_util.h" 6497 #include "components/policy/core/common/chrome_schema.h" 6498 #include "components/prefs/pref_service.h" 6499+ 6500+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6501 #include "components/safe_browsing/core/common/safe_browsing_prefs.h" 6502+#endif 6503+ 6504 #include "components/safe_browsing/core/features.h" 6505 #include "components/url_matcher/url_matcher.h" 6506 #include "content/public/browser/web_contents.h" 6507@@ -137,6 +145,7 @@ bool* UIEnabledStorage() { 6508 return &enabled; 6509 } 6510 6511+#if BUILDFLAG(FULL_SAFE_BROWSING) 6512 safe_browsing::EventResult CalculateEventResult( 6513 const enterprise_connectors::AnalysisSettings& settings, 6514 bool allowed_by_scan_result, 6515@@ -148,7 +157,7 @@ safe_browsing::EventResult CalculateEventResult( 6516 : (should_warn ? safe_browsing::EventResult::WARNED 6517 : safe_browsing::EventResult::BLOCKED); 6518 } 6519- 6520+#endif 6521 } // namespace 6522 6523 ContentAnalysisDelegate::Data::Data() = default; 6524@@ -179,6 +188,7 @@ void ContentAnalysisDelegate::BypassWarnings() { 6525 if (callback_.is_null()) 6526 return; 6527 6528+#if BUILDFLAG(FULL_SAFE_BROWSING) 6529 // Mark the full text as complying and report a warning bypass. 6530 if (text_warning_) { 6531 std::fill(result_.text_results.begin(), result_.text_results.end(), true); 6532@@ -204,6 +214,7 @@ void ContentAnalysisDelegate::BypassWarnings() { 6533 extensions::SafeBrowsingPrivateEventRouter::kTriggerFileUpload, 6534 access_point_, file_info_[index].size, warning.second); 6535 } 6536+#endif 6537 6538 RunCallback(); 6539 } 6540@@ -212,6 +223,7 @@ void ContentAnalysisDelegate::Cancel(bool warning) { 6541 if (callback_.is_null()) 6542 return; 6543 6544+#if BUILDFLAG(FULL_SAFE_BROWSING) 6545 // Don't report this upload as cancelled if the user didn't bypass the 6546 // warning. 6547 if (!warning) { 6548@@ -219,6 +231,7 @@ void ContentAnalysisDelegate::Cancel(bool warning) { 6549 base::TimeTicks::Now() - upload_start_time_, 0, 6550 "CancelledByUser", false); 6551 } 6552+#endif 6553 6554 // Make sure to reject everything. 6555 FillAllResultsWith(false); 6556@@ -356,8 +369,11 @@ ContentAnalysisDelegate::ContentAnalysisDelegate( 6557 CompletionCallback callback, 6558 safe_browsing::DeepScanAccessPoint access_point) 6559 : data_(std::move(data)), 6560- callback_(std::move(callback)), 6561- access_point_(access_point) { 6562+ callback_(std::move(callback)) 6563+#if BUILDFLAG(FULL_SAFE_BROWSING) 6564+ ,access_point_(access_point) 6565+#endif 6566+ { 6567 DCHECK(web_contents); 6568 profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext()); 6569 url_ = web_contents->GetLastCommittedURL(); 6570@@ -372,9 +388,12 @@ void ContentAnalysisDelegate::StringRequestCallback( 6571 int64_t content_size = 0; 6572 for (const std::u16string& entry : data_.text) 6573 content_size += (entry.size() * sizeof(char16_t)); 6574+ 6575+#if BUILDFLAG(FULL_SAFE_BROWSING) 6576 RecordDeepScanMetrics(access_point_, 6577 base::TimeTicks::Now() - upload_start_time_, 6578 content_size, result, response); 6579+#endif 6580 6581 text_request_complete_ = true; 6582 auto action = enterprise_connectors::GetHighestPrecedenceAction(response); 6583@@ -386,11 +405,13 @@ void ContentAnalysisDelegate::StringRequestCallback( 6584 std::fill(result_.text_results.begin(), result_.text_results.end(), 6585 text_complies); 6586 6587+#if BUILDFLAG(FULL_SAFE_BROWSING) 6588 MaybeReportDeepScanningVerdict( 6589 profile_, url_, "Text data", std::string(), "text/plain", 6590 extensions::SafeBrowsingPrivateEventRouter::kTriggerWebContentUpload, 6591 access_point_, content_size, result, response, 6592 CalculateEventResult(data_.settings, text_complies, should_warn)); 6593+#endif 6594 6595 if (!text_complies) { 6596 if (should_warn) { 6597@@ -419,11 +440,13 @@ void ContentAnalysisDelegate::CompleteFileRequestCallback( 6598 bool should_warn = action == enterprise_connectors::TriggeredRule::WARN; 6599 result_.paths_results[index] = file_complies; 6600 6601+#if BUILDFLAG(FULL_SAFE_BROWSING) 6602 MaybeReportDeepScanningVerdict( 6603 profile_, url_, path.AsUTF8Unsafe(), file_info_[index].sha256, mime_type, 6604 extensions::SafeBrowsingPrivateEventRouter::kTriggerFileUpload, 6605 access_point_, file_info_[index].size, result, response, 6606 CalculateEventResult(data_.settings, file_complies, should_warn)); 6607+#endif 6608 6609 ++file_result_count_; 6610 6611@@ -452,9 +475,11 @@ void ContentAnalysisDelegate::FileRequestCallback( 6612 DCHECK(it != data_.paths.end()); 6613 size_t index = std::distance(data_.paths.begin(), it); 6614 6615+#if BUILDFLAG(FULL_SAFE_BROWSING) 6616 RecordDeepScanMetrics(access_point_, 6617 base::TimeTicks::Now() - upload_start_time_, 6618 file_info_[index].size, result, response); 6619+#endif 6620 6621 base::ThreadPool::PostTaskAndReplyWithResult( 6622 FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()}, 6623@@ -467,10 +492,12 @@ void ContentAnalysisDelegate::FileRequestCallback( 6624 bool ContentAnalysisDelegate::UploadData() { 6625 upload_start_time_ = base::TimeTicks::Now(); 6626 6627+#if BUILDFLAG(FULL_SAFE_BROWSING) 6628 // Create a text request and a file request for each file. 6629 PrepareTextRequest(); 6630 for (const base::FilePath& path : data_.paths) 6631 PrepareFileRequest(path); 6632+#endif 6633 6634 data_uploaded_ = true; 6635 // Do not add code under this comment. The above line should be the last thing 6636@@ -479,6 +506,7 @@ bool ContentAnalysisDelegate::UploadData() { 6637 return !text_request_complete_ || file_result_count_ != data_.paths.size(); 6638 } 6639 6640+#if BUILDFLAG(FULL_SAFE_BROWSING) 6641 void ContentAnalysisDelegate::PrepareTextRequest() { 6642 std::string full_text; 6643 for (const auto& text : data_.text) 6644@@ -534,6 +562,7 @@ void ContentAnalysisDelegate::PrepareRequest( 6645 for (const std::string& tag : data_.settings.tags) 6646 request->add_tag(tag); 6647 } 6648+#endif 6649 6650 void ContentAnalysisDelegate::FillAllResultsWith(bool status) { 6651 std::fill(result_.text_results.begin(), result_.text_results.end(), status); 6652@@ -541,7 +570,11 @@ void ContentAnalysisDelegate::FillAllResultsWith(bool status) { 6653 } 6654 6655 BinaryUploadService* ContentAnalysisDelegate::GetBinaryUploadService() { 6656+#if BUILDFLAG(FULL_SAFE_BROWSING) 6657 return safe_browsing::BinaryUploadServiceFactory::GetForProfile(profile_); 6658+#else 6659+ return nullptr; 6660+#endif 6661 } 6662 6663 void ContentAnalysisDelegate::UploadTextForDeepScanning( 6664diff --git a/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h b/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h 6665index fbab5d66e5..8df980e1fb 100644 6666--- a/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h 6667+++ b/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h 6668@@ -22,6 +22,7 @@ 6669 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" 6670 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 6671 #include "components/enterprise/common/proto/connectors.pb.h" 6672+#include "components/safe_browsing/buildflags.h" 6673 #include "content/public/browser/web_contents_view_delegate.h" 6674 #include "url/gurl.h" 6675 6676@@ -247,6 +248,7 @@ class ContentAnalysisDelegate { 6677 // to true right before returning. 6678 bool UploadData(); 6679 6680+#if BUILDFLAG(FULL_SAFE_BROWSING) 6681 // Prepares an upload request for the text in |data_|. If |data_.text| is 6682 // empty, this method does nothing. 6683 void PrepareTextRequest(); 6684@@ -260,6 +262,7 @@ class ContentAnalysisDelegate { 6685 // service. 6686 void PrepareRequest(enterprise_connectors::AnalysisConnector connector, 6687 safe_browsing::BinaryUploadService::Request* request); 6688+#endif 6689 6690 // Fills the arrays in |result_| with the given boolean status. 6691 void FillAllResultsWith(bool status); 6692@@ -350,8 +353,10 @@ class ContentAnalysisDelegate { 6693 // Pointer to UI when enabled. 6694 ContentAnalysisDialog* dialog_ = nullptr; 6695 6696+#if BUILDFLAG(FULL_SAFE_BROWSING) 6697 // Access point to use to record UMA metrics. 6698 safe_browsing::DeepScanAccessPoint access_point_; 6699+#endif 6700 6701 // Scanning result to be shown to the user once every request is done. 6702 FinalResult final_result_ = FinalResult::SUCCESS; 6703diff --git a/chrome/browser/enterprise/connectors/connectors_service.cc b/chrome/browser/enterprise/connectors/connectors_service.cc 6704index 2a28a3e059..493f1acead 100644 6705--- a/chrome/browser/enterprise/connectors/connectors_service.cc 6706+++ b/chrome/browser/enterprise/connectors/connectors_service.cc 6707@@ -265,6 +265,7 @@ base::Optional<std::string> ConnectorsService::GetDMTokenForRealTimeUrlCheck() 6708 return base::nullopt; 6709 } 6710 6711+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6712 safe_browsing::EnterpriseRealTimeUrlCheckMode 6713 ConnectorsService::GetAppliedRealTimeUrlCheck() const { 6714 if (!ConnectorsEnabled() || 6715@@ -277,6 +278,7 @@ ConnectorsService::GetAppliedRealTimeUrlCheck() const { 6716 Profile::FromBrowserContext(context_)->GetPrefs()->GetInteger( 6717 prefs::kSafeBrowsingEnterpriseRealTimeUrlCheckMode)); 6718 } 6719+#endif 6720 6721 ConnectorsManager* ConnectorsService::ConnectorsManagerForTesting() { 6722 return connectors_manager_.get(); 6723diff --git a/chrome/browser/enterprise/connectors/connectors_service.h b/chrome/browser/enterprise/connectors/connectors_service.h 6724index e0415ce336..41dd7f6312 100644 6725--- a/chrome/browser/enterprise/connectors/connectors_service.h 6726+++ b/chrome/browser/enterprise/connectors/connectors_service.h 6727@@ -13,7 +13,12 @@ 6728 #include "components/keyed_service/content/browser_context_keyed_service_factory.h" 6729 #include "components/keyed_service/core/keyed_service.h" 6730 #include "components/policy/core/common/policy_types.h" 6731+#include "components/safe_browsing/buildflags.h" 6732+ 6733+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6734 #include "components/safe_browsing/core/common/safe_browsing_prefs.h" 6735+#endif 6736+ 6737 #include "content/public/browser/browser_context.h" 6738 6739 namespace base { 6740@@ -73,11 +78,13 @@ class ConnectorsService : public KeyedService { 6741 // is no token to use. 6742 base::Optional<std::string> GetDMTokenForRealTimeUrlCheck() const; 6743 6744+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6745 // Returns the value to used by the enterprise real-time URL check Connector 6746 // if it is set and if the scope it's set at has a valid browser-profile 6747 // affiliation. 6748 safe_browsing::EnterpriseRealTimeUrlCheckMode GetAppliedRealTimeUrlCheck() 6749 const; 6750+#endif 6751 6752 // Testing functions. 6753 ConnectorsManager* ConnectorsManagerForTesting(); 6754diff --git a/chrome/browser/enterprise/signals/context_info_fetcher.cc b/chrome/browser/enterprise/signals/context_info_fetcher.cc 6755index 9ab02af1f4..cf299e0761 100644 6756--- a/chrome/browser/enterprise/signals/context_info_fetcher.cc 6757+++ b/chrome/browser/enterprise/signals/context_info_fetcher.cc 6758@@ -50,7 +50,11 @@ void ContextInfoFetcher::Fetch(ContextInfoCallback callback) { 6759 GetAnalysisConnectorProviders(enterprise_connectors::FILE_DOWNLOADED); 6760 info.on_bulk_data_entry_providers = 6761 GetAnalysisConnectorProviders(enterprise_connectors::BULK_DATA_ENTRY); 6762+ 6763+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6764 info.realtime_url_check_mode = GetRealtimeUrlCheckMode(); 6765+#endif 6766+ 6767 info.on_security_event_providers = GetOnSecurityEventProviders(); 6768 info.browser_version = version_info::GetVersionNumber(); 6769 6770@@ -92,10 +96,12 @@ std::vector<std::string> ContextInfoFetcher::GetAnalysisConnectorProviders( 6771 return connectors_service_->GetAnalysisServiceProviderNames(connector); 6772 } 6773 6774+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6775 safe_browsing::EnterpriseRealTimeUrlCheckMode 6776 ContextInfoFetcher::GetRealtimeUrlCheckMode() { 6777 return connectors_service_->GetAppliedRealTimeUrlCheck(); 6778 } 6779+#endif 6780 6781 std::vector<std::string> ContextInfoFetcher::GetOnSecurityEventProviders() { 6782 return connectors_service_->GetReportingServiceProviderNames( 6783diff --git a/chrome/browser/enterprise/signals/context_info_fetcher.h b/chrome/browser/enterprise/signals/context_info_fetcher.h 6784index 098c428352..8a89e4818a 100644 6785--- a/chrome/browser/enterprise/signals/context_info_fetcher.h 6786+++ b/chrome/browser/enterprise/signals/context_info_fetcher.h 6787@@ -6,10 +6,15 @@ 6788 #define CHROME_BROWSER_ENTERPRISE_SIGNALS_CONTEXT_INFO_FETCHER_H_ 6789 6790 #include <string> 6791+#include <memory> 6792 #include <vector> 6793 6794 #include "base/callback_forward.h" 6795+#include "components/safe_browsing/buildflags.h" 6796+ 6797+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6798 #include "components/safe_browsing/core/common/safe_browsing_prefs.h" 6799+#endif 6800 6801 namespace content { 6802 class BrowserContext; 6803@@ -35,7 +40,11 @@ struct ContextInfo { 6804 std::vector<std::string> on_file_downloaded_providers; 6805 std::vector<std::string> on_bulk_data_entry_providers; 6806 std::vector<std::string> on_security_event_providers; 6807+ 6808+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6809 safe_browsing::EnterpriseRealTimeUrlCheckMode realtime_url_check_mode; 6810+#endif 6811+ 6812 std::string browser_version; 6813 }; 6814 6815@@ -76,7 +85,9 @@ class ContextInfoFetcher { 6816 std::vector<std::string> GetAnalysisConnectorProviders( 6817 enterprise_connectors::AnalysisConnector connector); 6818 6819+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6820 safe_browsing::EnterpriseRealTimeUrlCheckMode GetRealtimeUrlCheckMode(); 6821+#endif 6822 6823 std::vector<std::string> GetOnSecurityEventProviders(); 6824 6825diff --git a/chrome/browser/error_reporting/BUILD.gn b/chrome/browser/error_reporting/BUILD.gn 6826index f9ba0712b8..2ae2230074 100644 6827--- a/chrome/browser/error_reporting/BUILD.gn 6828+++ b/chrome/browser/error_reporting/BUILD.gn 6829@@ -5,7 +5,7 @@ import("//build/config/chromeos/ui_mode.gni") 6830 6831 # TODO(crbug.com/1129544) This is currently disabled due to Windows DLL 6832 # thunking issues. Fix & re-enable. 6833-assert(is_linux || is_chromeos_ash || is_chromeos_lacros) 6834+assert(is_linux || is_chromeos_ash || is_chromeos_lacros || is_ohos) 6835 6836 source_set("constants") { 6837 sources = [ 6838diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn 6839index c8a4da2105..37117db7fc 100644 6840--- a/chrome/browser/extensions/BUILD.gn 6841+++ b/chrome/browser/extensions/BUILD.gn 6842@@ -1148,7 +1148,7 @@ static_library("extensions") { 6843 "//components/enterprise/common/proto:connectors_proto", 6844 "//components/keep_alive_registry", 6845 ] 6846- if (is_linux || is_chromeos) { 6847+ if (is_linux || is_chromeos || is_ohos) { 6848 sources += 6849 [ "api/image_writer_private/removable_storage_provider_linux.cc" ] 6850 } 6851@@ -1272,7 +1272,7 @@ static_library("extensions") { 6852 deps += [ "//rlz:rlz_lib" ] 6853 } 6854 6855- if (toolkit_views) { 6856+ if (toolkit_views || is_ohos) { 6857 deps += [ "//ui/views" ] 6858 } 6859 6860diff --git a/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc b/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc 6861index 2b40124456..76ddaa32cf 100644 6862--- a/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc 6863+++ b/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc 6864@@ -245,6 +245,8 @@ base::FilePath GetEndpointVerificationDir() { 6865 if (path.empty()) 6866 #elif defined(OS_MAC) 6867 if (!base::PathService::Get(base::DIR_APP_DATA, &path)) 6868+#elif defined(OS_OHOS) 6869+ if (!base::PathService::Get(base::DIR_OHOS_APP_DATA, &path)) 6870 #else 6871 if (true) 6872 #endif 6873diff --git a/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc 6874index 0c795e2e8c..023a6453ab 100644 6875--- a/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc 6876+++ b/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc 6877@@ -68,10 +68,16 @@ api::enterprise_reporting_private::ContextInfo ToContextInfo( 6878 info.on_file_downloaded_providers = signals.on_file_downloaded_providers; 6879 info.on_bulk_data_entry_providers = signals.on_bulk_data_entry_providers; 6880 info.on_security_event_providers = signals.on_security_event_providers; 6881+ 6882+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6883 switch (signals.realtime_url_check_mode) { 6884 case safe_browsing::REAL_TIME_CHECK_DISABLED: 6885+#endif 6886+ 6887 info.realtime_url_check_mode = extensions::api:: 6888 enterprise_reporting_private::REALTIME_URL_CHECK_MODE_DISABLED; 6889+ 6890+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 6891 break; 6892 case safe_browsing::REAL_TIME_CHECK_FOR_MAINFRAME_ENABLED: 6893 info.realtime_url_check_mode = 6894@@ -79,6 +85,8 @@ api::enterprise_reporting_private::ContextInfo ToContextInfo( 6895 REALTIME_URL_CHECK_MODE_ENABLED_MAIN_FRAME; 6896 break; 6897 } 6898+#endif 6899+ 6900 info.browser_version = signals.browser_version; 6901 6902 return info; 6903diff --git a/chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.cc b/chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.cc 6904index c32321a8ed..f3ce4b7f5e 100644 6905--- a/chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.cc 6906+++ b/chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.cc 6907@@ -15,6 +15,10 @@ 6908 6909 namespace extensions { 6910 6911+NetworkingPrivateDelegateFactory::UIDelegateFactory::UIDelegateFactory() {} 6912+ 6913+NetworkingPrivateDelegateFactory::UIDelegateFactory::~UIDelegateFactory() {} 6914+ 6915 NetworkingPrivateUIDelegateFactoryImpl:: 6916 NetworkingPrivateUIDelegateFactoryImpl() {} 6917 6918diff --git a/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_api.cc b/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_api.cc 6919index 579d813e1b..b70366c0e3 100644 6920--- a/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_api.cc 6921+++ b/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_api.cc 6922@@ -22,10 +22,10 @@ using safe_browsing::SafeBrowsingNavigationObserverManager; 6923 namespace extensions { 6924 6925 namespace { 6926- 6927+#if BUILDFLAG(FULL_SAFE_BROWSING) 6928 // The number of user gestures we trace back for the referrer chain. 6929 const int kReferrerUserGestureLimit = 2; 6930- 6931+#endif 6932 } // namespace 6933 6934 //////////////////////////////////////////////////////////////////////////////// 6935@@ -52,6 +52,7 @@ SafeBrowsingPrivateGetReferrerChainFunction::Run() { 6936 base::StringPrintf("Could not find tab with id %d.", params->tab_id))); 6937 } 6938 6939+#if BUILDFLAG(FULL_SAFE_BROWSING) 6940 Profile* profile = Profile::FromBrowserContext(browser_context()); 6941 if (!SafeBrowsingNavigationObserverManager::IsEnabledAndReady(profile)) 6942 return RespondNow(NoArguments()); 6943@@ -86,6 +87,9 @@ SafeBrowsingPrivateGetReferrerChainFunction::Run() { 6944 return RespondNow(ArgumentList( 6945 api::safe_browsing_private::GetReferrerChain::Results::Create( 6946 referrer_entries))); 6947+#else 6948+ return RespondLater(); 6949+#endif 6950 } 6951 6952 } // namespace extensions 6953diff --git a/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc b/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc 6954index f860532891..60a8fdd25c 100644 6955--- a/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc 6956+++ b/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc 6957@@ -71,6 +71,7 @@ const char kChromeBrowserCloudManagementClientDescription[] = 6958 #endif 6959 const char kProfilePolicyClientDescription[] = "a profile-level user"; 6960 6961+#if defined(FULL_SAFE_BROWSING) 6962 void AddAnalysisConnectorVerdictToEvent( 6963 const enterprise_connectors::ContentAnalysisResponse::Result& result, 6964 base::Value* event) { 6965@@ -101,6 +102,7 @@ std::string MalwareRuleToThreatType(const std::string& rule_name) { 6966 return "UNKNOWN"; 6967 } 6968 } 6969+#endif // FULL_SAFE_BROWSING 6970 6971 bool IsClientValid(const std::string& dm_token, 6972 policy::CloudPolicyClient* client) { 6973@@ -236,6 +238,7 @@ void SafeBrowsingPrivateEventRouter::OnPolicySpecifiedPasswordReuseDetected( 6974 event_router_->BroadcastEvent(std::move(extension_event)); 6975 } 6976 6977+#if defined(FULL_SAFE_BROWSING) 6978 auto settings = GetReportingSettings(); 6979 if (!settings.has_value() || 6980 settings->enabled_event_names.count(kKeyPasswordReuseEvent) == 0) { 6981@@ -250,6 +253,8 @@ void SafeBrowsingPrivateEventRouter::OnPolicySpecifiedPasswordReuseDetected( 6982 6983 ReportRealtimeEvent(kKeyPasswordReuseEvent, std::move(settings.value()), 6984 std::move(event)); 6985+#endif 6986+ 6987 } 6988 6989 void SafeBrowsingPrivateEventRouter::OnPolicySpecifiedPasswordChanged( 6990@@ -305,6 +310,7 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadOpened( 6991 event_router_->BroadcastEvent(std::move(extension_event)); 6992 } 6993 6994+#if defined(FULL_SAFE_BROWSING) 6995 auto settings = GetReportingSettings(); 6996 if (!settings.has_value() || 6997 settings->enabled_event_names.count(kKeyDangerousDownloadEvent) == 0) { 6998@@ -322,14 +328,18 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadOpened( 6999 if (content_size >= 0) 7000 event.SetIntKey(kKeyContentSize, content_size); 7001 event.SetStringKey(kKeyTrigger, kTriggerFileDownload); 7002+#if BUILDFLAG(FULL_SAFE_BROWSING) 7003 event.SetStringKey( 7004 kKeyEventResult, 7005 safe_browsing::EventResultToString(safe_browsing::EventResult::BYPASSED)); 7006+#endif 7007 event.SetBoolKey(kKeyClickedThrough, true); 7008 event.SetStringKey(kKeyThreatType, DangerTypeToThreatType(danger_type)); 7009 7010 ReportRealtimeEvent(kKeyDangerousDownloadEvent, std::move(settings.value()), 7011 std::move(event)); 7012+#endif // FULL_SAFE_BROWSING 7013+ 7014 } 7015 7016 void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialShown( 7017@@ -357,6 +367,7 @@ void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialShown( 7018 event_router_->BroadcastEvent(std::move(extension_event)); 7019 } 7020 7021+#if BUILDFLAG(FULL_SAFE_BROWSING) 7022 auto settings = GetReportingSettings(); 7023 if (!settings.has_value() || 7024 settings->enabled_event_names.count(kKeyInterstitialEvent) == 0) { 7025@@ -379,6 +390,8 @@ void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialShown( 7026 7027 ReportRealtimeEvent(kKeyInterstitialEvent, std::move(settings.value()), 7028 std::move(event)); 7029+#endif // FULL_SAFE_BROWSING 7030+ 7031 } 7032 7033 void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialProceeded( 7034@@ -406,6 +419,7 @@ void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialProceeded( 7035 event_router_->BroadcastEvent(std::move(extension_event)); 7036 } 7037 7038+#if defined(FULL_SAFE_BROWSING) 7039 auto settings = GetReportingSettings(); 7040 if (!settings.has_value() || 7041 settings->enabled_event_names.count(kKeyInterstitialEvent) == 0) { 7042@@ -418,12 +432,16 @@ void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialProceeded( 7043 event.SetIntKey(kKeyNetErrorCode, net_error_code); 7044 event.SetStringKey(kKeyProfileUserName, params.user_name); 7045 event.SetBoolKey(kKeyClickedThrough, true); 7046+ 7047+#if BUILDFLAG(FULL_SAFE_BROWSING) 7048 event.SetStringKey( 7049 kKeyEventResult, 7050 safe_browsing::EventResultToString(safe_browsing::EventResult::BYPASSED)); 7051- 7052+#endif 7053 ReportRealtimeEvent(kKeyInterstitialEvent, std::move(settings.value()), 7054 std::move(event)); 7055+#endif // FULL_SAFE_BROWSING 7056+ 7057 } 7058 7059 void SafeBrowsingPrivateEventRouter::OnAnalysisConnectorResult( 7060@@ -436,6 +454,8 @@ void SafeBrowsingPrivateEventRouter::OnAnalysisConnectorResult( 7061 const enterprise_connectors::ContentAnalysisResponse::Result& result, 7062 const int64_t content_size, 7063 safe_browsing::EventResult event_result) { 7064+ 7065+#if defined(FULL_SAFE_BROWSING) 7066 if (result.tag() == "malware") { 7067 DCHECK_EQ(1, result.triggered_rules().size()); 7068 OnDangerousDeepScanningResult( 7069@@ -447,6 +467,8 @@ void SafeBrowsingPrivateEventRouter::OnAnalysisConnectorResult( 7070 OnSensitiveDataEvent(url, file_name, download_digest_sha256, mime_type, 7071 trigger, result, content_size, event_result); 7072 } 7073+#endif // FULL_SAFE_BROWSING 7074+ 7075 } 7076 7077 void SafeBrowsingPrivateEventRouter::OnDangerousDeepScanningResult( 7078@@ -461,6 +483,8 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDeepScanningResult( 7079 const std::string& malware_family, 7080 const std::string& malware_category, 7081 const std::string& evidence_locker_filepath) { 7082+ 7083+#if defined(FULL_SAFE_BROWSING) 7084 auto settings = GetReportingSettings(); 7085 if (!settings.has_value() || 7086 settings->enabled_event_names.count(kKeyDangerousDownloadEvent) == 0) { 7087@@ -479,8 +503,12 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDeepScanningResult( 7088 if (content_size >= 0) 7089 event.SetIntKey(kKeyContentSize, content_size); 7090 event.SetStringKey(kKeyTrigger, trigger); 7091+ 7092+#if BUILDFLAG(FULL_SAFE_BROWSING) 7093 event.SetStringKey(kKeyEventResult, 7094 safe_browsing::EventResultToString(event_result)); 7095+#endif 7096+ 7097 event.SetBoolKey(kKeyClickedThrough, 7098 event_result == safe_browsing::EventResult::BYPASSED); 7099 if (!malware_family.empty()) 7100@@ -493,6 +521,8 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDeepScanningResult( 7101 7102 ReportRealtimeEvent(kKeyDangerousDownloadEvent, std::move(settings.value()), 7103 std::move(event)); 7104+#endif // FULL_SAFE_BROWSING 7105+ 7106 } 7107 7108 void SafeBrowsingPrivateEventRouter::OnSensitiveDataEvent( 7109@@ -504,6 +534,8 @@ void SafeBrowsingPrivateEventRouter::OnSensitiveDataEvent( 7110 const enterprise_connectors::ContentAnalysisResponse::Result& result, 7111 const int64_t content_size, 7112 safe_browsing::EventResult event_result) { 7113+ 7114+#if defined(FULL_SAFE_BROWSING) 7115 auto settings = GetReportingSettings(); 7116 if (!settings.has_value() || 7117 settings->enabled_event_names.count(kKeySensitiveDataEvent) == 0) { 7118@@ -521,8 +553,12 @@ void SafeBrowsingPrivateEventRouter::OnSensitiveDataEvent( 7119 if (content_size >= 0) 7120 event.SetIntKey(kKeyContentSize, content_size); 7121 event.SetStringKey(kKeyTrigger, trigger); 7122+ 7123+#if BUILDFLAG(FULL_SAFE_BROWSING) 7124 event.SetStringKey(kKeyEventResult, 7125 safe_browsing::EventResultToString(event_result)); 7126+#endif 7127+ 7128 event.SetBoolKey(kKeyClickedThrough, 7129 event_result == safe_browsing::EventResult::BYPASSED); 7130 if (!result.evidence_locker_filepath().empty()) { 7131@@ -534,6 +570,8 @@ void SafeBrowsingPrivateEventRouter::OnSensitiveDataEvent( 7132 7133 ReportRealtimeEvent(kKeySensitiveDataEvent, std::move(settings.value()), 7134 std::move(event)); 7135+#endif // FULL_SAFE_BROWSING 7136+ 7137 } 7138 7139 void SafeBrowsingPrivateEventRouter::OnAnalysisConnectorWarningBypassed( 7140@@ -545,6 +583,8 @@ void SafeBrowsingPrivateEventRouter::OnAnalysisConnectorWarningBypassed( 7141 safe_browsing::DeepScanAccessPoint access_point, 7142 const enterprise_connectors::ContentAnalysisResponse::Result& result, 7143 const int64_t content_size) { 7144+ 7145+#if defined(FULL_SAFE_BROWSING) 7146 auto settings = GetReportingSettings(); 7147 if (!settings.has_value() || 7148 settings->enabled_event_names.count(kKeySensitiveDataEvent) == 0) { 7149@@ -562,9 +602,13 @@ void SafeBrowsingPrivateEventRouter::OnAnalysisConnectorWarningBypassed( 7150 if (content_size >= 0) 7151 event.SetIntKey(kKeyContentSize, content_size); 7152 event.SetStringKey(kKeyTrigger, trigger); 7153+ 7154+#if BUILDFLAG(FULL_SAFE_BROWSING) 7155 event.SetStringKey( 7156 kKeyEventResult, 7157 safe_browsing::EventResultToString(safe_browsing::EventResult::BYPASSED)); 7158+#endif 7159+ 7160 event.SetBoolKey(kKeyClickedThrough, true); 7161 if (!result.evidence_locker_filepath().empty()) { 7162 event.SetStringKey(kKeyEvidenceLockerFilePath, 7163@@ -575,6 +619,8 @@ void SafeBrowsingPrivateEventRouter::OnAnalysisConnectorWarningBypassed( 7164 7165 ReportRealtimeEvent(kKeySensitiveDataEvent, std::move(settings.value()), 7166 std::move(event)); 7167+#endif // FULL_SAFE_BROWSING 7168+ 7169 } 7170 7171 void SafeBrowsingPrivateEventRouter::OnUnscannedFileEvent( 7172@@ -587,6 +633,8 @@ void SafeBrowsingPrivateEventRouter::OnUnscannedFileEvent( 7173 const std::string& reason, 7174 const int64_t content_size, 7175 safe_browsing::EventResult event_result) { 7176+ 7177+#if defined(FULL_SAFE_BROWSING) 7178 auto settings = GetReportingSettings(); 7179 if (!settings.has_value() || 7180 settings->enabled_event_names.count(kKeyUnscannedFileEvent) == 0) { 7181@@ -605,13 +653,19 @@ void SafeBrowsingPrivateEventRouter::OnUnscannedFileEvent( 7182 if (content_size >= 0) 7183 event.SetIntKey(kKeyContentSize, content_size); 7184 event.SetStringKey(kKeyTrigger, trigger); 7185+ 7186+#if BUILDFLAG(FULL_SAFE_BROWSING) 7187 event.SetStringKey(kKeyEventResult, 7188 safe_browsing::EventResultToString(event_result)); 7189+#endif 7190+ 7191 event.SetBoolKey(kKeyClickedThrough, 7192 event_result == safe_browsing::EventResult::BYPASSED); 7193 7194 ReportRealtimeEvent(kKeyUnscannedFileEvent, std::move(settings.value()), 7195 std::move(event)); 7196+#endif // FULL_SAFE_BROWSING 7197+ 7198 } 7199 7200 void SafeBrowsingPrivateEventRouter::OnDangerousDownloadEvent( 7201@@ -654,8 +708,11 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadEvent( 7202 if (content_size >= 0) 7203 event.SetIntKey(kKeyContentSize, content_size); 7204 event.SetStringKey(kKeyTrigger, kTriggerFileDownload); 7205+ 7206+#if BUILDFLAG(FULL_SAFE_BROWSING) 7207 event.SetStringKey(kKeyEventResult, 7208 safe_browsing::EventResultToString(event_result)); 7209+#endif 7210 7211 ReportRealtimeEvent(kKeyDangerousDownloadEvent, std::move(settings.value()), 7212 std::move(event)); 7213@@ -680,6 +737,8 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadWarningBypassed( 7214 const std::string& threat_type, 7215 const std::string& mime_type, 7216 const int64_t content_size) { 7217+ 7218+#if defined(FULL_SAFE_BROWSING) 7219 auto settings = GetReportingSettings(); 7220 if (!settings.has_value() || 7221 settings->enabled_event_names.count(kKeyDangerousDownloadEvent) == 0) { 7222@@ -699,12 +758,17 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadWarningBypassed( 7223 if (content_size >= 0) 7224 event.SetIntKey(kKeyContentSize, content_size); 7225 event.SetStringKey(kKeyTrigger, kTriggerFileDownload); 7226+ 7227+#if BUILDFLAG(FULL_SAFE_BROWSING) 7228 event.SetStringKey( 7229 kKeyEventResult, 7230 safe_browsing::EventResultToString(safe_browsing::EventResult::BYPASSED)); 7231+#endif 7232 7233 ReportRealtimeEvent(kKeyDangerousDownloadEvent, std::move(settings.value()), 7234 std::move(event)); 7235+#endif // FULL_SAFE_BROWSING 7236+ 7237 } 7238 7239 // static 7240@@ -977,7 +1041,11 @@ void SafeBrowsingPrivateEventRouter::ReportRealtimeEvent( 7241 } 7242 7243 std::string SafeBrowsingPrivateEventRouter::GetProfileUserName() const { 7244+#if BUILDFLAG(FULL_SAFE_BROWSING) 7245 return safe_browsing::GetProfileEmail(identity_manager_); 7246+#else 7247+ return ""; 7248+#endif 7249 } 7250 7251 #if BUILDFLAG(IS_CHROMEOS_ASH) 7252diff --git a/chrome/browser/extensions/api/settings_private/generated_prefs.cc b/chrome/browser/extensions/api/settings_private/generated_prefs.cc 7253index f9704d6f06..3843913b15 100644 7254--- a/chrome/browser/extensions/api/settings_private/generated_prefs.cc 7255+++ b/chrome/browser/extensions/api/settings_private/generated_prefs.cc 7256@@ -15,6 +15,7 @@ 7257 #include "chrome/browser/safe_browsing/generated_safe_browsing_pref.h" 7258 #include "chrome/common/extensions/api/settings_private.h" 7259 #include "components/content_settings/core/common/pref_names.h" 7260+#include "components/safe_browsing/buildflags.h" 7261 7262 #if BUILDFLAG(IS_CHROMEOS_ASH) 7263 #include "chrome/browser/extensions/api/settings_private/chromeos_resolve_time_zone_by_geolocation_method_short.h" 7264@@ -99,8 +100,10 @@ void GeneratedPrefs::CreatePrefs() { 7265 profile_); 7266 prefs_[kGeneratedPasswordLeakDetectionPref] = 7267 std::make_unique<GeneratedPasswordLeakDetectionPref>(profile_); 7268+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7269 prefs_[safe_browsing::kGeneratedSafeBrowsingPref] = 7270 std::make_unique<safe_browsing::GeneratedSafeBrowsingPref>(profile_); 7271+#endif 7272 prefs_[content_settings::kGeneratedNotificationPref] = 7273 std::make_unique<content_settings::GeneratedNotificationPref>(profile_); 7274 } 7275diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc 7276index 1a1294016d..626b8e1772 100644 7277--- a/chrome/browser/extensions/api/settings_private/prefs_util.cc 7278+++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc 7279@@ -287,9 +287,10 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetAllowlistedKeys() { 7280 settings_api::PrefType::PREF_TYPE_BOOLEAN; 7281 (*s_allowlist)[::prefs::kSafeBrowsingScoutReportingEnabled] = 7282 settings_api::PrefType::PREF_TYPE_BOOLEAN; 7283+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7284 (*s_allowlist)[::safe_browsing::kGeneratedSafeBrowsingPref] = 7285 settings_api::PrefType::PREF_TYPE_NUMBER; 7286- 7287+#endif 7288 // Sync and personalization page. 7289 (*s_allowlist)[::prefs::kSearchSuggestEnabled] = 7290 settings_api::PrefType::PREF_TYPE_BOOLEAN; 7291diff --git a/chrome/browser/extensions/api/tabs/windows_event_router.cc b/chrome/browser/extensions/api/tabs/windows_event_router.cc 7292index 734cefc15a..90c4c4e70e 100644 7293--- a/chrome/browser/extensions/api/tabs/windows_event_router.cc 7294+++ b/chrome/browser/extensions/api/tabs/windows_event_router.cc 7295@@ -164,6 +164,8 @@ WindowsEventRouter::WindowsEventRouter(Profile* profile) 7296 content::NotificationService::AllSources()); 7297 #elif defined(TOOLKIT_VIEWS) 7298 views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); 7299+#elif defined(OS_OHOS) 7300+ LOG(INFO) << "WindowsEventRouter::WindowsEventRouter TODO for OS_OHOS"; 7301 #else 7302 #error Unsupported 7303 #endif 7304diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc 7305index d4cdfc2f5a..2675713312 100644 7306--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc 7307+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc 7308@@ -42,6 +42,7 @@ 7309 #include "components/prefs/pref_service.h" 7310 #include "components/prefs/scoped_user_pref_update.h" 7311 #include "components/signin/public/identity_manager/identity_manager.h" 7312+#include "components/safe_browsing/buildflags.h" 7313 #include "content/public/browser/gpu_feature_checker.h" 7314 #include "content/public/browser/storage_partition.h" 7315 #include "content/public/browser/web_contents.h" 7316@@ -204,8 +205,10 @@ void ShowBlockedByParentDialog(const Extension* extension, 7317 7318 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) 7319 7320+#if BUILDFLAG(FULL_SAFE_BROWSING) 7321 // The number of user gestures to trace back for the referrer chain. 7322 const int kExtensionReferrerUserGestureLimit = 2; 7323+#endif 7324 7325 WebstoreInstaller::Delegate* test_webstore_installer_delegate = nullptr; 7326 7327@@ -1098,6 +1101,7 @@ WebstorePrivateGetReferrerChainFunction:: 7328 7329 ExtensionFunction::ResponseAction 7330 WebstorePrivateGetReferrerChainFunction::Run() { 7331+#if BUILDFLAG(FULL_SAFE_BROWSING) 7332 Profile* profile = chrome_details_.GetProfile(); 7333 if (!SafeBrowsingNavigationObserverManager::IsEnabledAndReady(profile)) 7334 return RespondNow(ArgumentList( 7335@@ -1143,6 +1147,9 @@ WebstorePrivateGetReferrerChainFunction::Run() { 7336 return RespondNow( 7337 ArgumentList(api::webstore_private::GetReferrerChain::Results::Create( 7338 serialized_referrer_proto))); 7339+#else 7340+ return RespondLater(); 7341+#endif 7342 } 7343 7344 WebstorePrivateGetExtensionStatusFunction:: 7345diff --git a/chrome/browser/extensions/blocklist_state_fetcher.cc b/chrome/browser/extensions/blocklist_state_fetcher.cc 7346index fd18b0b520..36826b2da6 100644 7347--- a/chrome/browser/extensions/blocklist_state_fetcher.cc 7348+++ b/chrome/browser/extensions/blocklist_state_fetcher.cc 7349@@ -32,6 +32,7 @@ BlocklistStateFetcher::~BlocklistStateFetcher() { 7350 void BlocklistStateFetcher::Request(const std::string& id, 7351 RequestCallback callback) { 7352 DCHECK_CURRENTLY_ON(BrowserThread::UI); 7353+#if BUILDFLAG(FULL_SAFE_BROWSING) 7354 if (!safe_browsing_config_) { 7355 if (g_browser_process && g_browser_process->safe_browsing_service()) { 7356 SetSafeBrowsingConfig( 7357@@ -57,6 +58,7 @@ void BlocklistStateFetcher::Request(const std::string& id, 7358 g_browser_process->safe_browsing_service()->GetURLLoaderFactory(); 7359 } 7360 } 7361+#endif 7362 7363 SendRequest(id); 7364 } 7365diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc 7366index e41f860400..94c95543b5 100644 7367--- a/chrome/browser/extensions/extension_service.cc 7368+++ b/chrome/browser/extensions/extension_service.cc 7369@@ -150,6 +150,7 @@ const char* const kObsoleteComponentExtensionIds[] = { 7370 "ljoammodoonkhnehlncldjelhidljdpi" // Genius 7371 }; 7372 7373+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7374 void ReportExtensionDisabledRemotely(bool should_be_remotely_disabled, 7375 ExtensionUpdateCheckDataKey reason) { 7376 // Report that the extension is newly disabled due to Omaha attributes. 7377@@ -182,6 +183,7 @@ void ReportNoUpdateCheckKeys() { 7378 base::UmaHistogramEnumeration("Extensions.ExtensionDisabledRemotely", 7379 ExtensionUpdateCheckDataKey::kNoKey); 7380 } 7381+#endif 7382 7383 void ReportReenableExtensionFromMalware() { 7384 base::UmaHistogramCounts100("Extensions.ExtensionReenabledRemotely", 1); 7385@@ -885,6 +887,7 @@ bool ExtensionService::IsExtensionEnabled( 7386 return extension_registrar_.IsExtensionEnabled(extension_id); 7387 } 7388 7389+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7390 void ExtensionService::PerformActionBasedOnOmahaAttributes( 7391 const std::string& extension_id, 7392 const base::Value& attributes) { 7393@@ -925,6 +928,7 @@ void ExtensionService::HandleMalwareOmahaAttribute( 7394 // Show an error for the newly blocklisted extension. 7395 error_controller_->ShowErrorIfNeeded(); 7396 } 7397+#endif 7398 7399 void ExtensionService::MaybeEnableRemotelyDisabledExtension( 7400 const std::string& extension_id) { 7401diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h 7402index 88c7c5968f..abeef88116 100644 7403--- a/chrome/browser/extensions/extension_service.h 7404+++ b/chrome/browser/extensions/extension_service.h 7405@@ -31,6 +31,7 @@ 7406 #include "chrome/browser/profiles/profile_manager_observer.h" 7407 #include "chrome/browser/upgrade_detector/upgrade_observer.h" 7408 #include "components/sync/model/string_ordinal.h" 7409+#include "components/safe_browsing/buildflags.h" 7410 #include "content/public/browser/notification_observer.h" 7411 #include "content/public/browser/notification_registrar.h" 7412 #include "extensions/browser/api/declarative_net_request/ruleset_install_pref.h" 7413@@ -274,9 +275,11 @@ class ExtensionService : public ExtensionServiceInterface, 7414 void RemoveDisableReasonAndMaybeEnable(const std::string& extension_id, 7415 disable_reason::DisableReason reason); 7416 7417+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7418 // Performs action based on Omaha attributes for the extension. 7419 void PerformActionBasedOnOmahaAttributes(const std::string& extension_id, 7420 const base::Value& attributes); 7421+#endif 7422 7423 // Disables the extension. If the extension is already disabled, just adds 7424 // the |disable_reasons| (a bitmask of disable_reason::DisableReason - there 7425@@ -557,9 +560,11 @@ class ExtensionService : public ExtensionServiceInterface, 7426 // Helper method to determine if an extension can be blocked. 7427 bool CanBlockExtension(const Extension* extension) const; 7428 7429+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7430 // Handles the malware Omaha attribute for remotely disabled extensions. 7431 void HandleMalwareOmahaAttribute(const std::string& extension_id, 7432 const base::Value& attributes); 7433+#endif 7434 7435 // Enables an extension that was only previously disabled remotely. 7436 void MaybeEnableRemotelyDisabledExtension(const std::string& extension_id); 7437diff --git a/chrome/browser/extensions/extension_system_impl.cc b/chrome/browser/extensions/extension_system_impl.cc 7438index e016a21fd0..e8ff8bf118 100644 7439--- a/chrome/browser/extensions/extension_system_impl.cc 7440+++ b/chrome/browser/extensions/extension_system_impl.cc 7441@@ -464,8 +464,12 @@ void ExtensionSystemImpl::InstallUpdate( 7442 void ExtensionSystemImpl::PerformActionBasedOnOmahaAttributes( 7443 const std::string& extension_id, 7444 const base::Value& attributes) { 7445+ 7446+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7447 extension_service()->PerformActionBasedOnOmahaAttributes(extension_id, 7448 attributes); 7449+#endif 7450+ 7451 } 7452 7453 bool ExtensionSystemImpl::FinishDelayedInstallationIfReady( 7454diff --git a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc 7455index 89317d47d3..92dc6e2f67 100644 7456--- a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc 7457+++ b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc 7458@@ -25,7 +25,11 @@ 7459 #include "chrome/browser/file_system_access/file_system_access_permission_context_factory.h" 7460 #include "chrome/browser/file_system_access/file_system_access_permission_request_manager.h" 7461 #include "chrome/browser/profiles/profile.h" 7462+ 7463+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7464 #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h" 7465+#endif 7466+ 7467 #include "chrome/browser/ui/file_system_access_dialogs.h" 7468 #include "chrome/common/chrome_paths.h" 7469 #include "components/content_settings/core/browser/host_content_settings_map.h" 7470@@ -278,6 +282,7 @@ BindResultCallbackToCurrentSequence( 7471 base::SequencedTaskRunnerHandle::Get(), std::move(callback)); 7472 } 7473 7474+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7475 void DoSafeBrowsingCheckOnUIThread( 7476 content::GlobalFrameRoutingId frame_id, 7477 std::unique_ptr<content::FileSystemAccessWriteItem> item, 7478@@ -350,6 +355,7 @@ InterpretSafeBrowsingResult(safe_browsing::DownloadCheckResult result) { 7479 NOTREACHED(); 7480 return ChromeFileSystemAccessPermissionContext::AfterWriteCheckResult::kBlock; 7481 } 7482+#endif // SAFE_BROWSING_AVAILABLE 7483 7484 std::string GenerateLastPickedDirectoryKey(const std::string& id) { 7485 return id.empty() ? kDefaultLastPickedDirectoryKey 7486@@ -825,6 +831,7 @@ void ChromeFileSystemAccessPermissionContext::ConfirmSensitiveDirectoryAccess( 7487 std::move(callback))); 7488 } 7489 7490+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7491 void ChromeFileSystemAccessPermissionContext::PerformAfterWriteChecks( 7492 std::unique_ptr<content::FileSystemAccessWriteItem> item, 7493 content::GlobalFrameRoutingId frame_id, 7494@@ -846,6 +853,7 @@ void ChromeFileSystemAccessPermissionContext::PerformAfterWriteChecks( 7495 }, 7496 base::SequencedTaskRunnerHandle::Get(), std::move(callback)))); 7497 } 7498+#endif 7499 7500 void ChromeFileSystemAccessPermissionContext:: 7501 DidConfirmSensitiveDirectoryAccess( 7502diff --git a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h 7503index ec5c2bc932..ddc69f1419 100644 7504--- a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h 7505+++ b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h 7506@@ -12,6 +12,7 @@ 7507 #include "components/content_settings/core/common/content_settings_types.h" 7508 #include "components/keyed_service/core/keyed_service.h" 7509 #include "components/permissions/permission_util.h" 7510+#include "components/safe_browsing/buildflags.h" 7511 #include "content/public/browser/file_system_access_permission_context.h" 7512 #include "third_party/blink/public/mojom/permissions/permission_status.mojom.h" 7513 7514@@ -63,10 +64,14 @@ class ChromeFileSystemAccessPermissionContext 7515 HandleType handle_type, 7516 content::GlobalFrameRoutingId frame_id, 7517 base::OnceCallback<void(SensitiveDirectoryResult)> callback) override; 7518+ 7519+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7520 void PerformAfterWriteChecks( 7521 std::unique_ptr<content::FileSystemAccessWriteItem> item, 7522 content::GlobalFrameRoutingId frame_id, 7523 base::OnceCallback<void(AfterWriteCheckResult)> callback) override; 7524+#endif 7525+ 7526 bool CanObtainReadPermission(const url::Origin& origin) override; 7527 bool CanObtainWritePermission(const url::Origin& origin) override; 7528 7529diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc 7530index 3127164f14..d8f5c2212c 100644 7531--- a/chrome/browser/first_run/first_run.cc 7532+++ b/chrome/browser/first_run/first_run.cc 7533@@ -278,7 +278,7 @@ void SetupInitialPrefsFromInstallPrefs( 7534 7535 // -- Platform-specific functions -- 7536 7537-#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_BSD) 7538+#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_BSD) && !defined(OS_OHOS) 7539 bool IsOrganicFirstRun() { 7540 std::string brand; 7541 google_brand::GetBrand(&brand); 7542diff --git a/chrome/browser/first_run/first_run_dialog.h b/chrome/browser/first_run/first_run_dialog.h 7543index ba4a13b672..e3a09a8dbe 100644 7544--- a/chrome/browser/first_run/first_run_dialog.h 7545+++ b/chrome/browser/first_run/first_run_dialog.h 7546@@ -12,7 +12,7 @@ 7547 // Hide this function on platforms where the dialog does not exist. 7548 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 7549 // of lacros-chrome is complete. 7550-#if defined(OS_MAC) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) 7551+#if defined(OS_MAC) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 7552 7553 class Profile; 7554 7555diff --git a/chrome/browser/first_run/first_run_internal_posix.cc b/chrome/browser/first_run/first_run_internal_posix.cc 7556index c9f8852839..c1908fd6fd 100644 7557--- a/chrome/browser/first_run/first_run_internal_posix.cc 7558+++ b/chrome/browser/first_run/first_run_internal_posix.cc 7559@@ -46,7 +46,7 @@ enum class ForcedShowDialogState { 7560 ForcedShowDialogState g_forced_show_dialog_state = 7561 ForcedShowDialogState::kNotForced; 7562 7563-#if !BUILDFLAG(IS_CHROMEOS_ASH) 7564+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_OHOS) 7565 // Returns whether the first run dialog should be shown. This is only true for 7566 // certain builds, and only if the user has not already set preferences. In a 7567 // real, official-build first run, initializes the default metrics reporting if 7568@@ -97,7 +97,7 @@ void ForceFirstRunDialogShownForTesting(bool shown) { 7569 } 7570 7571 void DoPostImportPlatformSpecificTasks(Profile* profile) { 7572-#if !BUILDFLAG(IS_CHROMEOS_ASH) 7573+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_OHOS) 7574 if (!ShouldShowFirstRunDialog()) 7575 return; 7576 7577diff --git a/chrome/browser/font_access/chrome_font_access_delegate.cc b/chrome/browser/font_access/chrome_font_access_delegate.cc 7578index 7262851220..b7f1328045 100644 7579--- a/chrome/browser/font_access/chrome_font_access_delegate.cc 7580+++ b/chrome/browser/font_access/chrome_font_access_delegate.cc 7581@@ -20,7 +20,12 @@ ChromeFontAccessDelegate::RunChooser( 7582 // TODO(crbug.com/1151464): Decide whether or not to extend/refactor the 7583 // bubble view launched by chrome::ShowDeviceChooserDialog() or build a new 7584 // one. 7585+#if !defined(OS_OHOS) 7586 return std::make_unique<FontAccessChooser>(chrome::ShowDeviceChooserDialog( 7587 frame, std::make_unique<FontAccessChooserController>( 7588 frame, selection, std::move(callback)))); 7589+#else 7590+ LOG(INFO) << "ChromeFontAccessDelegate::RunChooser TODO for OS_OHOS"; 7591+ return nullptr; 7592+#endif 7593 } 7594diff --git a/chrome/browser/hid/chrome_hid_delegate.cc b/chrome/browser/hid/chrome_hid_delegate.cc 7595index 671000bc7c..464dff397e 100644 7596--- a/chrome/browser/hid/chrome_hid_delegate.cc 7597+++ b/chrome/browser/hid/chrome_hid_delegate.cc 7598@@ -40,9 +40,14 @@ std::unique_ptr<content::HidChooser> ChromeHidDelegate::RunChooser( 7599 if (!permission_observer_.IsObservingSources()) 7600 permission_observer_.Add(chooser_context); 7601 7602+#if !defined(OS_OHOS) 7603 return std::make_unique<HidChooser>(chrome::ShowDeviceChooserDialog( 7604 frame, std::make_unique<HidChooserController>(frame, std::move(filters), 7605 std::move(callback)))); 7606+#else 7607+ LOG(INFO) << "ChromeHidDelegate::RunChooser TODO for OS_OHOS"; 7608+ return nullptr; 7609+#endif 7610 } 7611 7612 bool ChromeHidDelegate::CanRequestDevicePermission( 7613diff --git a/chrome/browser/intranet_redirect_detector.h b/chrome/browser/intranet_redirect_detector.h 7614index 19a86ab0ca..df63b8315d 100644 7615--- a/chrome/browser/intranet_redirect_detector.h 7616+++ b/chrome/browser/intranet_redirect_detector.h 7617@@ -28,7 +28,7 @@ class SimpleURLLoader; 7618 class PrefRegistrySimple; 7619 7620 #if !(defined(OS_MAC) || defined(OS_WIN) || defined(OS_LINUX) || \ 7621- defined(OS_CHROMEOS)) 7622+ defined(OS_CHROMEOS) || defined(OS_OHOS)) 7623 #error "IntranetRedirectDetector should only be built on Desktop platforms." 7624 #endif 7625 7626diff --git a/chrome/browser/media/router/discovery/discovery_network_list_posix.cc b/chrome/browser/media/router/discovery/discovery_network_list_posix.cc 7627index 6bae32098d..443f01efdc 100644 7628--- a/chrome/browser/media/router/discovery/discovery_network_list_posix.cc 7629+++ b/chrome/browser/media/router/discovery/discovery_network_list_posix.cc 7630@@ -40,6 +40,7 @@ using sll = struct sockaddr_dl; 7631 #define SOCKET_ADDRESS(s) (LLADDR(s)) 7632 #endif 7633 7634+#if !defined(OS_OHOS) 7635 void GetDiscoveryNetworkInfoListImpl( 7636 const struct ifaddrs* if_list, 7637 std::vector<DiscoveryNetworkInfo>* network_info_list) { 7638@@ -88,12 +89,14 @@ void GetDiscoveryNetworkInfoListImpl( 7639 SOCKET_ADDRESS_LEN(ll_addr))}); 7640 } 7641 } 7642+#endif 7643 7644 } // namespace 7645 7646 std::vector<DiscoveryNetworkInfo> GetDiscoveryNetworkInfoList() { 7647 std::vector<DiscoveryNetworkInfo> network_ids; 7648 7649+#if !defined(OS_OHOS) 7650 struct ifaddrs* if_list; 7651 if (getifaddrs(&if_list)) { 7652 return network_ids; 7653@@ -102,6 +105,9 @@ std::vector<DiscoveryNetworkInfo> GetDiscoveryNetworkInfoList() { 7654 GetDiscoveryNetworkInfoListImpl(if_list, &network_ids); 7655 StableSortDiscoveryNetworkInfo(network_ids.begin(), network_ids.end()); 7656 freeifaddrs(if_list); 7657+#else 7658+ LOG(INFO) << "GetDiscoveryNetworkInfoList TODO in OS_OHOS"; 7659+#endif 7660 return network_ids; 7661 } 7662 7663diff --git a/chrome/browser/media/webrtc/display_media_access_handler.cc b/chrome/browser/media/webrtc/display_media_access_handler.cc 7664index 73e1390ca2..38f283718c 100644 7665--- a/chrome/browser/media/webrtc/display_media_access_handler.cc 7666+++ b/chrome/browser/media/webrtc/display_media_access_handler.cc 7667@@ -107,6 +107,7 @@ void DisplayMediaAccessHandler::HandleRequest( 7668 return; 7669 } 7670 7671+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7672 // SafeBrowsing Delayed Warnings experiment can delay some SafeBrowsing 7673 // warnings until user interaction. If the current page has a delayed warning, 7674 // it'll have a user interaction observer attached. Show the warning 7675@@ -121,6 +122,7 @@ void DisplayMediaAccessHandler::HandleRequest( 7676 observer->OnDesktopCaptureRequest(); 7677 return; 7678 } 7679+#endif 7680 7681 #if defined(OS_MAC) 7682 // Do not allow picker UI to be shown on a page that isn't in the foreground 7683diff --git a/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc b/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc 7684index b8f2ec4114..cef108c8ac 100644 7685--- a/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc 7686+++ b/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc 7687@@ -43,6 +43,8 @@ const char kProduct[] = "Chrome_ChromeOS"; 7688 const char kProduct[] = "Chrome_Linux"; 7689 #elif defined(OS_ANDROID) 7690 const char kProduct[] = "Chrome_Android"; 7691+#elif defined(OS_OHOS) 7692+const char kProduct[] = "Chrome_Ohos"; 7693 #else 7694 #error Platform not supported. 7695 #endif 7696diff --git a/chrome/browser/media/webrtc/webrtc_log_uploader.cc b/chrome/browser/media/webrtc/webrtc_log_uploader.cc 7697index bb05781a99..747f4e2d5f 100644 7698--- a/chrome/browser/media/webrtc/webrtc_log_uploader.cc 7699+++ b/chrome/browser/media/webrtc/webrtc_log_uploader.cc 7700@@ -360,6 +360,8 @@ void WebRtcLogUploader::SetupMultipart( 7701 const char product[] = "Chrome_Android"; 7702 #elif BUILDFLAG(IS_CHROMEOS_ASH) 7703 const char product[] = "Chrome_ChromeOS"; 7704+#elif defined(OS_OHOS) 7705+ const char product[] = "Chrome_Ohos"; 7706 #else 7707 #error Platform not supported. 7708 #endif 7709diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc 7710index 52c6a8e9b1..4e5e9a4c4d 100644 7711--- a/chrome/browser/metrics/chrome_metrics_service_client.cc 7712+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc 7713@@ -800,8 +800,10 @@ void ChromeMetricsServiceClient::RegisterMetricsServiceProviders() { 7714 metrics_service_->RegisterMetricsProvider( 7715 std::make_unique<HttpsEngagementMetricsProvider>()); 7716 7717+#if BUILDFLAG(FULL_SAFE_BROWSING) 7718 metrics_service_->RegisterMetricsProvider( 7719 std::make_unique<CertificateReportingMetricsProvider>()); 7720+#endif 7721 7722 #if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) 7723 metrics_service_->RegisterMetricsProvider( 7724diff --git a/chrome/browser/net/profile_network_context_service.cc b/chrome/browser/net/profile_network_context_service.cc 7725index f0a12b07c4..339024e0d2 100644 7726--- a/chrome/browser/net/profile_network_context_service.cc 7727+++ b/chrome/browser/net/profile_network_context_service.cc 7728@@ -608,6 +608,9 @@ ProfileNetworkContextService::CreateClientCertStore() { 7729 // cert matching is done by the OS as part of the call to show the cert 7730 // selection dialog. 7731 return nullptr; 7732+#elif defined(OS_OHOS) 7733+ LOG(ERROR) << "ProfileNetworkContextService::CreateClientCertStore TODO for OS_OHOS"; 7734+ return nullptr; 7735 #else 7736 #error Unknown platform. 7737 #endif 7738diff --git a/chrome/browser/notifications/notification_display_service_impl.cc b/chrome/browser/notifications/notification_display_service_impl.cc 7739index c50c2208e6..995f3c4631 100644 7740--- a/chrome/browser/notifications/notification_display_service_impl.cc 7741+++ b/chrome/browser/notifications/notification_display_service_impl.cc 7742@@ -29,7 +29,7 @@ 7743 #endif 7744 7745 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || \ 7746- defined(OS_WIN) 7747+ defined(OS_WIN) || defined(OS_OHOS) 7748 #include "chrome/browser/send_tab_to_self/desktop_notification_handler.h" 7749 #include "chrome/browser/sharing/sharing_notification_handler.h" 7750 #endif 7751diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc 7752index 5bccfec4e1..cbf20266f8 100644 7753--- a/chrome/browser/password_manager/chrome_password_manager_client.cc 7754+++ b/chrome/browser/password_manager/chrome_password_manager_client.cc 7755@@ -249,10 +249,11 @@ void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( 7756 autofill::AutofillClient* autofill_client) { 7757 if (FromWebContents(contents)) 7758 return; 7759- 7760+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7761 contents->SetUserData(UserDataKey(), 7762 base::WrapUnique(new ChromePasswordManagerClient( 7763 contents, autofill_client))); 7764+#endif 7765 } 7766 7767 ChromePasswordManagerClient::~ChromePasswordManagerClient() = default; 7768@@ -793,16 +794,22 @@ autofill::LanguageCode ChromePasswordManagerClient::GetPageLanguage() const { 7769 return autofill::LanguageCode(); 7770 } 7771 7772+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7773 safe_browsing::PasswordProtectionService* 7774 ChromePasswordManagerClient::GetPasswordProtectionService() const { 7775+#if BUILDFLAG(FULL_SAFE_BROWSING) 7776 return safe_browsing::ChromePasswordProtectionService:: 7777 GetPasswordProtectionService(profile_); 7778+#else 7779+ return nullptr; 7780+#endif 7781 } 7782 7783 #if defined(ON_FOCUS_PING_ENABLED) 7784 void ChromePasswordManagerClient::CheckSafeBrowsingReputation( 7785 const GURL& form_action, 7786 const GURL& frame_url) { 7787+#if BUILDFLAG(FULL_SAFE_BROWSING) 7788 safe_browsing::PasswordProtectionService* pps = 7789 GetPasswordProtectionService(); 7790 if (pps) { 7791@@ -810,6 +817,7 @@ void ChromePasswordManagerClient::CheckSafeBrowsingReputation( 7792 web_contents(), web_contents()->GetLastCommittedURL(), form_action, 7793 frame_url, pps->GetAccountInfo().hosted_domain); 7794 } 7795+#endif // BUILDFLAG(FULL_SAFE_BROWSING) 7796 } 7797 #endif // defined(ON_FOCUS_PING_ENABLED) 7798 7799@@ -819,6 +827,7 @@ void ChromePasswordManagerClient::CheckProtectedPasswordEntry( 7800 const std::vector<password_manager::MatchingReusedCredential>& 7801 matching_reused_credentials, 7802 bool password_field_exists) { 7803+#if BUILDFLAG(FULL_SAFE_BROWSING) 7804 safe_browsing::PasswordProtectionService* pps = 7805 GetPasswordProtectionService(); 7806 if (!pps) 7807@@ -827,14 +836,18 @@ void ChromePasswordManagerClient::CheckProtectedPasswordEntry( 7808 pps->MaybeStartProtectedPasswordEntryRequest( 7809 web_contents(), web_contents()->GetLastCommittedURL(), username, 7810 password_type, matching_reused_credentials, password_field_exists); 7811+#endif 7812 } 7813+#endif // BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7814 7815 void ChromePasswordManagerClient::LogPasswordReuseDetectedEvent() { 7816+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7817 safe_browsing::PasswordProtectionService* pps = 7818 GetPasswordProtectionService(); 7819 if (pps) { 7820 pps->MaybeLogPasswordReuseDetectedEvent(web_contents()); 7821 } 7822+#endif 7823 } 7824 7825 ukm::SourceId ChromePasswordManagerClient::GetUkmSourceId() { 7826@@ -1274,6 +1287,7 @@ void ChromePasswordManagerClient::OnPaste() { 7827 } 7828 #endif 7829 7830+#if BUILDFLAG(FULL_SAFE_BROWSING) 7831 if (!used_crosapi_workaround) { 7832 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 7833 // Given that this clipboard data read happens in the background and not 7834@@ -1284,7 +1298,8 @@ void ChromePasswordManagerClient::OnPaste() { 7835 ui::EndpointType::kDefault, /*notify_if_restricted=*/false); 7836 clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &data_dst, &text); 7837 } 7838- 7839+#endif 7840+ used_crosapi_workaround = false; 7841 was_on_paste_called_ = true; 7842 password_reuse_detection_manager_.OnPaste(std::move(text)); 7843 } 7844@@ -1316,6 +1331,7 @@ void ChromePasswordManagerClient::OnInputEvent( 7845 #else // !defined(OS_ANDROID) 7846 if (event.GetType() != blink::WebInputEvent::Type::kChar) 7847 return; 7848+#if BUILDFLAG(FULL_SAFE_BROWSING) 7849 const blink::WebKeyboardEvent& key_event = 7850 static_cast<const blink::WebKeyboardEvent&>(event); 7851 // Key & 0x1f corresponds to the value of the key when either the control or 7852@@ -1325,6 +1341,7 @@ void ChromePasswordManagerClient::OnInputEvent( 7853 } else { 7854 password_reuse_detection_manager_.OnKeyPressedCommitted(key_event.text); 7855 } 7856+#endif // full_safe_browsing 7857 #endif // defined(OS_ANDROID) 7858 } 7859 7860@@ -1362,6 +1379,7 @@ bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage( 7861 is_enabled = false; 7862 } 7863 7864+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7865 // SafeBrowsing Delayed Warnings experiment can delay some SafeBrowsing 7866 // warnings until user interaction. If the current page has a delayed warning, 7867 // it'll have a user interaction observer attached. Disable password 7868@@ -1372,6 +1390,7 @@ bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage( 7869 observer->OnPasswordSaveOrAutofillDenied(); 7870 is_enabled = false; 7871 } 7872+#endif 7873 7874 if (log_manager_->IsLoggingActive()) { 7875 password_manager::BrowserSavePasswordProgressLogger logger( 7876diff --git a/chrome/browser/password_manager/chrome_password_manager_client.h b/chrome/browser/password_manager/chrome_password_manager_client.h 7877index f56c171960..dc2426521c 100644 7878--- a/chrome/browser/password_manager/chrome_password_manager_client.h 7879+++ b/chrome/browser/password_manager/chrome_password_manager_client.h 7880@@ -189,6 +189,7 @@ class ChromePasswordManagerClient 7881 void AnnotateNavigationEntry(bool has_password_field) override; 7882 autofill::LanguageCode GetPageLanguage() const override; 7883 7884+#if BUILDFLAG(FULL_SAFE_BROWSING) 7885 safe_browsing::PasswordProtectionService* GetPasswordProtectionService() 7886 const override; 7887 7888@@ -202,7 +203,8 @@ class ChromePasswordManagerClient 7889 const std::string& username, 7890 const std::vector<password_manager::MatchingReusedCredential>& 7891 matching_reused_credentials, 7892- bool password_field_exists) override; 7893+ bool password_field_exists); 7894+#endif // BUILDFLAG(FULL_SAFE_BROWSING) 7895 7896 void LogPasswordReuseDetectedEvent() override; 7897 7898diff --git a/chrome/browser/permissions/abusive_origin_permission_revocation_request.cc b/chrome/browser/permissions/abusive_origin_permission_revocation_request.cc 7899index 511d4d5a1a..8eb8175fdd 100644 7900--- a/chrome/browser/permissions/abusive_origin_permission_revocation_request.cc 7901+++ b/chrome/browser/permissions/abusive_origin_permission_revocation_request.cc 7902@@ -16,7 +16,12 @@ 7903 #include "components/permissions/permission_uma_util.h" 7904 #include "components/permissions/permissions_client.h" 7905 #include "components/prefs/pref_service.h" 7906+#include "components/safe_browsing/buildflags.h" 7907+ 7908+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 7909 #include "components/safe_browsing/core/common/safe_browsing_prefs.h" 7910+#endif 7911+ 7912 #include "components/safe_browsing/core/db/database_manager.h" 7913 7914 namespace { 7915@@ -76,6 +81,7 @@ void SetOriginStatus(Profile* profile, 7916 base::WrapUnique(dict.DeepCopy())); 7917 } 7918 7919+#if BUILDFLAG(FULL_SAFE_BROWSING) 7920 void RevokePermission(const GURL& origin, Profile* profile) { 7921 permissions::PermissionsClient::Get() 7922 ->GetSettingsMap(profile) 7923@@ -91,6 +97,7 @@ void RevokePermission(const GURL& origin, Profile* profile) { 7924 ContentSettingsType::NOTIFICATIONS, 7925 permissions::PermissionSourceUI::AUTO_REVOCATION, origin, profile); 7926 } 7927+#endif 7928 } // namespace 7929 7930 AbusiveOriginPermissionRevocationRequest:: 7931@@ -136,6 +143,7 @@ void AbusiveOriginPermissionRevocationRequest::CheckAndRevokeIfAbusive() { 7932 DCHECK(profile_); 7933 DCHECK(callback_); 7934 7935+#if BUILDFLAG(FULL_SAFE_BROWSING) 7936 if (!AbusiveOriginNotificationsPermissionRevocationConfig::IsEnabled() || 7937 !safe_browsing::IsSafeBrowsingEnabled(*profile_->GetPrefs()) || 7938 IsOriginExemptedFromFutureRevocations(profile_, origin_)) { 7939@@ -169,6 +177,7 @@ void AbusiveOriginPermissionRevocationRequest::OnSiteReputationReady( 7940 CrowdDenyPreloadData::SiteReputation::ABUSIVE_PROMPTS || 7941 site_reputation->notification_ux_quality() == 7942 CrowdDenyPreloadData::SiteReputation::ABUSIVE_CONTENT)) { 7943+ #if BUILDFLAG(FULL_SAFE_BROWSING) 7944 DCHECK(g_browser_process->safe_browsing_service()); 7945 7946 if (g_browser_process->safe_browsing_service()) { 7947@@ -180,12 +189,16 @@ void AbusiveOriginPermissionRevocationRequest::OnSiteReputationReady( 7948 weak_factory_.GetWeakPtr())); 7949 return; 7950 } 7951+ #endif 7952 } 7953 NotifyCallback(Outcome::PERMISSION_NOT_REVOKED); 7954+#endif // BUILDFLAG(FULL_SAFE_BROWSING) 7955+ 7956 } 7957 7958 void AbusiveOriginPermissionRevocationRequest::OnSafeBrowsingVerdictReceived( 7959 CrowdDenySafeBrowsingRequest::Verdict verdict) { 7960+#if BUILDFLAG(FULL_SAFE_BROWSING) 7961 DCHECK(safe_browsing_request_); 7962 DCHECK(profile_); 7963 DCHECK(callback_); 7964@@ -196,6 +209,7 @@ void AbusiveOriginPermissionRevocationRequest::OnSafeBrowsingVerdictReceived( 7965 } else { 7966 NotifyCallback(Outcome::PERMISSION_NOT_REVOKED); 7967 } 7968+#endif 7969 } 7970 7971 void AbusiveOriginPermissionRevocationRequest::NotifyCallback(Outcome outcome) { 7972diff --git a/chrome/browser/permissions/abusive_origin_permission_revocation_request.h b/chrome/browser/permissions/abusive_origin_permission_revocation_request.h 7973index be61d528f0..177ff742e3 100644 7974--- a/chrome/browser/permissions/abusive_origin_permission_revocation_request.h 7975+++ b/chrome/browser/permissions/abusive_origin_permission_revocation_request.h 7976@@ -10,6 +10,7 @@ 7977 #include "chrome/browser/permissions/crowd_deny_preload_data.h" 7978 #include "chrome/browser/permissions/crowd_deny_safe_browsing_request.h" 7979 #include "url/gurl.h" 7980+#include "components/safe_browsing/buildflags.h" 7981 7982 class Profile; 7983 enum class ContentSettingsType; 7984@@ -62,8 +63,9 @@ class AbusiveOriginPermissionRevocationRequest { 7985 void OnSafeBrowsingVerdictReceived( 7986 CrowdDenySafeBrowsingRequest::Verdict verdict); 7987 void NotifyCallback(Outcome outcome); 7988- 7989+#if BUILDFLAG(FULL_SAFE_BROWSING) 7990 base::Optional<CrowdDenySafeBrowsingRequest> safe_browsing_request_; 7991+#endif 7992 Profile* profile_; 7993 const GURL origin_; 7994 OutcomeCallback callback_; 7995diff --git a/chrome/browser/permissions/contextual_notification_permission_ui_selector.cc b/chrome/browser/permissions/contextual_notification_permission_ui_selector.cc 7996index 97ceabe5fa..13437faabd 100644 7997--- a/chrome/browser/permissions/contextual_notification_permission_ui_selector.cc 7998+++ b/chrome/browser/permissions/contextual_notification_permission_ui_selector.cc 7999@@ -21,6 +21,7 @@ 8000 #include "chrome/common/chrome_features.h" 8001 #include "components/permissions/permission_request.h" 8002 #include "components/safe_browsing/core/db/database_manager.h" 8003+#include "components/safe_browsing/buildflags.h" 8004 8005 namespace { 8006 8007@@ -107,6 +108,7 @@ base::Optional<Decision> GetDecisionBasedOnSiteReputation( 8008 return base::nullopt; 8009 } 8010 8011+#if BUILDFLAG(FULL_SAFE_BROWSING) 8012 // Roll the dice to decide whether to use the normal UI even when the preload 8013 // data indicates that quiet UI should be used. This creates a control group of 8014 // normal UI prompt impressions, which facilitates comparing acceptance rates, 8015@@ -126,6 +128,7 @@ bool ShouldHoldBackQuietUI(QuietUiReason quiet_ui_reason) { 8016 base::UmaHistogramBoolean("Permissions.CrowdDeny.DidHoldbackQuietUi", result); 8017 return result; 8018 } 8019+#endif 8020 8021 } // namespace 8022 8023@@ -150,9 +153,11 @@ void ContextualNotificationPermissionUiSelector::SelectUiToUse( 8024 } 8025 8026 void ContextualNotificationPermissionUiSelector::Cancel() { 8027+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8028 // The computation either finishes synchronously above, or is waiting on the 8029 // Safe Browsing check. 8030 safe_browsing_request_.reset(); 8031+#endif 8032 } 8033 8034 ContextualNotificationPermissionUiSelector:: 8035@@ -177,9 +182,11 @@ void ContextualNotificationPermissionUiSelector::OnSiteReputationReady( 8036 // Browsing to verify; but do not ping if it is not warranted. 8037 if (!decision || (!decision->quiet_ui_reason && !decision->warning_reason)) { 8038 Notify(Decision::UseNormalUiAndShowNoWarning()); 8039- return; 8040+ } else { 8041+ Notify(decision.value()); 8042 } 8043 8044+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8045 DCHECK(!safe_browsing_request_); 8046 DCHECK(g_browser_process->safe_browsing_service()); 8047 8048@@ -191,11 +198,13 @@ void ContextualNotificationPermissionUiSelector::OnSiteReputationReady( 8049 base::BindOnce(&ContextualNotificationPermissionUiSelector:: 8050 OnSafeBrowsingVerdictReceived, 8051 base::Unretained(this), *decision)); 8052+#endif 8053 } 8054 8055 void ContextualNotificationPermissionUiSelector::OnSafeBrowsingVerdictReceived( 8056 Decision candidate_decision, 8057 CrowdDenySafeBrowsingRequest::Verdict verdict) { 8058+#if BUILDFLAG(FULL_SAFE_BROWSING) 8059 DCHECK(safe_browsing_request_); 8060 DCHECK(callback_); 8061 8062@@ -213,6 +222,7 @@ void ContextualNotificationPermissionUiSelector::OnSafeBrowsingVerdictReceived( 8063 Notify(candidate_decision); 8064 break; 8065 } 8066+#endif 8067 } 8068 8069 void ContextualNotificationPermissionUiSelector::Notify( 8070diff --git a/chrome/browser/permissions/contextual_notification_permission_ui_selector.h b/chrome/browser/permissions/contextual_notification_permission_ui_selector.h 8071index a940831e80..32265ed9e0 100644 8072--- a/chrome/browser/permissions/contextual_notification_permission_ui_selector.h 8073+++ b/chrome/browser/permissions/contextual_notification_permission_ui_selector.h 8074@@ -10,6 +10,7 @@ 8075 #include "chrome/browser/permissions/crowd_deny_preload_data.h" 8076 #include "chrome/browser/permissions/crowd_deny_safe_browsing_request.h" 8077 #include "components/permissions/notification_permission_ui_selector.h" 8078+#include "components/safe_browsing/buildflags.h" 8079 8080 namespace permissions { 8081 class PermissionRequest; 8082@@ -55,8 +56,9 @@ class ContextualNotificationPermissionUiSelector 8083 void OnSiteReputationReady( 8084 const url::Origin& origin, 8085 const CrowdDenyPreloadData::SiteReputation* reputation); 8086- 8087+#if BUILDFLAG(FULL_SAFE_BROWSING) 8088 base::Optional<CrowdDenySafeBrowsingRequest> safe_browsing_request_; 8089+#endif 8090 DecisionMadeCallback callback_; 8091 base::WeakPtrFactory<ContextualNotificationPermissionUiSelector> 8092 weak_factory_{this}; 8093diff --git a/chrome/browser/permissions/prediction_based_permission_ui_selector.cc b/chrome/browser/permissions/prediction_based_permission_ui_selector.cc 8094index d2e6710e42..54ae60306e 100644 8095--- a/chrome/browser/permissions/prediction_based_permission_ui_selector.cc 8096+++ b/chrome/browser/permissions/prediction_based_permission_ui_selector.cc 8097@@ -20,6 +20,7 @@ 8098 #include "components/permissions/prediction_service/prediction_service_messages.pb.h" 8099 #include "components/prefs/pref_service.h" 8100 #include "components/safe_browsing/core/common/safe_browsing_prefs.h" 8101+#include "components/safe_browsing/buildflags.h" 8102 8103 namespace { 8104 8105@@ -181,9 +182,16 @@ void PredictionBasedPermissionUiSelector::LookupReponseReceived( 8106 bool PredictionBasedPermissionUiSelector::IsAllowedToUseAssistedPrompts() { 8107 // We need to also check `kQuietNotificationPrompts` here since there is no 8108 // generic safeguard anywhere else in the stack. 8109+ 8110+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8111 return base::FeatureList::IsEnabled(features::kQuietNotificationPrompts) && 8112 base::FeatureList::IsEnabled(features::kPermissionPredictions) && 8113 safe_browsing::IsSafeBrowsingEnabled(*(profile_->GetPrefs())); 8114+#else 8115+ return base::FeatureList::IsEnabled(features::kQuietNotificationPrompts) && 8116+ base::FeatureList::IsEnabled(features::kPermissionPredictions); 8117+#endif 8118+ 8119 } 8120 8121 // static 8122diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc 8123index cbe3372144..7ce0722c14 100644 8124--- a/chrome/browser/platform_util_linux.cc 8125+++ b/chrome/browser/platform_util_linux.cc 8126@@ -13,14 +13,18 @@ 8127 #include "base/threading/scoped_blocking_call.h" 8128 #include "chrome/browser/chrome_notification_types.h" 8129 #include "chrome/browser/platform_util_internal.h" 8130+#if !defined(OS_OHOS) 8131 #include "components/dbus/thread_linux/dbus_thread_linux.h" 8132+#endif 8133 #include "content/public/browser/browser_thread.h" 8134 #include "content/public/browser/notification_observer.h" 8135 #include "content/public/browser/notification_registrar.h" 8136 #include "content/public/browser/notification_service.h" 8137+#if !defined(OS_OHOS) 8138 #include "dbus/bus.h" 8139 #include "dbus/message.h" 8140 #include "dbus/object_proxy.h" 8141+#endif 8142 #include "url/gurl.h" 8143 8144 using content::BrowserThread; 8145@@ -29,10 +33,12 @@ namespace platform_util { 8146 8147 namespace { 8148 8149+#if !defined(OS_OHOS) 8150 const char kFreedesktopFileManagerName[] = "org.freedesktop.FileManager1"; 8151 const char kFreedesktopFileManagerPath[] = "/org/freedesktop/FileManager1"; 8152 8153 const char kMethodShowItems[] = "ShowItems"; 8154+#endif 8155 8156 class ShowItemHelper : public content::NotificationObserver { 8157 public: 8158@@ -54,14 +60,17 @@ class ShowItemHelper : public content::NotificationObserver { 8159 const content::NotificationDetails& details) override { 8160 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 8161 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); 8162+#if !defined(OS_OHOS) 8163 // The browser process is about to exit. Clean up while we still can. 8164 if (bus_) 8165 bus_->ShutdownOnDBusThreadAndBlock(); 8166 bus_.reset(); 8167 filemanager_proxy_ = nullptr; 8168+#endif 8169 } 8170 8171 void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { 8172+ #if !defined(OS_OHOS) 8173 if (!bus_) { 8174 // Sets up the D-Bus connection. 8175 dbus::Bus::Options bus_options; 8176@@ -94,9 +103,11 @@ class ShowItemHelper : public content::NotificationObserver { 8177 &show_items_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 8178 base::BindOnce(&ShowItemHelper::ShowItemInFolderResponse, 8179 weak_ptr_factory_.GetWeakPtr(), profile, full_path)); 8180+ #endif 8181 } 8182 8183 private: 8184+#if !defined(OS_OHOS) 8185 void ShowItemInFolderResponse(Profile* profile, 8186 const base::FilePath& full_path, 8187 dbus::Response* response) { 8188@@ -108,12 +119,12 @@ class ShowItemHelper : public content::NotificationObserver { 8189 OpenItem(profile, full_path.DirName(), OPEN_FOLDER, 8190 OpenOperationCallback()); 8191 } 8192- 8193+#endif 8194 content::NotificationRegistrar registrar_; 8195- 8196+#if !defined(OS_OHOS) 8197 scoped_refptr<dbus::Bus> bus_; 8198 dbus::ObjectProxy* filemanager_proxy_ = nullptr; 8199- 8200+#endif 8201 base::WeakPtrFactory<ShowItemHelper> weak_ptr_factory_{this}; 8202 }; 8203 8204diff --git a/chrome/browser/plugins/plugins_resource_service.cc b/chrome/browser/plugins/plugins_resource_service.cc 8205index dea3c4fc49..fae48278c3 100644 8206--- a/chrome/browser/plugins/plugins_resource_service.cc 8207+++ b/chrome/browser/plugins/plugins_resource_service.cc 8208@@ -66,6 +66,8 @@ GURL GetPluginsServerURL() { 8209 filename = "plugins_linux.json"; 8210 #elif defined(OS_MAC) 8211 filename = "plugins_mac.json"; 8212+#elif defined(OS_OHOS) 8213+ filename = "plugins_linux.json"; 8214 #else 8215 #error Unknown platform 8216 #endif 8217diff --git a/chrome/browser/policy/BUILD.gn b/chrome/browser/policy/BUILD.gn 8218index 4093dac5b3..c2d7ad07dd 100644 8219--- a/chrome/browser/policy/BUILD.gn 8220+++ b/chrome/browser/policy/BUILD.gn 8221@@ -7,7 +7,7 @@ import("//build/config/features.gni") 8222 source_set("path_parser") { 8223 sources = [ "policy_path_parser.h" ] 8224 8225- if (is_chromeos || is_linux) { 8226+ if (is_chromeos || is_linux || is_ohos) { 8227 sources += [ "policy_path_parser_linux.cc" ] 8228 } else if (is_mac) { 8229 sources += [ "policy_path_parser_mac.mm" ] 8230diff --git a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc 8231index a369688941..4163f26fd0 100644 8232--- a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc 8233+++ b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc 8234@@ -43,7 +43,7 @@ 8235 #include "chrome/browser/policy/browser_dm_token_storage_mac.h" 8236 #endif // defined(OS_MAC) 8237 8238-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 8239+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 8240 #include "chrome/browser/policy/browser_dm_token_storage_linux.h" 8241 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) 8242 8243@@ -75,7 +75,7 @@ void ChromeBrowserCloudManagementControllerDesktop:: 8244 8245 #if defined(OS_MAC) 8246 storage_delegate = std::make_unique<BrowserDMTokenStorageMac>(); 8247-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) 8248+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 8249 storage_delegate = std::make_unique<BrowserDMTokenStorageLinux>(); 8250 #elif defined(OS_WIN) 8251 storage_delegate = std::make_unique<BrowserDMTokenStorageWin>(); 8252diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc 8253index cb44a0300e..40e028eb42 100644 8254--- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc 8255+++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc 8256@@ -270,7 +270,9 @@ void ChromeBrowserMainExtraPartsProfiles:: 8257 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 8258 CaptivePortalServiceFactory::GetInstance(); 8259 #endif 8260+#if BUILDFLAG(FULL_SAFE_BROWSING) 8261 CertificateReportingServiceFactory::GetInstance(); 8262+#endif 8263 #if !defined(OS_ANDROID) 8264 ChromeBrowsingDataLifetimeManagerFactory::GetInstance(); 8265 #endif 8266diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc 8267index f75b19f9ed..1b04a1e6a2 100644 8268--- a/chrome/browser/profiles/profile_impl.cc 8269+++ b/chrome/browser/profiles/profile_impl.cc 8270@@ -628,6 +628,7 @@ void ProfileImpl::LoadPrefsForNormalStartup(bool async_prefs) { 8271 8272 mojo::PendingRemote<prefs::mojom::TrackedPreferenceValidationDelegate> 8273 pref_validation_delegate; 8274+#if BUILDFLAG(FULL_SAFE_BROWSING) 8275 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service( 8276 g_browser_process->safe_browsing_service()); 8277 if (safe_browsing_service.get()) { 8278@@ -639,6 +640,7 @@ void ProfileImpl::LoadPrefsForNormalStartup(bool async_prefs) { 8279 pref_validation_delegate.InitWithNewPipeAndPassReceiver()); 8280 } 8281 } 8282+#endif 8283 8284 prefs_ = 8285 CreatePrefService(pref_registry_, CreateExtensionPrefStore(this, false), 8286diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc 8287index 7aea889587..a5e8e56016 100644 8288--- a/chrome/browser/profiles/profiles_state.cc 8289+++ b/chrome/browser/profiles/profiles_state.cc 8290@@ -316,6 +316,7 @@ bool SetActiveProfileToGuestIfLocked() { 8291 #endif // !BUILDFLAG(IS_CHROMEOS_ASH) 8292 8293 void RemoveBrowsingDataForProfile(const base::FilePath& profile_path) { 8294+#if BUILDFLAG(FULL_SAFE_BROWSING) 8295 // The BrowsingDataRemover relies on many objects that aren't created in unit 8296 // tests. Previously this code would depend on content::ResourceDispatcherHost 8297 // but that's gone, so do a similar hack for now. 8298@@ -332,6 +333,7 @@ void RemoveBrowsingDataForProfile(const base::FilePath& profile_path) { 8299 profile = profile->GetPrimaryOTRProfile(); 8300 8301 profile->Wipe(); 8302+#endif 8303 } 8304 8305 #if !BUILDFLAG(IS_CHROMEOS_ASH) 8306diff --git a/chrome/browser/reputation/reputation_service.cc b/chrome/browser/reputation/reputation_service.cc 8307index 69a20d735d..e595f61973 100644 8308--- a/chrome/browser/reputation/reputation_service.cc 8309+++ b/chrome/browser/reputation/reputation_service.cc 8310@@ -119,6 +119,7 @@ void ReputationService::GetReputationStatus(const GURL& url, 8311 ReputationCheckCallback callback) { 8312 DCHECK(url.SchemeIsHTTPOrHTTPS()); 8313 8314+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8315 bool has_delayed_warning = 8316 !!safe_browsing::SafeBrowsingUserInteractionObserver::FromWebContents( 8317 web_contents); 8318@@ -136,6 +137,7 @@ void ReputationService::GetReputationStatus(const GURL& url, 8319 GetReputationStatusWithEngagedSites(url, has_delayed_warning, 8320 std::move(callback), 8321 service->GetLatestEngagedSites()); 8322+#endif 8323 } 8324 8325 bool ReputationService::IsIgnored(const GURL& url) const { 8326diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service.h b/chrome/browser/safe_browsing/chrome_password_protection_service.h 8327index 678746f2d5..3e6f64feef 100644 8328--- a/chrome/browser/safe_browsing/chrome_password_protection_service.h 8329+++ b/chrome/browser/safe_browsing/chrome_password_protection_service.h 8330@@ -213,8 +213,13 @@ class ChromePasswordProtectionService : public PasswordProtectionService, 8331 // policy, this function should always return PHISHING_REUSE. Otherwise, 8332 // returns the specified pref value adjusted for the given username's account 8333 // type. 8334+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8335 PasswordProtectionTrigger GetPasswordProtectionWarningTriggerPref( 8336 ReusedPasswordAccountType password_type) const override; 8337+#else 8338+ PasswordProtectionTrigger GetPasswordProtectionWarningTriggerPref( 8339+ ReusedPasswordAccountType password_type) const; 8340+#endif 8341 8342 // If |url| matches Safe Browsing allowlist domains, password protection 8343 // change password URL, or password protection login URLs in the enterprise 8344diff --git a/chrome/browser/safe_browsing/url_checker_delegate_impl.cc b/chrome/browser/safe_browsing/url_checker_delegate_impl.cc 8345index b1e9744173..07be890d41 100644 8346--- a/chrome/browser/safe_browsing/url_checker_delegate_impl.cc 8347+++ b/chrome/browser/safe_browsing/url_checker_delegate_impl.cc 8348@@ -51,6 +51,7 @@ void DestroyNoStatePrefetchContents( 8349 } 8350 } 8351 8352+#if !defined(OS_OHOS) 8353 void CreateSafeBrowsingUserInteractionObserver( 8354 const content::WebContents::Getter& web_contents_getter, 8355 const security_interstitials::UnsafeResource& resource, 8356@@ -73,9 +74,13 @@ void CreateSafeBrowsingUserInteractionObserver( 8357 return; 8358 } 8359 #endif 8360+ 8361+#if !defined(OS_OHOS) 8362 SafeBrowsingUserInteractionObserver::CreateForWebContents( 8363 web_contents, resource, is_main_frame, ui_manager); 8364+#endif 8365 } 8366+#endif 8367 8368 } // namespace 8369 8370@@ -112,10 +117,12 @@ void UrlCheckerDelegateImpl::StartDisplayingBlockingPageHelper( 8371 const net::HttpRequestHeaders& headers, 8372 bool is_main_frame, 8373 bool has_user_gesture) { 8374+#if !defined(OS_OHOS) 8375 content::GetUIThreadTaskRunner({})->PostTask( 8376 FROM_HERE, 8377 base::BindOnce(&SafeBrowsingUIManager::StartDisplayingBlockingPage, 8378 ui_manager_, resource)); 8379+#endif 8380 } 8381 8382 // Starts displaying the SafeBrowsing interstitial page. 8383@@ -123,10 +130,12 @@ void UrlCheckerDelegateImpl:: 8384 StartObservingInteractionsForDelayedBlockingPageHelper( 8385 const security_interstitials::UnsafeResource& resource, 8386 bool is_main_frame) { 8387+#if !defined(OS_OHOS) 8388 content::GetUIThreadTaskRunner({})->PostTask( 8389 FROM_HERE, base::BindOnce(&CreateSafeBrowsingUserInteractionObserver, 8390 resource.web_contents_getter, resource, 8391 is_main_frame, ui_manager_)); 8392+#endif 8393 } 8394 8395 bool UrlCheckerDelegateImpl::IsUrlAllowlisted(const GURL& url) { 8396diff --git a/chrome/browser/safe_browsing/url_lookup_service_factory.cc b/chrome/browser/safe_browsing/url_lookup_service_factory.cc 8397index 52da66e37b..1f9b1026ba 100644 8398--- a/chrome/browser/safe_browsing/url_lookup_service_factory.cc 8399+++ b/chrome/browser/safe_browsing/url_lookup_service_factory.cc 8400@@ -54,6 +54,8 @@ RealTimeUrlLookupServiceFactory::RealTimeUrlLookupServiceFactory() 8401 8402 KeyedService* RealTimeUrlLookupServiceFactory::BuildServiceInstanceFor( 8403 content::BrowserContext* context) const { 8404+ 8405+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8406 if (!g_browser_process->safe_browsing_service()) { 8407 return nullptr; 8408 } 8409@@ -74,6 +76,10 @@ KeyedService* RealTimeUrlLookupServiceFactory::BuildServiceInstanceFor( 8410 ProfileSyncServiceFactory::GetForProfile(profile), 8411 IdentityManagerFactory::GetForProfile(profile)), 8412 profile->IsOffTheRecord(), g_browser_process->variations_service()); 8413+#else 8414+ return nullptr; 8415+#endif 8416+ 8417 } 8418 8419 } // namespace safe_browsing 8420diff --git a/chrome/browser/serial/chrome_serial_delegate.cc b/chrome/browser/serial/chrome_serial_delegate.cc 8421index 5c9cefe505..09b24d1cf2 100644 8422--- a/chrome/browser/serial/chrome_serial_delegate.cc 8423+++ b/chrome/browser/serial/chrome_serial_delegate.cc 8424@@ -34,9 +34,14 @@ std::unique_ptr<content::SerialChooser> ChromeSerialDelegate::RunChooser( 8425 content::RenderFrameHost* frame, 8426 std::vector<blink::mojom::SerialPortFilterPtr> filters, 8427 content::SerialChooser::Callback callback) { 8428+#if !defined(OS_OHOS) 8429 return std::make_unique<SerialChooser>(chrome::ShowDeviceChooserDialog( 8430 frame, std::make_unique<SerialChooserController>( 8431 frame, std::move(filters), std::move(callback)))); 8432+#else 8433+ LOG(INFO) << "ChromeSerialDelegate::RunChooser TODO for OS_OHOS"; 8434+ return nullptr; 8435+#endif 8436 } 8437 8438 bool ChromeSerialDelegate::CanRequestPortPermission( 8439diff --git a/chrome/browser/sharing/shared_clipboard/feature_flags.cc b/chrome/browser/sharing/shared_clipboard/feature_flags.cc 8440index 0d17ad2381..cd78e50d74 100644 8441--- a/chrome/browser/sharing/shared_clipboard/feature_flags.cc 8442+++ b/chrome/browser/sharing/shared_clipboard/feature_flags.cc 8443@@ -8,7 +8,7 @@ const base::Feature kSharedClipboardUI{"SharedClipboardUI", 8444 base::FEATURE_DISABLED_BY_DEFAULT}; 8445 8446 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 8447- defined(OS_CHROMEOS) 8448+ defined(OS_CHROMEOS) || defined(OS_OHOS) 8449 const base::Feature kRemoteCopyReceiver{"RemoteCopyReceiver", 8450 base::FEATURE_ENABLED_BY_DEFAULT}; 8451 8452diff --git a/chrome/browser/sharing/shared_clipboard/feature_flags.h b/chrome/browser/sharing/shared_clipboard/feature_flags.h 8453index 65818f84ce..ea79077ad3 100644 8454--- a/chrome/browser/sharing/shared_clipboard/feature_flags.h 8455+++ b/chrome/browser/sharing/shared_clipboard/feature_flags.h 8456@@ -15,7 +15,7 @@ 8457 extern const base::Feature kSharedClipboardUI; 8458 8459 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 8460- defined(OS_CHROMEOS) 8461+ defined(OS_CHROMEOS) || defined(OS_OHOS) 8462 // Feature to enable handling remote copy messages. 8463 extern const base::Feature kRemoteCopyReceiver; 8464 8465diff --git a/chrome/browser/ssl/chrome_security_blocking_page_factory.cc b/chrome/browser/ssl/chrome_security_blocking_page_factory.cc 8466index e89930881e..75e7903a8e 100644 8467--- a/chrome/browser/ssl/chrome_security_blocking_page_factory.cc 8468+++ b/chrome/browser/ssl/chrome_security_blocking_page_factory.cc 8469@@ -94,6 +94,7 @@ bool IsEnterpriseManaged() { 8470 // CaptivePortalBlockingPage to be invoked when the user has pressed the 8471 // connect button. 8472 void OpenLoginPage(content::WebContents* web_contents) { 8473+#if !defined(OS_OHOS) 8474 #if !BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 8475 // OpenLoginTabForWebContents() is not available on Android (the only 8476 // platform on which captive portal detection is not enabled). Simply open 8477@@ -108,6 +109,9 @@ void OpenLoginPage(content::WebContents* web_contents) { 8478 ChromeSecurityBlockingPageFactory::OpenLoginTabForWebContents(web_contents, 8479 true); 8480 #endif // !BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 8481+#else 8482+ LOG(ERROR) << "OpenLoginPage TODO for OS_OHOS"; 8483+#endif 8484 } 8485 8486 std::unique_ptr<ContentMetricsHelper> CreateMetricsHelperAndStartRecording( 8487diff --git a/chrome/browser/ssl/sct_reporting_service_factory.cc b/chrome/browser/ssl/sct_reporting_service_factory.cc 8488index 1319d0e475..aebe2cd4bc 100644 8489--- a/chrome/browser/ssl/sct_reporting_service_factory.cc 8490+++ b/chrome/browser/ssl/sct_reporting_service_factory.cc 8491@@ -32,6 +32,8 @@ SCTReportingServiceFactory::~SCTReportingServiceFactory() = default; 8492 8493 KeyedService* SCTReportingServiceFactory::BuildServiceInstanceFor( 8494 content::BrowserContext* profile) const { 8495+ 8496+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8497 safe_browsing::SafeBrowsingService* safe_browsing_service = 8498 g_browser_process->safe_browsing_service(); 8499 // In unit tests the safe browsing service can be null, if this happens, 8500@@ -41,6 +43,9 @@ KeyedService* SCTReportingServiceFactory::BuildServiceInstanceFor( 8501 8502 return new SCTReportingService(safe_browsing_service, 8503 static_cast<Profile*>(profile)); 8504+#else 8505+ return nullptr; 8506+#endif 8507 } 8508 8509 content::BrowserContext* SCTReportingServiceFactory::GetBrowserContextToUse( 8510diff --git a/chrome/browser/ssl/security_state_tab_helper.cc b/chrome/browser/ssl/security_state_tab_helper.cc 8511index 810fdd18c2..9f3c445aee 100644 8512--- a/chrome/browser/ssl/security_state_tab_helper.cc 8513+++ b/chrome/browser/ssl/security_state_tab_helper.cc 8514@@ -209,6 +209,7 @@ SecurityStateTabHelper::GetMaliciousContentStatus() const { 8515 web_contents()->GetController().GetVisibleEntry(); 8516 if (!entry) 8517 return security_state::MALICIOUS_CONTENT_STATUS_NONE; 8518+#if BUILDFLAG(FULL_SAFE_BROWSING) 8519 safe_browsing::SafeBrowsingService* sb_service = 8520 g_browser_process->safe_browsing_service(); 8521 if (!sb_service) 8522@@ -292,6 +293,9 @@ SecurityStateTabHelper::GetMaliciousContentStatus() const { 8523 } 8524 } 8525 return security_state::MALICIOUS_CONTENT_STATUS_NONE; 8526+#else 8527+ return security_state::MALICIOUS_CONTENT_STATUS_NONE; 8528+#endif 8529 } 8530 8531 WEB_CONTENTS_USER_DATA_KEY_IMPL(SecurityStateTabHelper) 8532diff --git a/chrome/browser/subresource_filter/chrome_subresource_filter_client.cc b/chrome/browser/subresource_filter/chrome_subresource_filter_client.cc 8533index 2312a63fb4..cf3f0a95eb 100644 8534--- a/chrome/browser/subresource_filter/chrome_subresource_filter_client.cc 8535+++ b/chrome/browser/subresource_filter/chrome_subresource_filter_client.cc 8536@@ -57,10 +57,14 @@ void ChromeSubresourceFilterClient::ShowNotification() { 8537 8538 const scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> 8539 ChromeSubresourceFilterClient::GetSafeBrowsingDatabaseManager() { 8540+#if BUILDFLAG(FULL_SAFE_BROWSING) 8541 safe_browsing::SafeBrowsingService* safe_browsing_service = 8542 g_browser_process->safe_browsing_service(); 8543 return safe_browsing_service ? safe_browsing_service->database_manager() 8544 : nullptr; 8545+#else 8546+ return nullptr; 8547+#endif 8548 } 8549 8550 subresource_filter::ProfileInteractionManager* 8551diff --git a/chrome/browser/tracing/crash_service_uploader.cc b/chrome/browser/tracing/crash_service_uploader.cc 8552index e59f3a4d73..3a06d061e9 100644 8553--- a/chrome/browser/tracing/crash_service_uploader.cc 8554+++ b/chrome/browser/tracing/crash_service_uploader.cc 8555@@ -161,6 +161,8 @@ void TraceCrashServiceUploader::DoCompressOnBackgroundThread( 8556 const char product[] = "Chrome_Linux"; 8557 #elif defined(OS_ANDROID) 8558 const char product[] = "Chrome_Android"; 8559+#elif defined(OS_OHOS) 8560+ const char product[] = "Chrome_OHOS"; 8561 #else 8562 #error Platform not supported. 8563 #endif 8564diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn 8565index 1dbbf65c02..a286ad7319 100644 8566--- a/chrome/browser/ui/BUILD.gn 8567+++ b/chrome/browser/ui/BUILD.gn 8568@@ -1648,7 +1648,7 @@ static_library("ui") { 8569 deps += [ "//ui/base/ime/linux" ] 8570 } 8571 8572- if (!toolkit_views) { 8573+ if (!toolkit_views && !is_ohos) { 8574 sources += [ "media_router/cloud_services_dialog.cc" ] 8575 } 8576 8577@@ -2867,7 +2867,7 @@ static_library("ui") { 8578 ] 8579 } 8580 8581- if (is_win || is_mac || is_linux || is_chromeos) { 8582+ if (is_win || is_mac || is_linux || is_chromeos || is_ohos) { 8583 sources += [ 8584 "autofill/payments/virtual_card_selection_dialog_controller.h", 8585 "autofill/payments/virtual_card_selection_dialog_controller_impl.cc", 8586@@ -2934,7 +2934,7 @@ static_library("ui") { 8587 deps += [ "//ui/webui" ] 8588 } 8589 8590- if (is_win || is_mac || (is_linux || is_chromeos_lacros)) { 8591+ if (is_win || is_mac || (is_linux || is_chromeos_lacros) || is_ohos) { 8592 sources += [ 8593 "bookmarks/bookmark_bubble_sign_in_delegate.cc", 8594 "bookmarks/bookmark_bubble_sign_in_delegate.h", 8595@@ -3382,7 +3382,7 @@ static_library("ui") { 8596 } 8597 } 8598 8599- if (is_linux || is_chromeos_lacros) { 8600+ if (is_linux || is_chromeos_lacros || is_ohos) { 8601 sources += [ 8602 "views/apps/chrome_app_window_client_views_linux.cc", 8603 "views/first_run_dialog.cc", 8604@@ -3484,7 +3484,7 @@ static_library("ui") { 8605 } 8606 } 8607 8608- if (toolkit_views) { 8609+ if (toolkit_views || is_ohos) { 8610 sources += [ 8611 "autofill/address_editor_controller.cc", 8612 "autofill/address_editor_controller.h", 8613@@ -4367,7 +4367,7 @@ static_library("ui") { 8614 8615 allow_circular_includes_from += [ "//chrome/browser/ui/views" ] 8616 8617- if (is_linux || is_chromeos_lacros) { 8618+ if (is_linux || is_chromeos_lacros || is_ohos) { 8619 sources += [ 8620 "views/chrome_views_delegate_linux.cc", 8621 "views/frame/desktop_linux_browser_frame_view.cc", 8622@@ -4379,7 +4379,7 @@ static_library("ui") { 8623 ] 8624 } 8625 8626- if (is_linux || is_chromeos) { 8627+ if (is_linux || is_chromeos || is_ohos) { 8628 sources += [ 8629 "views/process_singleton_dialog_linux.cc", 8630 "views/status_icons/status_tray_linux.cc", 8631@@ -4423,7 +4423,7 @@ static_library("ui") { 8632 ] 8633 } 8634 8635- if (is_win || (is_linux || is_chromeos_lacros)) { 8636+ if (is_win || (is_linux || is_chromeos_lacros) || is_ohos) { 8637 sources += [ 8638 "views/native_widget_factory.cc", 8639 "views/native_widget_factory.h", 8640diff --git a/chrome/browser/ui/aura/tab_contents/web_drag_bookmark_handler_aura.cc b/chrome/browser/ui/aura/tab_contents/web_drag_bookmark_handler_aura.cc 8641index 2790cc07d6..a76512990f 100644 8642--- a/chrome/browser/ui/aura/tab_contents/web_drag_bookmark_handler_aura.cc 8643+++ b/chrome/browser/ui/aura/tab_contents/web_drag_bookmark_handler_aura.cc 8644@@ -41,11 +41,15 @@ void WebDragBookmarkHandlerAura::OnDragOver() { 8645 8646 void WebDragBookmarkHandlerAura::OnReceiveDragData( 8647 const ui::OSExchangeData& data) { 8648+#if !defined(OS_OHOS) 8649 if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) { 8650 // Read the bookmark drag data and save it for use in later events in this 8651 // drag. 8652 bookmark_drag_data_.Read(data); 8653 } 8654+#else 8655+ LOG(INFO) << "WebDragBookmarkHandlerAura::OnReceiveDragData TODO for OS_OHOS"; 8656+#endif 8657 } 8658 8659 void WebDragBookmarkHandlerAura::OnDragEnter() { 8660diff --git a/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.cc b/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.cc 8661index 41ff8996fb..97037e1abd 100644 8662--- a/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.cc 8663+++ b/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.cc 8664@@ -14,8 +14,12 @@ BluetoothChooserDesktop::BluetoothChooserDesktop( 8665 auto controller = 8666 std::make_unique<BluetoothChooserController>(frame, event_handler); 8667 bluetooth_chooser_controller_ = controller->GetWeakPtr(); 8668+#if !defined(OS_OHOS) 8669 close_closure_ = 8670 chrome::ShowDeviceChooserDialog(frame, std::move(controller)); 8671+#else 8672+ LOG(INFO) << "BluetoothChooserDesktop::BluetoothChooserDesktop TODO for OS_OHOS"; 8673+#endif 8674 } 8675 8676 BluetoothChooserDesktop::~BluetoothChooserDesktop() { 8677@@ -24,8 +28,10 @@ BluetoothChooserDesktop::~BluetoothChooserDesktop() { 8678 // instance. 8679 if (bluetooth_chooser_controller_) 8680 bluetooth_chooser_controller_->ResetEventHandler(); 8681+#if !defined(OS_OHOS) 8682 if (close_closure_) 8683 std::move(close_closure_).Run(); 8684+#endif 8685 } 8686 8687 void BluetoothChooserDesktop::SetAdapterPresence(AdapterPresence presence) { 8688diff --git a/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h b/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h 8689index bfa6287756..067b423ff6 100644 8690--- a/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h 8691+++ b/chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h 8692@@ -42,7 +42,9 @@ class BluetoothChooserDesktop : public content::BluetoothChooser { 8693 8694 // Closes the displayed UI if it is still open. Used to ensure the bubble 8695 // closes if this controller is torn down. 8696+#if !defined(OS_OHOS) 8697 base::OnceClosure close_closure_; 8698+#endif 8699 8700 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserDesktop); 8701 }; 8702diff --git a/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc b/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc 8703index 6bf1e605f0..3203236cd9 100644 8704--- a/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc 8705+++ b/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc 8706@@ -14,8 +14,12 @@ BluetoothScanningPromptDesktop::BluetoothScanningPromptDesktop( 8707 auto controller = 8708 std::make_unique<BluetoothScanningPromptController>(frame, event_handler); 8709 bluetooth_scanning_prompt_controller_ = controller->GetWeakPtr(); 8710+#if !defined(OS_OHOS) 8711 close_closure_ = 8712 chrome::ShowDeviceChooserDialog(frame, std::move(controller)); 8713+#else 8714+ LOG(INFO) << "BluetoothScanningPromptDesktop::BluetoothScanningPromptDesktop TODO for OS_OHOS"; 8715+#endif 8716 } 8717 8718 BluetoothScanningPromptDesktop::~BluetoothScanningPromptDesktop() { 8719@@ -24,8 +28,10 @@ BluetoothScanningPromptDesktop::~BluetoothScanningPromptDesktop() { 8720 // BluetoothScanningPrompt instance. 8721 if (bluetooth_scanning_prompt_controller_) 8722 bluetooth_scanning_prompt_controller_->ResetEventHandler(); 8723+#if !defined(OS_OHOS) 8724 if (close_closure_) 8725 std::move(close_closure_).Run(); 8726+#endif 8727 } 8728 8729 void BluetoothScanningPromptDesktop::AddOrUpdateDevice( 8730diff --git a/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.h b/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.h 8731index 20d897c05a..6d4a09ec02 100644 8732--- a/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.h 8733+++ b/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.h 8734@@ -38,8 +38,9 @@ class BluetoothScanningPromptDesktop : public content::BluetoothScanningPrompt { 8735 8736 // Closes the displayed UI, if there is one. This is used to ensure the UI 8737 // closes if this controller is destroyed. 8738+#if !defined(OS_OHOS) 8739 base::OnceClosure close_closure_; 8740- 8741+#endif 8742 DISALLOW_COPY_AND_ASSIGN(BluetoothScanningPromptDesktop); 8743 }; 8744 8745diff --git a/chrome/browser/ui/bookmarks/bookmark_utils.cc b/chrome/browser/ui/bookmarks/bookmark_utils.cc 8746index 04dbba1200..51df5e6a67 100644 8747--- a/chrome/browser/ui/bookmarks/bookmark_utils.cc 8748+++ b/chrome/browser/ui/bookmarks/bookmark_utils.cc 8749@@ -32,7 +32,7 @@ 8750 #include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h" 8751 #include "ui/base/pointer/touch_ui_controller.h" 8752 8753-#if defined(TOOLKIT_VIEWS) 8754+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 8755 #include "ui/gfx/canvas.h" 8756 #include "ui/gfx/color_utils.h" 8757 #include "ui/gfx/image/image_skia_source.h" 8758@@ -53,7 +53,7 @@ using ::bookmarks::BookmarkModel; 8759 using ::bookmarks::BookmarkNode; 8760 using ::ui::mojom::DragOperation; 8761 8762-#if defined(TOOLKIT_VIEWS) 8763+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 8764 // Image source that flips the supplied source image in RTL. 8765 class RTLFlipSource : public gfx::ImageSkiaSource { 8766 public: 8767@@ -257,7 +257,7 @@ bool IsValidBookmarkDropLocation(Profile* profile, 8768 return true; 8769 } 8770 8771-#if defined(TOOLKIT_VIEWS) 8772+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 8773 // TODO(bsep): vectorize the Windows versions: crbug.com/564112 8774 ui::ImageModel GetBookmarkFolderIcon(SkColor text_color) { 8775 gfx::ImageSkia folder; 8776diff --git a/chrome/browser/ui/bookmarks/bookmark_utils.h b/chrome/browser/ui/bookmarks/bookmark_utils.h 8777index 60b699cbf0..523692d4f8 100644 8778--- a/chrome/browser/ui/bookmarks/bookmark_utils.h 8779+++ b/chrome/browser/ui/bookmarks/bookmark_utils.h 8780@@ -93,7 +93,7 @@ bool IsValidBookmarkDropLocation(Profile* profile, 8781 const bookmarks::BookmarkNode* drop_parent, 8782 size_t index); 8783 8784-#if defined(TOOLKIT_VIEWS) 8785+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 8786 // |text_color| is the color of associated text and is used to derive the icon's 8787 // color. 8788 ui::ImageModel GetBookmarkFolderIcon(SkColor text_color); 8789diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc 8790index 5469cf1130..5ba23f6fb8 100644 8791--- a/chrome/browser/ui/browser_commands.cc 8792+++ b/chrome/browser/ui/browser_commands.cc 8793@@ -1655,7 +1655,7 @@ void ToggleCommander(Browser* browser) { 8794 commander::Commander::Get()->ToggleForBrowser(browser); 8795 } 8796 8797-#if !defined(TOOLKIT_VIEWS) 8798+#if !defined(TOOLKIT_VIEWS) && !defined(OS_OHOS) 8799 base::Optional<int> GetKeyboardFocusedTabIndex(const Browser* browser) { 8800 return base::nullopt; 8801 } 8802diff --git a/chrome/browser/ui/browser_dialogs.cc b/chrome/browser/ui/browser_dialogs.cc 8803index 738a0c5602..475be6360f 100644 8804--- a/chrome/browser/ui/browser_dialogs.cc 8805+++ b/chrome/browser/ui/browser_dialogs.cc 8806@@ -14,7 +14,7 @@ void RecordDialogCreation(DialogIdentifier identifier) { 8807 DialogIdentifier::MAX_VALUE); 8808 } 8809 8810-#if !defined(TOOLKIT_VIEWS) 8811+#if !defined(TOOLKIT_VIEWS) && !defined(OS_OHOS) 8812 void ShowWindowNamePrompt(Browser* browser) { 8813 NOTIMPLEMENTED(); 8814 } 8815@@ -27,7 +27,7 @@ void ShowWindowNamePromptForTesting(Browser* browser, 8816 8817 } // namespace chrome 8818 8819-#if !defined(TOOLKIT_VIEWS) 8820+#if !defined(TOOLKIT_VIEWS) && !defined(OS_OHOS) 8821 // There's no dialog version of this available outside views, run callback as if 8822 // the dialog was instantly accepted. 8823 void ShowFolderUploadConfirmationDialog( 8824diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h 8825index 8b2247ff0c..4b4d555b35 100644 8826--- a/chrome/browser/ui/browser_dialogs.h 8827+++ b/chrome/browser/ui/browser_dialogs.h 8828@@ -174,7 +174,7 @@ void HideTaskManagerViews(); 8829 8830 #endif // OS_MAC 8831 8832-#if defined(TOOLKIT_VIEWS) 8833+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 8834 8835 // Creates a toolkit-views based LoginHandler (e.g. HTTP-Auth dialog). 8836 std::unique_ptr<LoginHandler> CreateLoginHandlerViews( 8837diff --git a/chrome/browser/ui/file_system_access_dialogs.cc b/chrome/browser/ui/file_system_access_dialogs.cc 8838index 367f92f2a5..a527b3dfbd 100644 8839--- a/chrome/browser/ui/file_system_access_dialogs.cc 8840+++ b/chrome/browser/ui/file_system_access_dialogs.cc 8841@@ -6,7 +6,7 @@ 8842 8843 #include "components/permissions/permission_util.h" 8844 8845-#if !defined(TOOLKIT_VIEWS) 8846+#if !defined(TOOLKIT_VIEWS) && !defined(OS_OHOS) 8847 void ShowFileSystemAccessPermissionDialog( 8848 const FileSystemAccessPermissionRequestManager::RequestData& request, 8849 base::OnceCallback<void(permissions::PermissionAction result)> callback, 8850diff --git a/chrome/browser/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_desktop.cc b/chrome/browser/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_desktop.cc 8851index c0f114a947..abfa6b13b7 100644 8852--- a/chrome/browser/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_desktop.cc 8853+++ b/chrome/browser/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_desktop.cc 8854@@ -36,6 +36,8 @@ JavaScriptTabModalDialogManagerDelegateDesktop:: 8855 8856 void JavaScriptTabModalDialogManagerDelegateDesktop::WillRunDialog() { 8857 BrowserList::AddObserver(this); 8858+ 8859+#if BUILDFLAG(FULL_SAFE_BROWSING) 8860 // SafeBrowsing Delayed Warnings experiment can delay some SafeBrowsing 8861 // warnings until user interaction. If the current page has a delayed warning, 8862 // it'll have a user interaction observer attached. Show the warning 8863@@ -46,6 +48,8 @@ void JavaScriptTabModalDialogManagerDelegateDesktop::WillRunDialog() { 8864 if (observer) { 8865 observer->OnJavaScriptDialog(); 8866 } 8867+#endif // BUILDFLAG(FULL_SAFE_BROWSING) 8868+ 8869 } 8870 8871 void JavaScriptTabModalDialogManagerDelegateDesktop::DidCloseDialog() { 8872diff --git a/chrome/browser/ui/tab_contents/chrome_web_contents_view_handle_drop.cc b/chrome/browser/ui/tab_contents/chrome_web_contents_view_handle_drop.cc 8873index 27a192e2ec..69e7530676 100644 8874--- a/chrome/browser/ui/tab_contents/chrome_web_contents_view_handle_drop.cc 8875+++ b/chrome/browser/ui/tab_contents/chrome_web_contents_view_handle_drop.cc 8876@@ -17,7 +17,9 @@ 8877 #include "content/public/browser/web_contents.h" 8878 #include "content/public/browser/web_contents_view_delegate.h" 8879 #include "content/public/common/drop_data.h" 8880+#include "components/safe_browsing/buildflags.h" 8881 8882+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 8883 namespace { 8884 8885 void CompletionCallback( 8886@@ -113,3 +115,16 @@ void HandleOnPerformDrop( 8887 base::BindOnce(&ScanData, web_contents, std::move(callback))); 8888 } 8889 } 8890+ 8891+#else 8892+ 8893+void HandleOnPerformDrop( 8894+ content::WebContents* web_contents, 8895+ const content::DropData& drop_data, 8896+ content::WebContentsViewDelegate::DropCompletionCallback callback) { 8897+ // In the original code, this ran safe_browsing::DeepScanningDialogDelegate 8898+ // Instead, run the code under "if (!safe_browsing::DeepScanningDialogDelegate::IsEnabled(...)) ..." 8899+ std::move(callback).Run( 8900+ content::WebContentsViewDelegate::DropCompletionResult::kContinue); 8901+} 8902+#endif 8903\ No newline at end of file 8904diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc 8905index d2b75343e8..1e59e4ed31 100644 8906--- a/chrome/browser/ui/tab_helpers.cc 8907+++ b/chrome/browser/ui/tab_helpers.cc 8908@@ -153,7 +153,7 @@ 8909 #endif 8910 8911 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 8912- defined(OS_CHROMEOS) 8913+ defined(OS_CHROMEOS) || defined(OS_OHOS) 8914 #include "chrome/browser/ui/blocked_content/framebust_block_tab_helper.h" 8915 #include "chrome/browser/ui/hats/hats_helper.h" 8916 #endif 8917@@ -325,11 +325,13 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) { 8918 // See https://crbug.com/910288. 8919 resource_coordinator::ResourceCoordinatorTabHelper::CreateForWebContents( 8920 web_contents); 8921+#if BUILDFLAG(FULL_SAFE_BROWSING) 8922 safe_browsing::SafeBrowsingNavigationObserver::MaybeCreateForWebContents( 8923 web_contents); 8924 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(web_contents); 8925 safe_browsing::TriggerCreator::MaybeCreateTriggersForWebContents( 8926 profile, web_contents); 8927+#endif 8928 ReputationWebContentsObserver::CreateForWebContents(web_contents); 8929 SearchEngineTabHelper::CreateForWebContents(web_contents); 8930 SecurityStateTabHelper::CreateForWebContents(web_contents); 8931diff --git a/chrome/browser/ui/views/BUILD.gn b/chrome/browser/ui/views/BUILD.gn 8932index 54829b2cb7..664277a34f 100644 8933--- a/chrome/browser/ui/views/BUILD.gn 8934+++ b/chrome/browser/ui/views/BUILD.gn 8935@@ -6,7 +6,7 @@ import("//build/config/chromeos/ui_mode.gni") 8936 import("//build/config/ui.gni") 8937 import("//ui/views/features.gni") 8938 8939-assert(toolkit_views) 8940+assert(toolkit_views || is_ohos) 8941 8942 component("views") { 8943 output_name = "browser_ui_views" 8944diff --git a/chrome/browser/ui/views/certificate_selector.cc b/chrome/browser/ui/views/certificate_selector.cc 8945index 5bce36c39a..71db0c5550 100644 8946--- a/chrome/browser/ui/views/certificate_selector.cc 8947+++ b/chrome/browser/ui/views/certificate_selector.cc 8948@@ -288,8 +288,12 @@ void CertificateSelector::ViewCertButtonPressed() { 8949 net::ClientCertIdentity* const cert = GetSelectedCert(); 8950 if (!cert) 8951 return; 8952+#if !defined(OS_OHOS) 8953 ShowCertificateViewer(web_contents_, web_contents_->GetTopLevelNativeWindow(), 8954 cert->certificate()); 8955+#else 8956+ LOG(INFO) << "CertificateSelector::ViewCertButtonPressed TODO for OS_OHOS"; 8957+#endif 8958 } 8959 8960 void CertificateSelector::OnSelectionChanged() { 8961diff --git a/chrome/browser/ui/views/chrome_views_delegate.h b/chrome/browser/ui/views/chrome_views_delegate.h 8962index 393070d00b..c2c359bb14 100644 8963--- a/chrome/browser/ui/views/chrome_views_delegate.h 8964+++ b/chrome/browser/ui/views/chrome_views_delegate.h 8965@@ -50,7 +50,7 @@ class ChromeViewsDelegate : public views::ViewsDelegate { 8966 base::OnceClosure callback) override; 8967 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 8968 // of lacros-chrome is complete. 8969-#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 8970+#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 8971 gfx::ImageSkia* GetDefaultWindowIcon() const override; 8972 bool WindowManagerProvidesTitleBar(bool maximized) override; 8973 #endif 8974diff --git a/chrome/browser/ui/views/download/download_danger_prompt_views.cc b/chrome/browser/ui/views/download/download_danger_prompt_views.cc 8975index 6e063d0b1d..94fc2659ae 100644 8976--- a/chrome/browser/ui/views/download/download_danger_prompt_views.cc 8977+++ b/chrome/browser/ui/views/download/download_danger_prompt_views.cc 8978@@ -271,11 +271,13 @@ void DownloadDangerPromptViews::RunDone(Action action) { 8979 if (!download_->GetURL().is_empty() && 8980 !content::DownloadItemUtils::GetBrowserContext(download_) 8981 ->IsOffTheRecord()) { 8982+ #if BUILDFLAG(FULL_SAFE_BROWSING) 8983 ClientSafeBrowsingReportRequest::ReportType report_type 8984 = show_context_ ? 8985 ClientSafeBrowsingReportRequest::DANGEROUS_DOWNLOAD_BY_API : 8986 ClientSafeBrowsingReportRequest::DANGEROUS_DOWNLOAD_RECOVERY; 8987 SendSafeBrowsingDownloadReport(report_type, accept, *download_); 8988+ #endif 8989 } 8990 } 8991 download_->RemoveObserver(this); 8992diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc 8993index fe92b1c432..de9214b6a0 100644 8994--- a/chrome/browser/ui/views/download/download_item_view.cc 8995+++ b/chrome/browser/ui/views/download/download_item_view.cc 8996@@ -775,11 +775,19 @@ void DownloadItemView::UpdateLabels() { 8997 8998 deep_scanning_label_->SetVisible(mode_ == Mode::kDeepScanning); 8999 if (deep_scanning_label_->GetVisible()) { 9000- const int id = (model_->download() && 9001+ int id; 9002+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 9003+ id = (model_->download() && 9004 safe_browsing::DeepScanningRequest::ShouldUploadBinary( 9005 model_->download())) 9006 ? IDS_PROMPT_DEEP_SCANNING_DOWNLOAD 9007 : IDS_PROMPT_DEEP_SCANNING_APP_DOWNLOAD; 9008+#else 9009+ id = model_->download() 9010+ ? IDS_PROMPT_DEEP_SCANNING_DOWNLOAD 9011+ : IDS_PROMPT_DEEP_SCANNING_APP_DOWNLOAD; 9012+#endif 9013+ 9014 const std::u16string filename = ElidedFilename(*deep_scanning_label_); 9015 size_t filename_offset; 9016 deep_scanning_label_->SetText( 9017@@ -801,11 +809,15 @@ void DownloadItemView::UpdateButtons() { 9018 } 9019 9020 const bool allow_open_during_deep_scan = 9021+#if BUILDFLAG(FULL_SAFE_BROWSING) 9022 (mode_ == Mode::kDeepScanning) && 9023 !enterprise_connectors::ConnectorsServiceFactory::GetForBrowserContext( 9024 model_->profile()) 9025 ->DelayUntilVerdict( 9026 enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED); 9027+#else 9028+ false; 9029+#endif 9030 open_button_->SetEnabled((mode_ == Mode::kNormal) || prompt_to_scan || 9031 allow_open_during_deep_scan); 9032 9033@@ -1234,7 +1246,9 @@ void DownloadItemView::ShowContextMenuImpl(const gfx::Rect& rect, 9034 } 9035 9036 void DownloadItemView::OpenDownloadDuringAsyncScanning() { 9037+#if BUILDFLAG(FULL_SAFE_BROWSING) 9038 model_->CompleteSafeBrowsingScan(); 9039+#endif 9040 model_->SetOpenWhenComplete(true); 9041 } 9042 9043diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_linux.cc b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_linux.cc 9044index 87b6ebe86d..041f5f7fe6 100644 9045--- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_linux.cc 9046+++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_linux.cc 9047@@ -151,7 +151,7 @@ void BrowserDesktopWindowTreeHostLinux::OnWindowStateChanged( 9048 //////////////////////////////////////////////////////////////////////////////// 9049 // BrowserDesktopWindowTreeHost, public: 9050 9051-#if !BUILDFLAG(IS_CHROMEOS_LACROS) 9052+#if !BUILDFLAG(IS_CHROMEOS_LACROS) && !defined(OS_OHOS) 9053 // static 9054 BrowserDesktopWindowTreeHost* 9055 BrowserDesktopWindowTreeHost::CreateBrowserDesktopWindowTreeHost( 9056diff --git a/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc b/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc 9057index e459fd85b1..4f1aeb8492 100644 9058--- a/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc 9059+++ b/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc 9060@@ -67,7 +67,11 @@ bool DesktopBrowserFrameAuraLinux::UseCustomFrame() const { 9061 9062 void DesktopBrowserFrameAuraLinux::TabDraggingKindChanged( 9063 TabDragKind tab_drag_kind) { 9064+#if !defined(OS_OHOS) 9065 host_->TabDraggingKindChanged(tab_drag_kind); 9066+#else 9067+ LOG(INFO) << "DesktopBrowserFrameAuraLinux::TabDraggingKindChanged TODO for OS_OHOS"; 9068+#endif 9069 } 9070 9071 void DesktopBrowserFrameAuraLinux::OnUseCustomChromeFrameChanged() { 9072diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc 9073index 6aee25a053..e91cea1674 100644 9074--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc 9075+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc 9076@@ -6,7 +6,7 @@ 9077 9078 #include "build/build_config.h" 9079 9080-#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) 9081+#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_OHOS) 9082 9083 // static 9084 std::unique_ptr<OpaqueBrowserFrameViewPlatformSpecific> 9085diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view.cc 9086index 163aa4ac01..5cc8109549 100644 9087--- a/chrome/browser/ui/views/page_info/page_info_bubble_view.cc 9088+++ b/chrome/browser/ui/views/page_info/page_info_bubble_view.cc 9089@@ -1028,7 +1028,9 @@ void PageInfoBubbleView::HandleMoreInfoRequestAsync(int view_id) { 9090 if (certificate_ && top_window) { 9091 presenter_->RecordPageInfoAction( 9092 PageInfo::PAGE_INFO_CERTIFICATE_DIALOG_OPENED); 9093+#if !defined(OS_OHOS) 9094 ShowCertificateViewer(web_contents(), top_window, certificate_.get()); 9095+#endif 9096 } 9097 break; 9098 } 9099diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc 9100index 037105a4c7..948340f99e 100644 9101--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc 9102+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc 9103@@ -590,8 +590,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, 9104 return &NewWebUI<PredictorsUI>; 9105 if (url.host_piece() == chrome::kChromeUIQuotaInternalsHost) 9106 return &NewWebUI<QuotaInternalsUI>; 9107+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 9108 if (url.host_piece() == safe_browsing::kChromeUISafeBrowsingHost) 9109 return &NewWebUI<safe_browsing::SafeBrowsingUI>; 9110+#endif 9111 if (url.host_piece() == chrome::kChromeUISignInInternalsHost) 9112 return &NewWebUI<SignInInternalsUI>; 9113 if (url.host_piece() == chrome::kChromeUISuggestionsHost) 9114diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_ui.h b/chrome/browser/ui/webui/chromeos/login/oobe_ui.h 9115index 82d442e425..e9f933e23d 100644 9116--- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.h 9117+++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.h 9118@@ -62,7 +62,7 @@ class OobeUI : public ui::MojoWebUIController { 9119 9120 protected: 9121 virtual ~Observer() {} 9122- DISALLOW_COPY(Observer); 9123+ DISALLOW_COPY_BASE(Observer); 9124 }; 9125 9126 OobeUI(content::WebUI* web_ui, const GURL& url); 9127diff --git a/chrome/browser/ui/webui/discards/BUILD.gn b/chrome/browser/ui/webui/discards/BUILD.gn 9128index 1262bc6e40..757e99097c 100644 9129--- a/chrome/browser/ui/webui/discards/BUILD.gn 9130+++ b/chrome/browser/ui/webui/discards/BUILD.gn 9131@@ -4,7 +4,7 @@ 9132 9133 import("//mojo/public/tools/bindings/mojom.gni") 9134 9135-if (is_win || is_mac || is_linux || is_chromeos) { 9136+if (is_win || is_mac || is_linux || is_chromeos || is_ohos) { 9137 mojom("mojo_bindings") { 9138 sources = [ 9139 "discards.mojom", 9140diff --git a/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc 9141index ee3461ee5c..98fba5e732 100644 9142--- a/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc 9143+++ b/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc 9144@@ -367,7 +367,9 @@ void DownloadsDOMHandler::OpenDuringScanningRequiringGesture( 9145 if (download) { 9146 DownloadItemModel model(download); 9147 model.SetOpenWhenComplete(true); 9148+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 9149 model.CompleteSafeBrowsingScan(); 9150+#endif 9151 } 9152 } 9153 9154diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc 9155index bbd2869208..0577e79432 100644 9156--- a/chrome/browser/ui/webui/favicon_source.cc 9157+++ b/chrome/browser/ui/webui/favicon_source.cc 9158@@ -220,7 +220,12 @@ bool FaviconSource::ShouldServiceRequest( 9159 9160 ui::NativeTheme* FaviconSource::GetNativeTheme( 9161 const content::WebContents::Getter& wc_getter) { 9162+#if !defined(OS_OHOS) 9163 return webui::GetNativeTheme(wc_getter.Run()); 9164+#else 9165+ LOG(INFO) << "FaviconSource::GetNativeTheme TODO for OS_OHOS"; 9166+ return nullptr; 9167+#endif 9168 } 9169 9170 void FaviconSource::OnFaviconDataAvailable( 9171diff --git a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc 9172index 61e783625f..9a94d5d7ce 100644 9173--- a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc 9174+++ b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc 9175@@ -262,6 +262,7 @@ std::unique_ptr<BadClockBlockingPage> CreateBadClockBlockingPage( 9176 clock_state, nullptr); 9177 } 9178 9179+#if BUILDFLAG(FULL_SAFE_BROWSING) 9180 std::unique_ptr<LookalikeUrlBlockingPage> CreateLookalikeInterstitialPage( 9181 content::WebContents* web_contents) { 9182 GURL request_url("https://example.net"); 9183@@ -277,6 +278,7 @@ std::unique_ptr<LookalikeUrlBlockingPage> CreateLookalikeInterstitialPage( 9184 std::make_unique<LookalikeUrlControllerClient>(web_contents, request_url, 9185 safe_url)); 9186 } 9187+#endif 9188 9189 std::unique_ptr<security_interstitials::InsecureFormBlockingPage> 9190 CreateInsecureFormPage(content::WebContents* web_contents) { 9191@@ -287,6 +289,7 @@ CreateInsecureFormPage(content::WebContents* web_contents) { 9192 request_url)); 9193 } 9194 9195+#if BUILDFLAG(FULL_SAFE_BROWSING) 9196 std::unique_ptr<safe_browsing::SafeBrowsingBlockingPage> 9197 CreateSafeBrowsingBlockingPage(content::WebContents* web_contents) { 9198 safe_browsing::SBThreatType threat_type = 9199@@ -393,6 +396,7 @@ CreateSafeBrowsingQuietBlockingPage(content::WebContents* web_contents) { 9200 g_browser_process->safe_browsing_service()->ui_manager().get(), 9201 web_contents, main_frame_url, resource, is_giant_webview)); 9202 } 9203+#endif 9204 9205 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 9206 std::unique_ptr<CaptivePortalBlockingPage> CreateCaptivePortalBlockingPage( 9207@@ -510,12 +514,16 @@ void InterstitialHTMLSource::StartDataRequest( 9208 interstitial_delegate = CreateBlockedInterceptionBlockingPage(web_contents); 9209 } else if (path_without_query == "/legacy-tls") { 9210 interstitial_delegate = CreateLegacyTLSBlockingPage(web_contents); 9211+#if BUILDFLAG(FULL_SAFE_BROWSING) 9212 } else if (path_without_query == "/safebrowsing") { 9213 interstitial_delegate = CreateSafeBrowsingBlockingPage(web_contents); 9214+#endif 9215 } else if (path_without_query == "/clock") { 9216 interstitial_delegate = CreateBadClockBlockingPage(web_contents); 9217+#if BUILDFLAG(FULL_SAFE_BROWSING) 9218 } else if (path_without_query == "/lookalike") { 9219 interstitial_delegate = CreateLookalikeInterstitialPage(web_contents); 9220+#endif 9221 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 9222 } else if (path_without_query == "/captiveportal") { 9223 interstitial_delegate = CreateCaptivePortalBlockingPage(web_contents); 9224@@ -527,10 +535,12 @@ void InterstitialHTMLSource::StartDataRequest( 9225 } 9226 9227 if (path_without_query == "/quietsafebrowsing") { 9228+#if BUILDFLAG(FULL_SAFE_BROWSING) 9229 std::unique_ptr<TestSafeBrowsingBlockingPageQuiet> blocking_page = 9230 CreateSafeBrowsingQuietBlockingPage(web_contents); 9231 html = blocking_page->GetHTML(); 9232 interstitial_delegate = std::move(blocking_page); 9233+#endif 9234 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) 9235 } else if (path_without_query == "/supervised_user") { 9236 html = GetSupervisedUserInterstitialHTML(path); 9237diff --git a/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc b/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc 9238index fd7415abd6..86aa5acb13 100644 9239--- a/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc 9240+++ b/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc 9241@@ -194,9 +194,13 @@ void NewTabPageThirdPartyHandler::NotifyAboutTheme() { 9242 theme->shortcut_use_white_tile_icon = 9243 color_utils::IsDark(theme->shortcut_background_color); 9244 theme->shortcut_use_title_pill = false; 9245+#if !defined(OS_OHOS) 9246 theme->color_background = color_utils::SkColorToRgbaString( 9247 GetThemeColor(webui::GetNativeTheme(web_contents_), theme_provider, 9248 ThemeProperties::COLOR_NTP_BACKGROUND)); 9249+#else 9250+ LOG(INFO) << "NewTabPageThirdPartyHandler::NotifyAboutTheme TODO for OS_OHOS"; 9251+#endif 9252 if (theme_provider.HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { 9253 theme->background_tiling = GetNewTabBackgroundTilingCSS(theme_provider); 9254 theme->bookmark_bar_attached = 9255diff --git a/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc b/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc 9256index 68372f0e87..2fcca35923 100644 9257--- a/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc 9258+++ b/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc 9259@@ -70,10 +70,14 @@ content::WebUIDataSource* CreateNewTabPageThirdPartyUiHtmlSource( 9260 GetNewTabBackgroundTilingCSS(theme_provider)); 9261 source->AddString("bookmarkbarattached", 9262 bookmarkBarAttached ? "bookmark-bar-attached" : ""); 9263+#if !defined(OS_OHOS) 9264 source->AddString("colorBackground", 9265 color_utils::SkColorToRgbaString(GetThemeColor( 9266 webui::GetNativeTheme(web_contents), theme_provider, 9267 ThemeProperties::COLOR_NTP_BACKGROUND))); 9268+#else 9269+ LOG(INFO) << "CreateNewTabPageThirdPartyUiHtmlSource TODO for OS_OHOS"; 9270+#endif 9271 source->AddString("themeId", 9272 profile->GetPrefs()->GetString(prefs::kCurrentThemeID)); 9273 source->AddString("hascustombackground", 9274diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc 9275index e771fa5215..51f122afca 100644 9276--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc 9277+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc 9278@@ -473,7 +473,11 @@ scoped_refptr<base::RefCountedString> NTPResourceCache::CreateNewTabGuestHTML( 9279 9280 void NTPResourceCache::CreateNewTabIncognitoCSS( 9281 const content::WebContents::Getter wc_getter) { 9282+#if !defined(OS_OHOS) 9283 const ui::NativeTheme* native_theme = webui::GetNativeTheme(wc_getter.Run()); 9284+#else 9285+ LOG(INFO) << "NTPResourceCache::CreateNewTabIncognitoCSS TODO for OS_OHOS"; 9286+#endif 9287 const ui::ThemeProvider& tp = ThemeService::GetThemeProviderForProfile( 9288 profile_->GetPrimaryOTRProfile()); 9289 9290@@ -485,8 +489,10 @@ void NTPResourceCache::CreateNewTabIncognitoCSS( 9291 profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); 9292 9293 // Colors. 9294+#if !defined(OS_OHOS) 9295 substitutions["colorBackground"] = color_utils::SkColorToRgbaString( 9296 GetThemeColor(native_theme, tp, ThemeProperties::COLOR_NTP_BACKGROUND)); 9297+#endif 9298 substitutions["backgroundBarDetached"] = GetNewTabBackgroundCSS(tp, false); 9299 substitutions["backgroundBarAttached"] = GetNewTabBackgroundCSS(tp, true); 9300 substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp); 9301@@ -507,7 +513,12 @@ void NTPResourceCache::CreateNewTabIncognitoCSS( 9302 9303 void NTPResourceCache::CreateNewTabCSS( 9304 const content::WebContents::Getter wc_getter) { 9305+#if !defined(OS_OHOS) 9306 const ui::NativeTheme* native_theme = webui::GetNativeTheme(wc_getter.Run()); 9307+#else 9308+ const ui::NativeTheme* native_theme = nullptr; 9309+ LOG(INFO) << "NTPResourceCache::CreateNewTabCSS TODO for OS_OHOS"; 9310+#endif 9311 const ui::ThemeProvider& tp = 9312 ThemeService::GetThemeProviderForProfile(profile_); 9313 9314diff --git a/chrome/browser/ui/webui/signin/profile_picker_handler.cc b/chrome/browser/ui/webui/signin/profile_picker_handler.cc 9315index 8186c8638d..1393ecfe21 100644 9316--- a/chrome/browser/ui/webui/signin/profile_picker_handler.cc 9317+++ b/chrome/browser/ui/webui/signin/profile_picker_handler.cc 9318@@ -122,6 +122,7 @@ base::Value GetAutogeneratedProfileThemeInfoValue(int color_id, 9319 return dict; 9320 } 9321 9322+#if !defined(OS_OHOS) 9323 base::Value CreateDefaultProfileThemeInfo(int avatar_icon_size, 9324 bool dark_mode) { 9325 SkColor frame_color = ThemeProperties::GetDefaultColor( 9326@@ -135,6 +136,7 @@ base::Value CreateDefaultProfileThemeInfo(int avatar_icon_size, 9327 kDefaultThemeColorId, base::nullopt, frame_color, active_tab_color, 9328 frame_text_color, avatar_icon_size); 9329 } 9330+#endif 9331 9332 base::Value CreateAutogeneratedProfileThemeInfo(int color_id, 9333 SkColor color, 9334@@ -406,9 +408,13 @@ void ProfilePickerHandler::HandleGetProfileThemeInfo( 9335 base::Value dict; 9336 switch (color_id) { 9337 case kDefaultThemeColorId: 9338+#if !defined(OS_OHOS) 9339 dict = CreateDefaultProfileThemeInfo( 9340 avatar_icon_size, webui::GetNativeTheme(web_ui()->GetWebContents()) 9341 ->ShouldUseDarkColors()); 9342+#else 9343+ LOG(INFO) << "ProfilePickerHandler::HandleGetProfileThemeInfo kDefaultThemeColorId TODO for OS_OHOS"; 9344+#endif 9345 break; 9346 case kManuallyPickedColorId: 9347 dict = CreateAutogeneratedProfileThemeInfo(color_id, *color, 9348diff --git a/chrome/browser/ui/webui/theme_handler.cc b/chrome/browser/ui/webui/theme_handler.cc 9349index eca1912068..68b87e1c01 100644 9350--- a/chrome/browser/ui/webui/theme_handler.cc 9351+++ b/chrome/browser/ui/webui/theme_handler.cc 9352@@ -40,11 +40,13 @@ void ThemeHandler::OnJavascriptAllowed() { 9353 // Listen for theme installation. 9354 ThemeServiceFactory::GetForProfile(GetProfile())->AddObserver(this); 9355 9356+#if defined(TOOLKIT_VIEWS) 9357 // Or native theme change. 9358 if (web_ui()) { 9359 theme_observation_.Observe( 9360 webui::GetNativeTheme(web_ui()->GetWebContents())); 9361 } 9362+#endif 9363 } 9364 9365 void ThemeHandler::OnJavascriptDisallowed() { 9366@@ -60,12 +62,14 @@ void ThemeHandler::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) { 9367 // There are two types of theme update. a) The observed theme change. e.g. 9368 // switch between light/dark mode. b) A different theme is enabled. e.g. 9369 // switch between GTK and classic theme on Linux. Reset observer in case b). 9370+#if defined(TOOLKIT_VIEWS) 9371 ui::NativeTheme* current_theme = 9372 webui::GetNativeTheme(web_ui()->GetWebContents()); 9373 if (observed_theme != current_theme) { 9374 theme_observation_.Reset(); 9375 theme_observation_.Observe(current_theme); 9376 } 9377+#endif 9378 SendThemeChanged(); 9379 } 9380 9381diff --git a/chrome/browser/usb/web_usb_chooser_desktop.cc b/chrome/browser/usb/web_usb_chooser_desktop.cc 9382index 92616165a1..8dba126ad2 100644 9383--- a/chrome/browser/usb/web_usb_chooser_desktop.cc 9384+++ b/chrome/browser/usb/web_usb_chooser_desktop.cc 9385@@ -20,8 +20,10 @@ WebUsbChooserDesktop::~WebUsbChooserDesktop() = default; 9386 void WebUsbChooserDesktop::ShowChooser( 9387 std::unique_ptr<UsbChooserController> controller) { 9388 closure_runner_.RunAndReset(); 9389+#if !defined(OS_OHOS) 9390 closure_runner_.ReplaceClosure(chrome::ShowDeviceChooserDialog( 9391 render_frame_host(), std::move(controller))); 9392+#endif 9393 } 9394 9395 base::WeakPtr<WebUsbChooser> WebUsbChooserDesktop::GetWeakPtr() { 9396diff --git a/chrome/browser/web_applications/components/BUILD.gn b/chrome/browser/web_applications/components/BUILD.gn 9397index c4fb300ebd..c8ef022537 100644 9398--- a/chrome/browser/web_applications/components/BUILD.gn 9399+++ b/chrome/browser/web_applications/components/BUILD.gn 9400@@ -108,7 +108,7 @@ source_set("components") { 9401 sources += [ "web_app_shortcut_chromeos.cc" ] 9402 } 9403 9404- if (is_linux || is_chromeos_lacros) { 9405+ if (is_linux || is_chromeos_lacros || is_ohos) { 9406 # Desktop linux, doesn't count ChromeOS. 9407 sources += [ 9408 "web_app_file_handler_registration_linux.cc", 9409diff --git a/chrome/browser/web_applications/components/web_app_file_handler_registration.h b/chrome/browser/web_applications/components/web_app_file_handler_registration.h 9410index 788a767ef7..1292e8850a 100644 9411--- a/chrome/browser/web_applications/components/web_app_file_handler_registration.h 9412+++ b/chrome/browser/web_applications/components/web_app_file_handler_registration.h 9413@@ -42,7 +42,7 @@ void UnregisterFileHandlersWithOs(const AppId& app_id, 9414 std::unique_ptr<ShortcutInfo> info, 9415 base::OnceCallback<void()> callback); 9416 9417-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 9418+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9419 using RegisterMimeTypesOnLinuxCallback = 9420 base::OnceCallback<bool(base::FilePath profile_path, 9421 std::string file_contents)>; 9422diff --git a/chrome/browser/web_applications/components/web_app_run_on_os_login.cc b/chrome/browser/web_applications/components/web_app_run_on_os_login.cc 9423index 7166cbde95..61d3b51072 100644 9424--- a/chrome/browser/web_applications/components/web_app_run_on_os_login.cc 9425+++ b/chrome/browser/web_applications/components/web_app_run_on_os_login.cc 9426@@ -34,7 +34,7 @@ namespace internals { 9427 9428 // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is 9429 // complete. 9430-#if !(defined(OS_WIN) || defined(OS_MAC) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))) 9431+#if !(defined(OS_WIN) || defined(OS_MAC) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS)) 9432 // This boilerplate function is used for platforms that don't support Run On OS 9433 // Login. Currently the feature is supported on Windows, Linux and MacOS. 9434 bool RegisterRunOnOsLogin(const ShortcutInfo& shortcut_info) { 9435diff --git a/chrome/browser/web_applications/components/web_application_info.cc b/chrome/browser/web_applications/components/web_application_info.cc 9436index 8b460a6ac5..25a4a201f9 100644 9437--- a/chrome/browser/web_applications/components/web_application_info.cc 9438+++ b/chrome/browser/web_applications/components/web_application_info.cc 9439@@ -14,11 +14,11 @@ IconBitmaps::~IconBitmaps() = default; 9440 9441 IconBitmaps::IconBitmaps(const IconBitmaps&) = default; 9442 9443-IconBitmaps::IconBitmaps(IconBitmaps&&) = default; 9444+IconBitmaps::IconBitmaps(IconBitmaps&&) noexcept = default; 9445 9446 IconBitmaps& IconBitmaps::operator=(const IconBitmaps&) = default; 9447 9448-IconBitmaps& IconBitmaps::operator=(IconBitmaps&&) = default; 9449+IconBitmaps& IconBitmaps::operator=(IconBitmaps&&) noexcept = default; 9450 9451 void IconBitmaps::SetBitmapsForPurpose( 9452 IconPurpose purpose, 9453@@ -51,7 +51,7 @@ WebApplicationIconInfo::WebApplicationIconInfo(const GURL& url, 9454 WebApplicationIconInfo::WebApplicationIconInfo(const WebApplicationIconInfo&) = 9455 default; 9456 9457-WebApplicationIconInfo::WebApplicationIconInfo(WebApplicationIconInfo&&) = 9458+WebApplicationIconInfo::WebApplicationIconInfo(WebApplicationIconInfo&&) noexcept = 9459 default; 9460 9461 WebApplicationIconInfo::~WebApplicationIconInfo() = default; 9462@@ -60,7 +60,7 @@ WebApplicationIconInfo& WebApplicationIconInfo::operator=( 9463 const WebApplicationIconInfo&) = default; 9464 9465 WebApplicationIconInfo& WebApplicationIconInfo::operator=( 9466- WebApplicationIconInfo&&) = default; 9467+ WebApplicationIconInfo&&) noexcept = default; 9468 9469 // WebApplicationShortcutsMenuItemInfo::Icon 9470 WebApplicationShortcutsMenuItemInfo::Icon::Icon() = default; 9471diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni 9472index 6050d17099..fa26d2dc9d 100644 9473--- a/chrome/chrome_paks.gni 9474+++ b/chrome/chrome_paks.gni 9475@@ -56,7 +56,7 @@ template("chrome_repack_percent") { 9476 deps += invoker.deps 9477 } 9478 9479- if (toolkit_views) { 9480+ if (toolkit_views || is_ohos) { 9481 sources += [ "$root_gen_dir/ui/views/resources/views_resources_${percent}_percent.pak" ] 9482 deps += [ "//ui/views/resources" ] 9483 } 9484diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn 9485index 79d548cceb..692dda0565 100644 9486--- a/chrome/common/BUILD.gn 9487+++ b/chrome/common/BUILD.gn 9488@@ -376,7 +376,7 @@ static_library("common") { 9489 "service_process_util.cc", 9490 "service_process_util.h", 9491 ] 9492- if (is_linux || is_chromeos) { 9493+ if (is_linux || is_chromeos || is_ohos) { 9494 sources += [ "service_process_util_linux.cc" ] 9495 } 9496 if (is_mac) { 9497@@ -480,7 +480,7 @@ static_library("common") { 9498 public_deps += [ "//chrome/common/safe_browsing" ] 9499 } 9500 9501- if (is_linux || is_chromeos) { 9502+ if (is_linux || is_chromeos || is_ohos) { 9503 sources += [ 9504 "auto_start_linux.cc", 9505 "auto_start_linux.h", 9506@@ -627,7 +627,7 @@ static_library("constants") { 9507 "chrome_paths_lacros.h", 9508 ] 9509 deps += [ "//chromeos/crosapi/cpp" ] 9510- } else if (is_linux || is_chromeos) { 9511+ } else if (is_linux || is_chromeos || is_ohos) { 9512 sources += [ "chrome_paths_linux.cc" ] 9513 } 9514 if (is_mac) { 9515diff --git a/chrome/common/channel_info.h b/chrome/common/channel_info.h 9516index 8881e314d0..75cf8ed776 100644 9517--- a/chrome/common/channel_info.h 9518+++ b/chrome/common/channel_info.h 9519@@ -93,7 +93,7 @@ std::string GetChannelSuffixForDataDir(); 9520 9521 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9522 // of lacros-chrome is complete. 9523-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9524+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9525 // Returns the channel-specific filename of the desktop shortcut used to launch 9526 // the browser. 9527 std::string GetDesktopName(base::Environment* env); 9528diff --git a/chrome/common/channel_info_posix.cc b/chrome/common/channel_info_posix.cc 9529index 62ff67422f..b5b1dac943 100644 9530--- a/chrome/common/channel_info_posix.cc 9531+++ b/chrome/common/channel_info_posix.cc 9532@@ -90,7 +90,7 @@ std::string GetChannelSuffixForDataDir() { 9533 9534 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9535 // of lacros-chrome is complete. 9536-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9537+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9538 std::string GetDesktopName(base::Environment* env) { 9539 #if BUILDFLAG(GOOGLE_CHROME_BRANDING) 9540 // Google Chrome packaged as a snap is a special case: the application name 9541diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc 9542index 543a1ad197..5a0fcf9539 100644 9543--- a/chrome/common/chrome_features.cc 9544+++ b/chrome/common/chrome_features.cc 9545@@ -81,7 +81,7 @@ const base::Feature kAsyncDns { 9546 #endif 9547 }; 9548 9549-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) 9550+#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9551 // Enables the Restart background mode optimization. When all Chrome UI is 9552 // closed and it goes in the background, allows to restart the browser to 9553 // discard memory. 9554@@ -339,7 +339,7 @@ const base::Feature kEnableAllSystemWebApps{"EnableAllSystemWebApps", 9555 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9556 // of lacros-chrome is complete. 9557 #if defined(OS_WIN) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || \ 9558- defined(OS_MAC) 9559+ defined(OS_MAC) || defined(OS_OHOS) 9560 COMPONENT_EXPORT(CHROME_FEATURES) 9561 // Enables ephemeral Guest profiles on desktop. 9562 extern const base::Feature kEnableEphemeralGuestProfilesOnDesktop{ 9563@@ -515,7 +515,7 @@ const base::Feature kIncompatibleApplicationsWarning{ 9564 #endif 9565 9566 #if defined(OS_MAC) || defined(OS_WIN) || defined(OS_LINUX) || \ 9567- defined(OS_CHROMEOS) 9568+ defined(OS_CHROMEOS) || defined(OS_OHOS) 9569 // When enabled, removes any theme or background customization done by the user 9570 // and also overrides any dark/light mode treatment on the Incognito UI. 9571 const base::Feature kIncognitoBrandConsistencyForDesktop{ 9572diff --git a/chrome/common/chrome_features.h b/chrome/common/chrome_features.h 9573index 2bc88bc829..e2f1b81a12 100644 9574--- a/chrome/common/chrome_features.h 9575+++ b/chrome/common/chrome_features.h 9576@@ -70,7 +70,7 @@ extern const base::Feature kAppShimNewCloseBehavior; 9577 9578 COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kAsyncDns; 9579 9580-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) 9581+#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9582 COMPONENT_EXPORT(CHROME_FEATURES) 9583 extern const base::Feature kBackgroundModeAllowRestart; 9584 #endif // defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) 9585@@ -228,7 +228,7 @@ extern const base::Feature kEnableAmbientAuthenticationInIncognito; 9586 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9587 // of lacros-chrome is complete. 9588 #if defined(OS_WIN) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || \ 9589- defined(OS_MAC) 9590+ defined(OS_MAC) || defined(OS_OHOS) 9591 COMPONENT_EXPORT(CHROME_FEATURES) 9592 extern const base::Feature kEnableEphemeralGuestProfilesOnDesktop; 9593 #endif // defined(OS_WIN) || (defined(OS_LINUX) || 9594@@ -343,7 +343,7 @@ extern const base::Feature kIncompatibleApplicationsWarning; 9595 #endif // defined(OS_ANDROID) 9596 9597 #if defined(OS_MAC) || defined(OS_WIN) || defined(OS_LINUX) || \ 9598- defined(OS_CHROMEOS) 9599+ defined(OS_CHROMEOS) || defined(OS_OHOS) 9600 COMPONENT_EXPORT(CHROME_FEATURES) 9601 extern const base::Feature kIncognitoBrandConsistencyForDesktop; 9602 #endif 9603diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h 9604index 0dfe8a6652..d19697ae35 100644 9605--- a/chrome/common/chrome_paths.h 9606+++ b/chrome/common/chrome_paths.h 9607@@ -111,7 +111,7 @@ enum { 9608 DIR_CHROMEOS_CUSTOM_WALLPAPERS, // Directory where custom wallpapers 9609 // reside. 9610 #endif 9611-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) 9612+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_OHOS) 9613 DIR_NATIVE_MESSAGING, // System directory where native messaging host 9614 // manifest files are stored. 9615 DIR_USER_NATIVE_MESSAGING, // Directory with Native Messaging Hosts 9616diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc 9617index 99346c8012..446867010f 100644 9618--- a/chrome/common/chrome_switches.cc 9619+++ b/chrome/common/chrome_switches.cc 9620@@ -809,7 +809,7 @@ const char kAllowNaClSocketAPI[] = "allow-nacl-socket-api"; 9621 #endif 9622 9623 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || \ 9624- defined(OS_WIN) 9625+ defined(OS_WIN) || defined(OS_OHOS) 9626 const char kEnableNewAppMenuIcon[] = "enable-new-app-menu-icon"; 9627 9628 // Causes the browser to launch directly in guest mode. 9629diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h 9630index fd5496c91f..6e90b0c427 100644 9631--- a/chrome/common/chrome_switches.h 9632+++ b/chrome/common/chrome_switches.h 9633@@ -256,7 +256,7 @@ extern const char kAllowNaClSocketAPI[]; 9634 #endif 9635 9636 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || \ 9637- defined(OS_WIN) 9638+ defined(OS_WIN) || defined(OS_OHOS) 9639 extern const char kEnableNewAppMenuIcon[]; 9640 extern const char kGuest[]; 9641 #endif 9642diff --git a/chrome/common/features.gni b/chrome/common/features.gni 9643index 4452a2ec88..275786d440 100644 9644--- a/chrome/common/features.gni 9645+++ b/chrome/common/features.gni 9646@@ -40,7 +40,7 @@ declare_args() { 9647 enable_basic_print_dialog = enable_basic_printing && !is_chromeos_ash 9648 9649 # Enables the Click to Call feature on desktop platforms. 9650- enable_click_to_call = is_mac || is_win || is_linux || is_chromeos 9651+ enable_click_to_call = is_mac || is_win || is_linux || is_chromeos || is_ohos 9652 9653 # Hangout services is an extension that adds extra features to Hangouts. 9654 # It is enableable separately to facilitate testing. 9655diff --git a/chrome/common/importer/BUILD.gn b/chrome/common/importer/BUILD.gn 9656index 1dc45cbeeb..9b189d98e1 100644 9657--- a/chrome/common/importer/BUILD.gn 9658+++ b/chrome/common/importer/BUILD.gn 9659@@ -91,7 +91,7 @@ source_set("importer") { 9660 "importer_url_row.h", 9661 "pstore_declarations.h", 9662 ] 9663- if (is_chromeos || is_linux) { 9664+ if (is_chromeos || is_linux || is_ohos) { 9665 sources += [ "firefox_importer_utils_linux.cc" ] 9666 } else if (is_mac) { 9667 sources += [ 9668diff --git a/chrome/common/importer/importer_data_types.cc b/chrome/common/importer/importer_data_types.cc 9669index 9715826b7d..c922096453 100644 9670--- a/chrome/common/importer/importer_data_types.cc 9671+++ b/chrome/common/importer/importer_data_types.cc 9672@@ -34,7 +34,7 @@ ImportedPasswordForm::ImportedPasswordForm() = default; 9673 ImportedPasswordForm::ImportedPasswordForm(const ImportedPasswordForm& form) = 9674 default; 9675 9676-ImportedPasswordForm::ImportedPasswordForm(ImportedPasswordForm&& form) = 9677+ImportedPasswordForm::ImportedPasswordForm(ImportedPasswordForm&& form) noexcept = 9678 default; 9679 9680 ImportedPasswordForm& ImportedPasswordForm::operator=( 9681diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc 9682index 7dfc0103e9..fa3f2cc91b 100644 9683--- a/chrome/common/pref_names.cc 9684+++ b/chrome/common/pref_names.cc 9685@@ -1113,7 +1113,7 @@ const char kAllowedDomainsForApps[] = "settings.allowed_domains_for_apps"; 9686 9687 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9688 // of lacros-chrome is complete. 9689-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9690+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9691 // Linux specific preference on whether we should match the system theme. 9692 const char kUsesSystemTheme[] = "extensions.theme.use_system"; 9693 #endif 9694@@ -1264,7 +1264,7 @@ const char kShowUpdatePromotionInfoBar[] = 9695 9696 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9697 // of lacros-chrome is complete. 9698-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9699+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9700 // Boolean that is false if we should show window manager decorations. If 9701 // true, we draw a custom chrome frame (thicker title bar and blue border). 9702 const char kUseCustomChromeFrame[] = "browser.custom_chrome_frame"; 9703@@ -1723,7 +1723,7 @@ const char kDownloadDefaultDirectory[] = "download.default_directory"; 9704 const char kDownloadDirUpgraded[] = "download.directory_upgrade"; 9705 9706 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 9707- defined(OS_MAC) 9708+ defined(OS_MAC) || defined(OS_OHOS) 9709 const char kOpenPdfDownloadInSystemReader[] = 9710 "download.open_pdf_in_system_reader"; 9711 #endif 9712@@ -1993,7 +1993,7 @@ const char kWebAppsUninstalledDefaultChromeApps[] = 9713 const char kWebAppsPreferences[] = "web_apps.web_app_ids"; 9714 9715 #if defined(OS_WIN) || defined(OS_MAC) || \ 9716- (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) 9717+ (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 9718 // Dictionary that maps origins to web apps that can act as URL handlers. 9719 const char kWebAppsUrlHandlerInfo[] = "web_apps.url_handler_info"; 9720 #endif 9721@@ -2109,7 +2109,7 @@ const char kAmbientAuthenticationInPrivateModesEnabled[] = 9722 // requests. 9723 const char kBasicAuthOverHttpEnabled[] = "auth.basic_over_http_enabled"; 9724 9725-#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_CHROMEOS) 9726+#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9727 // Boolean that specifies whether OK-AS-DELEGATE flag from KDC is respected 9728 // along with kAuthNegotiateDelegateAllowlist. 9729 const char kAuthNegotiateDelegateByKdcPolicy[] = 9730@@ -2746,7 +2746,7 @@ const char kSigninInterceptionEnabled[] = "signin.interception_enabled"; 9731 9732 // TODO(crbug.com/1179280): Remove OS_LINUX once https://crbug.com/1169547 is 9733 // done. 9734-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 9735+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9736 // Boolean pref indicating whether the user is allowed to create secondary 9737 // profiles in Lacros browser. This is set by a policy, and the default value 9738 // for managed users is false. 9739@@ -3007,7 +3007,7 @@ const char kBlockAutoplayEnabled[] = "media.block_autoplay"; 9740 9741 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9742 // of lacros-chrome is complete. 9743-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9744+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9745 // Boolean that indicates if native notifications are allowed to be used in 9746 // place of Chrome notifications. Will be replaced by kAllowSystemNotifications. 9747 const char kAllowNativeNotifications[] = "native_notifications.allowed"; 9748diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h 9749index 4b8a9737e9..e32bc99b29 100644 9750--- a/chrome/common/pref_names.h 9751+++ b/chrome/common/pref_names.h 9752@@ -366,7 +366,7 @@ extern const char kForceYouTubeRestrict[]; 9753 extern const char kAllowedDomainsForApps[]; 9754 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9755 // of lacros-chrome is complete. 9756-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9757+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9758 extern const char kUsesSystemTheme[]; 9759 #endif 9760 extern const char kCurrentThemePackFilename[]; 9761@@ -395,7 +395,7 @@ extern const char kShowUpdatePromotionInfoBar[]; 9762 #endif 9763 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9764 // of lacros-chrome is complete. 9765-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9766+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9767 extern const char kUseCustomChromeFrame[]; 9768 #endif 9769 #if BUILDFLAG(ENABLE_PLUGINS) 9770@@ -568,7 +568,7 @@ extern const char kDownloadExtensionsToOpenByPolicy[]; 9771 extern const char kDownloadAllowedURLsForOpenByPolicy[]; 9772 extern const char kDownloadDirUpgraded[]; 9773 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 9774- defined(OS_MAC) 9775+ defined(OS_MAC) || defined(OS_OHOS) 9776 extern const char kOpenPdfDownloadInSystemReader[]; 9777 #endif 9778 #if defined(OS_ANDROID) 9779@@ -671,7 +671,7 @@ extern const char kWebAppsUninstalledDefaultChromeApps[]; 9780 extern const char kWebAppsPreferences[]; 9781 9782 #if defined(OS_WIN) || defined(OS_MAC) || \ 9783- (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) 9784+ (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 9785 extern const char kWebAppsUrlHandlerInfo[]; 9786 #endif 9787 9788@@ -807,7 +807,7 @@ extern const char kGloballyScopeHTTPAuthCacheEnabled[]; 9789 extern const char kAmbientAuthenticationInPrivateModesEnabled[]; 9790 extern const char kBasicAuthOverHttpEnabled[]; 9791 9792-#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_CHROMEOS) 9793+#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9794 extern const char kAuthNegotiateDelegateByKdcPolicy[]; 9795 #endif // defined(OS_LINUX) || defined(OS_MAC) || defined(OS_CHROMEOS) 9796 9797@@ -926,7 +926,7 @@ extern const char kSigninAllowedOnNextStartup[]; 9798 extern const char kSigninInterceptionEnabled[]; 9799 // TODO(crbug.com/1179280): Remove OS_LINUX once https://crbug.com/1169547 is 9800 // done. 9801-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 9802+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9803 extern const char kLacrosSecondaryProfilesAllowed[]; 9804 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) 9805 9806@@ -1040,7 +1040,7 @@ extern const char kBlockAutoplayEnabled[]; 9807 9808 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9809 // of lacros-chrome is complete. 9810-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 9811+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 9812 extern const char kAllowNativeNotifications[]; 9813 extern const char kAllowSystemNotifications[]; 9814 #endif 9815diff --git a/chrome/common/service_process_util_posix.cc b/chrome/common/service_process_util_posix.cc 9816index 059174502d..48bfa7dd46 100644 9817--- a/chrome/common/service_process_util_posix.cc 9818+++ b/chrome/common/service_process_util_posix.cc 9819@@ -117,8 +117,14 @@ ServiceProcessState::CreateServiceProcessDataRegion(size_t size) { 9820 // Everything has worked out so far, so open a read-only handle to the region 9821 // in order to be able to create a writable region (which needs a read-only 9822 // handle in order to convert to a read-only region. 9823+#if !defined(OS_OHOS) 9824 base::ScopedFD read_only_fd( 9825 HANDLE_EINTR(open(path.value().c_str(), O_RDONLY, kOwnerOnly))); 9826+#else 9827+ base::ScopedFD read_only_fd( 9828+ HANDLE_EINTR(open(path.value().c_str(), O_RDONLY | O_CREAT, kOwnerOnly))); 9829+ LOG(INFO) << "ServiceProcessState::CreateServiceProcessDataRegion read_only_fd TODO for OS_OHOS"; 9830+#endif 9831 if (!read_only_fd.is_valid()) { 9832 DPLOG(ERROR) << "Could not reopen shared memory region as read-only"; 9833 return {}; 9834diff --git a/chrome/common/webui_url_constants.cc b/chrome/common/webui_url_constants.cc 9835index ebfd4062fc..f9509098f4 100644 9836--- a/chrome/common/webui_url_constants.cc 9837+++ b/chrome/common/webui_url_constants.cc 9838@@ -361,7 +361,7 @@ const char kChromeUIWebUIJsErrorURL[] = "chrome://webuijserror/"; 9839 #endif 9840 9841 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 9842- defined(OS_CHROMEOS) 9843+ defined(OS_CHROMEOS) || defined(OS_OHOS) 9844 const char kChromeUIDiscardsHost[] = "discards"; 9845 const char kChromeUIDiscardsURL[] = "chrome://discards/"; 9846 #endif 9847@@ -383,7 +383,7 @@ const char kChromeUISandboxHost[] = "sandbox"; 9848 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9849 // of lacros-chrome is complete. 9850 #if defined(OS_WIN) || defined(OS_MAC) || \ 9851- (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) 9852+ (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 9853 const char kChromeUIBrowserSwitchHost[] = "browser-switch"; 9854 const char kChromeUIBrowserSwitchURL[] = "chrome://browser-switch/"; 9855 const char kChromeUIEnterpriseProfileWelcomeHost[] = 9856diff --git a/chrome/common/webui_url_constants.h b/chrome/common/webui_url_constants.h 9857index cd2bebc4cf..633ca04d3f 100644 9858--- a/chrome/common/webui_url_constants.h 9859+++ b/chrome/common/webui_url_constants.h 9860@@ -306,13 +306,13 @@ extern const char kChromeUIOSSettingsHost[]; 9861 extern const char kChromeUIOSSettingsURL[]; 9862 #endif 9863 9864-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 9865+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 9866 extern const char kChromeUIWebUIJsErrorHost[]; 9867 extern const char kChromeUIWebUIJsErrorURL[]; 9868 #endif 9869 9870 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 9871- defined(OS_CHROMEOS) 9872+ defined(OS_CHROMEOS) || defined(OS_OHOS) 9873 extern const char kChromeUIDiscardsHost[]; 9874 extern const char kChromeUIDiscardsURL[]; 9875 #endif 9876@@ -327,14 +327,14 @@ extern const char kChromeUILinuxProxyConfigHost[]; 9877 #endif 9878 9879 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 9880- defined(OS_ANDROID) 9881+ defined(OS_ANDROID) || defined(OS_OHOS) 9882 extern const char kChromeUISandboxHost[]; 9883 #endif 9884 9885 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 9886 // of lacros-chrome is complete. 9887 #if defined(OS_WIN) || defined(OS_MAC) || \ 9888- (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) 9889+ (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 9890 extern const char kChromeUIBrowserSwitchHost[]; 9891 extern const char kChromeUIBrowserSwitchURL[]; 9892 extern const char kChromeUIEnterpriseProfileWelcomeHost[]; 9893@@ -347,7 +347,7 @@ extern const char kChromeUIProfilePickerStartupQuery[]; 9894 #endif 9895 9896 #if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(TOOLKIT_VIEWS)) || \ 9897- defined(USE_AURA) 9898+ defined(USE_AURA) || defined(OS_OHOS) 9899 extern const char kChromeUITabModalConfirmDialogHost[]; 9900 #endif 9901 9902diff --git a/chrome/service/cloud_print/print_system.cc b/chrome/service/cloud_print/print_system.cc 9903index 277ec4236a..cba6e4a1d0 100644 9904--- a/chrome/service/cloud_print/print_system.cc 9905+++ b/chrome/service/cloud_print/print_system.cc 9906@@ -36,7 +36,7 @@ std::string PrintSystem::GenerateProxyId() { 9907 return base::GenerateGUID(); 9908 } 9909 9910-#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && !defined(USE_CUPS) 9911+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && !defined(USE_CUPS) || defined(OS_OHOS) 9912 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( 9913 const base::DictionaryValue*) { 9914 return nullptr; 9915diff --git a/chrome/services/printing/public/mojom/BUILD.gn b/chrome/services/printing/public/mojom/BUILD.gn 9916index aa96e58b58..143a19cc32 100644 9917--- a/chrome/services/printing/public/mojom/BUILD.gn 9918+++ b/chrome/services/printing/public/mojom/BUILD.gn 9919@@ -35,7 +35,7 @@ mojom("mojom") { 9920 sources += [ "pdf_to_emf_converter.mojom" ] 9921 } 9922 9923- if (is_win || is_mac || is_linux || is_chromeos) { 9924+ if (is_win || is_mac || is_linux || is_chromeos || is_ohos) { 9925 sources += [ "print_backend_service.mojom" ] 9926 deps += [ "//printing/backend/mojom" ] 9927 } 9928diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn 9929index 3165971e9e..a2ecab3635 100644 9930--- a/chrome/test/BUILD.gn 9931+++ b/chrome/test/BUILD.gn 9932@@ -1755,7 +1755,7 @@ if (!is_android) { 9933 "//ash/keyboard/ui:test_support", 9934 "//chrome/browser/chromeos:arc_test_support", 9935 "//chrome/browser/chromeos:test_support", 9936- "//chrome/browser/media/router:test_support", 9937+ ##"//chrome/browser/media/router:test_support", 9938 "//chrome/browser/resources/chromeos/accessibility:browser_tests", 9939 "//chrome/browser/ui/ash/holding_space:browser_tests", 9940 "//chrome/services/file_util/public/cpp:browser_tests", 9941@@ -3392,7 +3392,7 @@ template("performance_test_suite_template") { 9942 data_deps = [ 9943 "//base:base_perftests", 9944 "//chrome/test:telemetry_perf_tests", 9945- "//components:components_perftests", 9946+ #"//components:components_perftests", 9947 "//components/tracing:tracing_perftests", 9948 "//gpu:command_buffer_perftests", 9949 "//gpu:gpu_perftests", 9950@@ -3408,7 +3408,7 @@ template("performance_test_suite_template") { 9951 data_deps += [ "//third_party/angle/src/tests:angle_perftests" ] 9952 } 9953 9954- if (!is_android && !is_fuchsia) { 9955+ if (!is_android && !is_fuchsia && !is_ohos) { 9956 data_deps += [ 9957 "//chrome/test:load_library_perf_tests", 9958 "//ui/views:views_perftests", 9959diff --git a/chrome/utility/BUILD.gn b/chrome/utility/BUILD.gn 9960index 3c1c93059d..de5e50c90f 100644 9961--- a/chrome/utility/BUILD.gn 9962+++ b/chrome/utility/BUILD.gn 9963@@ -77,7 +77,35 @@ static_library("utility") { 9964 deps += [ "//chrome/services/mac_notifications" ] 9965 } 9966 9967- if (!is_android) { 9968+ if (is_ohos) { 9969+ sources += [ 9970+ "importer/bookmark_html_reader.cc", 9971+ "importer/bookmark_html_reader.h", 9972+ "importer/bookmarks_file_importer.cc", 9973+ "importer/bookmarks_file_importer.h", 9974+ "importer/external_process_importer_bridge.cc", 9975+ "importer/external_process_importer_bridge.h", 9976+ "importer/favicon_reencode.cc", 9977+ "importer/favicon_reencode.h", 9978+ "importer/firefox_importer.cc", 9979+ "importer/firefox_importer.h", 9980+ "importer/importer.cc", 9981+ "importer/importer.h", 9982+ "importer/importer_creator.cc", 9983+ "importer/importer_creator.h", 9984+ "importer/profile_import_impl.cc", 9985+ "importer/profile_import_impl.h", 9986+ ] 9987+ deps += [ 9988+ "//chrome/common:mojo_bindings", 9989+ "//chrome/common/importer:interfaces", 9990+ "//chrome/services/speech:lib", 9991+ "//components/autofill/core/common", 9992+ "//services/proxy_resolver:lib", 9993+ ] 9994+ } 9995+ 9996+ if (!is_android && !is_ohos) { 9997 sources += [ 9998 "importer/bookmark_html_reader.cc", 9999 "importer/bookmark_html_reader.h", 10000diff --git a/chrome/utility/importer/firefox_importer.cc b/chrome/utility/importer/firefox_importer.cc 10001index 2682b3d386..504e2dece0 100644 10002--- a/chrome/utility/importer/firefox_importer.cc 10003+++ b/chrome/utility/importer/firefox_importer.cc 10004@@ -27,7 +27,7 @@ 10005 #include "sql/statement.h" 10006 #include "url/gurl.h" 10007 10008-#if !defined(OS_MAC) 10009+#if !defined(OS_MAC) && !defined(OS_OHOS) 10010 #include "chrome/utility/importer/nss_decryptor.h" 10011 #endif 10012 10013@@ -150,7 +150,7 @@ void FirefoxImporter::StartImport(const importer::SourceProfile& source_profile, 10014 ImportBookmarks(); 10015 bridge_->NotifyItemEnded(importer::FAVORITES); 10016 } 10017-#if !defined(OS_MAC) 10018+#if !defined(OS_MAC) && !defined(OS_OHOS) 10019 if ((items & importer::PASSWORDS) && !cancelled()) { 10020 bridge_->NotifyItemStarted(importer::PASSWORDS); 10021 ImportPasswords(); 10022@@ -375,7 +375,7 @@ void FirefoxImporter::ImportBookmarks() { 10023 } 10024 } 10025 10026-#if !defined(OS_MAC) 10027+#if !defined(OS_MAC) && !defined(OS_OHOS) 10028 void FirefoxImporter::ImportPasswords() { 10029 // Initializes NSS3. 10030 NSSDecryptor decryptor; 10031diff --git a/chrome/utility/importer/firefox_importer.h b/chrome/utility/importer/firefox_importer.h 10032index 456da624fe..1a3e4b4a51 100644 10033--- a/chrome/utility/importer/firefox_importer.h 10034+++ b/chrome/utility/importer/firefox_importer.h 10035@@ -60,7 +60,7 @@ class FirefoxImporter : public Importer { 10036 10037 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, ImportBookmarksV25); 10038 void ImportBookmarks(); 10039-#if !defined(OS_MAC) 10040+#if !defined(OS_MAC) && !defined(OS_OHOS) 10041 void ImportPasswords(); 10042 #endif 10043 void ImportHistory(); 10044diff --git a/components/BUILD.gn b/components/BUILD.gn 10045index c8d828c205..28e3e365e3 100644 10046--- a/components/BUILD.gn 10047+++ b/components/BUILD.gn 10048@@ -49,7 +49,7 @@ if (is_ios) { 10049 test("components_unittests") { 10050 use_xvfb = use_xvfb_in_this_config 10051 10052- if (is_android || is_linux || is_chromeos || is_mac || is_win) { 10053+ if (is_android || is_linux || is_chromeos || is_mac || is_win || is_ohos) { 10054 data = [ "test/data/" ] 10055 } 10056 10057@@ -421,7 +421,7 @@ test("components_unittests") { 10058 } 10059 10060 # Desktop-only deps. 10061- if (!is_android && !is_ios) { 10062+ if (!is_android && !is_ios && !is_ohos) { 10063 deps += [ 10064 # See comment in components/guest_view/browser/BUILD.gn for why 10065 # guest_view is currently non-mobile. 10066diff --git a/components/bookmarks/browser/BUILD.gn b/components/bookmarks/browser/BUILD.gn 10067index abbb395c67..8d8756f578 100644 10068--- a/components/bookmarks/browser/BUILD.gn 10069+++ b/components/bookmarks/browser/BUILD.gn 10070@@ -79,7 +79,7 @@ static_library("browser") { 10071 all_dependent_configs = [ "//ui/views:flags" ] 10072 } 10073 10074- if (toolkit_views && !is_mac) { 10075+ if (toolkit_views && !is_mac || is_ohos) { 10076 sources += [ "bookmark_node_data_views.cc" ] 10077 } 10078 10079diff --git a/components/bookmarks/browser/bookmark_node_data.h b/components/bookmarks/browser/bookmark_node_data.h 10080index 36cf5ee89d..ca07845a7c 100644 10081--- a/components/bookmarks/browser/bookmark_node_data.h 10082+++ b/components/bookmarks/browser/bookmark_node_data.h 10083@@ -18,7 +18,7 @@ 10084 #include "ui/base/clipboard/clipboard_buffer.h" 10085 #include "url/gurl.h" 10086 10087-#if defined(TOOLKIT_VIEWS) 10088+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 10089 #include "ui/base/clipboard/clipboard_format_type.h" 10090 #endif 10091 10092@@ -27,7 +27,7 @@ class Pickle; 10093 class PickleIterator; 10094 } 10095 10096-#if defined(TOOLKIT_VIEWS) 10097+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 10098 namespace ui { 10099 class OSExchangeData; 10100 } 10101@@ -114,7 +114,7 @@ struct BookmarkNodeData { 10102 10103 ~BookmarkNodeData(); 10104 10105-#if defined(TOOLKIT_VIEWS) 10106+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 10107 static const ui::ClipboardFormatType& GetBookmarkFormatType(); 10108 #endif 10109 10110@@ -133,7 +133,7 @@ struct BookmarkNodeData { 10111 // WriteToClipboard() but will also attempt to read a plain bookmark. 10112 bool ReadFromClipboard(ui::ClipboardBuffer buffer); 10113 10114-#if defined(TOOLKIT_VIEWS) 10115+#if defined(TOOLKIT_VIEWS) || defined(OS_OHOS) 10116 // Writes elements to data. If there is only one element and it is a URL 10117 // the URL and title are written to the clipboard in a format other apps can 10118 // use. 10119diff --git a/components/captive_portal/core/features.gni b/components/captive_portal/core/features.gni 10120index 9b277f56f4..f4903f333f 100644 10121--- a/components/captive_portal/core/features.gni 10122+++ b/components/captive_portal/core/features.gni 10123@@ -6,5 +6,5 @@ import("//build/config/compiler/compiler.gni") 10124 10125 # Please keep features in alphabetical order. 10126 declare_args() { 10127- enable_captive_portal_detection = !is_android && !is_chromecast && !is_ios 10128+ enable_captive_portal_detection = !is_android && !is_chromecast && !is_ios && !is_ohos 10129 } 10130diff --git a/components/content_settings/core/browser/website_settings_registry.cc b/components/content_settings/core/browser/website_settings_registry.cc 10131index e2900ed03e..d812b8d7c1 100644 10132--- a/components/content_settings/core/browser/website_settings_registry.cc 10133+++ b/components/content_settings/core/browser/website_settings_registry.cc 10134@@ -96,6 +96,8 @@ const WebsiteSettingsInfo* WebsiteSettingsRegistry::Register( 10135 if (!(platform & PLATFORM_FUCHSIA)) 10136 return nullptr; 10137 sync_status = WebsiteSettingsInfo::UNSYNCABLE; 10138+#elif defined(OS_OHOS) 10139+ sync_status = WebsiteSettingsInfo::UNSYNCABLE; 10140 #else 10141 #error "Unsupported platform" 10142 #endif 10143diff --git a/components/crash/content/browser/BUILD.gn b/components/crash/content/browser/BUILD.gn 10144index 5d51207878..ae3f74a5ea 100644 10145--- a/components/crash/content/browser/BUILD.gn 10146+++ b/components/crash/content/browser/BUILD.gn 10147@@ -21,7 +21,7 @@ source_set("browser") { 10148 "//content/public/common", 10149 ] 10150 10151- if (is_linux || is_chromeos || is_android) { 10152+ if (is_linux || is_chromeos || is_android || is_ohos) { 10153 # Want this file on both Linux and Android. 10154 sources += [ 10155 "crash_handler_host_linux.cc", 10156diff --git a/components/crash/core/app/BUILD.gn b/components/crash/core/app/BUILD.gn 10157index 29ff6a8adc..96fa3f199d 100644 10158--- a/components/crash/core/app/BUILD.gn 10159+++ b/components/crash/core/app/BUILD.gn 10160@@ -52,7 +52,7 @@ static_library("app") { 10161 "crashpad.h", 10162 ] 10163 10164- if (is_linux || is_chromeos) { 10165+ if (is_linux || is_chromeos || is_ohos) { 10166 sources += [ 10167 "breakpad_linux.cc", 10168 "breakpad_linux.h", 10169@@ -88,7 +88,7 @@ static_library("app") { 10170 libs = [ "log" ] 10171 } 10172 10173- if (is_android || is_linux || is_chromeos) { 10174+ if (is_android || is_linux || is_chromeos || is_ohos) { 10175 deps += [ 10176 "//base:base_static", 10177 "//components/crash/core/common", 10178@@ -96,7 +96,7 @@ static_library("app") { 10179 ] 10180 } 10181 10182- if (is_linux || is_chromeos) { 10183+ if (is_linux || is_chromeos || is_ohos) { 10184 deps += [ "//third_party/breakpad:client" ] 10185 } 10186 10187@@ -129,7 +129,7 @@ static_library("app") { 10188 sources += [ "crashpad_ios.mm" ] 10189 } 10190 10191- if (is_linux || is_chromeos) { 10192+ if (is_linux || is_chromeos || is_ohos) { 10193 data_deps = [ "//third_party/crashpad/crashpad/handler:crashpad_handler" ] 10194 } 10195 } 10196diff --git a/components/crash/core/app/crash_switches.cc b/components/crash/core/app/crash_switches.cc 10197index dfcb6bd37c..04307930ab 100644 10198--- a/components/crash/core/app/crash_switches.cc 10199+++ b/components/crash/core/app/crash_switches.cc 10200@@ -17,7 +17,7 @@ namespace switches { 10201 // is a standalone executable. 10202 const char kCrashpadHandler[] = "crashpad-handler"; 10203 10204-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 10205+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 10206 // The process ID of the Crashpad handler. 10207 const char kCrashpadHandlerPid[] = "crashpad-handler-pid"; 10208 #endif 10209diff --git a/components/crash/core/app/crash_switches.h b/components/crash/core/app/crash_switches.h 10210index 1855b80d18..bb617ce855 100644 10211--- a/components/crash/core/app/crash_switches.h 10212+++ b/components/crash/core/app/crash_switches.h 10213@@ -13,7 +13,7 @@ namespace switches { 10214 10215 extern const char kCrashpadHandler[]; 10216 10217-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 10218+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 10219 extern const char kCrashpadHandlerPid[]; 10220 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) 10221 10222diff --git a/components/crash/core/app/crashpad.cc b/components/crash/core/app/crashpad.cc 10223index 851fc33b89..b7c71a8f30 100644 10224--- a/components/crash/core/app/crashpad.cc 10225+++ b/components/crash/core/app/crashpad.cc 10226@@ -124,7 +124,7 @@ void InitializeCrashpadImpl(bool initial_client, 10227 DCHECK(browser_process || process_type == "Chrome Installer" || 10228 process_type == "notification-helper" || 10229 process_type == "GCPW Installer" || process_type == "GCPW DLL"); 10230-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 10231+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 10232 DCHECK(browser_process); 10233 #else 10234 #error Port. 10235@@ -199,7 +199,7 @@ void InitializeCrashpadImpl(bool initial_client, 10236 // other "main, first process" to initialize things. There is no "relauncher" 10237 // on Windows, so this is synonymous with initial_client. 10238 const bool should_initialize_database_and_set_upload_policy = initial_client; 10239-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 10240+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 10241 const bool should_initialize_database_and_set_upload_policy = browser_process; 10242 #endif 10243 if (should_initialize_database_and_set_upload_policy) { 10244@@ -277,7 +277,8 @@ void DumpWithoutCrashing() { 10245 } 10246 #endif 10247 10248-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 10249+ 10250+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 10251 void CrashWithoutDumping(const std::string& message) { 10252 crashpad::CrashpadClient::CrashWithoutDump(message); 10253 } 10254diff --git a/components/crash/core/app/crashpad.h b/components/crash/core/app/crashpad.h 10255index 032e78128e..c2730b99e0 100644 10256--- a/components/crash/core/app/crashpad.h 10257+++ b/components/crash/core/app/crashpad.h 10258@@ -38,7 +38,7 @@ class CrashReportDatabase; 10259 10260 namespace crash_reporter { 10261 10262-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 10263+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 10264 bool IsCrashpadEnabled(); 10265 #endif 10266 10267@@ -146,7 +146,7 @@ void RequestSingleCrashUpload(const std::string& local_id); 10268 10269 void DumpWithoutCrashing(); 10270 10271-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 10272+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 10273 // Logs message and immediately crashes the current process without triggering a 10274 // crash dump. 10275 void CrashWithoutDumping(const std::string& message); 10276@@ -197,10 +197,13 @@ bool DumpWithoutCrashingForClient(CrashReporterClient* client); 10277 void AllowMemoryRange(void* begin, size_t size); 10278 #endif // OS_ANDROID 10279 10280-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 10281+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 10282+ 10283+#if !defined(__MUSL__) 10284 // Install a handler that gets a chance to handle faults before Crashpad. This 10285 // is used by V8 for trap-based bounds checks. 10286 void SetFirstChanceExceptionHandler(bool (*handler)(int, siginfo_t*, void*)); 10287+#endif 10288 10289 // Gets the socket and process ID of the Crashpad handler connected to this 10290 // process, valid if this function returns `true`. 10291diff --git a/components/crash/core/app/crashpad_linux.cc b/components/crash/core/app/crashpad_linux.cc 10292index 8eb3f40775..2c570912f2 100644 10293--- a/components/crash/core/app/crashpad_linux.cc 10294+++ b/components/crash/core/app/crashpad_linux.cc 10295@@ -28,6 +28,7 @@ namespace crash_reporter { 10296 10297 namespace { 10298 10299+#if !defined(__MUSL__) 10300 // TODO(jperaza): This is the first chance handler type used by Breakpad and v8. 10301 // The Crashpad FirstChanceHandler type explicitly declares the third parameter 10302 // to be a ucontext_t* instead of a void*. Using a reinterpret cast to convert 10303@@ -42,15 +43,18 @@ bool FirstChanceHandlerHelper(int signo, 10304 ucontext_t* context) { 10305 return g_first_chance_handler(signo, siginfo, context); 10306 } 10307+#endif 10308 10309 } // namespace 10310 10311+#if !defined(__MUSL__) 10312 void SetFirstChanceExceptionHandler(bool (*handler)(int, siginfo_t*, void*)) { 10313 DCHECK(!g_first_chance_handler); 10314 g_first_chance_handler = handler; 10315 crashpad::CrashpadClient::SetFirstChanceExceptionHandler( 10316 FirstChanceHandlerHelper); 10317 } 10318+#endif 10319 10320 bool IsCrashpadEnabled() { 10321 return base::CommandLine::ForCurrentProcess()->HasSwitch( 10322diff --git a/components/embedder_support/user_agent_utils.cc b/components/embedder_support/user_agent_utils.cc 10323index 3fe061b30f..7d93a65fdb 100644 10324--- a/components/embedder_support/user_agent_utils.cc 10325+++ b/components/embedder_support/user_agent_utils.cc 10326@@ -46,7 +46,7 @@ std::string GetUserAgent() { 10327 } 10328 10329 std::string product = GetProduct(); 10330-#if defined(OS_ANDROID) 10331+#if (defined(OS_ANDROID) || defined(OS_OHOS)) 10332 if (command_line->HasSwitch(switches::kUseMobileUserAgent)) 10333 product += " Mobile"; 10334 #endif 10335diff --git a/components/feature_engagement/public/event_constants.cc b/components/feature_engagement/public/event_constants.cc 10336index 1c675326b6..684b2e4b76 100644 10337--- a/components/feature_engagement/public/event_constants.cc 10338+++ b/components/feature_engagement/public/event_constants.cc 10339@@ -11,13 +11,13 @@ namespace feature_engagement { 10340 namespace events { 10341 10342 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10343- defined(OS_CHROMEOS) 10344+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10345 const char kNewTabOpened[] = "new_tab_opened"; 10346 #endif // defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || 10347 // defined(OS_CHROMEOS) 10348 10349 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10350- defined(OS_CHROMEOS) 10351+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10352 const char kSixthTabOpened[] = "sixth_tab_opened"; 10353 const char kTabGroupCreated[] = "tab_group_created"; 10354 10355diff --git a/components/feature_engagement/public/event_constants.h b/components/feature_engagement/public/event_constants.h 10356index f541f1e59c..cb68a8c411 100644 10357--- a/components/feature_engagement/public/event_constants.h 10358+++ b/components/feature_engagement/public/event_constants.h 10359@@ -13,7 +13,7 @@ namespace events { 10360 10361 // Desktop and IOS. 10362 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10363- defined(OS_CHROMEOS) 10364+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10365 // The user has explicitly opened a new tab via an entry point from inside of 10366 // Chrome. 10367 extern const char kNewTabOpened[]; 10368@@ -22,7 +22,7 @@ extern const char kNewTabOpened[]; 10369 10370 // Desktop 10371 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10372- defined(OS_CHROMEOS) 10373+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10374 // A new tab was opened when 5 (or more) tabs were already open. 10375 extern const char kSixthTabOpened[]; 10376 // The user made a new tab group. 10377diff --git a/components/feature_engagement/public/feature_constants.cc b/components/feature_engagement/public/feature_constants.cc 10378index d7dc1e411a..ea59364a75 100644 10379--- a/components/feature_engagement/public/feature_constants.cc 10380+++ b/components/feature_engagement/public/feature_constants.cc 10381@@ -13,7 +13,7 @@ const base::Feature kIPHDummyFeature{"IPH_Dummy", 10382 base::FEATURE_DISABLED_BY_DEFAULT}; 10383 10384 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10385- defined(OS_CHROMEOS) 10386+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10387 const base::Feature kIPHDesktopTabGroupsNewGroupFeature{ 10388 "IPH_DesktopTabGroupsNewGroup", base::FEATURE_DISABLED_BY_DEFAULT}; 10389 const base::Feature kIPHFocusModeFeature{"IPH_FocusMode", 10390diff --git a/components/feature_engagement/public/feature_constants.h b/components/feature_engagement/public/feature_constants.h 10391index 3f75bc7503..d31f91e4c5 100644 10392--- a/components/feature_engagement/public/feature_constants.h 10393+++ b/components/feature_engagement/public/feature_constants.h 10394@@ -17,7 +17,7 @@ extern const base::Feature kIPHDemoMode; 10395 extern const base::Feature kIPHDummyFeature; 10396 10397 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10398- defined(OS_CHROMEOS) 10399+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10400 extern const base::Feature kIPHDesktopTabGroupsNewGroupFeature; 10401 extern const base::Feature kIPHFocusModeFeature; 10402 extern const base::Feature kIPHGlobalMediaControlsFeature; 10403diff --git a/components/feature_engagement/public/feature_list.cc b/components/feature_engagement/public/feature_list.cc 10404index ca8078ef00..e17aae8492 100644 10405--- a/components/feature_engagement/public/feature_list.cc 10406+++ b/components/feature_engagement/public/feature_list.cc 10407@@ -81,7 +81,7 @@ const base::Feature* const kAllFeatures[] = { 10408 &kIPHDiscoverFeedHeaderFeature, 10409 #endif // defined(OS_IOS) 10410 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10411- defined(OS_CHROMEOS) 10412+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10413 &kIPHDesktopTabGroupsNewGroupFeature, 10414 &kIPHFocusModeFeature, 10415 &kIPHGlobalMediaControlsFeature, 10416diff --git a/components/feature_engagement/public/feature_list.h b/components/feature_engagement/public/feature_list.h 10417index 4a396d2b68..faeb61ebaf 100644 10418--- a/components/feature_engagement/public/feature_list.h 10419+++ b/components/feature_engagement/public/feature_list.h 10420@@ -151,7 +151,7 @@ DEFINE_VARIATION_PARAM(kIPHDiscoverFeedHeaderFeature, 10421 #endif // defined(OS_IOS) 10422 10423 #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10424- defined(OS_CHROMEOS) 10425+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10426 DEFINE_VARIATION_PARAM(kIPHDesktopTabGroupsNewGroupFeature, 10427 "IPH_DesktopTabGroupsNewGroup"); 10428 DEFINE_VARIATION_PARAM(kIPHFocusModeFeature, "IPH_FocusMode"); 10429@@ -240,7 +240,7 @@ constexpr flags_ui::FeatureEntry::FeatureVariation 10430 VARIATION_ENTRY(kIPHBadgedTranslateManualTriggerFeature), 10431 VARIATION_ENTRY(kIPHDiscoverFeedHeaderFeature), 10432 #elif defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ 10433- defined(OS_CHROMEOS) 10434+ defined(OS_CHROMEOS) || defined(OS_OHOS) 10435 VARIATION_ENTRY(kIPHDesktopTabGroupsNewGroupFeature), 10436 VARIATION_ENTRY(kIPHFocusModeFeature), 10437 VARIATION_ENTRY(kIPHGlobalMediaControls), 10438diff --git a/components/flags_ui/flags_state.cc b/components/flags_ui/flags_state.cc 10439index ada1da69c7..c28edea370 100644 10440--- a/components/flags_ui/flags_state.cc 10441+++ b/components/flags_ui/flags_state.cc 10442@@ -108,6 +108,7 @@ const struct { 10443 {kOsLinux, "Linux"}, {kOsCrOS, "Chrome OS"}, 10444 {kOsAndroid, "Android"}, {kOsCrOSOwnerOnly, "Chrome OS (owner only)"}, 10445 {kOsIos, "iOS"}, {kOsFuchsia, "Fuchsia"}, 10446+ {kOsOhOS, "OhOS"} 10447 }; 10448 10449 // Adds a |StringValue| to |list| for each platform where |bitmask| indicates 10450@@ -695,6 +696,8 @@ int FlagsState::GetCurrentPlatform() { 10451 return kOsAndroid; 10452 #elif defined(OS_FUCHSIA) 10453 return kOsFuchsia; 10454+#elif defined(OS_OHOS) 10455+ return kOsOhOS; 10456 #else 10457 #error Unknown platform 10458 #endif 10459diff --git a/components/flags_ui/flags_state.h b/components/flags_ui/flags_state.h 10460index 5e2ecd999c..356bc564e1 100644 10461--- a/components/flags_ui/flags_state.h 10462+++ b/components/flags_ui/flags_state.h 10463@@ -46,10 +46,11 @@ enum { 10464 kOsIos = 1 << 6, 10465 kDeprecated = 1 << 7, 10466 kOsFuchsia = 1 << 8, 10467+ kOsOhOS = 1 << 9, 10468 10469 // Flags marked with this are internal to the flags system. Never set this on 10470 // a manually-added flag. 10471- kFlagInfrastructure = 1 << 9, 10472+ kFlagInfrastructure = 1 << 10, 10473 }; 10474 10475 // A flag controlling the behavior of the |ConvertFlagsToSwitches| function - 10476diff --git a/components/javascript_dialogs/BUILD.gn b/components/javascript_dialogs/BUILD.gn 10477index 9403425594..ff109d2a53 100644 10478--- a/components/javascript_dialogs/BUILD.gn 10479+++ b/components/javascript_dialogs/BUILD.gn 10480@@ -41,7 +41,7 @@ static_library("javascript_dialogs") { 10481 deps += [ "//ui/aura" ] 10482 } 10483 10484- if (toolkit_views) { 10485+ if (toolkit_views || is_ohos) { 10486 sources += [ 10487 "views/app_modal_dialog_view_views.cc", 10488 "views/app_modal_dialog_view_views.h", 10489diff --git a/components/metrics/BUILD.gn b/components/metrics/BUILD.gn 10490index 2e7364c47c..48da7db8e3 100644 10491--- a/components/metrics/BUILD.gn 10492+++ b/components/metrics/BUILD.gn 10493@@ -142,7 +142,7 @@ static_library("metrics") { 10494 sources += [ "drive_metrics_provider_ios.mm" ] 10495 } 10496 10497- if (is_linux || is_chromeos) { 10498+ if (is_linux || is_chromeos || is_ohos) { 10499 sources += [ 10500 "drive_metrics_provider_linux.cc", 10501 "system_memory_stats_recorder_linux.cc", 10502diff --git a/components/offline_pages/buildflags/features.gni b/components/offline_pages/buildflags/features.gni 10503index 2c8c75b1f4..09b6a0e609 100644 10504--- a/components/offline_pages/buildflags/features.gni 10505+++ b/components/offline_pages/buildflags/features.gni 10506@@ -5,7 +5,7 @@ 10507 declare_args() { 10508 # Whether to enable OfflinePages support. Currently user-visible features 10509 # are Android-only. 10510- enable_offline_pages = is_android 10511+ enable_offline_pages = is_android || is_ohos 10512 10513 # This enables test API for locally-built harness which is used for quality 10514 # evaluations. Requires setting this variable manually at local environment. 10515diff --git a/components/optimization_guide/features.gni b/components/optimization_guide/features.gni 10516index 7c43da5f2f..25a29e5478 100644 10517--- a/components/optimization_guide/features.gni 10518+++ b/components/optimization_guide/features.gni 10519@@ -8,5 +8,5 @@ declare_args() { 10520 # Disable tflite build on Windows on ARM 10521 # http://crbug.com/1169611 10522 build_with_tflite_lib = is_android || (is_win && target_cpu != "arm64") || 10523- is_linux || is_mac || is_chromeos 10524+ is_linux || is_mac || is_chromeos || is_ohos 10525 } 10526diff --git a/components/os_crypt/BUILD.gn b/components/os_crypt/BUILD.gn 10527index 79f9744a94..5f20ee306a 100644 10528--- a/components/os_crypt/BUILD.gn 10529+++ b/components/os_crypt/BUILD.gn 10530@@ -52,7 +52,7 @@ component("os_crypt") { 10531 defines = [ "IS_OS_CRYPT_IMPL" ] 10532 10533 if ((is_posix || is_fuchsia) && !is_apple && 10534- (!(is_linux || is_chromeos_lacros) || is_chromecast)) { 10535+ (!(is_linux || is_chromeos_lacros || is_ohos) || is_chromecast)) { 10536 sources += [ "os_crypt_posix.cc" ] 10537 } 10538 10539@@ -69,7 +69,7 @@ component("os_crypt") { 10540 libs = [ "crypt32.lib" ] 10541 } 10542 10543- if ((is_linux || is_chromeos_lacros) && !is_chromecast) { 10544+ if ((is_linux || is_chromeos_lacros || is_ohos) && !is_chromecast) { 10545 sources += [ 10546 "key_storage_config_linux.cc", 10547 "key_storage_config_linux.h", 10548diff --git a/components/os_crypt/os_crypt.h b/components/os_crypt/os_crypt.h 10549index e5ac0cfd3a..c2f49e1d2a 100644 10550--- a/components/os_crypt/os_crypt.h 10551+++ b/components/os_crypt/os_crypt.h 10552@@ -38,7 +38,7 @@ class OSCrypt { 10553 public: 10554 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 10555 // of lacros-chrome is complete. 10556-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 10557+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 10558 // Set the configuration of OSCrypt. 10559 static COMPONENT_EXPORT(OS_CRYPT) void SetConfig( 10560 std::unique_ptr<os_crypt::Config> config); 10561@@ -47,7 +47,7 @@ class OSCrypt { 10562 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 10563 // of lacros-chrome is complete. 10564 #if defined(OS_APPLE) || defined(OS_WIN) || \ 10565- (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) 10566+ (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_OHOS) 10567 // On Linux returns true iff the real secret key (not hardcoded one) is 10568 // available. On MacOS returns true if Keychain is available (for mock 10569 // Keychain it returns true if not using locked Keychain, false if using 10570diff --git a/components/paint_preview/common/serial_utils.cc b/components/paint_preview/common/serial_utils.cc 10571index 8fd6f25be7..e5566fb147 100644 10572--- a/components/paint_preview/common/serial_utils.cc 10573+++ b/components/paint_preview/common/serial_utils.cc 10574@@ -167,9 +167,9 @@ PictureSerializationContext::PictureSerializationContext() = default; 10575 PictureSerializationContext::~PictureSerializationContext() = default; 10576 10577 PictureSerializationContext::PictureSerializationContext( 10578- PictureSerializationContext&&) = default; 10579+ PictureSerializationContext&&) noexcept = default; 10580 PictureSerializationContext& PictureSerializationContext::operator=( 10581- PictureSerializationContext&&) = default; 10582+ PictureSerializationContext&&) noexcept = default; 10583 10584 TypefaceSerializationContext::TypefaceSerializationContext( 10585 TypefaceUsageMap* usage) 10586diff --git a/components/password_manager/content/browser/content_password_manager_driver.cc b/components/password_manager/content/browser/content_password_manager_driver.cc 10587index eacdd7d1ac..9273b805d5 100644 10588--- a/components/password_manager/content/browser/content_password_manager_driver.cc 10589+++ b/components/password_manager/content/browser/content_password_manager_driver.cc 10590@@ -316,7 +316,7 @@ void ContentPasswordManagerDriver::CheckSafeBrowsingReputation( 10591 if (client_->GetMetricsRecorder()) { 10592 client_->GetMetricsRecorder()->RecordUserFocusedPasswordField(); 10593 } 10594-#if defined(ON_FOCUS_PING_ENABLED) 10595+#if defined(ON_FOCUS_PING_ENABLED) && BUILDFLAG(FULL_SAFE_BROWSING) 10596 client_->CheckSafeBrowsingReputation(form_action, frame_url); 10597 #endif 10598 } 10599diff --git a/components/password_manager/core/browser/password_manager_client.h b/components/password_manager/core/browser/password_manager_client.h 10600index c293bf6ed9..099adbdc8b 100644 10601--- a/components/password_manager/core/browser/password_manager_client.h 10602+++ b/components/password_manager/core/browser/password_manager_client.h 10603@@ -334,7 +334,7 @@ class PasswordManagerClient { 10604 virtual safe_browsing::PasswordProtectionService* 10605 GetPasswordProtectionService() const = 0; 10606 10607-#if defined(ON_FOCUS_PING_ENABLED) 10608+#if defined(ON_FOCUS_PING_ENABLED) && BUILDFLAG(FULL_SAFE_BROWSING) 10609 // Checks the safe browsing reputation of the webpage when the 10610 // user focuses on a username/password field. This is used for reporting 10611 // only, and won't trigger a warning. 10612diff --git a/components/policy/BUILD.gn b/components/policy/BUILD.gn 10613index fe41262bb1..23647319f5 100644 10614--- a/components/policy/BUILD.gn 10615+++ b/components/policy/BUILD.gn 10616@@ -21,7 +21,7 @@ gen_policy_templates_local = false 10617 # enable these flags (but don't check that in!). 10618 gen_policy_templates_common = true 10619 gen_policy_templates_win = is_win 10620-gen_policy_templates_linux = is_linux || is_chromeos 10621+gen_policy_templates_linux = is_linux || is_chromeos || is_ohos 10622 gen_policy_templates_android = is_android 10623 gen_policy_templates_mac = is_mac 10624 gen_policy_templates_chromeos = is_chromeos_ash 10625diff --git a/components/renderer_context_menu/BUILD.gn b/components/renderer_context_menu/BUILD.gn 10626index ab75890d2a..2998febc70 100644 10627--- a/components/renderer_context_menu/BUILD.gn 10628+++ b/components/renderer_context_menu/BUILD.gn 10629@@ -29,7 +29,7 @@ static_library("renderer_context_menu") { 10630 "//ui/base", 10631 ] 10632 10633- if (toolkit_views) { 10634+ if (toolkit_views || is_ohos) { 10635 sources += [ 10636 "views/toolkit_delegate_views.cc", 10637 "views/toolkit_delegate_views.h", 10638diff --git a/components/safe_browsing/content/browser/client_side_detection_host.cc b/components/safe_browsing/content/browser/client_side_detection_host.cc 10639index 76852c30a3..b2b850cbdb 100644 10640--- a/components/safe_browsing/content/browser/client_side_detection_host.cc 10641+++ b/components/safe_browsing/content/browser/client_side_detection_host.cc 10642@@ -343,6 +343,7 @@ void ClientSideDetectionHost::DidFinishNavigation( 10643 10644 current_url_ = navigation_handle->GetURL(); 10645 10646+#if BUILDFLAG(FULL_SAFE_BROWSING) 10647 // Check whether we can cassify the current URL for phishing. 10648 classification_request_ = new ShouldClassifyUrlRequest( 10649 navigation_handle, 10650@@ -350,10 +351,12 @@ void ClientSideDetectionHost::DidFinishNavigation( 10651 weak_factory_.GetWeakPtr()), 10652 web_contents(), csd_service_, database_manager_.get(), this); 10653 classification_request_->Start(); 10654+#endif 10655 } 10656 10657 void ClientSideDetectionHost::SendModelToRenderFrame() { 10658 DCHECK_CURRENTLY_ON(BrowserThread::UI); 10659+#if BUILDFLAG(FULL_SAFE_BROWSING) 10660 if (!web_contents() || web_contents() != tab_ || !csd_service_) 10661 return; 10662 10663@@ -366,6 +369,7 @@ void ClientSideDetectionHost::SendModelToRenderFrame() { 10664 phishing_detector_.BindNewPipeAndPassReceiver()); 10665 phishing_detector_->SetPhishingModel(csd_service_->GetModelStr()); 10666 } 10667+#endif 10668 } 10669 10670 void ClientSideDetectionHost::WebContentsDestroyed() { 10671@@ -379,16 +383,19 @@ void ClientSideDetectionHost::WebContentsDestroyed() { 10672 10673 void ClientSideDetectionHost::RenderFrameCreated( 10674 content::RenderFrameHost* render_frame_host) { 10675+#if BUILDFLAG(FULL_SAFE_BROWSING) 10676 if (phishing_detector_) 10677 phishing_detector_.reset(); 10678 render_frame_host->GetRemoteInterfaces()->GetInterface( 10679 phishing_detector_.BindNewPipeAndPassReceiver()); 10680 phishing_detector_->SetPhishingModel(csd_service_->GetModelStr()); 10681+#endif 10682 } 10683 10684 void ClientSideDetectionHost::OnPhishingPreClassificationDone( 10685 bool should_classify) { 10686 DCHECK_CURRENTLY_ON(BrowserThread::UI); 10687+#if BUILDFLAG(FULL_SAFE_BROWSING) 10688 if (should_classify) { 10689 content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); 10690 phishing_detector_.reset(); 10691@@ -400,6 +407,7 @@ void ClientSideDetectionHost::OnPhishingPreClassificationDone( 10692 base::BindOnce(&ClientSideDetectionHost::PhishingDetectionDone, 10693 weak_factory_.GetWeakPtr())); 10694 } 10695+#endif 10696 } 10697 10698 void ClientSideDetectionHost::PhishingDetectionDone( 10699@@ -468,7 +476,7 @@ void ClientSideDetectionHost::MaybeShowPhishingWarning(bool is_from_cache, 10700 base::UmaHistogramBoolean("SBClientPhishing.ServerModelDetectsPhishing", 10701 is_phishing); 10702 } 10703- 10704+#if BUILDFLAG(FULL_SAFE_BROWSING) 10705 if (is_phishing) { 10706 DCHECK(web_contents()); 10707 if (ui_manager_.get()) { 10708@@ -494,6 +502,7 @@ void ClientSideDetectionHost::MaybeShowPhishingWarning(bool is_from_cache, 10709 // consider the malware vedict. 10710 weak_factory_.InvalidateWeakPtrs(); 10711 } 10712+#endif 10713 } 10714 10715 void ClientSideDetectionHost::set_client_side_detection_service( 10716diff --git a/components/safe_browsing/content/browser/client_side_detection_host.h b/components/safe_browsing/content/browser/client_side_detection_host.h 10717index 061788805f..d1a01438a2 100644 10718--- a/components/safe_browsing/content/browser/client_side_detection_host.h 10719+++ b/components/safe_browsing/content/browser/client_side_detection_host.h 10720@@ -17,6 +17,7 @@ 10721 #include "components/safe_browsing/content/common/safe_browsing.mojom-shared.h" 10722 #include "components/safe_browsing/content/common/safe_browsing.mojom.h" 10723 #include "components/safe_browsing/core/db/database_manager.h" 10724+#include "components/safe_browsing/buildflags.h" 10725 #include "content/public/browser/web_contents_observer.h" 10726 #include "mojo/public/cpp/bindings/remote.h" 10727 #include "services/service_manager/public/cpp/binder_registry.h" 10728@@ -129,8 +130,11 @@ class ClientSideDetectionHost : public content::WebContentsObserver { 10729 scoped_refptr<ShouldClassifyUrlRequest> classification_request_; 10730 // The current URL 10731 GURL current_url_; 10732+ 10733+ #if BUILDFLAG(FULL_SAFE_BROWSING) 10734 // The currently active message pipe to the renderer PhishingDetector. 10735 mojo::Remote<mojom::PhishingDetector> phishing_detector_; 10736+ #endif 10737 10738 // Records the start time of when phishing detection started. 10739 base::TimeTicks phishing_detection_start_time_; 10740diff --git a/components/safe_browsing/content/common/safe_browsing.mojom b/components/safe_browsing/content/common/safe_browsing.mojom 10741index fc814aa58c..e1fdb4f3a3 100644 10742--- a/components/safe_browsing/content/common/safe_browsing.mojom 10743+++ b/components/safe_browsing/content/common/safe_browsing.mojom 10744@@ -117,7 +117,7 @@ enum PhishingDetectorResult { 10745 INVALID_SCORE = 4, 10746 }; 10747 10748-[EnableIf=full_safe_browsing] 10749+// [EnableIf=full_safe_browsing] // remove safe browsing 10750 // Interface for setting the CSD model and to start phishing classification. 10751 interface PhishingDetector { 10752 // A classification model for client-side phishing detection. 10753diff --git a/components/safe_browsing/core/file_type_policies.cc b/components/safe_browsing/core/file_type_policies.cc 10754index 30df9b49f2..f1f10b6fab 100644 10755--- a/components/safe_browsing/core/file_type_policies.cc 10756+++ b/components/safe_browsing/core/file_type_policies.cc 10757@@ -10,6 +10,7 @@ 10758 #include "base/strings/string_util.h" 10759 #include "components/grit/components_resources.h" 10760 #include "ui/base/resource/resource_bundle.h" 10761+#include "components/safe_browsing/buildflags.h" 10762 10763 namespace safe_browsing { 10764 10765@@ -21,7 +22,9 @@ struct FileTypePoliciesSingletonTrait 10766 : public base::DefaultSingletonTraits<FileTypePolicies> { 10767 static FileTypePolicies* New() { 10768 FileTypePolicies* instance = new FileTypePolicies(); 10769+#if BUILDFLAG(FULL_SAFE_BROWSING) 10770 instance->PopulateFromResourceBundle(); 10771+#endif 10772 return instance; 10773 } 10774 }; 10775@@ -48,10 +51,12 @@ FileTypePolicies::~FileTypePolicies() { 10776 AutoLock lock(lock_); // DCHECK fail if the lock is held. 10777 } 10778 10779+#if BUILDFLAG(FULL_SAFE_BROWSING) 10780 std::string FileTypePolicies::ReadResourceBundle() { 10781 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 10782 return bundle.LoadDataResourceString(IDR_DOWNLOAD_FILE_TYPES_PB); 10783 } 10784+#endif 10785 10786 void FileTypePolicies::RecordUpdateMetrics(UpdateResult result, 10787 const std::string& src_name) { 10788@@ -67,12 +72,14 @@ void FileTypePolicies::RecordUpdateMetrics(UpdateResult result, 10789 } 10790 } 10791 10792+#if BUILDFLAG(FULL_SAFE_BROWSING) 10793 void FileTypePolicies::PopulateFromResourceBundle() { 10794 AutoLock lock(lock_); 10795 std::string binary_pb = ReadResourceBundle(); 10796 UpdateResult result = PopulateFromBinaryPb(binary_pb); 10797 RecordUpdateMetrics(result, "ResourceBundle"); 10798 } 10799+#endif 10800 10801 void FileTypePolicies::PopulateFromDynamicUpdate(const std::string& binary_pb) { 10802 AutoLock lock(lock_); 10803diff --git a/components/safe_browsing/core/file_type_policies.h b/components/safe_browsing/core/file_type_policies.h 10804index 45f0c09226..49f8f09d6b 100644 10805--- a/components/safe_browsing/core/file_type_policies.h 10806+++ b/components/safe_browsing/core/file_type_policies.h 10807@@ -11,6 +11,7 @@ 10808 #include "base/files/file_path.h" 10809 #include "base/gtest_prod_util.h" 10810 #include "base/synchronization/lock.h" 10811+#include "components/safe_browsing/buildflags.h" 10812 #include "components/safe_browsing/core/proto/download_file_types.pb.h" 10813 10814 namespace safe_browsing { 10815@@ -105,8 +106,10 @@ class FileTypePolicies { 10816 // only if it passes integrity checks. 10817 virtual UpdateResult PopulateFromBinaryPb(const std::string& binary_pb); 10818 10819+#if BUILDFLAG(FULL_SAFE_BROWSING) 10820 // Fetch the blob from the main resource bundle. 10821 virtual std::string ReadResourceBundle(); 10822+#endif 10823 10824 // Record the result of an update attempt. 10825 virtual void RecordUpdateMetrics(UpdateResult result, 10826@@ -124,10 +127,12 @@ class FileTypePolicies { 10827 void SwapConfig(std::unique_ptr<DownloadFileTypeConfig>& new_config); 10828 void SwapConfigLocked(std::unique_ptr<DownloadFileTypeConfig>& new_config); 10829 10830+#if BUILDFLAG(FULL_SAFE_BROWSING) 10831 // Read data from the main ResourceBundle. This updates the internal list 10832 // only if the data passes integrity checks. This is normally called once 10833 // after construction. 10834 void PopulateFromResourceBundle(); 10835+#endif 10836 10837 // The latest config we've committed. Starts out null. 10838 // Protected by lock_. 10839diff --git a/components/safe_browsing/core/password_protection/password_protection_service_base.cc b/components/safe_browsing/core/password_protection/password_protection_service_base.cc 10840index de89abb02f..478303c095 100644 10841--- a/components/safe_browsing/core/password_protection/password_protection_service_base.cc 10842+++ b/components/safe_browsing/core/password_protection/password_protection_service_base.cc 10843@@ -23,6 +23,7 @@ 10844 #include "components/safe_browsing/core/db/database_manager.h" 10845 #include "components/safe_browsing/core/features.h" 10846 #include "components/safe_browsing/core/password_protection/password_protection_request.h" 10847+#include "components/safe_browsing/buildflags.h" 10848 #include "google_apis/google_api_keys.h" 10849 #include "net/base/escape.h" 10850 #include "net/base/url_util.h" 10851@@ -83,9 +84,15 @@ bool PasswordProtectionServiceBase::ShouldShowModalWarning( 10852 return false; 10853 } 10854 10855+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 10856 return (verdict_type == LoginReputationClientResponse::PHISHING || 10857 verdict_type == LoginReputationClientResponse::LOW_REPUTATION) && 10858 IsWarningEnabled(password_type); 10859+#else 10860+ return (verdict_type == LoginReputationClientResponse::PHISHING || 10861+ verdict_type == LoginReputationClientResponse::LOW_REPUTATION); 10862+#endif 10863+ 10864 } 10865 10866 LoginReputationClientResponse::VerdictType 10867@@ -249,11 +256,13 @@ void PasswordProtectionServiceBase::HistoryServiceBeingDeleted( 10868 history_service_observation_.Reset(); 10869 } 10870 10871+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 10872 bool PasswordProtectionServiceBase::IsWarningEnabled( 10873 ReusedPasswordAccountType password_type) { 10874 return GetPasswordProtectionWarningTriggerPref(password_type) == 10875 PHISHING_REUSE; 10876 } 10877+#endif 10878 10879 // static 10880 ReusedPasswordType 10881diff --git a/components/safe_browsing/core/password_protection/password_protection_service_base.h b/components/safe_browsing/core/password_protection/password_protection_service_base.h 10882index 4339f763c6..4f24f9b5e9 100644 10883--- a/components/safe_browsing/core/password_protection/password_protection_service_base.h 10884+++ b/components/safe_browsing/core/password_protection/password_protection_service_base.h 10885@@ -130,9 +130,11 @@ class PasswordProtectionServiceBase : public history::HistoryServiceObserver { 10886 // Returns if the warning UI is enabled. 10887 bool IsWarningEnabled(ReusedPasswordAccountType password_type); 10888 10889+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 10890 // Returns the pref value of password protection warning trigger. 10891 virtual PasswordProtectionTrigger GetPasswordProtectionWarningTriggerPref( 10892 ReusedPasswordAccountType password_type) const = 0; 10893+#endif 10894 10895 // If |url| matches Safe Browsing allowlist domains, password protection 10896 // change password URL, or password protection login URLs in the enterprise 10897diff --git a/components/safe_browsing/core/resources/BUILD.gn b/components/safe_browsing/core/resources/BUILD.gn 10898index c0b0acc2d5..0dea3b4ec0 100644 10899--- a/components/safe_browsing/core/resources/BUILD.gn 10900+++ b/components/safe_browsing/core/resources/BUILD.gn 10901@@ -24,7 +24,7 @@ python2_action("make_file_types_protobuf") { 10902 10903 # Pick an architecture to generate for. These string match those 10904 # in the python script. 10905- if (is_android) { 10906+ if (is_android || is_ohos) { 10907 target_arch = "android" 10908 } else if (is_chromeos_ash) { 10909 target_arch = "chromeos" 10910diff --git a/components/security_interstitials/content/utils.cc b/components/security_interstitials/content/utils.cc 10911index bbfc938352..bce97c1ef5 100644 10912--- a/components/security_interstitials/content/utils.cc 10913+++ b/components/security_interstitials/content/utils.cc 10914@@ -33,7 +33,7 @@ void LaunchDateAndTimeSettings() { 10915 #if defined(OS_ANDROID) 10916 JNIEnv* env = base::android::AttachCurrentThread(); 10917 Java_DateAndTimeSettingsHelper_openDateAndTimeSettings(env); 10918-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) 10919+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 10920 struct ClockCommand { 10921 const char* const pathname; 10922 const char* const argument; 10923diff --git a/components/signin/features.gni b/components/signin/features.gni 10924index dea221ef95..238dbfaba9 100644 10925--- a/components/signin/features.gni 10926+++ b/components/signin/features.gni 10927@@ -5,7 +5,7 @@ 10928 import("//build/config/chromeos/ui_mode.gni") 10929 10930 # Dice is supported on the platform (but not necessarily enabled). 10931-enable_dice_support = is_linux || is_chromeos_lacros || is_mac || is_win 10932+enable_dice_support = is_linux || is_chromeos_lacros || is_mac || is_win || is_ohos 10933 10934 # Mirror is enabled and other account consistency mechanisms are not available. 10935 enable_mirror = is_android || is_ios 10936diff --git a/components/storage_monitor/BUILD.gn b/components/storage_monitor/BUILD.gn 10937index 28c1453f96..20a7efccd3 100644 10938--- a/components/storage_monitor/BUILD.gn 10939+++ b/components/storage_monitor/BUILD.gn 10940@@ -70,7 +70,7 @@ static_library("storage_monitor") { 10941 ] 10942 deps += [ "//services/device/public/mojom" ] 10943 } 10944- } else if (is_linux || is_chromeos_lacros) { 10945+ } else if (is_linux || is_chromeos_lacros || is_ohos) { 10946 if (use_udev) { 10947 sources += [ 10948 "mtab_watcher_linux.cc", 10949diff --git a/components/sync_device_info/BUILD.gn b/components/sync_device_info/BUILD.gn 10950index 1ddebb1293..8b3da1fa8a 100644 10951--- a/components/sync_device_info/BUILD.gn 10952+++ b/components/sync_device_info/BUILD.gn 10953@@ -58,7 +58,7 @@ static_library("sync_device_info") { 10954 sources += [ "local_device_info_util_ios.mm" ] 10955 } 10956 10957- if (is_linux || is_chromeos) { 10958+ if (is_linux || is_chromeos || is_ohos) { 10959 sources += [ "local_device_info_util_linux.cc" ] 10960 } 10961 10962diff --git a/components/update_client/update_query_params.cc b/components/update_client/update_query_params.cc 10963index 7c3946afb1..52b11abc95 100644 10964--- a/components/update_client/update_query_params.cc 10965+++ b/components/update_client/update_query_params.cc 10966@@ -40,6 +40,8 @@ const char kOs[] = 10967 "fuchsia"; 10968 #elif defined(OS_OPENBSD) 10969 "openbsd"; 10970+#elif defined(OS_OHOS) 10971+ "ohos"; 10972 #else 10973 #error "unknown os" 10974 #endif 10975diff --git a/components/variations/client_filterable_state.cc b/components/variations/client_filterable_state.cc 10976index 35883cd5b1..6dce1258af 100644 10977--- a/components/variations/client_filterable_state.cc 10978+++ b/components/variations/client_filterable_state.cc 10979@@ -28,7 +28,7 @@ Study::Platform ClientFilterableState::GetCurrentPlatform() { 10980 return Study::PLATFORM_ANDROID; 10981 #elif defined(OS_FUCHSIA) 10982 return Study::PLATFORM_FUCHSIA; 10983-#elif defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) 10984+#elif defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) || defined(OS_OHOS) 10985 // Default BSD and SOLARIS to Linux to not break those builds, although these 10986 // platforms are not officially supported by Chrome. 10987 return Study::PLATFORM_LINUX; 10988diff --git a/components/variations/service/variations_service.cc b/components/variations/service/variations_service.cc 10989index d4611738ef..34558c5870 100644 10990--- a/components/variations/service/variations_service.cc 10991+++ b/components/variations/service/variations_service.cc 10992@@ -119,6 +119,8 @@ std::string GetPlatformString() { 10993 // Default BSD and SOLARIS to Linux to not break those builds, although these 10994 // platforms are not officially supported by Chrome. 10995 return "linux"; 10996+#elif defined(OS_OHOS) 10997+ return "ohos"; 10998 #else 10999 #error Unknown platform 11000 #endif 11001diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn 11002index 84578ff8b9..a63f357a8a 100644 11003--- a/content/browser/BUILD.gn 11004+++ b/content/browser/BUILD.gn 11005@@ -2178,6 +2178,22 @@ source_set("browser") { 11006 ] 11007 } 11008 11009+ if (is_ohos) { 11010+ sources += [ 11011+ "child_process_launcher_helper_linux.cc", 11012+ "sandbox_host_linux.cc", 11013+ "sandbox_host_linux.h", 11014+ "sandbox_ipc_linux.cc", 11015+ "sandbox_ipc_linux.h", 11016+ "zygote_host/zygote_host_impl_linux.cc", 11017+ "zygote_host/zygote_host_impl_linux.h", 11018+ "memory/swap_metrics_driver_impl_linux.cc", 11019+ "memory/swap_metrics_driver_impl_linux.h", 11020+ "speech/tts_ohos.cc", 11021+ ] 11022+ public_deps += [ "//components/services/font/public/mojom" ] 11023+ } 11024+ 11025 if (is_chromeos_ash) { 11026 sources += [ 11027 "handwriting/handwriting_recognition_service_impl_cros.cc", 11028diff --git a/content/browser/direct_sockets/direct_sockets_service_impl.cc b/content/browser/direct_sockets/direct_sockets_service_impl.cc 11029index c6970c5bd5..5d0735c907 100644 11030--- a/content/browser/direct_sockets/direct_sockets_service_impl.cc 11031+++ b/content/browser/direct_sockets/direct_sockets_service_impl.cc 11032@@ -68,10 +68,12 @@ base::Optional<net::IPEndPoint> GetLocalAddr( 11033 return local_addr; 11034 } 11035 11036+#if BUILDFLAG(ENABLE_MDNS) 11037 bool ResemblesMulticastDNSName(const std::string& hostname) { 11038 return base::EndsWith(hostname, ".local") || 11039 base::EndsWith(hostname, ".local."); 11040 } 11041+#endif 11042 11043 bool ContainNonPubliclyRoutableAddress(const net::AddressList& addresses) { 11044 DCHECK(!addresses.empty()); 11045diff --git a/content/browser/file_system_access/fake_file_system_access_permission_context.cc b/content/browser/file_system_access/fake_file_system_access_permission_context.cc 11046index 1839c8e860..9d7e5272e1 100644 11047--- a/content/browser/file_system_access/fake_file_system_access_permission_context.cc 11048+++ b/content/browser/file_system_access/fake_file_system_access_permission_context.cc 11049@@ -45,12 +45,14 @@ void FakeFileSystemAccessPermissionContext::ConfirmSensitiveDirectoryAccess( 11050 std::move(callback).Run(SensitiveDirectoryResult::kAllowed); 11051 } 11052 11053+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11054 void FakeFileSystemAccessPermissionContext::PerformAfterWriteChecks( 11055 std::unique_ptr<FileSystemAccessWriteItem> item, 11056 GlobalFrameRoutingId frame_id, 11057 base::OnceCallback<void(AfterWriteCheckResult)> callback) { 11058 std::move(callback).Run(AfterWriteCheckResult::kAllow); 11059 } 11060+#endif 11061 11062 bool FakeFileSystemAccessPermissionContext::CanObtainReadPermission( 11063 const url::Origin& origin) { 11064diff --git a/content/browser/file_system_access/fake_file_system_access_permission_context.h b/content/browser/file_system_access/fake_file_system_access_permission_context.h 11065index 1cf5f476fc..49fdd84054 100644 11066--- a/content/browser/file_system_access/fake_file_system_access_permission_context.h 11067+++ b/content/browser/file_system_access/fake_file_system_access_permission_context.h 11068@@ -40,10 +40,12 @@ class FakeFileSystemAccessPermissionContext 11069 GlobalFrameRoutingId frame_id, 11070 base::OnceCallback<void(SensitiveDirectoryResult)> callback) override; 11071 11072+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11073 void PerformAfterWriteChecks( 11074 std::unique_ptr<FileSystemAccessWriteItem> item, 11075 GlobalFrameRoutingId frame_id, 11076 base::OnceCallback<void(AfterWriteCheckResult)> callback) override; 11077+#endif 11078 11079 bool CanObtainReadPermission(const url::Origin& origin) override; 11080 bool CanObtainWritePermission(const url::Origin& origin) override; 11081diff --git a/content/browser/file_system_access/file_system_access_file_writer_impl.cc b/content/browser/file_system_access/file_system_access_file_writer_impl.cc 11082index ee60c5e2e5..ec35da5b40 100644 11083--- a/content/browser/file_system_access/file_system_access_file_writer_impl.cc 11084+++ b/content/browser/file_system_access/file_system_access_file_writer_impl.cc 11085@@ -143,7 +143,9 @@ FileSystemAccessFileWriterImpl::FileSystemAccessFileWriterImpl( 11086 swap_url_(swap_url), 11087 quarantine_connection_callback_( 11088 std::move(quarantine_connection_callback)), 11089+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11090 has_transient_user_activation_(has_transient_user_activation), 11091+#endif 11092 auto_close_(auto_close) { 11093 DCHECK_EQ(swap_url.type(), url.type()); 11094 receiver_.set_disconnect_handler(base::BindOnce( 11095@@ -335,6 +337,7 @@ void FileSystemAccessFileWriterImpl::CloseImpl(CloseCallback callback) { 11096 11097 close_callback_ = std::move(callback); 11098 11099+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11100 if (!RequireSecurityChecks() || !manager()->permission_context()) { 11101 DidAfterWriteCheck( 11102 FileSystemAccessPermissionContext::AfterWriteCheckResult::kAllow); 11103@@ -344,6 +347,11 @@ void FileSystemAccessFileWriterImpl::CloseImpl(CloseCallback callback) { 11104 ComputeHashForSwapFile( 11105 base::BindOnce(&FileSystemAccessFileWriterImpl::DoAfterWriteCheck, 11106 weak_factory_.GetWeakPtr())); 11107+#else 11108+ DidAfterWriteCheck( 11109+ FileSystemAccessPermissionContext::AfterWriteCheckResult::kAllow); 11110+#endif 11111+ 11112 } 11113 11114 void FileSystemAccessFileWriterImpl::AbortImpl(AbortCallback callback) { 11115@@ -363,6 +371,7 @@ void FileSystemAccessFileWriterImpl::AbortImpl(AbortCallback callback) { 11116 manager()->RemoveFileWriter(this); 11117 } 11118 11119+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11120 // static 11121 void FileSystemAccessFileWriterImpl::DoAfterWriteCheck( 11122 base::File::Error hash_result, 11123@@ -391,6 +400,7 @@ void FileSystemAccessFileWriterImpl::DoAfterWriteCheck( 11124 base::BindOnce(&FileSystemAccessFileWriterImpl::DidAfterWriteCheck, 11125 weak_factory_.GetWeakPtr())); 11126 } 11127+#endif 11128 11129 void FileSystemAccessFileWriterImpl::DidAfterWriteCheck( 11130 FileSystemAccessPermissionContext::AfterWriteCheckResult result) { 11131diff --git a/content/browser/file_system_access/file_system_access_file_writer_impl.h b/content/browser/file_system_access/file_system_access_file_writer_impl.h 11132index 58e8c33c8d..817876eb48 100644 11133--- a/content/browser/file_system_access/file_system_access_file_writer_impl.h 11134+++ b/content/browser/file_system_access/file_system_access_file_writer_impl.h 11135@@ -99,9 +99,11 @@ class CONTENT_EXPORT FileSystemAccessFileWriterImpl 11136 void TruncateImpl(uint64_t length, TruncateCallback callback); 11137 void CloseImpl(CloseCallback callback); 11138 void AbortImpl(AbortCallback callback); 11139+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11140 void DoAfterWriteCheck(base::File::Error hash_result, 11141 const std::string& hash, 11142 int64_t size); 11143+#endif 11144 void DidAfterWriteCheck( 11145 FileSystemAccessPermissionContext::AfterWriteCheckResult result); 11146 void DidSwapFileSkipQuarantine(base::File::Error result); 11147@@ -134,9 +136,11 @@ class CONTENT_EXPORT FileSystemAccessFileWriterImpl 11148 11149 download::QuarantineConnectionCallback quarantine_connection_callback_; 11150 11151+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11152 // Keeps track of user activation state at creation time for after write 11153 // checks. 11154 bool has_transient_user_activation_ = false; 11155+#endif 11156 11157 // Changes will be written to the target file even if the stream isn't 11158 // explicitly closed. 11159diff --git a/content/browser/file_system_access/mock_file_system_access_permission_context.cc b/content/browser/file_system_access/mock_file_system_access_permission_context.cc 11160index 990073d609..9dc66a2a46 100644 11161--- a/content/browser/file_system_access/mock_file_system_access_permission_context.cc 11162+++ b/content/browser/file_system_access/mock_file_system_access_permission_context.cc 11163@@ -22,11 +22,13 @@ void MockFileSystemAccessPermissionContext::ConfirmSensitiveDirectoryAccess( 11164 frame_id, callback); 11165 } 11166 11167+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11168 void MockFileSystemAccessPermissionContext::PerformAfterWriteChecks( 11169 std::unique_ptr<FileSystemAccessWriteItem> item, 11170 GlobalFrameRoutingId frame_id, 11171 base::OnceCallback<void(AfterWriteCheckResult)> callback) { 11172 PerformAfterWriteChecks_(item.get(), frame_id, callback); 11173 } 11174+#endif 11175 11176 } // namespace content 11177diff --git a/content/browser/file_system_access/mock_file_system_access_permission_context.h b/content/browser/file_system_access/mock_file_system_access_permission_context.h 11178index 7f97f21069..4cf279fae2 100644 11179--- a/content/browser/file_system_access/mock_file_system_access_permission_context.h 11180+++ b/content/browser/file_system_access/mock_file_system_access_permission_context.h 11181@@ -49,10 +49,12 @@ class MockFileSystemAccessPermissionContext 11182 GlobalFrameRoutingId frame_id, 11183 base::OnceCallback<void(SensitiveDirectoryResult)>& callback)); 11184 11185+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11186 void PerformAfterWriteChecks( 11187 std::unique_ptr<FileSystemAccessWriteItem> item, 11188 GlobalFrameRoutingId frame_id, 11189 base::OnceCallback<void(AfterWriteCheckResult)> callback) override; 11190+#endif 11191 MOCK_METHOD(void, 11192 PerformAfterWriteChecks_, 11193 (FileSystemAccessWriteItem * item, 11194diff --git a/content/browser/scheduler/browser_task_executor.cc b/content/browser/scheduler/browser_task_executor.cc 11195index 4616c1caf4..71ff583c17 100644 11196--- a/content/browser/scheduler/browser_task_executor.cc 11197+++ b/content/browser/scheduler/browser_task_executor.cc 11198@@ -201,7 +201,7 @@ void BrowserTaskExecutor::CreateInternal( 11199 g_browser_task_executor->browser_ui_thread_handle_ 11200 ->EnableAllExceptBestEffortQueues(); 11201 11202-#if defined(OS_ANDROID) 11203+#if defined(OS_ANDROID) && !defined(OS_OHOS) 11204 base::PostTaskAndroid::SignalNativeSchedulerReady(); 11205 #endif 11206 } 11207diff --git a/content/browser/scheduler/responsiveness/native_event_observer.cc b/content/browser/scheduler/responsiveness/native_event_observer.cc 11208index 68ca528440..708b9d2caa 100644 11209--- a/content/browser/scheduler/responsiveness/native_event_observer.cc 11210+++ b/content/browser/scheduler/responsiveness/native_event_observer.cc 11211@@ -15,7 +15,7 @@ 11212 11213 #include "ui/events/platform/platform_event_source.h" 11214 11215-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11216+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11217 #include "ui/aura/env.h" 11218 #include "ui/events/event.h" 11219 #endif 11220@@ -39,7 +39,7 @@ NativeEventObserver::~NativeEventObserver() { 11221 DeregisterObserver(); 11222 } 11223 11224-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11225+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11226 void NativeEventObserver::RegisterObserver() { 11227 aura::Env::GetInstance()->AddWindowEventDispatcherObserver(this); 11228 } 11229diff --git a/content/browser/scheduler/responsiveness/native_event_observer.h b/content/browser/scheduler/responsiveness/native_event_observer.h 11230index be8a5e077f..600ca105bb 100644 11231--- a/content/browser/scheduler/responsiveness/native_event_observer.h 11232+++ b/content/browser/scheduler/responsiveness/native_event_observer.h 11233@@ -14,7 +14,7 @@ 11234 #include "content/public/browser/native_event_processor_observer_mac.h" 11235 #endif 11236 11237-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11238+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11239 #include "ui/aura/window_event_dispatcher_observer.h" 11240 #endif 11241 11242@@ -39,7 +39,7 @@ namespace responsiveness { 11243 class CONTENT_EXPORT NativeEventObserver 11244 #if defined(OS_MAC) 11245 : public NativeEventProcessorObserver 11246-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) 11247+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11248 : public aura::WindowEventDispatcherObserver 11249 #elif defined(OS_WIN) 11250 : public base::MessagePumpForUI::Observer 11251@@ -56,7 +56,7 @@ class CONTENT_EXPORT NativeEventObserver 11252 NativeEventObserver(WillRunEventCallback will_run_event_callback, 11253 DidRunEventCallback did_run_event_callback); 11254 11255-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11256+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11257 ~NativeEventObserver() override; 11258 #else 11259 virtual ~NativeEventObserver(); 11260@@ -68,7 +68,7 @@ class CONTENT_EXPORT NativeEventObserver 11261 // Exposed for tests. 11262 void WillRunNativeEvent(const void* opaque_identifier) override; 11263 void DidRunNativeEvent(const void* opaque_identifier) override; 11264-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) 11265+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11266 // aura::WindowEventDispatcherObserver overrides: 11267 void OnWindowEventDispatcherStartedProcessing( 11268 aura::WindowEventDispatcher* dispatcher, 11269@@ -85,7 +85,7 @@ class CONTENT_EXPORT NativeEventObserver 11270 void RegisterObserver(); 11271 void DeregisterObserver(); 11272 11273-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11274+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11275 struct EventInfo { 11276 const void* unique_id; 11277 }; 11278diff --git a/content/browser/speech/tts_ohos.cc b/content/browser/speech/tts_ohos.cc 11279new file mode 100644 11280index 0000000000..c4ba8612d9 11281--- /dev/null 11282+++ b/content/browser/speech/tts_ohos.cc 11283@@ -0,0 +1,47 @@ 11284+// Copyright (c) 2022 The Chromium Authors. All rights reserved. 11285+// Use of this source code is governed by a BSD-style license that can be 11286+// found in the LICENSE file. 11287+ 11288+#include "content/browser/speech/tts_platform_impl.h" 11289+ 11290+#include "base/no_destructor.h" 11291+ 11292+namespace content { 11293+ 11294+// Dummy implementation to prevent a browser crash 11295+class TtsPlatformImplOHOS : public TtsPlatformImpl { 11296+ public: 11297+ TtsPlatformImplOHOS() = default; 11298+ TtsPlatformImplOHOS(const TtsPlatformImplOHOS&) = delete; 11299+ TtsPlatformImplOHOS& operator=(const TtsPlatformImplOHOS&) = delete; 11300+ 11301+ // TtsPlatform implementation. 11302+ bool PlatformImplSupported() override { return false; } 11303+ bool PlatformImplInitialized() override { return false; } 11304+ void Speak(int utterance_id, 11305+ const std::string& utterance, 11306+ const std::string& lang, 11307+ const VoiceData& voice, 11308+ const UtteranceContinuousParameters& params, 11309+ base::OnceCallback<void(bool)> on_speak_finished) override { 11310+ std::move(on_speak_finished).Run(false); 11311+ } 11312+ bool StopSpeaking() override { return false; } 11313+ bool IsSpeaking() override { return false; } 11314+ void GetVoices(std::vector<VoiceData>* out_voices) override {} 11315+ void Pause() override {} 11316+ void Resume() override {} 11317+ 11318+ // Get the single instance of this class. 11319+ static TtsPlatformImplOHOS* GetInstance() { 11320+ static base::NoDestructor<TtsPlatformImplOHOS> tts_platform; 11321+ return tts_platform.get(); 11322+ } 11323+}; 11324+ 11325+// static 11326+TtsPlatformImpl* TtsPlatformImpl::GetInstance() { 11327+ return TtsPlatformImplOHOS::GetInstance(); 11328+} 11329+ 11330+} // namespace content 11331diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc 11332index 515df1ae27..65c4f1049f 100644 11333--- a/content/browser/storage_partition_impl.cc 11334+++ b/content/browser/storage_partition_impl.cc 11335@@ -2501,11 +2501,14 @@ void StoragePartitionImpl::InitNetworkContext() { 11336 GetContentClient()->browser()->ConfigureNetworkContextParams( 11337 browser_context_, is_in_memory_, relative_partition_path_, 11338 context_params.get(), cert_verifier_creation_params.get()); 11339+#if !defined(OS_OHOS) 11340 if (context_params->context_name && 11341 *context_params->context_name == "magic_shutting_down") { 11342 // Don't re-initialize the network context during shutdown. 11343+ LOG(INFO) << "StoragePartitionImpl::InitNetworkContext magic_shutting_down , return"; 11344 return; 11345 } 11346+#endif 11347 devtools_instrumentation::ApplyNetworkContextParamsOverrides( 11348 browser_context_, context_params.get()); 11349 DCHECK(!context_params->cert_verifier_params) 11350diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn 11351index 42f8eeb814..808e912eee 100644 11352--- a/content/common/BUILD.gn 11353+++ b/content/common/BUILD.gn 11354@@ -340,6 +340,22 @@ source_set("common") { 11355 sources -= [ "cursors/webcursor_aura.cc" ] 11356 } 11357 11358+ if (is_ohos) { 11359+ sources += [ 11360+ "common_sandbox_support_linux.cc", 11361+ "sandbox_init_linux.cc", 11362+ "zygote/sandbox_support_linux.cc", 11363+ "zygote/send_zygote_child_ping_linux.cc", 11364+ "zygote/zygote_commands_linux.h", 11365+ "zygote/zygote_communication_linux.cc", 11366+ "zygote/zygote_communication_linux.h", 11367+ "font_list_android.cc", 11368+ ] 11369+ deps += [ 11370+ ":set_process_title_linux", 11371+ ] 11372+ } 11373+ 11374 if (is_linux || is_chromeos) { 11375 sources += [ 11376 "common_sandbox_support_linux.cc", 11377@@ -363,7 +379,7 @@ source_set("common") { 11378 ] 11379 } 11380 11381- if (is_mac || is_win || is_android || is_fuchsia) { 11382+ if (is_mac || is_win || is_android || is_fuchsia || is_ohos) { 11383 sources -= [ "font_list_fontconfig.cc" ] 11384 } 11385 11386@@ -405,7 +421,7 @@ source_set("common") { 11387 } 11388 } 11389 11390-if (is_linux || is_chromeos) { 11391+if (is_linux || is_chromeos || is_ohos) { 11392 source_set("set_process_title_linux") { 11393 public = [ "set_process_title_linux.h" ] 11394 sources = [ "set_process_title_linux.cc" ] 11395diff --git a/content/common/common_sandbox_support_linux.cc b/content/common/common_sandbox_support_linux.cc 11396index 507c3558b5..d008ab0257 100644 11397--- a/content/common/common_sandbox_support_linux.cc 11398+++ b/content/common/common_sandbox_support_linux.cc 11399@@ -8,6 +8,7 @@ 11400 11401 #include <limits> 11402 #include <memory> 11403+#include <unistd.h> 11404 11405 #include "base/numerics/safe_conversions.h" 11406 #include "base/posix/eintr_wrapper.h" 11407diff --git a/content/common/features.gni b/content/common/features.gni 11408index 08e1e8709a..98c595d576 100644 11409--- a/content/common/features.gni 11410+++ b/content/common/features.gni 11411@@ -6,7 +6,7 @@ import("//build/config/chromecast_build.gni") 11412 11413 declare_args() { 11414 # Whether or not to use external popup menu. 11415- use_external_popup_menu = is_android || is_mac 11416+ use_external_popup_menu = is_android || is_mac || is_ohos 11417 11418 # Whether to perform critical memory pressure handling when in foreground (if 11419 # false, critical memory pressure is treated like moderate pressure in foreground). 11420@@ -14,8 +14,8 @@ declare_args() { 11421 11422 # Whether or not MBI mode (Multiple Blink Isolates) should be enabled, 11423 # depending on the build argument. 11424- mbi_mode = is_linux || is_chromeos || is_mac || is_win || is_android 11425+ mbi_mode = is_linux || is_chromeos || is_mac || is_win || is_android || is_ohos 11426 } 11427 11428 enable_screen_capture = 11429- is_linux || is_chromeos || is_mac || is_win || is_android 11430+ is_linux || is_chromeos || is_mac || is_win || is_android || is_ohos 11431diff --git a/content/common/set_process_title.cc b/content/common/set_process_title.cc 11432index a69a088697..b62a81f0a6 100644 11433--- a/content/common/set_process_title.cc 11434+++ b/content/common/set_process_title.cc 11435@@ -38,13 +38,14 @@ 11436 #include "base/threading/platform_thread.h" 11437 // Linux/glibc doesn't natively have setproctitle(). 11438 #include "content/common/set_process_title_linux.h" 11439+#include "content/public/common/content_switches.h" 11440 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) 11441 11442 namespace content { 11443 11444 // TODO(jrg): Find out if setproctitle or equivalent is available on Android. 11445 #if defined(OS_POSIX) && !defined(OS_MAC) && !defined(OS_SOLARIS) && \ 11446- !defined(OS_ANDROID) && !defined(OS_FUCHSIA) 11447+ !defined(OS_ANDROID) && !defined(OS_FUCHSIA) && !defined(OS_OHOS) 11448 11449 void SetProcessTitleFromCommandLine(const char** main_argv) { 11450 // Build a single string which consists of all the arguments separated 11451@@ -92,11 +93,19 @@ void SetProcessTitleFromCommandLine(const char** main_argv) { 11452 11453 const base::CommandLine* command_line = 11454 base::CommandLine::ForCurrentProcess(); 11455+#if !defined(OS_OHOS) 11456 for (size_t i = 1; i < command_line->argv().size(); ++i) { 11457 if (!title.empty()) 11458 title += " "; 11459 title += command_line->argv()[i]; 11460 } 11461+#else 11462+ const std::string& process_type = 11463+ command_line->GetSwitchValueASCII(switches::kProcessType); 11464+ if (!process_type.empty()) { 11465+ title = "webview-" + process_type; 11466+ } 11467+#endif 11468 // Disable prepending argv[0] with '-' if we prepended it ourselves above. 11469 setproctitle(have_argv0 ? "-%s" : "%s", title.c_str()); 11470 } 11471diff --git a/content/common/zygote/zygote_communication_linux.cc b/content/common/zygote/zygote_communication_linux.cc 11472index bdc2b0a5df..dfc4229aa6 100644 11473--- a/content/common/zygote/zygote_communication_linux.cc 11474+++ b/content/common/zygote/zygote_communication_linux.cc 11475@@ -236,6 +236,13 @@ void ZygoteCommunication::Init( 11476 cmd_line.PrependWrapper( 11477 browser_command_line.GetSwitchValueNative(switches::kZygoteCmdPrefix)); 11478 } 11479+ 11480+ if (browser_command_line.HasSwitch(switches::kLogFile)) { 11481+ cmd_line.AppendSwitchPath( 11482+ switches::kLogFile, 11483+ browser_command_line.GetSwitchValuePath(switches::kLogFile)); 11484+ } 11485+ 11486 // Append any switches from the service manager that need to be forwarded on 11487 // to the zygote/renderers. 11488 static const char* const kForwardSwitches[] = { 11489diff --git a/content/public/app/content_main_delegate.cc b/content/public/app/content_main_delegate.cc 11490index 17d256b852..8dd67207a3 100644 11491--- a/content/public/app/content_main_delegate.cc 11492+++ b/content/public/app/content_main_delegate.cc 11493@@ -24,7 +24,7 @@ int ContentMainDelegate::RunProcess( 11494 return -1; 11495 } 11496 11497-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11498+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11499 11500 void ContentMainDelegate::ZygoteStarting( 11501 std::vector<std::unique_ptr<ZygoteForkDelegate>>* delegates) {} 11502diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h 11503index 4162083f78..fcc6e75a4b 100644 11504--- a/content/public/app/content_main_delegate.h 11505+++ b/content/public/app/content_main_delegate.h 11506@@ -49,7 +49,7 @@ class CONTENT_EXPORT ContentMainDelegate { 11507 // Called right before the process exits. 11508 virtual void ProcessExiting(const std::string& process_type) {} 11509 11510-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11511+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11512 // Tells the embedder that the zygote process is starting, and allows it to 11513 // specify one or more zygote delegates if it wishes by storing them in 11514 // |*delegates|. 11515diff --git a/content/public/browser/file_system_access_permission_context.h b/content/public/browser/file_system_access_permission_context.h 11516index 63d5e5606b..d7827e4d54 100644 11517--- a/content/public/browser/file_system_access_permission_context.h 11518+++ b/content/public/browser/file_system_access_permission_context.h 11519@@ -11,6 +11,7 @@ 11520 #include "content/public/browser/global_routing_id.h" 11521 #include "third_party/blink/public/mojom/file_system_access/file_system_access_manager.mojom-shared.h" 11522 #include "url/origin.h" 11523+#include "components/safe_browsing/buildflags.h" 11524 11525 namespace content { 11526 11527@@ -107,12 +108,15 @@ class FileSystemAccessPermissionContext { 11528 base::OnceCallback<void(SensitiveDirectoryResult)> callback) = 0; 11529 11530 enum class AfterWriteCheckResult { kAllow, kBlock }; 11531+ 11532+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11533 // Runs a recently finished write operation through checks such as malware 11534 // or other security checks to determine if the write should be allowed. 11535 virtual void PerformAfterWriteChecks( 11536 std::unique_ptr<FileSystemAccessWriteItem> item, 11537 GlobalFrameRoutingId frame_id, 11538 base::OnceCallback<void(AfterWriteCheckResult)> callback) = 0; 11539+#endif 11540 11541 // Returns whether the give |origin| already allows read permission, or it is 11542 // possible to request one. This is used to block file dialogs from being 11543diff --git a/content/public/common/content_constants.cc b/content/public/common/content_constants.cc 11544index 88f1e915a9..096defba10 100644 11545--- a/content/public/common/content_constants.cc 11546+++ b/content/public/common/content_constants.cc 11547@@ -50,7 +50,7 @@ std::string GetCorsExemptRequestedWithHeaderName() { 11548 return base::JoinString(pieces, "-"); 11549 } 11550 11551-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11552+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11553 const int kLowestRendererOomScore = 300; 11554 const int kHighestRendererOomScore = 1000; 11555 11556diff --git a/content/public/common/content_constants.h b/content/public/common/content_constants.h 11557index 6b8e119a40..89662982e5 100644 11558--- a/content/public/common/content_constants.h 11559+++ b/content/public/common/content_constants.h 11560@@ -61,7 +61,7 @@ CONTENT_EXPORT extern const char kCorsExemptPurposeHeaderName[]; 11561 // it at run time. 11562 CONTENT_EXPORT std::string GetCorsExemptRequestedWithHeaderName(); 11563 11564-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11565+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11566 // The OOM score adj constants 11567 // The highest and lowest assigned OOM score adjustment (oom_score_adj) for 11568 // renderers and extensions used by the OomPriority Manager. 11569diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc 11570index b2fe2c5cad..3e6645553b 100644 11571--- a/content/public/common/content_features.cc 11572+++ b/content/public/common/content_features.cc 11573@@ -447,7 +447,7 @@ const base::Feature kMouseSubframeNoImplicitCapture{ 11574 // If the network service is enabled, runs it in process. 11575 const base::Feature kNetworkServiceInProcess { 11576 "NetworkServiceInProcess", 11577-#if defined(OS_ANDROID) 11578+#if defined(OS_ANDROID) || defined(OS_OHOS) 11579 base::FEATURE_ENABLED_BY_DEFAULT 11580 #else 11581 base::FEATURE_DISABLED_BY_DEFAULT 11582diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc 11583index 9e995c4939..f543db60a3 100644 11584--- a/content/public/common/content_switches.cc 11585+++ b/content/public/common/content_switches.cc 11586@@ -964,13 +964,17 @@ const char kEnableAutomation[] = "enable-automation"; 11587 11588 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 11589 // of lacros-chrome is complete. 11590-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 11591+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 11592 // Allows sending text-to-speech requests to speech-dispatcher, a common 11593 // Linux speech service. Because it's buggy, the user must explicitly 11594 // enable it so that visiting a random webpage can't cause instability. 11595 const char kEnableSpeechDispatcher[] = "enable-speech-dispatcher"; 11596 #endif 11597 11598+#if defined(OS_OHOS) 11599+const char kEnableMultiRendererProcess[] = "enable-multi-renderer-process"; 11600+#endif 11601+ 11602 #if defined(OS_WIN) 11603 // /prefetch:# arguments to use when launching various process types. It has 11604 // been observed that when file reads are consistent for 3 process launches with 11605diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h 11606index 00cc8c3a93..31d0a72c4b 100644 11607--- a/content/public/common/content_switches.h 11608+++ b/content/public/common/content_switches.h 11609@@ -265,10 +265,14 @@ CONTENT_EXPORT extern const char kRendererWaitForJavaDebugger[]; 11610 11611 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 11612 // of lacros-chrome is complete. 11613-#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 11614+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 11615 CONTENT_EXPORT extern const char kEnableSpeechDispatcher[]; 11616 #endif 11617 11618+#if defined(OS_OHOS) 11619+CONTENT_EXPORT extern const char kEnableMultiRendererProcess[]; 11620+#endif 11621+ 11622 #if defined(OS_WIN) 11623 CONTENT_EXPORT extern const char kPrefetchArgumentRenderer[]; 11624 CONTENT_EXPORT extern const char kPrefetchArgumentGpu[]; 11625diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn 11626index 9425dc5637..3cdc94634e 100644 11627--- a/content/renderer/BUILD.gn 11628+++ b/content/renderer/BUILD.gn 11629@@ -215,7 +215,8 @@ target(link_target_type, "renderer") { 11630 ] 11631 } 11632 11633- if (is_linux || is_chromeos) { 11634+ 11635+ if (is_linux || is_chromeos || is_ohos) { 11636 sources += [ "renderer_main_platform_delegate_linux.cc" ] 11637 } 11638 11639@@ -536,7 +537,7 @@ target(link_target_type, "renderer") { 11640 ] 11641 } 11642 11643- if (is_linux || is_chromeos || is_android) { 11644+ if (is_linux || is_chromeos || is_android || is_ohos) { 11645 deps += [ "//sandbox:sandbox_buildflags" ] 11646 } 11647 11648diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc 11649index 553dd2f7ac..ff09383120 100644 11650--- a/content/shell/app/shell_main_delegate.cc 11651+++ b/content/shell/app/shell_main_delegate.cc 11652@@ -186,7 +186,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { 11653 11654 void ShellMainDelegate::PreSandboxStartup() { 11655 #if defined(ARCH_CPU_ARM_FAMILY) && \ 11656- (defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)) 11657+ (defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS)) 11658 // Create an instance of the CPU class to parse /proc/cpuinfo and cache 11659 // cpu_brand info. 11660 base::CPU cpu_info; 11661@@ -205,9 +205,9 @@ void ShellMainDelegate::PreSandboxStartup() { 11662 // Reporting for sub-processes will be initialized in ZygoteForked. 11663 if (process_type != switches::kZygoteProcess) { 11664 crash_reporter::InitializeCrashpad(process_type.empty(), process_type); 11665-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11666- crash_reporter::SetFirstChanceExceptionHandler( 11667- v8::TryHandleWebAssemblyTrapPosix); 11668+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11669+ //crash_reporter::SetFirstChanceExceptionHandler( 11670+ // v8::TryHandleWebAssemblyTrapPosix); 11671 #endif 11672 } 11673 } 11674@@ -263,7 +263,7 @@ int ShellMainDelegate::RunProcess( 11675 #endif 11676 } 11677 11678-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11679+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11680 void ShellMainDelegate::ZygoteForked() { 11681 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 11682 switches::kEnableCrashReporter)) { 11683@@ -271,10 +271,15 @@ void ShellMainDelegate::ZygoteForked() { 11684 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 11685 switches::kProcessType); 11686 crash_reporter::InitializeCrashpad(false, process_type); 11687- crash_reporter::SetFirstChanceExceptionHandler( 11688- v8::TryHandleWebAssemblyTrapPosix); 11689+ //crash_reporter::SetFirstChanceExceptionHandler( 11690+ // v8::TryHandleWebAssemblyTrapPosix); 11691 } 11692 } 11693+ 11694+ 11695+void ShellMainDelegate::ZygoteStarting( 11696+ std::vector<std::unique_ptr<content::ZygoteForkDelegate>>* delegates) { 11697+} 11698 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) 11699 11700 void ShellMainDelegate::InitializeResourceBundle() { 11701diff --git a/content/shell/app/shell_main_delegate.h b/content/shell/app/shell_main_delegate.h 11702index ff32beccd6..69313e25d3 100644 11703--- a/content/shell/app/shell_main_delegate.h 11704+++ b/content/shell/app/shell_main_delegate.h 11705@@ -33,8 +33,10 @@ class ShellMainDelegate : public ContentMainDelegate { 11706 void PreSandboxStartup() override; 11707 int RunProcess(const std::string& process_type, 11708 const MainFunctionParams& main_function_params) override; 11709-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 11710+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11711 void ZygoteForked() override; 11712+ void ZygoteStarting( 11713+ std::vector<std::unique_ptr<content::ZygoteForkDelegate>>* delegates) override; 11714 #endif 11715 void PreCreateMainMessageLoop() override; 11716 ContentClient* CreateContentClient() override; 11717diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn 11718index f74fc18742..2687d4783b 100644 11719--- a/content/test/BUILD.gn 11720+++ b/content/test/BUILD.gn 11721@@ -679,9 +679,11 @@ if (is_fuchsia) { 11722 11723 group("telemetry_gpu_integration_test_scripts_only") { 11724 testonly = true 11725- deps = [ 11726- "//tools/perf/chrome_telemetry_build:telemetry_chrome_test_without_chrome", 11727- ] 11728+ if (!is_ohos) { 11729+ deps = [ 11730+ "//tools/perf/chrome_telemetry_build:telemetry_chrome_test_without_chrome", 11731+ ] 11732+ } 11733 11734 data = [ 11735 "//content/test/gpu/", 11736diff --git a/content/web_test/BUILD.gn b/content/web_test/BUILD.gn 11737index a814031680..196e58fbcf 100644 11738--- a/content/web_test/BUILD.gn 11739+++ b/content/web_test/BUILD.gn 11740@@ -7,7 +7,7 @@ import("//build/config/ui.gni") # For the use_x11 and toolkit_views variables. 11741 import("//mojo/public/tools/bindings/mojom.gni") 11742 import("//ppapi/buildflags/buildflags.gni") # For the enable_plugins variable. 11743 11744-if (is_android) { 11745+if (is_android || is_ohos) { 11746 import("//build/config/android/config.gni") 11747 } else if (is_mac) { 11748 import("//build/apple/tweak_info_plist.gni") 11749diff --git a/content/zygote/BUILD.gn b/content/zygote/BUILD.gn 11750index 27381b9a00..b95830aedf 100644 11751--- a/content/zygote/BUILD.gn 11752+++ b/content/zygote/BUILD.gn 11753@@ -5,7 +5,7 @@ 11754 import("//build/config/nacl/config.gni") 11755 import("//content/public/common/zygote/features.gni") 11756 11757-if (is_linux || is_chromeos) { 11758+if (is_linux || is_chromeos || is_ohos) { 11759 source_set("zygote") { 11760 sources = [ 11761 "zygote_linux.cc", 11762diff --git a/device/gamepad/BUILD.gn b/device/gamepad/BUILD.gn 11763index 4f2ddf5f9c..70a9b89127 100644 11764--- a/device/gamepad/BUILD.gn 11765+++ b/device/gamepad/BUILD.gn 11766@@ -122,7 +122,7 @@ component("gamepad") { 11767 deps += [ ":jni_headers" ] 11768 } 11769 11770- if (!is_android && !is_fuchsia) { 11771+ if (!is_android && !is_fuchsia && !is_ohos) { 11772 sources += [ 11773 "nintendo_controller.cc", 11774 "nintendo_controller.h", 11775diff --git a/extensions/browser/api/system_cpu/BUILD.gn b/extensions/browser/api/system_cpu/BUILD.gn 11776index 9f907cfe24..bf054dedc0 100644 11777--- a/extensions/browser/api/system_cpu/BUILD.gn 11778+++ b/extensions/browser/api/system_cpu/BUILD.gn 11779@@ -26,7 +26,7 @@ source_set("system_cpu") { 11780 sources += [ "cpu_info_provider_mac.cc" ] 11781 } 11782 11783- if (is_linux || is_chromeos) { 11784+ if (is_linux || is_chromeos || is_ohos) { 11785 sources += [ "cpu_info_provider_linux.cc" ] 11786 } 11787 11788diff --git a/extensions/browser/updater/update_service.cc b/extensions/browser/updater/update_service.cc 11789index 1f4c80cdf9..fe6e4dcd37 100644 11790--- a/extensions/browser/updater/update_service.cc 11791+++ b/extensions/browser/updater/update_service.cc 11792@@ -14,6 +14,7 @@ 11793 #include "base/metrics/histogram_macros.h" 11794 #include "components/update_client/crx_update_item.h" 11795 #include "components/update_client/update_client_errors.h" 11796+#include "components/safe_browsing/buildflags.h" 11797 #include "content/public/browser/browser_context.h" 11798 #include "content/public/browser/browser_thread.h" 11799 #include "content/public/browser/notification_details.h" 11800@@ -111,6 +112,7 @@ void UpdateService::OnEvent(Events event, const std::string& extension_id) { 11801 break; 11802 } 11803 11804+#if BUILDFLAG(SAFE_BROWSING_AVAILABLE) 11805 if (should_perform_action_on_omaha_attributes) { 11806 base::Value attributes = GetExtensionOmahaAttributes(extension_id); 11807 // Note that it's important to perform actions even if |attributes| is 11808@@ -118,6 +120,7 @@ void UpdateService::OnEvent(Events event, const std::string& extension_id) { 11809 ExtensionSystem::Get(browser_context_) 11810 ->PerformActionBasedOnOmahaAttributes(extension_id, attributes); 11811 } 11812+#endif 11813 } 11814 11815 UpdateService::UpdateService( 11816diff --git a/extensions/common/install_warning.h b/extensions/common/install_warning.h 11817index be1937edb1..8f4fb5dcb2 100644 11818--- a/extensions/common/install_warning.h 11819+++ b/extensions/common/install_warning.h 11820@@ -43,7 +43,7 @@ struct InstallWarning { 11821 // (e.g., an unrecognized permission "foo" in "permissions"). 11822 std::string specific; 11823 11824- DISALLOW_COPY(InstallWarning); 11825+ DISALLOW_COPY_BASE(InstallWarning); 11826 }; 11827 11828 // Let gtest print InstallWarnings. 11829diff --git a/gin/array_buffer.h b/gin/array_buffer.h 11830index 086371af29..1a5e944ca9 100644 11831--- a/gin/array_buffer.h 11832+++ b/gin/array_buffer.h 11833@@ -42,7 +42,7 @@ class GIN_EXPORT ArrayBuffer { 11834 11835 private: 11836 std::shared_ptr<v8::BackingStore> backing_store_; 11837- DISALLOW_COPY(ArrayBuffer); 11838+ DISALLOW_COPY_BASE(ArrayBuffer); 11839 }; 11840 11841 template<> 11842@@ -68,7 +68,7 @@ class GIN_EXPORT ArrayBufferView { 11843 size_t offset_; 11844 size_t num_bytes_; 11845 11846- DISALLOW_COPY(ArrayBufferView); 11847+ DISALLOW_COPY_BASE(ArrayBufferView); 11848 }; 11849 11850 template<> 11851diff --git a/gpu/command_buffer/common/gpu_memory_buffer_support.cc b/gpu/command_buffer/common/gpu_memory_buffer_support.cc 11852index 388de9f400..6976730735 100644 11853--- a/gpu/command_buffer/common/gpu_memory_buffer_support.cc 11854+++ b/gpu/command_buffer/common/gpu_memory_buffer_support.cc 11855@@ -55,7 +55,7 @@ bool IsImageSizeValidForGpuMemoryBufferFormat(const gfx::Size& size, 11856 uint32_t GetPlatformSpecificTextureTarget() { 11857 #if defined(OS_MAC) 11858 return macos_specific_texture_target; 11859-#elif defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 11860+#elif defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 11861 return GL_TEXTURE_EXTERNAL_OES; 11862 #elif defined(OS_WIN) || defined(OS_FUCHSIA) 11863 return GL_TEXTURE_2D; 11864diff --git a/gpu/command_buffer/service/BUILD.gn b/gpu/command_buffer/service/BUILD.gn 11865index b8bec7d5cd..81283e3b36 100644 11866--- a/gpu/command_buffer/service/BUILD.gn 11867+++ b/gpu/command_buffer/service/BUILD.gn 11868@@ -339,7 +339,7 @@ target(link_target_type, "gles2_sources") { 11869 "//gpu/vulkan", 11870 ] 11871 11872- if (is_linux || is_chromeos || is_fuchsia || is_android || is_win) { 11873+ if (is_linux || is_chromeos || is_fuchsia || is_android || is_win || is_ohos) { 11874 sources += [ 11875 "external_semaphore.cc", 11876 "external_semaphore.h", 11877diff --git a/gpu/command_buffer/service/external_semaphore.cc b/gpu/command_buffer/service/external_semaphore.cc 11878index ca828b681a..6ea5593b0f 100644 11879--- a/gpu/command_buffer/service/external_semaphore.cc 11880+++ b/gpu/command_buffer/service/external_semaphore.cc 11881@@ -39,7 +39,7 @@ GLuint ImportSemaphoreHandleToGLSemaphore(SemaphoreHandle handle) { 11882 }, 11883 base::Time::Now())); 11884 11885-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 11886+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 11887 if (handle.vk_handle_type() != 11888 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT) { 11889 DLOG(ERROR) << "Importing semaphore handle of unexpected type:" 11890diff --git a/gpu/command_buffer/service/external_vk_image_backing.cc b/gpu/command_buffer/service/external_vk_image_backing.cc 11891index 5e8c09cfb7..0e918e62b3 100644 11892--- a/gpu/command_buffer/service/external_vk_image_backing.cc 11893+++ b/gpu/command_buffer/service/external_vk_image_backing.cc 11894@@ -648,7 +648,7 @@ GLuint ExternalVkImageBacking::ProduceGLTextureInternal() { 11895 gl::GLApi* api = gl::g_current_gl_context; 11896 base::Optional<ScopedDedicatedMemoryObject> memory_object; 11897 if (!use_separate_gl_texture()) { 11898-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 11899+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 11900 auto memory_fd = image_->GetMemoryFd(); 11901 if (!memory_fd.is_valid()) 11902 return 0; 11903diff --git a/gpu/config/BUILD.gn b/gpu/config/BUILD.gn 11904index 9e291e8874..ce0faa980d 100644 11905--- a/gpu/config/BUILD.gn 11906+++ b/gpu/config/BUILD.gn 11907@@ -55,7 +55,7 @@ python2_action("process_json") { 11908 args += [ "win" ] 11909 } else if (is_mac) { 11910 args += [ "macosx" ] 11911- } else if (is_android) { 11912+ } else if (is_android || is_ohos) { 11913 args += [ "android" ] 11914 } else if (is_chromeos_ash) { 11915 args += [ "chromeos" ] 11916@@ -225,10 +225,10 @@ source_set("config_sources") { 11917 sources += [ "gpu_info_collector_mac.mm" ] 11918 frameworks = [ "OpenGL.framework" ] 11919 } 11920- if (is_linux || is_chromeos) { 11921+ if (is_linux || is_chromeos || is_ohos) { 11922 sources += [ "gpu_info_collector_linux.cc" ] 11923 } 11924- if (is_linux || is_chromeos || is_mac) { 11925+ if (is_linux || is_chromeos || is_mac || is_ohos) { 11926 deps += [ "//third_party/angle:angle_gpu_info_util" ] 11927 } 11928 if (use_x11) { 11929diff --git a/gpu/config/gpu_info_collector.cc b/gpu/config/gpu_info_collector.cc 11930index 22b65603e1..0f7902d494 100644 11931--- a/gpu/config/gpu_info_collector.cc 11932+++ b/gpu/config/gpu_info_collector.cc 11933@@ -316,7 +316,7 @@ bool CollectGraphicsInfoGL(GPUInfo* gpu_info) { 11934 gpu_info->max_msaa_samples = base::NumberToString(max_samples); 11935 base::UmaHistogramSparse("GPU.MaxMSAASampleCount", max_samples); 11936 11937-#if defined(OS_ANDROID) 11938+#if defined(OS_ANDROID) || defined(OS_OHOS) 11939 gpu_info->can_support_threaded_texture_mailbox = 11940 gl::GLSurfaceEGL::HasEGLExtension("EGL_KHR_fence_sync") && 11941 gl::GLSurfaceEGL::HasEGLExtension("EGL_KHR_image_base") && 11942@@ -481,7 +481,7 @@ void FillGPUInfoFromSystemInfo(GPUInfo* gpu_info, 11943 11944 void CollectGraphicsInfoForTesting(GPUInfo* gpu_info) { 11945 DCHECK(gpu_info); 11946-#if defined(OS_ANDROID) 11947+#if defined(OS_ANDROID) || defined(OS_OHOS) 11948 CollectContextGraphicsInfo(gpu_info); 11949 #else 11950 CollectBasicGraphicsInfo(gpu_info); 11951diff --git a/gpu/config/gpu_test_config.cc b/gpu/config/gpu_test_config.cc 11952index 592f71243e..992222b866 100644 11953--- a/gpu/config/gpu_test_config.cc 11954+++ b/gpu/config/gpu_test_config.cc 11955@@ -29,7 +29,7 @@ GPUTestConfig::OS GetCurrentOS() { 11956 #if BUILDFLAG(IS_CHROMEOS_ASH) 11957 return GPUTestConfig::kOsChromeOS; 11958 #elif (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || \ 11959- defined(OS_OPENBSD) 11960+ defined(OS_OPENBSD) || defined(OS_OHOS) 11961 return GPUTestConfig::kOsLinux; 11962 #elif defined(OS_WIN) 11963 int32_t major_version = 0; 11964diff --git a/gpu/ipc/common/gpu_memory_buffer_support.cc b/gpu/ipc/common/gpu_memory_buffer_support.cc 11965index 4ff68ba071..bc3d82eea0 100644 11966--- a/gpu/ipc/common/gpu_memory_buffer_support.cc 11967+++ b/gpu/ipc/common/gpu_memory_buffer_support.cc 11968@@ -105,6 +105,8 @@ bool GpuMemoryBufferSupport::IsNativeGpuMemoryBufferConfigurationSupported( 11969 } 11970 NOTREACHED(); 11971 return false; 11972+#elif defined(OS_OHOS) 11973+ return false; 11974 #elif defined(OS_ANDROID) 11975 if (!base::AndroidHardwareBufferCompat::IsSupportAvailable()) { 11976 return false; 11977diff --git a/gpu/ipc/service/BUILD.gn b/gpu/ipc/service/BUILD.gn 11978index 68c08ac4c8..160e035e87 100644 11979--- a/gpu/ipc/service/BUILD.gn 11980+++ b/gpu/ipc/service/BUILD.gn 11981@@ -123,7 +123,7 @@ component("service") { 11982 ] 11983 libs += [ "android" ] 11984 } 11985- if (is_linux || is_chromeos) { 11986+ if (is_linux || is_chromeos || is_ohos) { 11987 sources += [ "image_transport_surface_linux.cc" ] 11988 } 11989 if (is_linux || is_chromeos || use_ozone) { 11990diff --git a/gpu/vulkan/BUILD.gn b/gpu/vulkan/BUILD.gn 11991index b91be74241..24f1e42c05 100644 11992--- a/gpu/vulkan/BUILD.gn 11993+++ b/gpu/vulkan/BUILD.gn 11994@@ -123,7 +123,7 @@ if (enable_vulkan) { 11995 if (is_posix) { 11996 sources += [ "vulkan_util_posix.cc" ] 11997 11998- if (is_linux || is_chromeos) { 11999+ if (is_linux || is_chromeos || is_ohos) { 12000 sources += [ "vulkan_image_linux.cc" ] 12001 } 12002 } 12003diff --git a/gpu/vulkan/features.gni b/gpu/vulkan/features.gni 12004index 7a98011f98..fbb07272ec 100644 12005--- a/gpu/vulkan/features.gni 12006+++ b/gpu/vulkan/features.gni 12007@@ -8,7 +8,7 @@ import("//build/config/ui.gni") 12008 # For details see declare_args() in build/config/BUILDCONFIG.gn. 12009 declare_args() { 12010 # Enable experimental vulkan backend. 12011- enable_vulkan = is_linux || is_chromeos || is_android || is_fuchsia || is_win 12012+ enable_vulkan = is_linux || is_chromeos || is_android || is_fuchsia || is_win || is_ohos 12013 12014 # Enable swiftshader vulkan. Disabling it can save build time, however 12015 # --use-vulkan=swiftshader and some tests which use swiftshader vulkan will 12016diff --git a/gpu/vulkan/vulkan_function_pointers.cc b/gpu/vulkan/vulkan_function_pointers.cc 12017index f1377f99f9..7a08d7b406 100644 12018--- a/gpu/vulkan/vulkan_function_pointers.cc 12019+++ b/gpu/vulkan/vulkan_function_pointers.cc 12020@@ -898,7 +898,7 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers( 12021 } 12022 #endif // defined(OS_ANDROID) 12023 12024-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12025+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 12026 if (gfx::HasExtension(enabled_extensions, 12027 VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME)) { 12028 vkGetSemaphoreFdKHR = reinterpret_cast<PFN_vkGetSemaphoreFdKHR>( 12029@@ -942,7 +942,7 @@ bool VulkanFunctionPointers::BindDeviceFunctionPointers( 12030 } 12031 #endif // defined(OS_WIN) 12032 12033-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12034+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 12035 if (gfx::HasExtension(enabled_extensions, 12036 VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME)) { 12037 vkGetMemoryFdKHR = reinterpret_cast<PFN_vkGetMemoryFdKHR>( 12038diff --git a/gpu/vulkan/vulkan_function_pointers.h b/gpu/vulkan/vulkan_function_pointers.h 12039index 1ec6898e82..ba6173df9c 100644 12040--- a/gpu/vulkan/vulkan_function_pointers.h 12041+++ b/gpu/vulkan/vulkan_function_pointers.h 12042@@ -241,7 +241,7 @@ struct COMPONENT_EXPORT(VULKAN) VulkanFunctionPointers { 12043 vkGetAndroidHardwareBufferPropertiesANDROID; 12044 #endif // defined(OS_ANDROID) 12045 12046-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12047+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 12048 VulkanFunction<PFN_vkGetSemaphoreFdKHR> vkGetSemaphoreFdKHR; 12049 VulkanFunction<PFN_vkImportSemaphoreFdKHR> vkImportSemaphoreFdKHR; 12050 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12051@@ -252,7 +252,7 @@ struct COMPONENT_EXPORT(VULKAN) VulkanFunctionPointers { 12052 vkImportSemaphoreWin32HandleKHR; 12053 #endif // defined(OS_WIN) 12054 12055-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12056+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 12057 VulkanFunction<PFN_vkGetMemoryFdKHR> vkGetMemoryFdKHR; 12058 VulkanFunction<PFN_vkGetMemoryFdPropertiesKHR> vkGetMemoryFdPropertiesKHR; 12059 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12060@@ -292,7 +292,7 @@ struct COMPONENT_EXPORT(VULKAN) VulkanFunctionPointers { 12061 VulkanFunction<PFN_vkGetSwapchainImagesKHR> vkGetSwapchainImagesKHR; 12062 VulkanFunction<PFN_vkQueuePresentKHR> vkQueuePresentKHR; 12063 12064-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12065+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12066 VulkanFunction<PFN_vkGetImageDrmFormatModifierPropertiesEXT> 12067 vkGetImageDrmFormatModifierPropertiesEXT; 12068 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) 12069@@ -997,7 +997,7 @@ ALWAYS_INLINE VkResult vkGetAndroidHardwareBufferPropertiesANDROID( 12070 } 12071 #endif // defined(OS_ANDROID) 12072 12073-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12074+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 12075 ALWAYS_INLINE VkResult 12076 vkGetSemaphoreFdKHR(VkDevice device, 12077 const VkSemaphoreGetFdInfoKHR* pGetFdInfo, 12078@@ -1030,7 +1030,7 @@ vkImportSemaphoreWin32HandleKHR(VkDevice device, 12079 } 12080 #endif // defined(OS_WIN) 12081 12082-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 12083+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 12084 ALWAYS_INLINE VkResult vkGetMemoryFdKHR(VkDevice device, 12085 const VkMemoryGetFdInfoKHR* pGetFdInfo, 12086 int* pFd) { 12087@@ -1125,7 +1125,7 @@ ALWAYS_INLINE VkResult vkQueuePresentKHR(VkQueue queue, 12088 pPresentInfo); 12089 } 12090 12091-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12092+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12093 ALWAYS_INLINE VkResult vkGetImageDrmFormatModifierPropertiesEXT( 12094 VkDevice device, 12095 VkImage image, 12096diff --git a/gpu/vulkan/vulkan_image.h b/gpu/vulkan/vulkan_image.h 12097index 3afbbd4746..d8f43c8c03 100644 12098--- a/gpu/vulkan/vulkan_image.h 12099+++ b/gpu/vulkan/vulkan_image.h 12100@@ -84,7 +84,7 @@ class COMPONENT_EXPORT(VULKAN) VulkanImage { 12101 VkImageUsageFlags usage, 12102 VkImageCreateFlags flags); 12103 12104-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12105+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12106 static std::unique_ptr<VulkanImage> CreateWithExternalMemoryAndModifiers( 12107 VulkanDeviceQueue* device_queue, 12108 const gfx::Size& size, 12109@@ -166,7 +166,7 @@ class COMPONENT_EXPORT(VULKAN) VulkanImage { 12110 VkImageCreateFlags flags, 12111 VkImageTiling image_tiling); 12112 12113-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12114+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12115 bool InitializeWithExternalMemoryAndModifiers(VulkanDeviceQueue* device_queue, 12116 const gfx::Size& size, 12117 VkFormat format, 12118diff --git a/ios/chrome/browser/dom_distiller/dom_distiller_service_factory.h b/ios/chrome/browser/dom_distiller/dom_distiller_service_factory.h 12119index 870222a9a7..07ae167538 100644 12120--- a/ios/chrome/browser/dom_distiller/dom_distiller_service_factory.h 12121+++ b/ios/chrome/browser/dom_distiller/dom_distiller_service_factory.h 12122@@ -37,7 +37,7 @@ class DomDistillerServiceFactory : public BrowserStateKeyedServiceFactory { 12123 web::BrowserState* GetBrowserStateToUse( 12124 web::BrowserState* context) const override; 12125 12126- DISALLOW_COPY(DomDistillerServiceFactory); 12127+ DISALLOW_COPY_BASE(DomDistillerServiceFactory); 12128 }; 12129 12130 } // namespace dom_distiller 12131diff --git a/ipc/ipc_channel.h b/ipc/ipc_channel.h 12132index 48436e8f42..5d9cf2e65a 100644 12133--- a/ipc/ipc_channel.h 12134+++ b/ipc/ipc_channel.h 12135@@ -244,7 +244,7 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender { 12136 static std::string GenerateUniqueRandomChannelID(); 12137 #endif 12138 12139-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12140+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12141 // Sandboxed processes live in a PID namespace, so when sending the IPC hello 12142 // message from client to server we need to send the PID from the global 12143 // PID namespace. 12144diff --git a/ipc/ipc_channel_common.cc b/ipc/ipc_channel_common.cc 12145index 8990eee6bc..38e796d574 100644 12146--- a/ipc/ipc_channel_common.cc 12147+++ b/ipc/ipc_channel_common.cc 12148@@ -10,7 +10,7 @@ 12149 12150 namespace IPC { 12151 12152-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12153+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12154 12155 namespace { 12156 int g_global_pid = 0; 12157diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc 12158index 473fb1407c..84dede531e 100644 12159--- a/ipc/ipc_message_utils.cc 12160+++ b/ipc/ipc_message_utils.cc 12161@@ -361,7 +361,7 @@ void ParamTraits<unsigned int>::Log(const param_type& p, std::string* l) { 12162 l->append(base::NumberToString(p)); 12163 } 12164 12165-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 12166+#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) || \ 12167 defined(OS_FUCHSIA) || (defined(OS_ANDROID) && defined(ARCH_CPU_64_BITS)) 12168 void ParamTraits<long>::Log(const param_type& p, std::string* l) { 12169 l->append(base::NumberToString(p)); 12170diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h 12171index 97e7f0aa56..343f9da178 100644 12172--- a/ipc/ipc_message_utils.h 12173+++ b/ipc/ipc_message_utils.h 12174@@ -207,7 +207,7 @@ struct ParamTraits<unsigned int> { 12175 // 3) Android 64 bit and Fuchsia also have int64_t typedef'd to long. 12176 // Since we want to support Android 32<>64 bit IPC, as long as we don't have 12177 // these traits for 32 bit ARM then that'll catch any errors. 12178-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 12179+#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) || \ 12180 defined(OS_FUCHSIA) || (defined(OS_ANDROID) && defined(ARCH_CPU_64_BITS)) 12181 template <> 12182 struct ParamTraits<long> { 12183diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn 12184index c68099d5ba..7cabe2c6d5 100644 12185--- a/media/audio/BUILD.gn 12186+++ b/media/audio/BUILD.gn 12187@@ -236,7 +236,7 @@ source_set("audio") { 12188 ] 12189 } 12190 12191- if (is_linux || is_chromeos) { 12192+ if (is_linux || is_chromeos || is_ohos) { 12193 sources += [ "linux/audio_manager_linux.cc" ] 12194 } 12195 12196diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn 12197index 54e6842abd..56786f8ef1 100644 12198--- a/media/base/BUILD.gn 12199+++ b/media/base/BUILD.gn 12200@@ -440,7 +440,7 @@ source_set("base") { 12201 12202 # TODO(ziyangch): Check |is_chromecast| first when using cast media pipeline 12203 # on Android cast devices. 12204- if (is_android) { 12205+ if (is_android || is_ohos) { 12206 sources += [ "demuxer_memory_limit_android.cc" ] 12207 } else if (is_chromecast) { 12208 sources += [ "demuxer_memory_limit_cast.cc" ] 12209diff --git a/media/base/android_overlay_config.h b/media/base/android_overlay_config.h 12210index d51131024e..317456c56b 100644 12211--- a/media/base/android_overlay_config.h 12212+++ b/media/base/android_overlay_config.h 12213@@ -80,7 +80,7 @@ struct MEDIA_EXPORT AndroidOverlayConfig { 12214 // Optional, may be empty. 12215 PowerEfficientCB power_cb; 12216 12217- DISALLOW_COPY(AndroidOverlayConfig); 12218+ DISALLOW_COPY_BASE(AndroidOverlayConfig); 12219 }; 12220 12221 // Common factory type. 12222diff --git a/media/base/demuxer_memory_limit.h b/media/base/demuxer_memory_limit.h 12223index 2492eca1dd..4377878c1a 100644 12224--- a/media/base/demuxer_memory_limit.h 12225+++ b/media/base/demuxer_memory_limit.h 12226@@ -45,7 +45,7 @@ constexpr size_t kDemuxerStreamVideoMemoryLimitDefault = 150 * 1024 * 1024; 12227 constexpr size_t kDemuxerStreamVideoMemoryLimitMedium = 80 * 1024 * 1024; 12228 constexpr size_t kDemuxerStreamVideoMemoryLimitLow = 30 * 1024 * 1024; 12229 12230-#if defined(OS_ANDROID) 12231+#if defined(OS_ANDROID) || defined(OS_OHOS) 12232 // Special "very low" settings for 512MiB Android Go devices: 12233 // * audio memory limit: 1MB (30 seconds of 256Kbps content). 12234 // * video memory limit: 15MB (30 seconds of 4Mbps content). 12235diff --git a/media/base/demuxer_memory_limit_android.cc b/media/base/demuxer_memory_limit_android.cc 12236index 3ea849942e..a6935af0d1 100644 12237--- a/media/base/demuxer_memory_limit_android.cc 12238+++ b/media/base/demuxer_memory_limit_android.cc 12239@@ -4,7 +4,9 @@ 12240 12241 #include "media/base/demuxer_memory_limit.h" 12242 12243+#if !defined(OS_OHOS) 12244 #include "base/android/build_info.h" 12245+#endif 12246 #include "base/system/sys_info.h" 12247 12248 namespace media { 12249@@ -17,12 +19,14 @@ size_t SelectLimit(size_t default_limit, 12250 if (!base::SysInfo::IsLowEndDevice()) { 12251 return default_limit; 12252 } 12253+#if !defined(OS_OHOS) 12254 // Use very low limit on 512MiB Android Go devices only. 12255 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 12256 base::android::SDK_VERSION_OREO && 12257 base::SysInfo::AmountOfPhysicalMemoryMB() <= 512) { 12258 return very_low_limit; 12259 } 12260+#endif 12261 return low_limit; 12262 } 12263 12264diff --git a/media/capture/BUILD.gn b/media/capture/BUILD.gn 12265index 81f0559d73..ad4a451de9 100644 12266--- a/media/capture/BUILD.gn 12267+++ b/media/capture/BUILD.gn 12268@@ -262,7 +262,7 @@ component("capture_lib") { 12269 # This includes the case of ChromeOS 12270 # TODO: As we move to separately version Chrome from ChromeOS, we may need to split 12271 # these sources into linux, chromeos, and common. 12272- if (is_linux || is_chromeos) { 12273+ if (is_linux || is_chromeos || is_ohos) { 12274 sources += [ 12275 "video/linux/scoped_v4l2_device_fd.cc", 12276 "video/linux/scoped_v4l2_device_fd.h", 12277@@ -394,7 +394,7 @@ source_set("test_support") { 12278 "//ui/gfx:test_support", 12279 ] 12280 12281- if (is_linux || is_chromeos) { 12282+ if (is_linux || is_chromeos || is_ohos) { 12283 sources += [ 12284 "video/linux/fake_device_provider.cc", 12285 "video/linux/fake_device_provider.h", 12286diff --git a/media/capture/video/fake_video_capture_device_factory.cc b/media/capture/video/fake_video_capture_device_factory.cc 12287index b96840f0a6..5f5976b456 100644 12288--- a/media/capture/video/fake_video_capture_device_factory.cc 12289+++ b/media/capture/video/fake_video_capture_device_factory.cc 12290@@ -208,7 +208,7 @@ void FakeVideoCaptureDeviceFactory::GetDevicesInfo( 12291 int entry_index = 0; 12292 for (const auto& entry : devices_config_) { 12293 VideoCaptureApi api = 12294-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12295+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12296 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE; 12297 #elif defined(OS_MAC) 12298 VideoCaptureApi::MACOSX_AVFOUNDATION; 12299diff --git a/media/media_options.gni b/media/media_options.gni 12300index d24c662534..b3e22d553b 100644 12301--- a/media/media_options.gni 12302+++ b/media/media_options.gni 12303@@ -61,7 +61,7 @@ declare_args() { 12304 # Enable usage of OpenH264 within the media library. Used for software based 12305 # encoding of H264 content. 12306 media_use_openh264 = true 12307- if (is_ios || is_android || !proprietary_codecs) { 12308+ if (is_ios || is_android || is_ohos || !proprietary_codecs) { 12309 media_use_openh264 = false 12310 } 12311 12312@@ -102,7 +102,7 @@ declare_args() { 12313 12314 # Enable browser managed persistent metadata storage for EME persistent 12315 # session and persistent usage record session. 12316- enable_media_drm_storage = is_android || is_chromecast 12317+ enable_media_drm_storage = is_android || is_chromecast || is_ohos 12318 } 12319 12320 declare_args() { 12321@@ -126,7 +126,7 @@ declare_args() { 12322 12323 # Alsa should be used on non-Android, non-Mac POSIX systems. 12324 # Alsa should be used on desktop Chromecast and audio-only Chromecast builds. 12325- if (is_posix && !is_android && !is_mac && 12326+ if (is_posix && !is_android && !is_mac && !is_ohos && 12327 (!is_chromecast || is_cast_desktop_build || is_cast_audio_only)) { 12328 use_alsa = true 12329 12330@@ -200,7 +200,7 @@ _default_mojo_media_host = "" 12331 if (is_chromecast) { 12332 _default_mojo_media_services = cast_mojo_media_services 12333 _default_mojo_media_host = cast_mojo_media_host 12334-} else if (is_android) { 12335+} else if (is_android || is_ohos) { 12336 _default_mojo_media_services = [ 12337 "cdm", 12338 "audio_decoder", 12339@@ -255,7 +255,7 @@ declare_args() { 12340 declare_args() { 12341 # Media Remoting RPC is disabled on Android since it's unused but increases 12342 # the native binary size by ~70Kb. 12343- enable_media_remoting_rpc = enable_media_remoting && !is_android 12344+ enable_media_remoting_rpc = enable_media_remoting && !is_android && !is_ohos 12345 } 12346 12347 # TODO(ddorwin): Reorder this file so that all media_subcomponent_deps 12348diff --git a/mojo/public/tools/bindings/mojom.gni b/mojo/public/tools/bindings/mojom.gni 12349index 089e2699ff..17ac481c88 100644 12350--- a/mojo/public/tools/bindings/mojom.gni 12351+++ b/mojo/public/tools/bindings/mojom.gni 12352@@ -643,6 +643,8 @@ template("mojom") { 12353 enabled_features += [ "is_mac" ] 12354 } else if (is_win) { 12355 enabled_features += [ "is_win" ] 12356+ } else if (is_ohos) { 12357+ enabled_features += [ "is_ohos" ] 12358 } 12359 12360 action(parser_target_name) { 12361diff --git a/net/BUILD.gn b/net/BUILD.gn 12362index d3bed2a4ff..edc7e8f38d 100644 12363--- a/net/BUILD.gn 12364+++ b/net/BUILD.gn 12365@@ -1203,6 +1203,13 @@ component("net") { 12366 ] 12367 } 12368 12369+ if (is_ohos) { 12370+ sources += [ 12371+ "cert/cert_verify_proc_ohos.cc", 12372+ "cert/cert_verify_proc_ohos.h", 12373+ ] 12374+ } 12375+ 12376 if (is_chromeos_ash && use_nss_certs) { 12377 sources += [ 12378 "cert/nss_cert_database_chromeos.cc", 12379@@ -1224,7 +1231,7 @@ component("net") { 12380 ] 12381 } 12382 12383- if (is_linux || is_chromeos_lacros) { 12384+ if (is_linux || is_chromeos_lacros || is_ohos) { 12385 sources += [ 12386 "base/network_change_notifier_linux.cc", 12387 "base/network_change_notifier_linux.h", 12388@@ -1233,7 +1240,7 @@ component("net") { 12389 ] 12390 } 12391 12392- if (is_linux || is_chromeos || is_android) { 12393+ if (is_linux || is_chromeos || is_android || is_ohos) { 12394 sources += [ 12395 "base/address_tracker_linux.cc", 12396 "base/address_tracker_linux.h", 12397@@ -1379,7 +1386,7 @@ component("net") { 12398 } 12399 } 12400 12401- if (is_android || is_chromeos_ash) { 12402+ if (is_android || is_chromeos_ash || is_ohos) { 12403 sources += [ 12404 "base/network_change_notifier_posix.cc", 12405 "base/network_change_notifier_posix.h", 12406@@ -1412,13 +1419,19 @@ component("net") { 12407 } 12408 12409 # Use getifaddrs() on POSIX platforms, except Linux. 12410- if (is_posix && !is_linux && !is_chromeos) { 12411+ if (is_posix && !is_linux && !is_chromeos && !is_ohos) { 12412 sources += [ 12413 "base/network_interfaces_getifaddrs.cc", 12414 "base/network_interfaces_getifaddrs.h", 12415 ] 12416 } 12417 12418+ if (is_ohos) { 12419+ sources += [ 12420+ "cert/test_root_certs_builtin.cc", 12421+ ] 12422+ } 12423+ 12424 if (use_nss_certs) { 12425 sources += [ 12426 "cert/internal/system_trust_store_nss.h", 12427@@ -2541,7 +2554,7 @@ if (is_android) { 12428 } 12429 } 12430 12431-if (is_android || is_linux || is_chromeos) { 12432+if (is_android || is_linux || is_chromeos || is_ohos) { 12433 executable("disk_cache_memory_test") { 12434 testonly = true 12435 sources = [ "tools/disk_cache_memory_test/disk_cache_memory_test.cc" ] 12436@@ -4749,7 +4762,7 @@ test("net_unittests") { 12437 } 12438 12439 # Use getifaddrs() on POSIX platforms, except Linux and Android. 12440- if (is_posix && !is_linux && !is_chromeos && !is_android) { 12441+ if (is_posix && !is_linux && !is_chromeos && !is_android && !is_ohos) { 12442 sources += [ "base/network_interfaces_getifaddrs_unittest.cc" ] 12443 } 12444 12445diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc 12446index f98d4a7038..f385822f1d 100644 12447--- a/net/base/network_change_notifier.cc 12448+++ b/net/base/network_change_notifier.cc 12449@@ -34,7 +34,7 @@ 12450 #include "net/base/network_change_notifier_win.h" 12451 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch 12452 // of lacros-chrome is complete. 12453-#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 12454+#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 12455 #include "net/base/network_change_notifier_linux.h" 12456 #elif defined(OS_APPLE) 12457 #include "net/base/network_change_notifier_mac.h" 12458@@ -244,7 +244,7 @@ std::unique_ptr<NetworkChangeNotifier> NetworkChangeNotifier::CreateIfNeeded( 12459 #elif BUILDFLAG(IS_CHROMEOS_ASH) 12460 return std::make_unique<NetworkChangeNotifierPosix>(initial_type, 12461 initial_subtype); 12462-#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) 12463+#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_OHOS) 12464 return std::make_unique<NetworkChangeNotifierLinux>( 12465 std::unordered_set<std::string>()); 12466 #elif defined(OS_APPLE) 12467@@ -435,7 +435,7 @@ const char* NetworkChangeNotifier::ConnectionTypeToString( 12468 return kConnectionTypeNames[type]; 12469 } 12470 12471-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12472+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12473 // static 12474 const internal::AddressTrackerLinux* 12475 NetworkChangeNotifier::GetAddressTracker() { 12476@@ -773,7 +773,7 @@ NetworkChangeNotifier::NetworkChangeNotifier( 12477 can_add_observers_ = true; 12478 } 12479 12480-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12481+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12482 const internal::AddressTrackerLinux* 12483 NetworkChangeNotifier::GetAddressTrackerInternal() const { 12484 return NULL; 12485diff --git a/net/base/network_change_notifier.h b/net/base/network_change_notifier.h 12486index 577c2bc91a..83f3e08287 100644 12487--- a/net/base/network_change_notifier.h 12488+++ b/net/base/network_change_notifier.h 12489@@ -22,7 +22,7 @@ struct NetworkInterface; 12490 class SystemDnsConfigChangeNotifier; 12491 typedef std::vector<NetworkInterface> NetworkInterfaceList; 12492 12493-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12494+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12495 namespace internal { 12496 class AddressTrackerLinux; 12497 } 12498@@ -415,7 +415,7 @@ class NET_EXPORT NetworkChangeNotifier { 12499 // Chrome net code. 12500 static SystemDnsConfigChangeNotifier* GetSystemDnsConfigNotifier(); 12501 12502-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12503+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12504 // Returns the AddressTrackerLinux if present. 12505 static const internal::AddressTrackerLinux* GetAddressTracker(); 12506 #endif 12507@@ -571,7 +571,7 @@ class NET_EXPORT NetworkChangeNotifier { 12508 SystemDnsConfigChangeNotifier* system_dns_config_notifier = nullptr, 12509 bool omit_observers_in_constructor_for_testing = false); 12510 12511-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12512+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12513 // Returns the AddressTrackerLinux if present. 12514 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212 12515 virtual const internal::AddressTrackerLinux* 12516diff --git a/net/base/network_interfaces_getifaddrs.cc b/net/base/network_interfaces_getifaddrs.cc 12517index a848dec3c1..b7d2734f64 100644 12518--- a/net/base/network_interfaces_getifaddrs.cc 12519+++ b/net/base/network_interfaces_getifaddrs.cc 12520@@ -40,6 +40,13 @@ void freeifaddrs(struct ifaddrs* __ptr) __attribute__((weak_import)); 12521 } 12522 #endif // OS_ANDROID 12523 12524+#if defined(OS_OHOS) 12525+extern "C" { 12526+int getifaddrs(struct ifaddrs** __list_ptr) __attribute__((weak_import)); 12527+void freeifaddrs(struct ifaddrs* __ptr) __attribute__((weak_import)); 12528+} 12529+#endif 12530+ 12531 namespace net { 12532 namespace internal { 12533 12534diff --git a/net/cert/cert_verify_proc.cc b/net/cert/cert_verify_proc.cc 12535index 6135c24fe8..e6e463a24a 100644 12536--- a/net/cert/cert_verify_proc.cc 12537+++ b/net/cert/cert_verify_proc.cc 12538@@ -53,6 +53,8 @@ 12539 12540 #if defined(OS_ANDROID) 12541 #include "net/cert/cert_verify_proc_android.h" 12542+#elif defined(OS_OHOS) 12543+#include "net/cert/cert_verify_proc_ohos.h" 12544 #elif defined(OS_IOS) 12545 #include "net/cert/cert_verify_proc_ios.h" 12546 #elif defined(OS_MAC) 12547@@ -499,6 +501,8 @@ scoped_refptr<CertVerifyProc> CertVerifyProc::CreateSystemVerifyProc( 12548 scoped_refptr<CertNetFetcher> cert_net_fetcher) { 12549 #if defined(OS_ANDROID) 12550 return new CertVerifyProcAndroid(std::move(cert_net_fetcher)); 12551+#elif defined(OS_OHOS) 12552+ return new CertVerifyProcOHOS(std::move(cert_net_fetcher)); 12553 #elif defined(OS_IOS) 12554 return new CertVerifyProcIOS(); 12555 #elif defined(OS_MAC) 12556diff --git a/net/cert/cert_verify_proc_ohos.cc b/net/cert/cert_verify_proc_ohos.cc 12557new file mode 100644 12558index 0000000000..08010f9f4d 12559--- /dev/null 12560+++ b/net/cert/cert_verify_proc_ohos.cc 12561@@ -0,0 +1,34 @@ 12562+// Copyright (c) 2022 The Chromium Authors. All rights reserved. 12563+// Use of this source code is governed by a BSD-style license that can be 12564+// found in the LICENSE file. 12565+ 12566+#include "net/cert/cert_verify_proc_ohos.h" 12567+ 12568+#include "net/cert/cert_net_fetcher.h" 12569+ 12570+namespace net { 12571+CertVerifyProcOHOS::CertVerifyProcOHOS( 12572+ scoped_refptr<CertNetFetcher> cert_net_fetcher) 12573+ : cert_net_fetcher_(std::move(cert_net_fetcher)) {} 12574+ 12575+CertVerifyProcOHOS::~CertVerifyProcOHOS() {} 12576+ 12577+bool CertVerifyProcOHOS::SupportsAdditionalTrustAnchors() const { 12578+ return false; 12579+} 12580+ 12581+int CertVerifyProcOHOS::VerifyInternal( 12582+ X509Certificate* cert, 12583+ const std::string& hostname, 12584+ const std::string& ocsp_response, 12585+ const std::string& sct_list, 12586+ int flags, 12587+ CRLSet* crl_set, 12588+ const CertificateList& additional_trust_anchors, 12589+ CertVerifyResult* verify_result, 12590+ const NetLogWithSource& net_log) { 12591+ //TODO: no implement 12592+ return OK; 12593+} 12594+ 12595+} // namespace net 12596\ No newline at end of file 12597diff --git a/net/cert/cert_verify_proc_ohos.h b/net/cert/cert_verify_proc_ohos.h 12598new file mode 100644 12599index 0000000000..05fb1b6dfe 12600--- /dev/null 12601+++ b/net/cert/cert_verify_proc_ohos.h 12602@@ -0,0 +1,43 @@ 12603+// Copyright (c) 2022 The Chromium Authors. All rights reserved. 12604+// Use of this source code is governed by a BSD-style license that can be 12605+// found in the LICENSE file. 12606+ 12607+#ifndef NET_CERT_CERT_VERIFY_PROC_OHOS_H_ 12608+#define NET_CERT_CERT_VERIFY_PROC_OHOS_H_ 12609+ 12610+#include "base/macros.h" 12611+#include "net/base/net_export.h" 12612+#include "net/cert/cert_verify_proc.h" 12613+ 12614+namespace net { 12615+ 12616+class CertNetFetcher; 12617+ 12618+class NET_EXPORT CertVerifyProcOHOS : public CertVerifyProc { 12619+ public: 12620+ explicit CertVerifyProcOHOS(scoped_refptr<CertNetFetcher> net_fetcher); 12621+ 12622+ bool SupportsAdditionalTrustAnchors() const override; 12623+ 12624+ protected: 12625+ ~CertVerifyProcOHOS() override; 12626+ 12627+ private: 12628+ int VerifyInternal(X509Certificate* cert, 12629+ const std::string& hostname, 12630+ const std::string& ocsp_response, 12631+ const std::string& sct_list, 12632+ int flags, 12633+ CRLSet* crl_set, 12634+ const CertificateList& additional_trust_anchors, 12635+ CertVerifyResult* verify_result, 12636+ const NetLogWithSource& net_log) override; 12637+ 12638+ scoped_refptr<CertNetFetcher> cert_net_fetcher_; 12639+ 12640+ DISALLOW_COPY_AND_ASSIGN(CertVerifyProcOHOS); 12641+}; 12642+ 12643+} // namespace net 12644+ 12645+#endif // NET_CERT_CERT_VERIFY_PROC_OHOS_H_ 12646\ No newline at end of file 12647diff --git a/net/cert/test_root_certs.h b/net/cert/test_root_certs.h 12648index 836f29f242..27b3125ae5 100644 12649--- a/net/cert/test_root_certs.h 12650+++ b/net/cert/test_root_certs.h 12651@@ -75,7 +75,7 @@ class NET_EXPORT TestRootCerts { 12652 // engine is appropriate. The caller is responsible for freeing the 12653 // returned HCERTCHAINENGINE. 12654 HCERTCHAINENGINE GetChainEngine() const; 12655-#elif defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_CHROMEOS) 12656+#elif defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12657 TrustStore* test_trust_store() { return &test_trust_store_; } 12658 #endif 12659 12660@@ -93,12 +93,12 @@ class NET_EXPORT TestRootCerts { 12661 #elif defined(OS_APPLE) 12662 base::ScopedCFTypeRef<CFMutableArrayRef> temporary_roots_; 12663 TrustStoreInMemory test_trust_store_; 12664-#elif defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_CHROMEOS) 12665+#elif defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12666 TrustStoreInMemory test_trust_store_; 12667 #endif 12668 12669 #if defined(OS_WIN) || defined(OS_ANDROID) || defined(OS_FUCHSIA) || \ 12670- defined(OS_LINUX) || defined(OS_CHROMEOS) 12671+ defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12672 // True if there are no temporarily trusted root certificates. 12673 bool empty_ = true; 12674 #endif 12675diff --git a/net/der/parser.h b/net/der/parser.h 12676index 410a5aeb3d..53b7a8d786 100644 12677--- a/net/der/parser.h 12678+++ b/net/der/parser.h 12679@@ -207,7 +207,7 @@ class NET_EXPORT Parser { 12680 CBS cbs_; 12681 size_t advance_len_; 12682 12683- DISALLOW_COPY(Parser); 12684+ DISALLOW_COPY_BASE(Parser); 12685 }; 12686 12687 } // namespace der 12688diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn 12689index 482b2b93d7..d779de9edd 100644 12690--- a/net/dns/BUILD.gn 12691+++ b/net/dns/BUILD.gn 12692@@ -423,7 +423,7 @@ source_set("tests") { 12693 sources += [ "dns_config_service_win_unittest.cc" ] 12694 } 12695 12696- if (is_android) { 12697+ if (is_android || is_ohos) { 12698 sources += [ "dns_config_service_android_unittest.cc" ] 12699 } else if (is_posix) { 12700 sources += [ "dns_config_service_posix_unittest.cc" ] 12701diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc 12702index dddd4a98a9..4b14ee7ac8 100644 12703--- a/net/dns/dns_config_service_posix.cc 12704+++ b/net/dns/dns_config_service_posix.cc 12705@@ -99,7 +99,7 @@ base::Optional<DnsConfig> ReadDnsConfig() { 12706 memset(&_res, 0, sizeof(_res)); 12707 if (res_init() == 0) 12708 dns_config = ConvertResStateToDnsConfig(_res); 12709-#else // all other OS_POSIX 12710+#elif !defined(OS_OHOS) // all other OS_POSIX 12711 struct __res_state res; 12712 memset(&res, 0, sizeof(res)); 12713 if (res_ninit(&res) == 0) 12714@@ -241,6 +241,7 @@ void DnsConfigServicePosix::CreateReader() { 12715 config_reader_ = base::MakeRefCounted<ConfigReader>(*this); 12716 } 12717 12718+#if !defined(OS_OHOS) 12719 base::Optional<DnsConfig> ConvertResStateToDnsConfig( 12720 const struct __res_state& res) { 12721 DnsConfig dns_config; 12722@@ -344,6 +345,7 @@ base::Optional<DnsConfig> ConvertResStateToDnsConfig( 12723 } 12724 return dns_config; 12725 } 12726+#endif 12727 12728 } // namespace internal 12729 12730diff --git a/net/dns/dns_reloader.cc b/net/dns/dns_reloader.cc 12731index 0672e711af..01cb9aae7c 100644 12732--- a/net/dns/dns_reloader.cc 12733+++ b/net/dns/dns_reloader.cc 12734@@ -5,7 +5,7 @@ 12735 #include "net/dns/dns_reloader.h" 12736 12737 #if defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_OPENBSD) && \ 12738- !defined(OS_ANDROID) && !defined(OS_FUCHSIA) 12739+ !defined(OS_ANDROID) && !defined(OS_FUCHSIA) && !defined(OS_OHOS) 12740 12741 #include <resolv.h> 12742 12743diff --git a/net/dns/host_resolver_manager.cc b/net/dns/host_resolver_manager.cc 12744index 6450e1e96e..b56a9312bd 100644 12745--- a/net/dns/host_resolver_manager.cc 12746+++ b/net/dns/host_resolver_manager.cc 12747@@ -12,7 +12,7 @@ 12748 #include <netinet/in.h> 12749 #if !defined(OS_NACL) 12750 #include <net/if.h> 12751-#if !defined(OS_ANDROID) 12752+#if !defined(OS_ANDROID) && !defined(OS_OHOS) 12753 #include <ifaddrs.h> 12754 #endif // !defined(OS_ANDROID) 12755 #endif // !defined(OS_NACL) 12756@@ -243,7 +243,7 @@ bool HaveOnlyLoopbackAddresses() { 12757 #elif defined(OS_NACL) 12758 NOTIMPLEMENTED(); 12759 return false; 12760-#elif defined(OS_POSIX) || defined(OS_FUCHSIA) 12761+#elif (defined(OS_POSIX) && !defined(OS_OHOS)) || defined(OS_FUCHSIA) 12762 struct ifaddrs* interface_addr = NULL; 12763 int rv = getifaddrs(&interface_addr); 12764 if (rv != 0) { 12765@@ -277,6 +277,8 @@ bool HaveOnlyLoopbackAddresses() { 12766 } 12767 freeifaddrs(interface_addr); 12768 return result; 12769+#else 12770+ return false; 12771 #endif // defined(various platforms) 12772 } 12773 12774@@ -2524,7 +2526,7 @@ HostResolverManager::HostResolverManager( 12775 #if defined(OS_WIN) 12776 EnsureWinsockInit(); 12777 #endif 12778-#if (defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_ANDROID)) || \ 12779+#if (defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_ANDROID) && !defined(OS_OHOS)) || \ 12780 defined(OS_FUCHSIA) 12781 RunLoopbackProbeJob(); 12782 #endif 12783@@ -2533,7 +2535,7 @@ HostResolverManager::HostResolverManager( 12784 if (system_dns_config_notifier_) 12785 system_dns_config_notifier_->AddObserver(this); 12786 #if defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_OPENBSD) && \ 12787- !defined(OS_ANDROID) 12788+ !defined(OS_ANDROID) && !defined(OS_OHOS) 12789 EnsureDnsReloaderInit(); 12790 #endif 12791 12792@@ -3472,7 +3474,7 @@ void HostResolverManager::OnIPAddressChanged() { 12793 // Abandon all ProbeJobs. 12794 probe_weak_ptr_factory_.InvalidateWeakPtrs(); 12795 InvalidateCaches(); 12796-#if (defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_ANDROID)) || \ 12797+#if (defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_ANDROID) && !defined(OS_OHOS)) || \ 12798 defined(OS_FUCHSIA) 12799 RunLoopbackProbeJob(); 12800 #endif 12801diff --git a/net/dns/host_resolver_proc.cc b/net/dns/host_resolver_proc.cc 12802index 3da9fb4325..cf681caf54 100644 12803--- a/net/dns/host_resolver_proc.cc 12804+++ b/net/dns/host_resolver_proc.cc 12805@@ -177,7 +177,7 @@ int SystemHostResolverCall(const std::string& host, 12806 base::BlockingType::WILL_BLOCK); 12807 12808 #if defined(OS_POSIX) && !defined(OS_APPLE) && !defined(OS_OPENBSD) && \ 12809- !defined(OS_ANDROID) && !defined(OS_FUCHSIA) 12810+ !defined(OS_ANDROID) && !defined(OS_FUCHSIA) && !defined(OS_OHOS) 12811 DnsReloaderMaybeReload(); 12812 #endif 12813 base::Optional<AddressInfo> ai; 12814diff --git a/net/reporting/reporting_test_util.h b/net/reporting/reporting_test_util.h 12815index 629e765105..86554e4021 100644 12816--- a/net/reporting/reporting_test_util.h 12817+++ b/net/reporting/reporting_test_util.h 12818@@ -302,7 +302,7 @@ class TestReportingService : public ReportingService { 12819 int depth; 12820 12821 private: 12822- DISALLOW_COPY(Report); 12823+ DISALLOW_COPY_BASE(Report); 12824 }; 12825 12826 TestReportingService(); 12827diff --git a/net/socket/unix_domain_server_socket_posix.cc b/net/socket/unix_domain_server_socket_posix.cc 12828index 8b2e29b8d2..eb243b718b 100644 12829--- a/net/socket/unix_domain_server_socket_posix.cc 12830+++ b/net/socket/unix_domain_server_socket_posix.cc 12831@@ -34,7 +34,7 @@ UnixDomainServerSocket::~UnixDomainServerSocket() = default; 12832 bool UnixDomainServerSocket::GetPeerCredentials(SocketDescriptor socket, 12833 Credentials* credentials) { 12834 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 12835- defined(OS_FUCHSIA) 12836+ defined(OS_FUCHSIA) || defined(OS_OHOS) 12837 struct ucred user_cred; 12838 socklen_t len = sizeof(user_cred); 12839 if (getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &user_cred, &len) < 0) 12840diff --git a/net/socket/unix_domain_server_socket_posix.h b/net/socket/unix_domain_server_socket_posix.h 12841index 9da6bc0d5d..169a68cf2c 100644 12842--- a/net/socket/unix_domain_server_socket_posix.h 12843+++ b/net/socket/unix_domain_server_socket_posix.h 12844@@ -30,7 +30,7 @@ class NET_EXPORT UnixDomainServerSocket : public ServerSocket { 12845 // Credentials of a peer process connected to the socket. 12846 struct NET_EXPORT Credentials { 12847 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 12848- defined(OS_FUCHSIA) 12849+ defined(OS_FUCHSIA) || defined(OS_OHOS) 12850 // Linux and Fuchsia provide more information about the connected peer 12851 // than Windows/OS X. It's useful for permission-based authorization on 12852 // Android. 12853diff --git a/printing/BUILD.gn b/printing/BUILD.gn 12854index 90bfb18012..9f50881dbc 100644 12855--- a/printing/BUILD.gn 12856+++ b/printing/BUILD.gn 12857@@ -153,7 +153,7 @@ component("printing") { 12858 ] 12859 } 12860 12861- if (is_linux || is_chromeos_lacros) { 12862+ if (is_linux || is_chromeos_lacros || is_ohos) { 12863 sources += [ 12864 "printed_document_linux.cc", 12865 "printing_context_linux.cc", 12866diff --git a/printing/printing_features.cc b/printing/printing_features.cc 12867index 237a9d9f7f..1293efdb8f 100644 12868--- a/printing/printing_features.cc 12869+++ b/printing/printing_features.cc 12870@@ -44,7 +44,7 @@ bool ShouldPrintUsingXps(bool source_is_pdf) { 12871 #endif // defined(OS_WIN) 12872 12873 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 12874- defined(OS_CHROMEOS) 12875+ defined(OS_CHROMEOS) || defined(OS_OHOS) 12876 // Enables printing interactions with the operating system to be performed 12877 // out-of-process. 12878 const base::Feature kEnableOopPrintDrivers{"EnableOopPrintDrivers", 12879diff --git a/printing/printing_features.h b/printing/printing_features.h 12880index 72b155a3e7..6f20497a5c 100644 12881--- a/printing/printing_features.h 12882+++ b/printing/printing_features.h 12883@@ -35,7 +35,7 @@ PRINTING_EXPORT bool ShouldPrintUsingXps(bool source_is_pdf); 12884 #endif // defined(OS_WIN) 12885 12886 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ 12887- defined(OS_CHROMEOS) 12888+ defined(OS_CHROMEOS) || defined(OS_OHOS) 12889 PRINTING_EXPORT extern const base::Feature kEnableOopPrintDrivers; 12890 #endif // defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || 12891 // defined(OS_CHROMEOS) 12892diff --git a/sandbox/BUILD.gn b/sandbox/BUILD.gn 12893index 5bfd4d5aef..ee79c215b2 100644 12894--- a/sandbox/BUILD.gn 12895+++ b/sandbox/BUILD.gn 12896@@ -27,7 +27,7 @@ group("sandbox") { 12897 "//sandbox/mac:system_services", 12898 "//sandbox/mac/mojom", 12899 ] 12900- } else if (is_linux || is_chromeos || is_android) { 12901+ } else if (is_linux || is_chromeos || is_android || is_ohos) { 12902 public_deps = [ "//sandbox/linux:sandbox" ] 12903 } 12904 } 12905diff --git a/sandbox/features.gni b/sandbox/features.gni 12906index db30ae6d63..094a2f22d9 100644 12907--- a/sandbox/features.gni 12908+++ b/sandbox/features.gni 12909@@ -8,7 +8,7 @@ import("//build/config/nacl/config.gni") 12910 # currently. 12911 # Do not disable seccomp_bpf anywhere without talking to 12912 # security@chromium.org! 12913-use_seccomp_bpf = (is_linux || is_chromeos || is_android) && 12914+use_seccomp_bpf = (is_linux || is_chromeos || is_android || is_ohos) && 12915 (current_cpu == "x86" || current_cpu == "x64" || 12916 current_cpu == "arm" || current_cpu == "arm64" || 12917 current_cpu == "mipsel" || current_cpu == "mips64el") 12918@@ -18,4 +18,4 @@ use_seccomp_bpf = use_seccomp_bpf || is_nacl_nonsfi 12919 # SSBD (Speculative Store Bypass Disable) is a mitigation of Spectre Variant 4. 12920 # As Spectre Variant 4 can be mitigated by site isolation, opt-out SSBD on site 12921 # isolation fully applied platform. 12922-disable_seccomp_ssbd = use_seccomp_bpf && !is_android 12923+disable_seccomp_ssbd = use_seccomp_bpf && !is_android && !is_ohos 12924diff --git a/sandbox/linux/BUILD.gn b/sandbox/linux/BUILD.gn 12925index 2f778dd0bc..da1e2f70e1 100644 12926--- a/sandbox/linux/BUILD.gn 12927+++ b/sandbox/linux/BUILD.gn 12928@@ -12,9 +12,9 @@ if (is_android) { 12929 } 12930 12931 declare_args() { 12932- compile_suid_client = is_linux || is_chromeos 12933+ compile_suid_client = is_linux || is_chromeos || is_ohos 12934 12935- compile_credentials = is_linux || is_chromeos 12936+ compile_credentials = is_linux || is_chromeos || is_ohos 12937 12938 # On Android, use plain GTest. 12939 use_base_test_suite = is_linux || is_chromeos 12940diff --git a/sandbox/linux/services/credentials.h b/sandbox/linux/services/credentials.h 12941index 0cf99973c1..1d6514a109 100644 12942--- a/sandbox/linux/services/credentials.h 12943+++ b/sandbox/linux/services/credentials.h 12944@@ -13,6 +13,10 @@ 12945 12946 #include <string> 12947 #include <vector> 12948+#if defined(__MUSL__) 12949+#include <sys/types.h> 12950+#include <unistd.h> 12951+#endif 12952 12953 #include "base/compiler_specific.h" 12954 #include "base/macros.h" 12955diff --git a/sandbox/policy/BUILD.gn b/sandbox/policy/BUILD.gn 12956index cd8f38e845..00a2c7aff8 100644 12957--- a/sandbox/policy/BUILD.gn 12958+++ b/sandbox/policy/BUILD.gn 12959@@ -29,7 +29,7 @@ component("policy") { 12960 "//sandbox:common", 12961 ] 12962 public_deps = [] 12963- if (is_linux || is_chromeos) { 12964+ if (is_linux || is_chromeos || is_ohos) { 12965 sources += [ 12966 "linux/bpf_audio_policy_linux.cc", 12967 "linux/bpf_audio_policy_linux.h", 12968diff --git a/sandbox/policy/sandbox.cc b/sandbox/policy/sandbox.cc 12969index 95482e83b8..d4fedf8a5c 100644 12970--- a/sandbox/policy/sandbox.cc 12971+++ b/sandbox/policy/sandbox.cc 12972@@ -12,7 +12,7 @@ 12973 #include "base/android/jni_android.h" 12974 #endif // defined(OS_ANDROID) 12975 12976-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12977+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12978 #include "sandbox/policy/linux/sandbox_linux.h" 12979 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) 12980 12981@@ -30,7 +30,7 @@ 12982 namespace sandbox { 12983 namespace policy { 12984 12985-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 12986+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12987 bool Sandbox::Initialize(SandboxType sandbox_type, 12988 SandboxLinux::PreSandboxHook hook, 12989 const SandboxLinux::Options& options) { 12990@@ -109,7 +109,7 @@ bool Sandbox::IsProcessSandboxed() { 12991 // launching controls the sandbox and there are no ambient capabilities, so 12992 // basically everything but the browser is considered sandboxed. 12993 return !is_browser; 12994-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) 12995+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 12996 int status = SandboxLinux::GetInstance()->GetStatus(); 12997 constexpr int kLayer1Flags = SandboxLinux::Status::kSUID | 12998 SandboxLinux::Status::kPIDNS | 12999diff --git a/sandbox/policy/sandbox.h b/sandbox/policy/sandbox.h 13000index c842e1d19c..965e6ba90d 100644 13001--- a/sandbox/policy/sandbox.h 13002+++ b/sandbox/policy/sandbox.h 13003@@ -9,7 +9,7 @@ 13004 #include "sandbox/policy/export.h" 13005 #include "sandbox/policy/sandbox_type.h" 13006 13007-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13008+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13009 #include "sandbox/policy/linux/sandbox_linux.h" 13010 #endif 13011 13012@@ -34,7 +34,7 @@ namespace policy { 13013 13014 class SANDBOX_POLICY_EXPORT Sandbox { 13015 public: 13016-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13017+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13018 static bool Initialize(SandboxType sandbox_type, 13019 SandboxLinux::PreSandboxHook hook, 13020 const SandboxLinux::Options& options); 13021diff --git a/sandbox/policy/sandbox_type.cc b/sandbox/policy/sandbox_type.cc 13022index 8d6c520b7b..71ae35b40a 100644 13023--- a/sandbox/policy/sandbox_type.cc 13024+++ b/sandbox/policy/sandbox_type.cc 13025@@ -62,7 +62,7 @@ bool IsUnsandboxedSandboxType(SandboxType sandbox_type) { 13026 #if !defined(OS_MAC) 13027 case SandboxType::kSharingService: 13028 #endif 13029-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13030+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13031 case SandboxType::kZygoteIntermediateSandbox: 13032 #endif 13033 case SandboxType::kSpeechRecognition: 13034@@ -144,7 +144,7 @@ void SetCommandLineFlagsForSandboxType(base::CommandLine* command_line, 13035 case SandboxType::kNaClLoader: 13036 break; 13037 #endif // defined(OS_MAC) 13038-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13039+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13040 case SandboxType::kZygoteIntermediateSandbox: 13041 break; 13042 #endif 13043@@ -193,7 +193,7 @@ SandboxType SandboxTypeFromCommandLine(const base::CommandLine& command_line) { 13044 if (process_type == switches::kNaClBrokerProcess) 13045 return SandboxType::kNoSandbox; 13046 13047-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13048+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13049 // Intermediate process gains a sandbox later. 13050 if (process_type == switches::kZygoteProcessType) 13051 return SandboxType::kZygoteIntermediateSandbox; 13052@@ -265,7 +265,7 @@ std::string StringFromUtilitySandboxType(SandboxType sandbox_type) { 13053 #if defined(OS_FUCHSIA) 13054 case SandboxType::kWebContext: 13055 #endif // defined(OS_FUCHSIA) 13056-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13057+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13058 case SandboxType::kZygoteIntermediateSandbox: 13059 #endif 13060 NOTREACHED(); 13061diff --git a/sandbox/policy/sandbox_type.h b/sandbox/policy/sandbox_type.h 13062index 38dc1718ab..4ad78c5697 100644 13063--- a/sandbox/policy/sandbox_type.h 13064+++ b/sandbox/policy/sandbox_type.h 13065@@ -85,7 +85,7 @@ enum class SandboxType { 13066 kTts, 13067 #endif // BUILDFLAG(IS_CHROMEOS_ASH) 13068 13069-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13070+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13071 // Indicates that a process is a zygote and will get a real sandbox later. 13072 kZygoteIntermediateSandbox, 13073 #endif 13074diff --git a/sandbox/policy/switches.cc b/sandbox/policy/switches.cc 13075index 7e33328df4..edbf3fdfbf 100644 13076--- a/sandbox/policy/switches.cc 13077+++ b/sandbox/policy/switches.cc 13078@@ -83,7 +83,7 @@ const char kGpuSandboxFailuresFatal[] = "gpu-sandbox-failures-fatal"; 13079 // Meant to be used as a browser-level switch for testing purposes only. 13080 const char kNoSandbox[] = "no-sandbox"; 13081 13082-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13083+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13084 // Instructs the zygote to launch without a sandbox. Processes forked from this 13085 // type of zygote will apply their own custom sandboxes later. 13086 const char kNoZygoteSandbox[] = "no-zygote-sandbox"; 13087diff --git a/sandbox/policy/switches.h b/sandbox/policy/switches.h 13088index a2c9e9dd08..6bcf5ba897 100644 13089--- a/sandbox/policy/switches.h 13090+++ b/sandbox/policy/switches.h 13091@@ -55,7 +55,7 @@ SANDBOX_POLICY_EXPORT extern const char kDisableSetuidSandbox[]; 13092 SANDBOX_POLICY_EXPORT extern const char kGpuSandboxAllowSysVShm[]; 13093 SANDBOX_POLICY_EXPORT extern const char kGpuSandboxFailuresFatal[]; 13094 SANDBOX_POLICY_EXPORT extern const char kNoSandbox[]; 13095-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13096+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13097 SANDBOX_POLICY_EXPORT extern const char kNoZygoteSandbox[]; 13098 #endif 13099 #if defined(OS_WIN) 13100diff --git a/services/device/geolocation/location_arbitrator.cc b/services/device/geolocation/location_arbitrator.cc 13101index df0c7df2dc..527cff5fbb 100644 13102--- a/services/device/geolocation/location_arbitrator.cc 13103+++ b/services/device/geolocation/location_arbitrator.cc 13104@@ -162,7 +162,7 @@ LocationArbitrator::NewNetworkLocationProvider( 13105 13106 std::unique_ptr<LocationProvider> 13107 LocationArbitrator::NewSystemLocationProvider() { 13108-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) 13109+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_OHOS) 13110 return nullptr; 13111 #else 13112 return device::NewSystemLocationProvider(); 13113diff --git a/services/device/time_zone_monitor/BUILD.gn b/services/device/time_zone_monitor/BUILD.gn 13114index 00d3464033..2c8c208968 100644 13115--- a/services/device/time_zone_monitor/BUILD.gn 13116+++ b/services/device/time_zone_monitor/BUILD.gn 13117@@ -40,7 +40,7 @@ source_set("time_zone_monitor") { 13118 deps += [ "//ui/gfx" ] 13119 } 13120 13121- if (is_linux || is_chromeos_lacros) { 13122+ if (is_linux || is_chromeos_lacros || is_ohos) { 13123 sources += [ "time_zone_monitor_linux.cc" ] 13124 } 13125 13126diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/BUILD.gn b/services/resource_coordinator/public/cpp/memory_instrumentation/BUILD.gn 13127index 908dfec2d4..41e8f72ab6 100644 13128--- a/services/resource_coordinator/public/cpp/memory_instrumentation/BUILD.gn 13129+++ b/services/resource_coordinator/public/cpp/memory_instrumentation/BUILD.gn 13130@@ -29,7 +29,7 @@ component("memory_instrumentation") { 13131 sources += [ "os_metrics_win.cc" ] 13132 } 13133 13134- if (is_android || is_linux || is_chromeos) { 13135+ if (is_android || is_linux || is_chromeos || is_ohos) { 13136 sources += [ "os_metrics_linux.cc" ] 13137 } 13138 13139diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h 13140index 1fdd28fbef..84980130e0 100644 13141--- a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h 13142+++ b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h 13143@@ -45,7 +45,7 @@ class COMPONENT_EXPORT( 13144 mojom::RawOSMemDump*); 13145 static std::vector<mojom::VmRegionPtr> GetProcessMemoryMaps(base::ProcessId); 13146 13147-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13148+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 13149 static void SetProcSmapsForTesting(FILE*); 13150 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13151 13152@@ -61,7 +61,7 @@ class COMPONENT_EXPORT( 13153 static std::vector<mojom::VmRegionPtr> GetProcessModules(base::ProcessId); 13154 #endif 13155 13156-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13157+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 13158 // Provides information on the dump state of resident pages. These values are 13159 // written to logs. New enum values can be added, but existing enums must 13160 // never be renumbered or deleted and reused. 13161diff --git a/skia/BUILD.gn b/skia/BUILD.gn 13162index 28066d335a..cab3a89378 100644 13163--- a/skia/BUILD.gn 13164+++ b/skia/BUILD.gn 13165@@ -115,6 +115,13 @@ config("skia_config") { 13166 ] 13167 } 13168 13169+ # TODO: ohos use skia to be adapted 13170+ if (is_ohos) { 13171+ defines += [ 13172+ "USE_CHROMIUM_SKIA", 13173+ ] 13174+ } 13175+ 13176 if (is_mac) { 13177 defines += [ 13178 "SK_BUILD_FOR_MAC", 13179@@ -151,7 +158,7 @@ config("skia_library_config") { 13180 "SK_GAMMA_EXPONENT=1.2", 13181 "SK_GAMMA_CONTRAST=0.2", 13182 ] 13183- } else if (is_android) { 13184+ } else if (is_android || is_ohos) { 13185 defines += [ 13186 "SK_GAMMA_APPLY_TO_A8", 13187 "SK_GAMMA_EXPONENT=1.4", 13188@@ -169,7 +176,7 @@ config("skia_library_config") { 13189 ] 13190 } 13191 13192- if (is_android) { 13193+ if (is_android || is_ohos) { 13194 defines += [ 13195 # Android devices are typically more memory constrained, so default to a 13196 # smaller glyph cache (it may be overriden at runtime when the renderer 13197@@ -274,6 +281,9 @@ component("skia") { 13198 if (is_android) { 13199 sources += [ "ext/fontmgr_default_android.cc" ] 13200 } 13201+ if (is_ohos) { 13202+ sources += [ "ext/fontmgr_default_ohos.cc" ] 13203+ } 13204 if (is_linux || is_chromeos) { 13205 sources += [ "ext/fontmgr_default_linux.cc" ] 13206 } 13207@@ -486,6 +496,19 @@ component("skia") { 13208 ] 13209 } 13210 13211+ if (is_ohos) { 13212+ sources += [ 13213+ "//third_party/skia/src/ports/skia_ohos/FontConfig_ohos.cpp", 13214+ "//third_party/skia/src/ports/skia_ohos/SkFontMgr_ohos.cpp", 13215+ "//third_party/skia/src/ports/skia_ohos/SkFontStyleSet_ohos.cpp", 13216+ "//third_party/skia/src/ports/skia_ohos/SkTypeface_ohos.cpp", 13217+ ] 13218+ include_dirs = [ 13219+ "//third_party/skia/src/ports/skia_ohos", 13220+ "//third_party/jsoncpp/source/include", 13221+ ] 13222+ } 13223+ 13224 if (is_win || is_mac) { 13225 sources += [ 13226 # Add the FreeType custom font manager as a fallback backend for variable fonts. 13227diff --git a/skia/config/SkUserConfig.h b/skia/config/SkUserConfig.h 13228index 83a41864e4..d9417a16f7 100644 13229--- a/skia/config/SkUserConfig.h 13230+++ b/skia/config/SkUserConfig.h 13231@@ -161,10 +161,17 @@ SK_API void SkDebugf_FileLine(const char* file, 13232 ...); 13233 13234 #if !defined(ANDROID) // On Android, we use the skia default settings. 13235+#if defined(SK_CPU_LENDIAN) // on OHOS, B and R will exchange. 13236 #define SK_A32_SHIFT 24 13237-#define SK_R32_SHIFT 16 13238+#define SK_B32_SHIFT 16 13239 #define SK_G32_SHIFT 8 13240-#define SK_B32_SHIFT 0 13241+#define SK_R32_SHIFT 0 13242+#else 13243+#define SK_A32_SHIFT 24 13244+#define SK_R32_SHIFT 16 13245+#define SK_G32_SHIFT 8 13246+#define SK_B32_SHIFT 0 13247+#endif 13248 #endif 13249 13250 #if defined(SK_BUILD_FOR_MAC) 13251diff --git a/skia/ext/fontmgr_default_ohos.cc b/skia/ext/fontmgr_default_ohos.cc 13252new file mode 100644 13253index 0000000000..6558bbebea 13254--- /dev/null 13255+++ b/skia/ext/fontmgr_default_ohos.cc 13256@@ -0,0 +1,16 @@ 13257+// Copyright 2022 The Chromium Authors. All rights reserved. 13258+// Use of this source code is governed by a BSD-style license that can be 13259+// found in the LICENSE file. 13260+ 13261+#include "skia/ext/fontmgr_default.h" 13262+ 13263+#include "third_party/skia/include/core/SkFontMgr.h" 13264+#include "SkFontMgr_ohos.h" 13265+ 13266+namespace skia { 13267+ 13268+SK_API sk_sp<SkFontMgr> CreateDefaultSkFontMgr() { 13269+ return SkFontMgr_New_OHOS(nullptr); 13270+} 13271+ 13272+} // namespace skia 13273\ No newline at end of file 13274diff --git a/third_party/angle/BUILD.gn b/third_party/angle/BUILD.gn 13275index 238ad677eb..0aab18aea2 100644 13276--- a/third_party/angle/BUILD.gn 13277+++ b/third_party/angle/BUILD.gn 13278@@ -448,7 +448,7 @@ angle_static_library("angle_gpu_info_util") { 13279 libs += [ "dxgi.lib" ] 13280 } 13281 13282- if (is_linux || is_chromeos) { 13283+ if (is_linux || is_chromeos || is_ohos) { 13284 sources += libangle_gpu_info_util_linux_sources 13285 13286 if (angle_use_x11 && angle_has_build) { 13287diff --git a/third_party/angle/gni/angle.gni b/third_party/angle/gni/angle.gni 13288index aab30d53a9..42ee6145d1 100644 13289--- a/third_party/angle/gni/angle.gni 13290+++ b/third_party/angle/gni/angle.gni 13291@@ -21,7 +21,7 @@ if (angle_has_build) { 13292 import("//build/config/ui.gni") # import the use_x11 variable 13293 import("//build_overrides/build.gni") 13294 import("//testing/test.gni") 13295- if (is_android) { 13296+ if (is_android || is_ohos) { 13297 import("//build/config/android/config.gni") 13298 } 13299 13300@@ -85,7 +85,7 @@ declare_args() { 13301 angle_is_winuwp = is_win && target_os == "winuwp" 13302 13303 # Default to using "_angle" suffix on Android 13304- if (is_android) { 13305+ if (is_android || is_ohos) { 13306 angle_libs_suffix = "_angle" 13307 } else { 13308 angle_libs_suffix = "" 13309@@ -115,11 +115,11 @@ declare_args() { 13310 angle_has_build && 13311 ((is_win && !angle_is_winuwp) || 13312 (is_linux && (angle_use_x11 || angle_use_vulkan_display) && 13313- !is_chromeos) || is_android || is_fuchsia || is_ggp || is_mac) 13314+ !is_chromeos) || is_android || is_fuchsia || is_ggp || is_mac || is_ohos) 13315 13316 # Disable null backend to save space for official build. 13317 angle_enable_null = !is_official_build 13318- angle_enable_gl_desktop = !is_android && !is_ios 13319+ angle_enable_gl_desktop = !is_android && !is_ios && !is_ohos 13320 13321 # http://anglebug.com/2634 13322 angle_enable_metal = is_mac 13323@@ -130,7 +130,7 @@ declare_args() { 13324 # SwiftShader is not needed on Fuchsia because Vulkan is supported on all 13325 # devices that run Fuchsia. 13326 angle_enable_swiftshader = 13327- angle_enable_vulkan && !is_android && !is_fuchsia && !is_ggp 13328+ angle_enable_vulkan && !is_android && !is_fuchsia && !is_ggp && !is_ohos 13329 13330 angle_enable_hlsl = angle_enable_d3d9 || angle_enable_d3d11 13331 angle_enable_essl = angle_enable_gl || use_ozone 13332@@ -145,7 +145,7 @@ declare_args() { 13333 angle_enable_vulkan_validation_layers = 13334 angle_enable_vulkan && !is_ubsan && !is_tsan && !is_asan && 13335 (is_debug || dcheck_always_on) && !is_mac && 13336- (!is_android || ndk_api_level_at_least_26) 13337+ ((!is_android && !is_ohos) || ndk_api_level_at_least_26) 13338 13339 # Disable overlay by default 13340 angle_enable_overlay = false 13341diff --git a/third_party/angle/src/common/vulkan/BUILD.gn b/third_party/angle/src/common/vulkan/BUILD.gn 13342index e7cd440265..8cfa9531f1 100644 13343--- a/third_party/angle/src/common/vulkan/BUILD.gn 13344+++ b/third_party/angle/src/common/vulkan/BUILD.gn 13345@@ -35,7 +35,7 @@ group("angle_vulkan_entry_points") { 13346 "//third_party/fuchsia-sdk:vulkan_base", 13347 "//third_party/fuchsia-sdk/sdk/pkg/vulkan", 13348 ] 13349- } else if (!is_android && !is_ggp) { 13350+ } else if (!is_android && !is_ggp && !is_ohos) { 13351 if (angle_shared_libvulkan) { 13352 data_deps = [ "$angle_vulkan_loader_dir:libvulkan" ] 13353 } else { 13354@@ -65,7 +65,7 @@ angle_source_set("vulkan") { 13355 deps = [] 13356 data_deps = [] 13357 13358- if (!is_android && !is_fuchsia && !is_ggp) { 13359+ if (!is_android && !is_fuchsia && !is_ggp && !is_ohos) { 13360 if (angle_shared_libvulkan) { 13361 data_deps += [ "$angle_vulkan_loader_dir:libvulkan" ] 13362 } else { 13363@@ -98,7 +98,7 @@ if (angle_enable_vulkan_validation_layers) { 13364 } else { 13365 data_deps += 13366 [ "$angle_vulkan_validation_layers_dir:vulkan_validation_layers" ] 13367- if (!is_android) { 13368+ if (!is_android && !is_ohos) { 13369 data_deps += 13370 [ "$angle_vulkan_validation_layers_dir:vulkan_gen_json_files" ] 13371 } 13372diff --git a/third_party/angle/src/libGLESv2.gni b/third_party/angle/src/libGLESv2.gni 13373index 0350c28ac4..fae0228f77 100644 13374--- a/third_party/angle/src/libGLESv2.gni 13375+++ b/third_party/angle/src/libGLESv2.gni 13376@@ -70,7 +70,7 @@ xxhash_sources = [ 13377 "src/common/third_party/xxhash/xxhash.h", 13378 ] 13379 13380-if (is_linux || is_chromeos || is_android || is_fuchsia) { 13381+if (is_linux || is_chromeos || is_android || is_fuchsia || is_ohos) { 13382 libangle_common_sources += [ 13383 "src/common/system_utils_linux.cpp", 13384 "src/common/system_utils_posix.cpp", 13385diff --git a/third_party/angle/src/tests/BUILD.gn b/third_party/angle/src/tests/BUILD.gn 13386index e571ab0beb..077ad37f73 100644 13387--- a/third_party/angle/src/tests/BUILD.gn 13388+++ b/third_party/angle/src/tests/BUILD.gn 13389@@ -13,7 +13,7 @@ declare_args() { 13390 build_angle_gles1_conform_tests = false 13391 build_angle_trace_perf_tests = false 13392 build_angle_perftests = 13393- is_win || is_linux || is_chromeos || is_android || is_apple || is_fuchsia 13394+ is_win || is_linux || is_chromeos || is_android || is_apple || is_fuchsia || is_ohos 13395 } 13396 13397 angle_test("test_utils_unittest_helper") { 13398@@ -155,7 +155,7 @@ angle_test("angle_unittests") { 13399 } 13400 } 13401 13402-if (is_win || is_linux || is_chromeos || is_android || is_fuchsia || is_apple) { 13403+if (is_win || is_linux || is_chromeos || is_android || is_fuchsia || is_apple || is_ohos) { 13404 import("angle_end2end_tests.gni") 13405 13406 angle_test("angle_end2end_tests") { 13407@@ -186,7 +186,7 @@ if (is_win || is_linux || is_chromeos || is_android || is_fuchsia || is_apple) { 13408 "$angle_root:angle_image_util", 13409 ] 13410 13411- if (is_android) { 13412+ if (is_android || is_ohos) { 13413 include_dirs += [ "${android_ndk_root}/sysroot/usr/includes" ] 13414 } 13415 13416@@ -224,7 +224,7 @@ if (is_win || is_linux || is_chromeos || is_android || is_fuchsia || is_apple) { 13417 } 13418 } 13419 13420-if (is_win || is_linux || is_chromeos || is_android || is_fuchsia || is_apple) { 13421+if (is_win || is_linux || is_chromeos || is_android || is_fuchsia || is_apple || is_ohos) { 13422 import("angle_white_box_tests.gni") 13423 13424 angle_test("angle_white_box_tests") { 13425@@ -302,7 +302,7 @@ angle_perftests_common("angle_perftests_static") { 13426 test_utils = ":angle_common_test_utils_static" 13427 } 13428 13429-if (is_win || is_linux || is_chromeos || is_android || is_apple) { 13430+if (is_win || is_linux || is_chromeos || is_android || is_apple || is_ohos) { 13431 import("angle_perftests.gni") 13432 13433 # This test suite is for perf tests that use ANGLE's internals in some direct way. 13434diff --git a/third_party/blink/public/common/web_preferences/web_preferences.h b/third_party/blink/public/common/web_preferences/web_preferences.h 13435index ba58c8626d..08ed976ad4 100644 13436--- a/third_party/blink/public/common/web_preferences/web_preferences.h 13437+++ b/third_party/blink/public/common/web_preferences/web_preferences.h 13438@@ -220,7 +220,7 @@ struct BLINK_COMMON_EXPORT WebPreferences { 13439 // Representation of the Web App Manifest scope if any. 13440 GURL web_app_scope; 13441 13442-#if defined(OS_ANDROID) 13443+#if defined(OS_ANDROID) || defined(OS_OHOS) 13444 float font_scale_factor; 13445 float device_scale_adjustment; 13446 bool force_enable_zoom; 13447diff --git a/third_party/blink/renderer/BUILD.gn b/third_party/blink/renderer/BUILD.gn 13448index b06bf2b8e1..75473421f5 100644 13449--- a/third_party/blink/renderer/BUILD.gn 13450+++ b/third_party/blink/renderer/BUILD.gn 13451@@ -146,7 +146,7 @@ config("config") { 13452 config("non_test_config") { 13453 cflags = [] 13454 13455- if (is_clang) { 13456+ if (is_clang && !is_ohos) { 13457 cflags += [ "-Wglobal-constructors" ] 13458 } 13459 } 13460diff --git a/third_party/blink/renderer/config.gni b/third_party/blink/renderer/config.gni 13461index 89689ad370..ec02b05ca1 100644 13462--- a/third_party/blink/renderer/config.gni 13463+++ b/third_party/blink/renderer/config.gni 13464@@ -33,10 +33,10 @@ declare_args() { 13465 blink_symbol_level = -1 13466 13467 # If true, defaults image interpolation to low quality. 13468- use_low_quality_image_interpolation = is_android 13469+ use_low_quality_image_interpolation = is_android || is_ohos 13470 13471 # If true, ffmpeg will be used for computing FFTs for WebAudio 13472- use_webaudio_ffmpeg = !is_mac && !is_android && !use_webaudio_pffft 13473+ use_webaudio_ffmpeg = !is_mac && !is_android && !use_webaudio_pffft && !is_ohos 13474 13475 # If true, the new implementation (experimental) of Blink-V8 bindings 13476 # (of IDL callback function) is used. 13477diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc 13478index a520308e5d..58fc719381 100644 13479--- a/third_party/blink/renderer/core/frame/local_frame_view.cc 13480+++ b/third_party/blink/renderer/core/frame/local_frame_view.cc 13481@@ -43,6 +43,7 @@ 13482 #include "cc/trees/layer_tree_host.h" 13483 #include "components/paint_preview/common/paint_preview_tracker.h" 13484 #include "third_party/blink/public/common/features.h" 13485+#include "third_party/abseil-cpp/absl/base/macros.h" 13486 #include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink.h" 13487 #include "third_party/blink/public/mojom/scroll/scrollbar_mode.mojom-blink.h" 13488 #include "third_party/blink/public/platform/task_type.h" 13489diff --git a/third_party/blink/renderer/core/layout/build.gni b/third_party/blink/renderer/core/layout/build.gni 13490index 4e2863ae2a..3d63ff889c 100644 13491--- a/third_party/blink/renderer/core/layout/build.gni 13492+++ b/third_party/blink/renderer/core/layout/build.gni 13493@@ -738,7 +738,7 @@ if (is_linux || is_chromeos) { 13494 ] 13495 } 13496 13497-if (is_android) { 13498+if (is_android || is_ohos) { 13499 blink_core_sources_layout += [ 13500 "layout_theme_android.cc", 13501 "layout_theme_android.h", 13502diff --git a/third_party/blink/renderer/core/page/scrolling/text_fragment_selector_generator.h b/third_party/blink/renderer/core/page/scrolling/text_fragment_selector_generator.h 13503index d4af08daba..b41aed1c8e 100644 13504--- a/third_party/blink/renderer/core/page/scrolling/text_fragment_selector_generator.h 13505+++ b/third_party/blink/renderer/core/page/scrolling/text_fragment_selector_generator.h 13506@@ -7,6 +7,7 @@ 13507 13508 #include "base/optional.h" 13509 #include "components/shared_highlighting/core/common/shared_highlighting_metrics.h" 13510+#include "third_party/abseil-cpp/absl/base/macros.h" 13511 #include "third_party/blink/public/mojom/link_to_text/link_to_text.mojom-blink.h" 13512 #include "third_party/blink/renderer/core/editing/forward.h" 13513 #include "third_party/blink/renderer/core/page/scrolling/text_fragment_finder.h" 13514diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn 13515index 4b88d30a40..e0b3b8305a 100644 13516--- a/third_party/blink/renderer/platform/BUILD.gn 13517+++ b/third_party/blink/renderer/platform/BUILD.gn 13518@@ -1743,6 +1743,12 @@ component("platform") { 13519 ] 13520 } 13521 13522+ if (is_ohos) { 13523+ sources += [ 13524+ "fonts/android/font_cache_android.cc", 13525+ ] 13526+ } 13527+ 13528 if (is_android) { 13529 sources += [ 13530 "fonts/android/font_cache_android.cc", 13531@@ -1882,7 +1888,7 @@ static_library("test_support") { 13532 ] 13533 13534 # fuzzed_data_provider may not work with a custom toolchain. 13535- if (custom_toolchain == "" && is_clang) { 13536+ if (custom_toolchain == "" && is_clang && !is_ohos) { 13537 sources += [ 13538 "testing/fuzzed_data_provider.cc", 13539 "testing/fuzzed_data_provider.h", 13540diff --git a/third_party/blink/renderer/platform/fonts/font_cache.cc b/third_party/blink/renderer/platform/fonts/font_cache.cc 13541index df794d75c1..f9354241e7 100644 13542--- a/third_party/blink/renderer/platform/fonts/font_cache.cc 13543+++ b/third_party/blink/renderer/platform/fonts/font_cache.cc 13544@@ -80,7 +80,7 @@ const char kColorEmojiLocale[] = "und-Zsye"; 13545 13546 SkFontMgr* FontCache::static_font_manager_ = nullptr; 13547 13548-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13549+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13550 float FontCache::device_scale_factor_ = 1.0; 13551 #endif 13552 13553@@ -120,7 +120,7 @@ FontCache::FontCache() 13554 FontPlatformData* FontCache::SystemFontPlatformData( 13555 const FontDescription& font_description) { 13556 const AtomicString& family = FontCache::SystemFontFamily(); 13557-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) 13558+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_OHOS) 13559 if (family.IsEmpty() || family == font_family_names::kSystemUi) 13560 return nullptr; 13561 #else 13562diff --git a/third_party/blink/renderer/platform/fonts/font_cache.h b/third_party/blink/renderer/platform/fonts/font_cache.h 13563index e87551ae40..264a9e8df3 100644 13564--- a/third_party/blink/renderer/platform/fonts/font_cache.h 13565+++ b/third_party/blink/renderer/platform/fonts/font_cache.h 13566@@ -242,7 +242,7 @@ class PLATFORM_EXPORT FontCache { 13567 13568 static void AcceptLanguagesChanged(const String&); 13569 13570-#if defined(OS_ANDROID) 13571+#if defined(OS_ANDROID) || defined(OS_OHOS) 13572 static AtomicString GetGenericFamilyNameForScript( 13573 const AtomicString& family_name, 13574 const FontDescription&); 13575@@ -326,7 +326,7 @@ class PLATFORM_EXPORT FontCache { 13576 const FontFaceCreationParams&, 13577 std::string& name); 13578 13579-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 13580+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13581 static AtomicString GetFamilyNameForCharacter(SkFontMgr*, 13582 UChar32, 13583 const FontDescription&, 13584@@ -371,7 +371,7 @@ class PLATFORM_EXPORT FontCache { 13585 std::unique_ptr<FallbackFamilyStyleCache> fallback_params_cache_; 13586 #endif // defined(OS_WIN) 13587 13588-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 13589+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13590 static float device_scale_factor_; 13591 #endif 13592 13593diff --git a/third_party/blink/renderer/platform/fonts/font_platform_data.cc b/third_party/blink/renderer/platform/fonts/font_platform_data.cc 13594index ad318e8a22..600ac72a2c 100644 13595--- a/third_party/blink/renderer/platform/fonts/font_platform_data.cc 13596+++ b/third_party/blink/renderer/platform/fonts/font_platform_data.cc 13597@@ -266,7 +266,7 @@ WebFontRenderStyle FontPlatformData::QuerySystemRenderStyle( 13598 SkFontStyle font_style) { 13599 WebFontRenderStyle result; 13600 13601-#if !defined(OS_ANDROID) && !defined(OS_FUCHSIA) 13602+#if !defined(OS_ANDROID) && !defined(OS_FUCHSIA) && !defined(OS_OHOS) 13603 // If the font name is missing (i.e. probably a web font) or the sandbox is 13604 // disabled, use the system defaults. 13605 if (family.length() && Platform::Current()->GetSandboxSupport()) { 13606diff --git a/third_party/blink/renderer/platform/fonts/skia/font_cache_skia.cc b/third_party/blink/renderer/platform/fonts/skia/font_cache_skia.cc 13607index b962b210a9..0e3124aab6 100644 13608--- a/third_party/blink/renderer/platform/fonts/skia/font_cache_skia.cc 13609+++ b/third_party/blink/renderer/platform/fonts/skia/font_cache_skia.cc 13610@@ -61,7 +61,7 @@ AtomicString ToAtomicString(const SkString& str) { 13611 return AtomicString::FromUTF8(str.c_str(), str.size()); 13612 } 13613 13614-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 13615+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13616 // This function is called on android or when we are emulating android fonts on 13617 // linux and the embedder has overriden the default fontManager with 13618 // WebFontRendering::setSkiaFontMgr. 13619@@ -229,7 +229,7 @@ sk_sp<SkTypeface> FontCache::CreateTypeface( 13620 } 13621 #endif 13622 13623-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_WIN) 13624+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_WIN) || defined(OS_OHOS) 13625 // On linux if the fontManager has been overridden then we should be calling 13626 // the embedder provided font Manager rather than calling 13627 // SkTypeface::CreateFromName which may redirect the call to the default font 13628diff --git a/third_party/blink/renderer/platform/fonts/skia/sktypeface_factory.cc b/third_party/blink/renderer/platform/fonts/skia/sktypeface_factory.cc 13629index 1537330f5b..40587acbdb 100644 13630--- a/third_party/blink/renderer/platform/fonts/skia/sktypeface_factory.cc 13631+++ b/third_party/blink/renderer/platform/fonts/skia/sktypeface_factory.cc 13632@@ -16,7 +16,7 @@ sk_sp<SkTypeface> SkTypeface_Factory::FromFontConfigInterfaceIdAndTtcIndex( 13633 int config_id, 13634 int ttc_index) { 13635 #if !defined(OS_MAC) && !defined(OS_ANDROID) && !defined(OS_WIN) && \ 13636- !defined(OS_FUCHSIA) 13637+ !defined(OS_FUCHSIA) && !defined(OS_OHOS) 13638 sk_sp<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal()); 13639 SkFontConfigInterface::FontIdentity font_identity; 13640 font_identity.fID = config_id; 13641@@ -33,7 +33,7 @@ sk_sp<SkTypeface> SkTypeface_Factory::FromFilenameAndTtcIndex( 13642 const std::string& filename, 13643 int ttc_index) { 13644 #if !defined(OS_WIN) && !defined(OS_ANDROID) && !defined(OS_FUCHSIA) && \ 13645- !defined(OS_MAC) 13646+ !defined(OS_MAC) && !defined(OS_OHOS) 13647 return SkTypeface::MakeFromFile(filename.c_str(), ttc_index); 13648 #else 13649 NOTREACHED(); 13650diff --git a/third_party/blink/renderer/platform/scheduler/common/tracing_helper.h b/third_party/blink/renderer/platform/scheduler/common/tracing_helper.h 13651index ba5136874e..a4f2506d3f 100644 13652--- a/third_party/blink/renderer/platform/scheduler/common/tracing_helper.h 13653+++ b/third_party/blink/renderer/platform/scheduler/common/tracing_helper.h 13654@@ -223,7 +223,7 @@ class TraceableState : public TraceableVariable, private StateTracer<category> { 13655 const ConverterFuncPtr converter_; 13656 T state_; 13657 13658- DISALLOW_COPY(TraceableState); 13659+ DISALLOW_COPY_BASE(TraceableState); 13660 }; 13661 13662 template <const char* category, typename TypedValue> 13663@@ -407,7 +407,7 @@ class TraceableCounter : public TraceableVariable { 13664 const ConverterFuncPtr converter_; 13665 13666 T value_; 13667- DISALLOW_COPY(TraceableCounter); 13668+ DISALLOW_COPY_BASE(TraceableCounter); 13669 }; 13670 13671 // Add operators when it's needed. 13672diff --git a/third_party/blink/renderer/platform/wtf/stack_util.cc b/third_party/blink/renderer/platform/wtf/stack_util.cc 13673index 71b901f404..484bde86b1 100644 13674--- a/third_party/blink/renderer/platform/wtf/stack_util.cc 13675+++ b/third_party/blink/renderer/platform/wtf/stack_util.cc 13676@@ -30,7 +30,7 @@ size_t GetUnderestimatedStackSize() { 13677 // correctly for the main thread. 13678 13679 #elif defined(__GLIBC__) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \ 13680- defined(OS_FUCHSIA) 13681+ defined(OS_FUCHSIA) || defined(OS_OHOS) 13682 // pthread_getattr_np() can fail if the thread is not invoked by 13683 // pthread_create() (e.g., the main thread of blink_unittests). 13684 // If so, a conservative size estimate is returned. 13685@@ -98,7 +98,7 @@ return Threading::ThreadStackSize(); 13686 13687 void* GetStackStart() { 13688 #if defined(__GLIBC__) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \ 13689- defined(OS_FUCHSIA) 13690+ defined(OS_FUCHSIA) || defined(OS_OHOS) 13691 pthread_attr_t attr; 13692 int error; 13693 #if defined(OS_FREEBSD) 13694diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn 13695index d173445bcd..e545f029aa 100644 13696--- a/third_party/breakpad/BUILD.gn 13697+++ b/third_party/breakpad/BUILD.gn 13698@@ -16,7 +16,7 @@ config("tools_config") { 13699 "breakpad/src", 13700 "breakpad/src/third_party", 13701 ] 13702- if (is_android) { 13703+ if (is_android || is_ohos) { 13704 defines = [ "__ANDROID__" ] 13705 } 13706 if (is_clang) { 13707@@ -31,14 +31,14 @@ config("internal_config") { 13708 # This is needed for GTMLogger to work correctly. 13709 defines += [ "DEBUG" ] 13710 } 13711- if (is_android) { 13712+ if (is_android || is_ohos) { 13713 defines += [ "__ANDROID__" ] 13714 } 13715 } 13716 13717 config("client_config") { 13718 include_dirs = [ "breakpad/src" ] 13719- if (is_android) { 13720+ if (is_android || is_ohos && !use_musl) { 13721 include_dirs += [ "breakpad/src/common/android/include" ] 13722 } 13723 if (is_chromeos_ash) { 13724@@ -484,7 +484,7 @@ if (is_mac) { 13725 } 13726 } 13727 13728-if (is_linux || is_chromeos || is_android) { 13729+if (is_linux || is_chromeos || is_android || is_ohos) { 13730 if (current_toolchain == host_toolchain) { 13731 executable("symupload") { 13732 sources = [ 13733diff --git a/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc b/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc 13734index ca353c4099..0452da47e7 100644 13735--- a/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc 13736+++ b/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc 13737@@ -234,7 +234,7 @@ ExceptionHandler::ExceptionHandler(const MinidumpDescriptor& descriptor, 13738 !minidump_descriptor_.IsMicrodumpOnConsole()) 13739 minidump_descriptor_.UpdatePath(); 13740 13741-#if defined(__ANDROID__) 13742+#if defined(__ANDROID__) && !defined(OSOHOS) 13743 if (minidump_descriptor_.IsMicrodumpOnConsole()) 13744 logger::initializeCrashLogWriter(); 13745 #endif 13746diff --git a/third_party/breakpad/breakpad/src/client/linux/log/log.cc b/third_party/breakpad/breakpad/src/client/linux/log/log.cc 13747index 318794095b..c96c1fc5c2 100644 13748--- a/third_party/breakpad/breakpad/src/client/linux/log/log.cc 13749+++ b/third_party/breakpad/breakpad/src/client/linux/log/log.cc 13750@@ -29,7 +29,7 @@ 13751 13752 #include "client/linux/log/log.h" 13753 13754-#if defined(__ANDROID__) 13755+#if defined(__ANDROID__) && !defined(OSOHOS) 13756 #include <android/log.h> 13757 #include <dlfcn.h> 13758 #else 13759@@ -38,7 +38,7 @@ 13760 13761 namespace logger { 13762 13763-#if defined(__ANDROID__) 13764+#if defined(__ANDROID__) && !defined(OSOHOS) 13765 namespace { 13766 13767 // __android_log_buf_write() is not exported in the NDK and is being used by 13768@@ -74,7 +74,7 @@ int writeToCrashLog(const char* buf) { 13769 #endif 13770 13771 int write(const char* buf, size_t nbytes) { 13772-#if defined(__ANDROID__) 13773+#if defined(__ANDROID__) && !defined(OSOHOS) 13774 return __android_log_write(ANDROID_LOG_WARN, kAndroidLogTag, buf); 13775 #else 13776 return sys_write(2, buf, nbytes); 13777diff --git a/third_party/breakpad/breakpad/src/client/linux/log/log.h b/third_party/breakpad/breakpad/src/client/linux/log/log.h 13778index f94bbd5fb7..0d353959e3 100644 13779--- a/third_party/breakpad/breakpad/src/client/linux/log/log.h 13780+++ b/third_party/breakpad/breakpad/src/client/linux/log/log.h 13781@@ -39,7 +39,7 @@ int write(const char* buf, size_t nbytes); 13782 // In the case of Android the log can be written to the default system log 13783 // (default behavior of write() above, or to the crash log (see 13784 // writeToCrashLog() below). 13785-#if defined(__ANDROID__) 13786+#if defined(__ANDROID__) && !defined(OSOHOS) 13787 13788 // The logger must be initialized in a non-compromised context. 13789 void initializeCrashLogWriter(); 13790diff --git a/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc b/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc 13791index fa3c1713a5..4a8e616d87 100644 13792--- a/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc 13793+++ b/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc 13794@@ -198,7 +198,7 @@ class MicrodumpWriter { 13795 13796 // Writes one line to the system log. 13797 void LogLine(const char* msg) { 13798-#if defined(__ANDROID__) 13799+#if defined(__ANDROID__) && !defined(OSOHOS) 13800 logger::writeToCrashLog(msg); 13801 #else 13802 logger::write(msg, my_strlen(msg)); 13803diff --git a/third_party/crashpad/crashpad/BUILD.gn b/third_party/crashpad/crashpad/BUILD.gn 13804index 264c10d81e..1326043821 100644 13805--- a/third_party/crashpad/crashpad/BUILD.gn 13806+++ b/third_party/crashpad/crashpad/BUILD.gn 13807@@ -43,7 +43,6 @@ if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { 13808 deps += [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ] 13809 } 13810 if (crashpad_is_android) { 13811- use_raw_android_executable = true 13812 13813 copy("crashpad_test_data") { 13814 testonly = true 13815@@ -58,11 +57,14 @@ if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { 13816 13817 deps += [ ":crashpad_test_data" ] 13818 13819+ if (!is_ohos) { 13820+ use_raw_android_executable = true 13821 extra_dist_files = [ 13822 "$root_out_dir/crashpad_handler", 13823 "$root_out_dir/crashpad_test_test_multiprocess_exec_test_child", 13824 "$root_out_dir/crashpad_test_data", 13825 ] 13826+ } 13827 } 13828 } 13829 13830diff --git a/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni b/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni 13831index 51b99c3b93..4e3ec42ff0 100644 13832--- a/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni 13833+++ b/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni 13834@@ -39,7 +39,7 @@ if (crashpad_is_in_chromium) { 13835 crashpad_is_ios = is_ios 13836 crashpad_is_win = is_win 13837 crashpad_is_linux = is_linux || is_chromeos 13838- crashpad_is_android = is_android 13839+ crashpad_is_android = is_android || is_ohos 13840 crashpad_is_fuchsia = is_fuchsia 13841 13842 crashpad_is_posix = is_posix 13843@@ -68,6 +68,11 @@ if (crashpad_is_in_chromium) { 13844 crashpad_is_clang = mini_chromium_is_clang 13845 } 13846 13847+if (use_musl) { 13848+ crashpad_is_android = false 13849+ crashpad_is_linux = true 13850+} 13851+ 13852 template("crashpad_executable") { 13853 executable(target_name) { 13854 forward_variables_from(invoker, 13855diff --git a/third_party/crashpad/crashpad/client/crashpad_client.h b/third_party/crashpad/crashpad/client/crashpad_client.h 13856index cbe05516f2..8cd2eb04ac 100644 13857--- a/third_party/crashpad/crashpad/client/crashpad_client.h 13858+++ b/third_party/crashpad/crashpad/client/crashpad_client.h 13859@@ -34,7 +34,7 @@ 13860 #elif defined(OS_WIN) 13861 #include <windows.h> 13862 #include "util/win/scoped_handle.h" 13863-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13864+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 13865 #include <signal.h> 13866 #include <ucontext.h> 13867 #endif 13868@@ -122,7 +122,7 @@ class CrashpadClient { 13869 bool asynchronous_start, 13870 const std::vector<base::FilePath>& attachments = {}); 13871 13872-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || DOXYGEN 13873+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) || DOXYGEN 13874 //! \brief Retrieve the socket and process ID for the handler. 13875 //! 13876 //! `StartHandler()` must have successfully been called before calling this 13877@@ -338,7 +338,7 @@ class CrashpadClient { 13878 int socket); 13879 #endif // OS_ANDROID || DOXYGEN 13880 13881-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) || DOXYGEN 13882+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_OHOS) || DOXYGEN 13883 //! \brief Installs a signal handler to launch a handler process in reponse to 13884 //! a crash. 13885 //! 13886@@ -688,7 +688,7 @@ class CrashpadClient { 13887 #elif defined(OS_WIN) 13888 std::wstring ipc_pipe_; 13889 ScopedKernelHANDLE handler_start_thread_; 13890-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13891+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 13892 std::set<int> unhandled_signals_; 13893 #endif // OS_APPLE 13894 13895diff --git a/third_party/crashpad/crashpad/client/crashpad_client_linux.cc b/third_party/crashpad/crashpad/client/crashpad_client_linux.cc 13896index cf94e6bd31..295770d473 100644 13897--- a/third_party/crashpad/crashpad/client/crashpad_client_linux.cc 13898+++ b/third_party/crashpad/crashpad/client/crashpad_client_linux.cc 13899@@ -412,7 +412,7 @@ bool CrashpadClient::StartHandler( 13900 std::move(client_sock), handler_pid, &unhandled_signals_); 13901 } 13902 13903-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 13904+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 13905 // static 13906 bool CrashpadClient::GetHandlerSocket(int* sock, pid_t* pid) { 13907 auto signal_handler = RequestCrashDumpHandler::Get(); 13908diff --git a/third_party/crashpad/crashpad/client/crashpad_info.cc b/third_party/crashpad/crashpad/client/crashpad_info.cc 13909index 929c0df11f..b0a4bff325 100644 13910--- a/third_party/crashpad/crashpad/client/crashpad_info.cc 13911+++ b/third_party/crashpad/crashpad/client/crashpad_info.cc 13912@@ -95,7 +95,7 @@ extern "C" int* CRASHPAD_NOTE_REFERENCE; 13913 // static 13914 CrashpadInfo* CrashpadInfo::GetCrashpadInfo() { 13915 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 13916- defined(OS_FUCHSIA) 13917+ defined(OS_FUCHSIA) || defined(OS_OHOS) 13918 // This otherwise-unused reference is used so that any module that 13919 // references GetCrashpadInfo() will also include the note in the 13920 // .note.crashpad.info section. That note in turn contains the address of 13921diff --git a/third_party/crashpad/crashpad/client/simulate_crash.h b/third_party/crashpad/crashpad/client/simulate_crash.h 13922index d01e1682d7..d3c2298f31 100644 13923--- a/third_party/crashpad/crashpad/client/simulate_crash.h 13924+++ b/third_party/crashpad/crashpad/client/simulate_crash.h 13925@@ -23,7 +23,7 @@ 13926 #include "client/simulate_crash_ios.h" 13927 #elif defined(OS_WIN) 13928 #include "client/simulate_crash_win.h" 13929-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13930+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 13931 #include "client/simulate_crash_linux.h" 13932 #endif 13933 13934diff --git a/third_party/crashpad/crashpad/compat/linux/sys/ptrace.h b/third_party/crashpad/crashpad/compat/linux/sys/ptrace.h 13935index f8be372cc6..292f782b78 100644 13936--- a/third_party/crashpad/crashpad/compat/linux/sys/ptrace.h 13937+++ b/third_party/crashpad/crashpad/compat/linux/sys/ptrace.h 13938@@ -17,7 +17,9 @@ 13939 13940 #include_next <sys/ptrace.h> 13941 13942+#if !defined(__MUSL__) 13943 #include <sys/cdefs.h> 13944+#endif 13945 13946 // https://sourceware.org/bugzilla/show_bug.cgi?id=22433 13947 #if !defined(PTRACE_GET_THREAD_AREA) && !defined(PT_GET_THREAD_AREA) && \ 13948diff --git a/third_party/crashpad/crashpad/handler/handler_main.cc b/third_party/crashpad/crashpad/handler/handler_main.cc 13949index f5a8727f7e..3e04d2ebb3 100644 13950--- a/third_party/crashpad/crashpad/handler/handler_main.cc 13951+++ b/third_party/crashpad/crashpad/handler/handler_main.cc 13952@@ -62,7 +62,7 @@ 13953 #include "handler/linux/cros_crash_report_exception_handler.h" 13954 #endif 13955 13956-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13957+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 13958 #include <unistd.h> 13959 13960 #include "handler/linux/crash_report_exception_handler.h" 13961@@ -99,7 +99,7 @@ namespace crashpad { 13962 namespace { 13963 13964 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 13965- defined(OS_ANDROID) 13966+ defined(OS_ANDROID) || defined(OS_OHOS) 13967 #define ATTACHMENTS_SUPPORTED 1 13968 #endif // OS_WIN || OS_LINUX || OS_CHROMEOS || OS_ANDROID 13969 13970@@ -146,7 +146,7 @@ void Usage(const base::FilePath& me) { 13971 " --no-periodic-tasks don't scan for new reports or prune the database\n" 13972 " --no-rate-limit don't rate limit crash uploads\n" 13973 " --no-upload-gzip don't use gzip compression when uploading\n" 13974-#if defined(OS_ANDROID) 13975+#if defined(OS_ANDROID) || defined(OS_OHOS) 13976 " --no-write-minidump-to-database\n" 13977 " don't write minidump to database\n" 13978 #endif // OS_ANDROID 13979@@ -157,7 +157,7 @@ void Usage(const base::FilePath& me) { 13980 " --reset-own-crash-exception-port-to-system-default\n" 13981 " reset the server's exception handler to default\n" 13982 #endif // OS_APPLE 13983-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 13984+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 13985 " --sanitization-information=SANITIZATION_INFORMATION_ADDRESS\n" 13986 " the address of a SanitizationInformation struct.\n" 13987 " --shared-client-connection the file descriptor provided by\n" 13988@@ -180,7 +180,7 @@ void Usage(const base::FilePath& me) { 13989 " crash_reporter, thus skipping metrics consent\n" 13990 " checks\n" 13991 #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 13992-#if defined(OS_ANDROID) 13993+#if defined(OS_ANDROID) || defined(OS_OHOS) 13994 " --write-minidump-to-log write minidump to log\n" 13995 #endif // OS_ANDROID 13996 " --help display this help and exit\n" 13997@@ -200,12 +200,12 @@ struct Options { 13998 std::string mach_service; 13999 int handshake_fd; 14000 bool reset_own_crash_exception_port_to_system_default; 14001-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14002+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14003 VMAddress exception_information_address; 14004 VMAddress sanitization_information_address; 14005 int initial_client_fd; 14006 bool shared_client_connection; 14007-#if defined(OS_ANDROID) 14008+#if defined(OS_ANDROID) || defined(OS_OHOS) 14009 bool write_minidump_to_log; 14010 bool write_minidump_to_database; 14011 #endif // OS_ANDROID 14012@@ -287,7 +287,7 @@ class CallMetricsRecordNormalExit { 14013 }; 14014 14015 #if defined(OS_APPLE) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 14016- defined(OS_ANDROID) 14017+ defined(OS_ANDROID) || defined(OS_OHOS) 14018 14019 void HandleCrashSignal(int sig, siginfo_t* siginfo, void* context) { 14020 MetricsRecordExit(Metrics::LifetimeMilestone::kCrashed); 14021@@ -466,7 +466,7 @@ void MonitorSelf(const Options& options) { 14022 // instance of crashpad_handler to be writing metrics at a time, and it should 14023 // be the primary instance. 14024 CrashpadClient crashpad_client; 14025-#if defined(OS_ANDROID) 14026+#if defined(OS_ANDROID) || defined(OS_OHOS) 14027 if (!crashpad_client.StartHandlerAtCrash(executable_path, 14028 options.database, 14029 base::FilePath(), 14030@@ -546,7 +546,7 @@ int HandlerMain(int argc, 14031 kOptionLastChar = 255, 14032 kOptionAnnotation, 14033 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 14034- defined(OS_ANDROID) 14035+ defined(OS_ANDROID) || defined(OS_OHOS) 14036 kOptionAttachment, 14037 #endif // OS_WIN || OS_LINUX 14038 kOptionDatabase, 14039@@ -556,7 +556,7 @@ int HandlerMain(int argc, 14040 #if defined(OS_WIN) 14041 kOptionInitialClientData, 14042 #endif // OS_WIN 14043-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 14044+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 14045 kOptionInitialClientFD, 14046 #endif // OS_ANDROID || OS_LINUX || OS_CHROMEOS 14047 #if defined(OS_APPLE) 14048@@ -570,7 +570,7 @@ int HandlerMain(int argc, 14049 kOptionNoPeriodicTasks, 14050 kOptionNoRateLimit, 14051 kOptionNoUploadGzip, 14052-#if defined(OS_ANDROID) 14053+#if defined(OS_ANDROID) || defined(OS_OHOS) 14054 kOptionNoWriteMinidumpToDatabase, 14055 #endif // OS_ANDROID 14056 #if defined(OS_WIN) 14057@@ -579,7 +579,7 @@ int HandlerMain(int argc, 14058 #if defined(OS_APPLE) 14059 kOptionResetOwnCrashExceptionPortToSystemDefault, 14060 #endif // OS_APPLE 14061-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14062+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14063 kOptionSanitizationInformation, 14064 kOptionSharedClientConnection, 14065 kOptionTraceParentWithException, 14066@@ -593,7 +593,7 @@ int HandlerMain(int argc, 14067 kOptionMinidumpDirForTests, 14068 kOptionAlwaysAllowFeedback, 14069 #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 14070-#if defined(OS_ANDROID) 14071+#if defined(OS_ANDROID) || defined(OS_OHOS) 14072 kOptionWriteMinidumpToLog, 14073 #endif // OS_ANDROID 14074 14075@@ -617,7 +617,7 @@ int HandlerMain(int argc, 14076 nullptr, 14077 kOptionInitialClientData}, 14078 #endif // OS_APPLE 14079-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 14080+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 14081 {"initial-client-fd", required_argument, nullptr, kOptionInitialClientFD}, 14082 #endif // OS_ANDROID || OS_LINUX || OS_CHROMEOS 14083 #if defined(OS_APPLE) 14084@@ -640,7 +640,7 @@ int HandlerMain(int argc, 14085 {"no-periodic-tasks", no_argument, nullptr, kOptionNoPeriodicTasks}, 14086 {"no-rate-limit", no_argument, nullptr, kOptionNoRateLimit}, 14087 {"no-upload-gzip", no_argument, nullptr, kOptionNoUploadGzip}, 14088-#if defined(OS_ANDROID) 14089+#if defined(OS_ANDROID) || defined(OS_OHOS) 14090 {"no-write-minidump-to-database", 14091 no_argument, 14092 nullptr, 14093@@ -655,7 +655,7 @@ int HandlerMain(int argc, 14094 nullptr, 14095 kOptionResetOwnCrashExceptionPortToSystemDefault}, 14096 #endif // OS_APPLE 14097-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14098+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14099 {"sanitization-information", 14100 required_argument, 14101 nullptr, 14102@@ -684,7 +684,7 @@ int HandlerMain(int argc, 14103 nullptr, 14104 kOptionAlwaysAllowFeedback}, 14105 #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 14106-#if defined(OS_ANDROID) 14107+#if defined(OS_ANDROID) || defined(OS_OHOS) 14108 {"write-minidump-to-log", no_argument, nullptr, kOptionWriteMinidumpToLog}, 14109 #endif // OS_ANDROID 14110 {"help", no_argument, nullptr, kOptionHelp}, 14111@@ -700,13 +700,13 @@ int HandlerMain(int argc, 14112 options.handshake_fd = -1; 14113 #endif 14114 options.identify_client_via_url = true; 14115-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14116+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14117 options.initial_client_fd = kInvalidFileHandle; 14118 #endif 14119 options.periodic_tasks = true; 14120 options.rate_limit = true; 14121 options.upload_gzip = true; 14122-#if defined(OS_ANDROID) 14123+#if defined(OS_ANDROID) || defined(OS_OHOS) 14124 options.write_minidump_to_database = true; 14125 #endif 14126 14127@@ -756,7 +756,7 @@ int HandlerMain(int argc, 14128 break; 14129 } 14130 #endif // OS_WIN 14131-#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) 14132+#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 14133 case kOptionInitialClientFD: { 14134 if (!base::StringToInt(optarg, &options.initial_client_fd)) { 14135 ToolSupport::UsageHint(me, "failed to parse --initial-client-fd"); 14136@@ -802,7 +802,7 @@ int HandlerMain(int argc, 14137 options.upload_gzip = false; 14138 break; 14139 } 14140-#if defined(OS_ANDROID) 14141+#if defined(OS_ANDROID) || defined(OS_OHOS) 14142 case kOptionNoWriteMinidumpToDatabase: { 14143 options.write_minidump_to_database = false; 14144 break; 14145@@ -820,7 +820,7 @@ int HandlerMain(int argc, 14146 break; 14147 } 14148 #endif // OS_APPLE 14149-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14150+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14151 case kOptionSanitizationInformation: { 14152 if (!StringToNumber(optarg, 14153 &options.sanitization_information_address)) { 14154@@ -883,7 +883,7 @@ int HandlerMain(int argc, 14155 break; 14156 } 14157 #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 14158-#if defined(OS_ANDROID) 14159+#if defined(OS_ANDROID) || defined(OS_OHOS) 14160 case kOptionWriteMinidumpToLog: { 14161 options.write_minidump_to_log = true; 14162 break; 14163@@ -929,7 +929,7 @@ int HandlerMain(int argc, 14164 me, "--initial-client-data and --pipe-name are incompatible"); 14165 return ExitFailure(); 14166 } 14167-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14168+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14169 if (!options.exception_information_address && 14170 options.initial_client_fd == kInvalidFileHandle) { 14171 ToolSupport::UsageHint( 14172@@ -949,7 +949,7 @@ int HandlerMain(int argc, 14173 me, "--shared-client-connection requires --initial-client-fd"); 14174 return ExitFailure(); 14175 } 14176-#if defined(OS_ANDROID) 14177+#if defined(OS_ANDROID) || defined(OS_OHOS) 14178 if (!options.write_minidump_to_log && !options.write_minidump_to_database) { 14179 ToolSupport::UsageHint(me, 14180 "--no_write_minidump_to_database is required to use " 14181@@ -1028,7 +1028,7 @@ int HandlerMain(int argc, 14182 upload_thread.Get()->Start(); 14183 } 14184 14185-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14186+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14187 std::unique_ptr<ExceptionHandlerServer::Delegate> exception_handler; 14188 #else 14189 std::unique_ptr<CrashReportExceptionHandler> exception_handler; 14190@@ -1068,7 +1068,7 @@ int HandlerMain(int argc, 14191 #if defined(ATTACHMENTS_SUPPORTED) 14192 &options.attachments, 14193 #endif // ATTACHMENTS_SUPPORTED 14194-#if defined(OS_ANDROID) 14195+#if defined(OS_ANDROID) || defined(OS_OHOS) 14196 options.write_minidump_to_database, 14197 options.write_minidump_to_log, 14198 #endif // OS_ANDROID 14199@@ -1079,7 +1079,7 @@ int HandlerMain(int argc, 14200 user_stream_sources); 14201 #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) 14202 14203-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14204+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14205 if (options.exception_information_address) { 14206 ExceptionHandlerProtocol::ClientInformation info; 14207 info.exception_information_address = options.exception_information_address; 14208@@ -1152,7 +1152,7 @@ int HandlerMain(int argc, 14209 if (!options.pipe_name.empty()) { 14210 exception_handler_server.SetPipeName(base::UTF8ToWide(options.pipe_name)); 14211 } 14212-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14213+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14214 ExceptionHandlerServer exception_handler_server; 14215 #endif // OS_APPLE 14216 14217@@ -1174,7 +1174,7 @@ int HandlerMain(int argc, 14218 exception_handler_server.InitializeWithInheritedDataForInitialClient( 14219 options.initial_client_data, exception_handler.get()); 14220 } 14221-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14222+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14223 if (options.initial_client_fd == kInvalidFileHandle || 14224 !exception_handler_server.InitializeWithClient( 14225 ScopedFileHandle(options.initial_client_fd), 14226diff --git a/third_party/crashpad/crashpad/handler/handler_main.h b/third_party/crashpad/crashpad/handler/handler_main.h 14227index 252654118a..483e4108ed 100644 14228--- a/third_party/crashpad/crashpad/handler/handler_main.h 14229+++ b/third_party/crashpad/crashpad/handler/handler_main.h 14230@@ -35,7 +35,7 @@ int HandlerMain(int argc, 14231 char* argv[], 14232 const UserStreamDataSources* user_stream_sources); 14233 14234-#if defined(OS_ANDROID) 14235+#if defined(OS_ANDROID) || defined(OS_OHOS) 14236 //! \brief The `main()` entry point for Android libraries. 14237 //! 14238 //! This symbol is the entry point for crashpad when it is dynamically loaded 14239diff --git a/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc b/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc 14240index 0974e3ddf5..dbc5dabd7f 100644 14241--- a/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc 14242+++ b/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc 14243@@ -119,6 +119,8 @@ std::string MinidumpMiscInfoDebugBuildString() { 14244 static constexpr char kOS[] = "win"; 14245 #elif defined(OS_FUCHSIA) 14246 static constexpr char kOS[] = "fuchsia"; 14247+#elif defined(OS_OHOS) 14248+ static constexpr char kOS[] = "ohos"; 14249 #else 14250 #error define kOS for this operating system 14251 #endif 14252diff --git a/third_party/crashpad/crashpad/snapshot/crashpad_types/crashpad_info_reader.cc b/third_party/crashpad/crashpad/snapshot/crashpad_types/crashpad_info_reader.cc 14253index cedab59a72..195374c2d4 100644 14254--- a/third_party/crashpad/crashpad/snapshot/crashpad_types/crashpad_info_reader.cc 14255+++ b/third_party/crashpad/crashpad/snapshot/crashpad_types/crashpad_info_reader.cc 14256@@ -22,7 +22,7 @@ 14257 14258 #if defined(OS_WIN) 14259 #include "util/win/traits.h" 14260-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14261+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14262 #include "util/linux/traits.h" 14263 #elif defined(OS_FUCHSIA) 14264 #include "util/fuchsia/traits.h" 14265diff --git a/third_party/crashpad/crashpad/util/file/file_io.h b/third_party/crashpad/crashpad/util/file/file_io.h 14266index 1f502ad4b1..1dd6eb37d0 100644 14267--- a/third_party/crashpad/crashpad/util/file/file_io.h 14268+++ b/third_party/crashpad/crashpad/util/file/file_io.h 14269@@ -398,7 +398,7 @@ FileHandle LoggingOpenFileForWrite(const base::FilePath& path, 14270 FileWriteMode mode, 14271 FilePermissions permissions); 14272 14273-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 14274+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(__MUSL__) 14275 //! \brief Opens an in-memory file for input and output. 14276 //! 14277 //! This function first attempts to open the file with `memfd_create()`. If 14278diff --git a/third_party/crashpad/crashpad/util/file/file_io_posix.cc b/third_party/crashpad/crashpad/util/file/file_io_posix.cc 14279index 2baa8114fd..6a736404e7 100644 14280--- a/third_party/crashpad/crashpad/util/file/file_io_posix.cc 14281+++ b/third_party/crashpad/crashpad/util/file/file_io_posix.cc 14282@@ -153,7 +153,7 @@ FileHandle LoggingOpenFileForWrite(const base::FilePath& path, 14283 return fd; 14284 } 14285 14286-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 14287+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(__MUSL__) 14288 FileHandle LoggingOpenMemoryFileForReadAndWrite(const base::FilePath& name) { 14289 DCHECK(name.value().find('/') == std::string::npos); 14290 14291diff --git a/third_party/crashpad/crashpad/util/file/file_writer.cc b/third_party/crashpad/crashpad/util/file/file_writer.cc 14292index 73fe708796..6343fe0919 100644 14293--- a/third_party/crashpad/crashpad/util/file/file_writer.cc 14294+++ b/third_party/crashpad/crashpad/util/file/file_writer.cc 14295@@ -171,7 +171,7 @@ bool FileWriter::Open(const base::FilePath& path, 14296 return true; 14297 } 14298 14299-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 14300+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(__MUSL__) 14301 bool FileWriter::OpenMemfd(const base::FilePath& path) { 14302 CHECK(!file_.is_valid()); 14303 file_.reset(LoggingOpenMemoryFileForReadAndWrite(path)); 14304diff --git a/third_party/crashpad/crashpad/util/file/file_writer.h b/third_party/crashpad/crashpad/util/file/file_writer.h 14305index 987c0f59d5..f27e9abd68 100644 14306--- a/third_party/crashpad/crashpad/util/file/file_writer.h 14307+++ b/third_party/crashpad/crashpad/util/file/file_writer.h 14308@@ -131,7 +131,7 @@ class FileWriter : public FileWriterInterface { 14309 FileWriteMode write_mode, 14310 FilePermissions permissions); 14311 14312-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 14313+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(__MUSL__) 14314 //! \brief Wraps LoggingOpenMemoryFileForWrite(). 14315 //! 14316 //! \return `true` if the operation succeeded, `false` if it failed, with an 14317diff --git a/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.cc b/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.cc 14318index 27f180c6e1..4c2543d991 100644 14319--- a/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.cc 14320+++ b/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.cc 14321@@ -19,7 +19,7 @@ namespace crashpad { 14322 ExceptionHandlerProtocol::ClientInformation::ClientInformation() 14323 : exception_information_address(0), 14324 sanitization_information_address(0) 14325-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 14326+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(__MUSL__) 14327 , crash_loop_before_time(0) 14328 #endif // OS_LINUX || OS_CHROMEOS 14329 {} 14330diff --git a/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.h b/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.h 14331index 60b0b1b7ed..1efd79b495 100644 14332--- a/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.h 14333+++ b/third_party/crashpad/crashpad/util/linux/exception_handler_protocol.h 14334@@ -52,7 +52,7 @@ class ExceptionHandlerProtocol { 14335 //! SanitizationInformation struct, or 0 if there is no such struct. 14336 VMAddress sanitization_information_address; 14337 14338-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 14339+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(__MUSL__) 14340 //! \brief Indicates that the client is likely in a crash loop if a crash 14341 //! occurs before this timestamp. This value is only used by ChromeOS's 14342 //! `/sbin/crash_reporter`. 14343diff --git a/third_party/crashpad/crashpad/util/linux/thread_info.h b/third_party/crashpad/crashpad/util/linux/thread_info.h 14344index 5b55c24a76..c2ad0407ae 100644 14345--- a/third_party/crashpad/crashpad/util/linux/thread_info.h 14346+++ b/third_party/crashpad/crashpad/util/linux/thread_info.h 14347@@ -273,7 +273,7 @@ union FloatContext { 14348 "Size mismatch"); 14349 #elif defined(ARCH_CPU_ARMEL) 14350 static_assert(sizeof(f32_t::fpregs) == sizeof(user_fpregs), "Size mismatch"); 14351-#if !defined(__GLIBC__) 14352+#if !defined(__GLIBC__) && !defined(__MUSL__) 14353 static_assert(sizeof(f32_t::vfp) == sizeof(user_vfp), "Size mismatch"); 14354 #endif 14355 #elif defined(ARCH_CPU_ARM64) 14356diff --git a/third_party/crashpad/crashpad/util/misc/address_types.h b/third_party/crashpad/crashpad/util/misc/address_types.h 14357index 14942bd8ea..31b83e821c 100644 14358--- a/third_party/crashpad/crashpad/util/misc/address_types.h 14359+++ b/third_party/crashpad/crashpad/util/misc/address_types.h 14360@@ -25,7 +25,7 @@ 14361 #include <mach/mach_types.h> 14362 #elif defined(OS_WIN) 14363 #include "util/win/address_types.h" 14364-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14365+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14366 #include "util/linux/address_types.h" 14367 #elif defined(OS_FUCHSIA) 14368 #include <zircon/types.h> 14369@@ -55,7 +55,7 @@ using VMSize = mach_vm_size_t; 14370 using VMAddress = WinVMAddress; 14371 using VMSize = WinVMSize; 14372 14373-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14374+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14375 14376 using VMAddress = LinuxVMAddress; 14377 using VMSize = LinuxVMSize; 14378diff --git a/third_party/crashpad/crashpad/util/misc/capture_context.h b/third_party/crashpad/crashpad/util/misc/capture_context.h 14379index d21a24f19f..2456a937fd 100644 14380--- a/third_party/crashpad/crashpad/util/misc/capture_context.h 14381+++ b/third_party/crashpad/crashpad/util/misc/capture_context.h 14382@@ -21,7 +21,7 @@ 14383 #include <mach/mach.h> 14384 #elif defined(OS_WIN) 14385 #include <windows.h> 14386-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14387+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14388 #include <ucontext.h> 14389 #elif defined(OS_FUCHSIA) 14390 #include <signal.h> 14391@@ -38,7 +38,7 @@ using NativeCPUContext = arm_unified_thread_state; 14392 #elif defined(OS_WIN) 14393 using NativeCPUContext = CONTEXT; 14394 #elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ 14395- defined(OS_FUCHSIA) 14396+ defined(OS_FUCHSIA) || defined(OS_OHOS) 14397 using NativeCPUContext = ucontext_t; 14398 #endif // OS_APPLE 14399 14400diff --git a/third_party/crashpad/crashpad/util/misc/metrics.cc b/third_party/crashpad/crashpad/util/misc/metrics.cc 14401index 4b87f107df..07569de6cb 100644 14402--- a/third_party/crashpad/crashpad/util/misc/metrics.cc 14403+++ b/third_party/crashpad/crashpad/util/misc/metrics.cc 14404@@ -29,6 +29,8 @@ 14405 #define METRICS_OS_NAME "Linux" 14406 #elif defined(OS_FUCHSIA) 14407 #define METRICS_OS_NAME "Fuchsia" 14408+#elif defined(OS_OHOS) 14409+#define METRICS_OS_NAME "Ohos" 14410 #endif 14411 14412 namespace crashpad { 14413diff --git a/third_party/crashpad/crashpad/util/misc/time.h b/third_party/crashpad/crashpad/util/misc/time.h 14414index dc992bdcce..bba90ee10b 100644 14415--- a/third_party/crashpad/crashpad/util/misc/time.h 14416+++ b/third_party/crashpad/crashpad/util/misc/time.h 14417@@ -69,7 +69,7 @@ void GetTimeOfDay(timeval* tv); 14418 14419 #endif // OS_WIN 14420 14421-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || DOXYGEN 14422+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || DOXYGEN || defined(OS_OHOS) 14423 //! \brief Get the kernel boot time. Subsequent calls to this function may 14424 //! return different results due to the system clock being changed or 14425 //! imprecision in measuring the boot time. 14426diff --git a/third_party/crashpad/crashpad/util/misc/uuid.cc b/third_party/crashpad/crashpad/util/misc/uuid.cc 14427index 32ffea5259..432fac3f1c 100644 14428--- a/third_party/crashpad/crashpad/util/misc/uuid.cc 14429+++ b/third_party/crashpad/crashpad/util/misc/uuid.cc 14430@@ -96,7 +96,7 @@ bool UUID::InitializeWithNew() { 14431 InitializeFromBytes(uuid); 14432 return true; 14433 #elif defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 14434- defined(OS_ANDROID) || defined(OS_FUCHSIA) 14435+ defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(OS_OHOS) 14436 // Linux, Android, and Fuchsia do not provide a UUID generator in a 14437 // widely-available system library. On Linux and Android, uuid_generate() 14438 // from libuuid is not available everywhere. 14439diff --git a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc 14440index ba9c25d024..45acb390e7 100644 14441--- a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc 14442+++ b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc 14443@@ -123,7 +123,7 @@ class SSLStream : public Stream { 14444 return false; 14445 } 14446 } else { 14447-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 14448+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(__MUSL__) 14449 if (SSL_CTX_load_verify_locations( 14450 ctx_.get(), nullptr, "/etc/ssl/certs") <= 0) { 14451 LOG(ERROR) << "SSL_CTX_load_verify_locations"; 14452diff --git a/third_party/crashpad/crashpad/util/numeric/checked_address_range.cc b/third_party/crashpad/crashpad/util/numeric/checked_address_range.cc 14453index 4ba7ff3900..cdaae7e800 100644 14454--- a/third_party/crashpad/crashpad/util/numeric/checked_address_range.cc 14455+++ b/third_party/crashpad/crashpad/util/numeric/checked_address_range.cc 14456@@ -22,7 +22,7 @@ 14457 #include <mach/mach.h> 14458 #elif defined(OS_WIN) 14459 #include "util/win/address_types.h" 14460-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14461+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14462 #include "util/linux/address_types.h" 14463 #elif defined(OS_FUCHSIA) 14464 #include <zircon/types.h> 14465@@ -130,7 +130,7 @@ std::string CheckedAddressRangeGeneric<ValueType, SizeType>::AsString() const { 14466 template class CheckedAddressRangeGeneric<mach_vm_address_t, mach_vm_size_t>; 14467 #elif defined(OS_WIN) 14468 template class CheckedAddressRangeGeneric<WinVMAddress, WinVMSize>; 14469-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14470+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14471 template class CheckedAddressRangeGeneric<LinuxVMAddress, LinuxVMSize>; 14472 #elif defined(OS_FUCHSIA) 14473 template class CheckedAddressRangeGeneric<zx_vaddr_t, size_t>; 14474diff --git a/third_party/crashpad/crashpad/util/posix/close_multiple.cc b/third_party/crashpad/crashpad/util/posix/close_multiple.cc 14475index 0c078329b7..f4c68b5536 100644 14476--- a/third_party/crashpad/crashpad/util/posix/close_multiple.cc 14477+++ b/third_party/crashpad/crashpad/util/posix/close_multiple.cc 14478@@ -74,7 +74,7 @@ void CloseNowOrOnExec(int fd, bool ebadf_ok) { 14479 bool CloseMultipleNowOrOnExecUsingFDDir(int min_fd, int preserve_fd) { 14480 #if defined(OS_APPLE) 14481 static constexpr char kFDDir[] = "/dev/fd"; 14482-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14483+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14484 static constexpr char kFDDir[] = "/proc/self/fd"; 14485 #endif 14486 14487@@ -128,14 +128,14 @@ void CloseMultipleNowOrOnExec(int fd, int preserve_fd) { 14488 // bionic/libc/bionic/ndk_cruft.cpp getdtablesize(). 14489 int max_fd = implicit_cast<int>(sysconf(_SC_OPEN_MAX)); 14490 14491-#if !defined(OS_ANDROID) 14492+#if !defined(OS_ANDROID) && !defined(OS_OHOS) 14493 // getdtablesize() was removed effective Android 5.0.0 (API 21). Since it 14494 // returns the same thing as the sysconf() above, just skip it. See 14495 // https://android.googlesource.com/platform/bionic/+/462abab12b074c62c0999859e65d5a32ebb41951. 14496 max_fd = std::max(max_fd, getdtablesize()); 14497 #endif 14498 14499-#if !(defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)) || \ 14500+#if !(defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS)) || \ 14501 defined(OPEN_MAX) 14502 // Linux does not provide OPEN_MAX. See 14503 // https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/include/linux/limits.h?id=77293034696e3e0b6c8b8fc1f96be091104b3d2b. 14504@@ -163,7 +163,7 @@ void CloseMultipleNowOrOnExec(int fd, int preserve_fd) { 14505 } else { 14506 PLOG(WARNING) << "sysctl"; 14507 } 14508-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14509+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14510 // See linux-4.4.27/fs/file.c sysctl_nr_open, referenced by kernel/sys.c 14511 // do_prlimit() and kernel/sysctl.c fs_table. Inability to open this file is 14512 // not considered an error, because /proc may not be available or usable. 14513diff --git a/third_party/crashpad/crashpad/util/posix/drop_privileges.cc b/third_party/crashpad/crashpad/util/posix/drop_privileges.cc 14514index 75650d5a68..9d94f21ebc 100644 14515--- a/third_party/crashpad/crashpad/util/posix/drop_privileges.cc 14516+++ b/third_party/crashpad/crashpad/util/posix/drop_privileges.cc 14517@@ -73,7 +73,7 @@ void DropPrivileges() { 14518 CHECK_EQ(setegid(egid), -1); 14519 } 14520 } 14521-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14522+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14523 PCHECK(setresgid(gid, gid, gid) == 0) << "setresgid"; 14524 PCHECK(setresuid(uid, uid, uid) == 0) << "setresuid"; 14525 14526diff --git a/third_party/crashpad/crashpad/util/posix/process_info.h b/third_party/crashpad/crashpad/util/posix/process_info.h 14527index d144c04b55..b6b0a7e405 100644 14528--- a/third_party/crashpad/crashpad/util/posix/process_info.h 14529+++ b/third_party/crashpad/crashpad/util/posix/process_info.h 14530@@ -33,7 +33,7 @@ 14531 #include <sys/sysctl.h> 14532 #endif 14533 14534-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14535+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14536 #include "util/linux/ptrace_connection.h" 14537 #endif 14538 14539@@ -44,7 +44,7 @@ class ProcessInfo { 14540 ProcessInfo(); 14541 ~ProcessInfo(); 14542 14543-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || DOXYGEN 14544+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || DOXYGEN || defined(OS_OHOS) 14545 //! \brief Initializes this object with information about the process whose ID 14546 //! is \a pid using a PtraceConnection \a connection. 14547 //! 14548@@ -168,7 +168,7 @@ class ProcessInfo { 14549 private: 14550 #if defined(OS_APPLE) 14551 kinfo_proc kern_proc_info_; 14552-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14553+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14554 // Some members are marked mutable so that they can be lazily initialized by 14555 // const methods. These are always InitializationState-protected so that 14556 // multiple successive calls will always produce the same return value and out 14557diff --git a/third_party/crashpad/crashpad/util/posix/symbolic_constants_posix.cc b/third_party/crashpad/crashpad/util/posix/symbolic_constants_posix.cc 14558index c6e0fec77f..116dc723ac 100644 14559--- a/third_party/crashpad/crashpad/util/posix/symbolic_constants_posix.cc 14560+++ b/third_party/crashpad/crashpad/util/posix/symbolic_constants_posix.cc 14561@@ -64,7 +64,7 @@ constexpr const char* kSignalNames[] = { 14562 "INFO", 14563 "USR1", 14564 "USR2", 14565-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14566+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14567 #if defined(ARCH_CPU_MIPS_FAMILY) 14568 "HUP", 14569 "INT", 14570@@ -135,7 +135,7 @@ constexpr const char* kSignalNames[] = { 14571 #endif // defined(ARCH_CPU_MIPS_FAMILY) 14572 #endif 14573 }; 14574-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) 14575+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_OHOS) 14576 // NSIG is 64 to account for real-time signals. 14577 static_assert(base::size(kSignalNames) == 32, "kSignalNames length"); 14578 #else 14579diff --git a/third_party/dawn/scripts/dawn_features.gni b/third_party/dawn/scripts/dawn_features.gni 14580index 8477480c29..d9b6d7f367 100644 14581--- a/third_party/dawn/scripts/dawn_features.gni 14582+++ b/third_party/dawn/scripts/dawn_features.gni 14583@@ -63,7 +63,7 @@ declare_args() { 14584 14585 # Enables the compilation of Dawn's Vulkan backend 14586 dawn_enable_vulkan = is_linux || is_chromeos || is_win || is_fuchsia || 14587- is_android || dawn_use_swiftshader 14588+ is_android || dawn_use_swiftshader || is_ohos 14589 14590 # Enable support WGSL for shaders. 14591 dawn_enable_wgsl = true 14592diff --git a/third_party/dawn/src/common/BUILD.gn b/third_party/dawn/src/common/BUILD.gn 14593index a401a72de3..2293961a8f 100644 14594--- a/third_party/dawn/src/common/BUILD.gn 14595+++ b/third_party/dawn/src/common/BUILD.gn 14596@@ -148,7 +148,7 @@ config("dawn_internal") { 14597 # This GN file is discovered by all Chromium builds, but common doesn't support 14598 # all of Chromium's OSes so we explicitly make the target visible only on 14599 # systems we know Dawn is able to compile on. 14600-if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android) { 14601+if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android || is_ohos) { 14602 static_library("common") { 14603 sources = [ 14604 "Alloc.h", 14605diff --git a/third_party/ffmpeg/BUILD.gn b/third_party/ffmpeg/BUILD.gn 14606index f7f34ea414..cf93c07ded 100755 14607--- a/third_party/ffmpeg/BUILD.gn 14608+++ b/third_party/ffmpeg/BUILD.gn 14609@@ -328,7 +328,7 @@ target(link_target_type, "ffmpeg_internal") { 14610 "-L", 14611 rebase_path(target_gen_dir, root_build_dir), 14612 ] 14613- if (!is_android && !is_fuchsia) { 14614+ if (!is_android && !is_fuchsia && !is_ohos) { 14615 # OS=android requires that both -lz and -lm occur after 14616 # -lc++_shared on the link command line. Android link rules 14617 # already include -lm, and we get -lz as a transitive dependency 14618diff --git a/third_party/ffmpeg/ffmpeg_generated.gni b/third_party/ffmpeg/ffmpeg_generated.gni 14619index 88f513b32c..394efcabd9 100644 14620--- a/third_party/ffmpeg/ffmpeg_generated.gni 14621+++ b/third_party/ffmpeg/ffmpeg_generated.gni 14622@@ -12,9 +12,9 @@ ffmpeg_c_sources = [] 14623 ffmpeg_gas_sources = [] 14624 ffmpeg_asm_sources = [] 14625 14626-use_linux_config = is_linux || is_chromeos || is_fuchsia 14627+use_linux_config = is_linux || is_chromeos || is_fuchsia || use_musl 14628 14629-if ((is_android && current_cpu == "arm" && arm_use_neon) || (is_android && current_cpu == "arm64") || (is_android && current_cpu == "x64") || (is_android && current_cpu == "x86") || (is_mac) || (is_win) || (use_linux_config)) { 14630+if (((is_android || is_ohos) && current_cpu == "arm" && arm_use_neon) || (is_android && current_cpu == "arm64") || (is_android && current_cpu == "x64") || (is_android && current_cpu == "x86") || (is_mac) || (is_win) || (use_linux_config)) { 14631 ffmpeg_c_sources += [ 14632 "libavcodec/ac3_parser.c", 14633 "libavcodec/ac3tab.c", 14634@@ -194,7 +194,7 @@ if ((is_android && current_cpu == "arm" && arm_use_neon) || (is_android && curre 14635 ] 14636 } 14637 14638-if ((is_mac) || (is_win) || (use_linux_config)) { 14639+if ((is_mac) || (is_win) || (use_linux_config) || use_musl) { 14640 ffmpeg_c_sources += [ 14641 "libavcodec/autorename_libavcodec_hpeldsp.c", 14642 "libavcodec/autorename_libavcodec_videodsp.c", 14643@@ -209,7 +209,7 @@ if ((is_mac) || (is_win) || (use_linux_config)) { 14644 ] 14645 } 14646 14647-if ((current_cpu == "arm64" && ffmpeg_branding == "Chrome") || (current_cpu == "x64" && ffmpeg_branding == "Chrome") || (is_android && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (is_android && current_cpu == "x86" && ffmpeg_branding == "Chrome") || (is_mac && ffmpeg_branding == "Chrome") || (is_win && ffmpeg_branding == "Chrome") || (use_linux_config && ffmpeg_branding == "Chrome") || (use_linux_config && ffmpeg_branding == "ChromeOS")) { 14648+if ((current_cpu == "arm64" && ffmpeg_branding == "Chrome") || (current_cpu == "x64" && ffmpeg_branding == "Chrome") || ((is_android || is_ohos) && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (is_android && current_cpu == "x86" && ffmpeg_branding == "Chrome") || (is_mac && ffmpeg_branding == "Chrome") || (is_win && ffmpeg_branding == "Chrome") || (use_linux_config && ffmpeg_branding == "Chrome") || (use_linux_config && ffmpeg_branding == "ChromeOS")) { 14649 ffmpeg_c_sources += [ 14650 "libavcodec/aac_ac3_parser.c", 14651 "libavcodec/aac_parser.c", 14652@@ -291,7 +291,7 @@ if ((is_android && current_cpu == "arm64") || (is_mac && current_cpu == "arm64") 14653 ] 14654 } 14655 14656-if ((is_android && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm")) { 14657+if (((is_android || is_ohos) && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm")) { 14658 ffmpeg_c_sources += [ 14659 "libavcodec/arm/fft_init_arm.c", 14660 "libavcodec/arm/flacdsp_init_arm.c", 14661@@ -356,7 +356,7 @@ if ((current_cpu == "x64" && ffmpeg_branding == "Chrome") || (is_android && curr 14662 ] 14663 } 14664 14665-if ((is_android && current_cpu == "arm" && arm_use_neon) || (is_android && current_cpu == "arm64") || (is_android && current_cpu == "x64") || (is_android && current_cpu == "x86")) { 14666+if (((is_android || is_ohos) && current_cpu == "arm" && arm_use_neon) || (is_android && current_cpu == "arm64") || (is_android && current_cpu == "x64") || (is_android && current_cpu == "x86")) { 14667 ffmpeg_c_sources += [ 14668 "compat/strtod.c", 14669 ] 14670@@ -420,7 +420,7 @@ if (use_linux_config && ffmpeg_branding == "ChromeOS") { 14671 ] 14672 } 14673 14674-if ((use_linux_config && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm")) { 14675+if ((use_linux_config && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm") || (use_musl && current_cpu == "arm")) { 14676 ffmpeg_c_sources += [ 14677 "libavcodec/arm/h264pred_init_arm.c", 14678 "libavcodec/arm/hpeldsp_init_arm.c", 14679@@ -492,14 +492,14 @@ if ((is_mac && current_cpu == "arm64" && ffmpeg_branding == "Chrome") || (is_win 14680 ] 14681 } 14682 14683-if ((is_android && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "ChromeOS") || (use_linux_config && current_cpu == "arm" && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && ffmpeg_branding == "ChromeOS")) { 14684+if (((is_android || is_ohos) && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "ChromeOS") || (use_linux_config && current_cpu == "arm" && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && ffmpeg_branding == "ChromeOS")) { 14685 ffmpeg_c_sources += [ 14686 "libavcodec/arm/aacpsdsp_init_arm.c", 14687 "libavcodec/arm/sbrdsp_init_arm.c", 14688 ] 14689 } 14690 14691-if ((is_android && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm" && arm_use_neon)) { 14692+if (((is_android || is_ohos) && current_cpu == "arm" && arm_use_neon) || (use_linux_config && current_cpu == "arm" && arm_use_neon)) { 14693 ffmpeg_c_sources += [ 14694 "libavutil/arm/float_dsp_init_neon.c", 14695 ] 14696@@ -569,7 +569,7 @@ if (use_linux_config && current_cpu == "arm" && arm_use_neon) { 14697 ] 14698 } 14699 14700-if ((is_android && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "ChromeOS")) { 14701+if (((is_android || is_ohos) && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "Chrome") || (use_linux_config && current_cpu == "arm" && arm_use_neon && ffmpeg_branding == "ChromeOS")) { 14702 ffmpeg_gas_sources += [ 14703 "libavcodec/arm/aacpsdsp_neon.S", 14704 "libavcodec/arm/sbrdsp_neon.S", 14705diff --git a/third_party/ffmpeg/ffmpeg_options.gni b/third_party/ffmpeg/ffmpeg_options.gni 14706index 026e955058..532391358b 100644 14707--- a/third_party/ffmpeg/ffmpeg_options.gni 14708+++ b/third_party/ffmpeg/ffmpeg_options.gni 14709@@ -70,4 +70,8 @@ if ((is_linux || is_chromeos) && is_msan) { 14710 os_config = "linux" 14711 } else if (is_win && !is_clang) { 14712 os_config = "win-msvc" 14713+} else if (is_ohos && !use_musl) { 14714+ os_config = "android" 14715+} else if(use_musl) { 14716+ os_config = "linux" 14717 } 14718diff --git a/third_party/libjpeg_turbo/BUILD.gn b/third_party/libjpeg_turbo/BUILD.gn 14719index 5befffd782..f3cefb6a7b 100644 14720--- a/third_party/libjpeg_turbo/BUILD.gn 14721+++ b/third_party/libjpeg_turbo/BUILD.gn 14722@@ -128,7 +128,7 @@ if (current_cpu == "x86" || current_cpu == "x64") { 14723 } 14724 } else if (is_mac || is_ios) { 14725 defines += [ "MACHO" ] 14726- } else if (is_linux || is_android || is_fuchsia || is_chromeos) { 14727+ } else if (is_linux || is_android || is_fuchsia || is_chromeos || is_ohos) { 14728 defines += [ "ELF" ] 14729 } 14730 } 14731diff --git a/third_party/libsync/src/include/sync/sync.h b/third_party/libsync/src/include/sync/sync.h 14732index 50ed0ac57b..9f0375d71e 100644 14733--- a/third_party/libsync/src/include/sync/sync.h 14734+++ b/third_party/libsync/src/include/sync/sync.h 14735@@ -19,7 +19,17 @@ 14736 #ifndef __SYS_CORE_SYNC_H 14737 #define __SYS_CORE_SYNC_H 14738 14739+#ifdef __MUSL__ 14740+#ifdef __cplusplus 14741+# define __BEGIN_DECLS extern "C" { 14742+# define __END_DECLS } 14743+#else 14744+# define __BEGIN_DECLS 14745+# define __END_DECLS 14746+#endif 14747+#else 14748 #include <sys/cdefs.h> 14749+#endif 14750 #include <stdint.h> 14751 14752 #include <linux/types.h> 14753diff --git a/third_party/libxml/BUILD.gn b/third_party/libxml/BUILD.gn 14754index 2fc10cf03b..c5ebd5aa8a 100644 14755--- a/third_party/libxml/BUILD.gn 14756+++ b/third_party/libxml/BUILD.gn 14757@@ -4,7 +4,7 @@ 14758 14759 # Define an "os_include" variable that points at the OS-specific generated 14760 # headers. These were generated by running the configure script offline. 14761-if (is_linux || is_chromeos || is_android || is_nacl || is_fuchsia) { 14762+if (is_linux || is_chromeos || is_android || is_nacl || is_fuchsia || is_ohos) { 14763 os_include = "linux" 14764 } else if (is_apple) { 14765 os_include = "mac" 14766diff --git a/third_party/libxslt/BUILD.gn b/third_party/libxslt/BUILD.gn 14767index d0254b9f7b..189dd80fe1 100644 14768--- a/third_party/libxslt/BUILD.gn 14769+++ b/third_party/libxslt/BUILD.gn 14770@@ -86,7 +86,7 @@ static_library("libxslt") { 14771 } 14772 14773 cflags = [] 14774- if (is_linux || is_chromeos || is_android || is_fuchsia) { 14775+ if (is_linux || is_chromeos || is_android || is_fuchsia || is_ohos) { 14776 include_dirs = [ "linux" ] 14777 } else if (is_win) { 14778 include_dirs = [ "win32" ] 14779diff --git a/third_party/lss/linux_syscall_support.h b/third_party/lss/linux_syscall_support.h 14780index e4ac22644c..49f65da394 100644 14781--- a/third_party/lss/linux_syscall_support.h 14782+++ b/third_party/lss/linux_syscall_support.h 14783@@ -89,7 +89,7 @@ 14784 #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ 14785 defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ 14786 defined(__aarch64__) || defined(__s390__)) \ 14787- && (defined(__linux) || defined(__ANDROID__)) 14788+ && (defined(__linux) || defined(__ANDROID__) || defined(__MUSL__)) 14789 14790 #ifndef SYS_CPLUSPLUS 14791 #ifdef __cplusplus 14792@@ -4240,7 +4240,7 @@ struct kernel_statfs { 14793 return LSS_NAME(socketcall)(8, d, type, protocol, sv); 14794 } 14795 #endif 14796- #if defined(__NR_fstatat64) 14797+ #if defined(__NR_fstatat64) && !defined(__MUSL__) 14798 LSS_INLINE _syscall4(int, fstatat64, int, d, 14799 const char *, p, 14800 struct kernel_stat64 *, b, int, f) 14801diff --git a/third_party/pdfium/core/fxcrt/cfx_datetime.cpp b/third_party/pdfium/core/fxcrt/cfx_datetime.cpp 14802index fcf9eb0b76..4cf3069ff6 100644 14803--- a/third_party/pdfium/core/fxcrt/cfx_datetime.cpp 14804+++ b/third_party/pdfium/core/fxcrt/cfx_datetime.cpp 14805@@ -11,7 +11,7 @@ 14806 #include "third_party/base/check.h" 14807 14808 #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ 14809- defined(OS_APPLE) || defined(OS_ASMJS) 14810+ defined(OS_APPLE) || defined(OS_ASMJS) || defined(OS_OHOS) 14811 #include <sys/time.h> 14812 #include <time.h> 14813 #endif 14814diff --git a/third_party/pdfium/core/fxge/BUILD.gn b/third_party/pdfium/core/fxge/BUILD.gn 14815index 0ec54f337b..4a272cec66 100644 14816--- a/third_party/pdfium/core/fxge/BUILD.gn 14817+++ b/third_party/pdfium/core/fxge/BUILD.gn 14818@@ -160,7 +160,7 @@ source_set("fxge") { 14819 ] 14820 } 14821 14822- if (is_linux || is_chromeos) { 14823+ if (is_linux || is_chromeos || is_ohos) { 14824 sources += [ "fx_ge_linux.cpp" ] 14825 } 14826 14827diff --git a/third_party/pdfium/core/fxge/fx_ge_linux.cpp b/third_party/pdfium/core/fxge/fx_ge_linux.cpp 14828index bfd43755a2..8308a6e5af 100644 14829--- a/third_party/pdfium/core/fxge/fx_ge_linux.cpp 14830+++ b/third_party/pdfium/core/fxge/fx_ge_linux.cpp 14831@@ -17,7 +17,7 @@ 14832 #include "third_party/base/check.h" 14833 #include "third_party/base/stl_util.h" 14834 14835-#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ASMJS) 14836+#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_ASMJS) && !defined(OS_OHOS) 14837 #error "Included on the wrong platform" 14838 #endif 14839 14840diff --git a/third_party/perfetto/buildtools/BUILD.gn b/third_party/perfetto/buildtools/BUILD.gn 14841index 3e2df10738..cbb2e4df34 100644 14842--- a/third_party/perfetto/buildtools/BUILD.gn 14843+++ b/third_party/perfetto/buildtools/BUILD.gn 14844@@ -74,7 +74,7 @@ config("libunwindstack_config") { 14845 perfetto_isystem_cflag, 14846 rebase_path("android-core/demangle/include", root_build_dir), 14847 ] 14848- if (is_android) { 14849+ if (is_android || is_ohos) { 14850 cflags += [ 14851 perfetto_isystem_cflag, 14852 rebase_path("bionic/libc/include", root_build_dir), 14853@@ -653,7 +653,7 @@ if (use_custom_libcxx) { 14854 ] 14855 14856 # On linux this seems to introduce an unwanted glibc 2.18 dependency. 14857- if (is_android) { 14858+ if (is_android || is_ohos) { 14859 sources += [ "libcxxabi/src/cxa_thread_atexit.cpp" ] 14860 } 14861 configs -= [ 14862@@ -724,7 +724,7 @@ if (use_custom_libcxx) { 14863 "//gn/standalone/sanitizers:sanitizer_options_link_helper", 14864 ] 14865 defines = [ "_LIBCPP_BUILDING_LIBRARY" ] 14866- if ((is_linux || is_android) && (is_asan || is_tsan || is_msan)) { 14867+ if ((is_linux || is_android || is_ohos) && (is_asan || is_tsan || is_msan)) { 14868 # In {a,t,m}san configurations, operator new and operator delete will be 14869 # provided by the sanitizer runtime library. Since libc++ defines these 14870 # symbols with weak linkage, and the *san runtime uses strong linkage, it 14871@@ -794,7 +794,7 @@ source_set("benchmark") { 14872 } 14873 14874 # On Linux/Android use libbacktrace in debug builds for better stacktraces. 14875-if (is_linux || is_android) { 14876+if (is_linux || is_android || is_ohos) { 14877 config("libbacktrace_config") { 14878 visibility = _buildtools_visibility 14879 include_dirs = [ 14880@@ -1019,7 +1019,7 @@ source_set("libunwindstack") { 14881 "android-unwinding/libunwindstack/Symbols.cpp", 14882 "android-unwinding/libunwindstack/Unwinder.cpp", 14883 ] 14884- if (!is_android) { 14885+ if (!is_android && !is_ohos) { 14886 sources += [ 14887 "android-libbase/liblog_symbols.cpp", 14888 "android-libbase/logging.cpp", 14889diff --git a/third_party/perfetto/include/perfetto/base/build_config.h b/third_party/perfetto/include/perfetto/base/build_config.h 14890index bd3623f3df..bca04cf8a0 100644 14891--- a/third_party/perfetto/include/perfetto/base/build_config.h 14892+++ b/third_party/perfetto/include/perfetto/base/build_config.h 14893@@ -24,9 +24,26 @@ 14894 #define PERFETTO_BUILDFLAG(flag) \ 14895 (PERFETTO_BUILDFLAG_CAT(PERFETTO_BUILDFLAG_DEFINE_, flag)()) 14896 14897-#if defined(__ANDROID__) 14898+#if defined(OSOHOS) 14899+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0 14900+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 1 14901+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0 14902+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0 14903+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0 14904+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_IOS() 0 14905+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WASM() 0 14906+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_FUCHSIA() 0 14907+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_NACL() 0 14908+#endif 14909+ 14910+#if defined(__ANDROID__) && !defined(OSOHOS) 14911+#if defined(__MUSL__) 14912+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 0 14913+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 1 14914+#else 14915 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() 1 14916 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() 0 14917+#endif 14918 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_WIN() 0 14919 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_APPLE() 0 14920 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MAC() 0 14921diff --git a/third_party/perfetto/include/perfetto/ext/base/thread_utils.h b/third_party/perfetto/include/perfetto/ext/base/thread_utils.h 14922index fb47d3d5ff..8b53870dba 100644 14923--- a/third_party/perfetto/include/perfetto/ext/base/thread_utils.h 14924+++ b/third_party/perfetto/include/perfetto/ext/base/thread_utils.h 14925@@ -61,6 +61,8 @@ inline bool GetThreadName(std::string& out_result) { 14926 #if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) 14927 if (prctl(PR_GET_NAME, buf) != 0) 14928 return false; 14929+#elif defined(__MUSL__) 14930+ sprintf(buf, "thread_%d", (int) pthread_self()); 14931 #else 14932 if (pthread_getname_np(pthread_self(), buf, sizeof(buf)) != 0) 14933 return false; 14934diff --git a/third_party/protobuf/src/google/protobuf/stubs/common.cc b/third_party/protobuf/src/google/protobuf/stubs/common.cc 14935index 30802b1bb4..af9f47fbfa 100644 14936--- a/third_party/protobuf/src/google/protobuf/stubs/common.cc 14937+++ b/third_party/protobuf/src/google/protobuf/stubs/common.cc 14938@@ -49,7 +49,7 @@ 14939 #else 14940 #error "No suitable threading library available." 14941 #endif 14942-#if defined(__ANDROID__) 14943+#if defined(__ANDROID__) && !defined(OSOHOS) 14944 #include <android/log.h> 14945 #endif 14946 14947@@ -125,7 +125,7 @@ string VersionString(int version) { 14948 14949 namespace internal { 14950 14951-#if defined(__ANDROID__) 14952+#if defined(__ANDROID__) && !defined(OSOHOS) 14953 inline void DefaultLogHandler(LogLevel level, const char* filename, int line, 14954 const string& message) { 14955 if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { 14956diff --git a/third_party/skia/src/ports/skia_ohos/FontConfig_ohos.cpp b/third_party/skia/src/ports/skia_ohos/FontConfig_ohos.cpp 14957new file mode 100644 14958index 0000000000..3011940cfd 14959--- /dev/null 14960+++ b/third_party/skia/src/ports/skia_ohos/FontConfig_ohos.cpp 14961@@ -0,0 +1,1256 @@ 14962+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 14963+// Use of this source code is governed by a BSD-style license that can be 14964+// found in the LICENSE file. 14965+ 14966+#include "FontConfig_ohos.h" 14967+ 14968+#include <dirent.h> 14969+#include <libgen.h> 14970+#include <sys/stat.h> 14971+#include <sys/types.h> 14972+#include <unistd.h> 14973+#include "base/logging.h" 14974+ 14975+#include "include/core/SkFontStyle.h" 14976+#include "include/core/SkString.h" 14977+ 14978+using namespace ErrorCode; 14979+ 14980+static const char* OHOS_DEFAULT_CONFIG = "/system/etc/fontconfig.json"; 14981+ 14982+/*! Constructor 14983+ * \param fontScanner the scanner to get the font information from a font file 14984+ * \param fname the full name of system font configuration document. 14985+ * \n The default value is '/system/etc/fontconfig.json', if fname is given null 14986+ */ 14987+FontConfig_OHOS::FontConfig_OHOS(const SkTypeface_FreeType::Scanner& fontScanner, 14988+ const char* fname) 14989+{ 14990+ int err = parseConfig(fname); 14991+ if (err != NO_ERROR) { 14992+ return; 14993+ } 14994+ scanFonts(fontScanner); 14995+ resetGenericValue(); 14996+ resetFallbackValue(); 14997+} 14998+ 14999+/*! To get the fallbackForMap 15000+ * \return The reference of fallbackForMap 15001+ */ 15002+const FallbackForMap& FontConfig_OHOS::getFallbackForMap() const 15003+{ 15004+ return fallbackForMap; 15005+} 15006+ 15007+/*! To get the fallback set 15008+ * \return The reference of fallbackSet 15009+ */ 15010+const FallbackSet& FontConfig_OHOS::getFallbackSet() const 15011+{ 15012+ return fallbackSet; 15013+} 15014+ 15015+/*! To get the count of font style sets supported in the system 15016+ * \return The count of font style sets in generic family 15017+ */ 15018+int FontConfig_OHOS::getFamilyCount() const 15019+{ 15020+ return genericFamilySet.size(); 15021+} 15022+ 15023+/*! To get the family name of the default font style set 15024+ * \param[out] familyName a pointer of SkString object, to which the family value will be set. 15025+ * \return The count of typeface in this font style set 15026+ * \n Return -1, if there is no any font style set in the system. 15027+ */ 15028+int FontConfig_OHOS::getDefaultFamily(SkString* familyName) const 15029+{ 15030+ return getFamilyName(0, familyName); 15031+} 15032+ 15033+/*! To get the family name of a font style set 15034+ * \param index the index of a font style set in generic family 15035+ * \param[out] familyName a pointer of SkString object, to which the family value will be set 15036+ * \return The count of typeface in the font style set 15037+ * \n Return -1, if the 'index' is out of range 15038+ */ 15039+int FontConfig_OHOS::getFamilyName(int index, SkString* familyName) const 15040+{ 15041+ if (index < 0 || index >= this->getFamilyCount()) { 15042+ if (familyName) { 15043+ familyName->reset(); 15044+ } 15045+ return -1; 15046+ } 15047+ if (familyName) { 15048+ *familyName = genericFamilySet[index]->familyName; 15049+ } 15050+ return genericFamilySet[index]->typefaceSet->size(); 15051+} 15052+ 15053+/*! To get the count of a font style set 15054+ * \param styleIndex the index of a font style set 15055+ * \param isFallback to indicate the font style set is from generic family or fallback family 15056+ * \n false , the font style set is from generic family list 15057+ * \n true, the font style set is from fallback family list 15058+ * \return The count of typeface in the font style set 15059+ */ 15060+int FontConfig_OHOS::getTypefaceCount(int styleIndex, bool isFallback) const 15061+{ 15062+ if (styleIndex < 0) { 15063+ return -1; 15064+ } 15065+ if (isFallback) { 15066+ if ((unsigned int)styleIndex < fallbackSet.size()) { 15067+ return fallbackSet[styleIndex]->typefaceSet->size(); 15068+ } 15069+ } else { 15070+ if ((unsigned int)styleIndex < genericFamilySet.size()) { 15071+ return genericFamilySet[styleIndex]->typefaceSet->size(); 15072+ } 15073+ } 15074+ return -1; 15075+} 15076+ 15077+/*! To get a typeface 15078+ * \param styleIndex the index of a font style set 15079+ * \param index the index of a typeface in its style set 15080+ * \param isFallback false, the font style set is generic 15081+ * \n true, the font style set is fallback 15082+ * \return The pointer of a typeface 15083+ * \n Return null, if 'styleIndex' or 'index' is out of range 15084+ */ 15085+SkTypeface_OHOS* FontConfig_OHOS::getTypeface(int styleIndex, int index, 15086+ bool isFallback) const 15087+{ 15088+ if (styleIndex < 0 || index < 0 || 15089+ (isFallback && (unsigned int)styleIndex >= fallbackSet.size()) || 15090+ (!isFallback && (unsigned int)styleIndex >= genericFamilySet.size())) { 15091+ return nullptr; 15092+ } 15093+ if (isFallback) { 15094+ const TypefaceSet& tpSet = *(fallbackSet[styleIndex]->typefaceSet.get()); 15095+ if ((unsigned int)index < tpSet.size()) { 15096+ return tpSet[index].get(); 15097+ } 15098+ } else { 15099+ const TypefaceSet& tpSet = *(genericFamilySet[styleIndex]->typefaceSet.get()); 15100+ if ((unsigned int)index < tpSet.size()) { 15101+ return tpSet[index].get(); 15102+ } 15103+ } 15104+ return nullptr; 15105+} 15106+ 15107+/*! To get a typeface 15108+ * \param styleIndex the index a font style set 15109+ * \param style the font style to be matching 15110+ * \param isFallback false, the font style set is generic 15111+ * \n true, the font style set is fallback 15112+ * \return An object of typeface whose font style is the closest matching to 'style' 15113+ * \n Return null, if 'styleIndex' is out of range 15114+ */ 15115+SkTypeface_OHOS* FontConfig_OHOS::getTypeface(int styleIndex, const SkFontStyle& style, 15116+ bool isFallback) const 15117+{ 15118+ if (styleIndex < 0 || 15119+ (isFallback && (unsigned int)styleIndex >= fallbackSet.size()) || 15120+ (!isFallback && (unsigned int)styleIndex >= genericFamilySet.size())) { 15121+ return nullptr; 15122+ } 15123+ const TypefaceSet* pSet = nullptr; 15124+ if (isFallback) { 15125+ pSet = fallbackSet[styleIndex]->typefaceSet.get(); 15126+ } else { 15127+ pSet = genericFamilySet[styleIndex]->typefaceSet.get(); 15128+ } 15129+ sk_sp<SkTypeface_OHOS> tp = matchFontStyle(*pSet, style); 15130+ if (tp.get() != nullptr) { 15131+ return tp.get(); 15132+ } 15133+ return nullptr; 15134+} 15135+ 15136+/*! To get the index of a font style set 15137+ * \param familyName the family name of the font style set 15138+ * \n get the index of default font style set, if 'familyName' is null 15139+ * \param[out] isFallback to tell if the family is from generic or fallback to the caller. 15140+ * \n isFallback is false, if the font style is from generic family list 15141+ * \n isFallback is true, if the font style is from fallback family list 15142+ * \return The index of the font style set 15143+ * \n Return -1, if 'familyName' is not found in the system 15144+ */ 15145+int FontConfig_OHOS::getStyleIndex(const char* familyName, bool& isFallback) const 15146+{ 15147+ if (familyName == nullptr) { 15148+ isFallback = false; 15149+ return 0; 15150+ } 15151+ SkString fname(familyName); 15152+ int* p = genericNames.find(fname); 15153+ if (p) { 15154+ isFallback = false; 15155+ return *p; 15156+ } else { 15157+ p = fallbackNames.find(fname); 15158+ if (p) { 15159+ isFallback = true; 15160+ return *p; 15161+ } 15162+ } 15163+ return -1; 15164+} 15165+ 15166+/*! Find the closest matching typeface 15167+ * \param typefaceSet a typeface set belonging to the same font style set 15168+ * \param pattern the font style to be matching 15169+ * \return The typeface object which is the closest matching to 'pattern' 15170+ * \n Return null, if the count of typeface is 0 15171+ */ 15172+sk_sp<SkTypeface_OHOS> FontConfig_OHOS::matchFontStyle(const TypefaceSet& typefaceSet, 15173+ const SkFontStyle& pattern) 15174+{ 15175+ int count = typefaceSet.size(); 15176+ if (count == 0) { 15177+ return nullptr; 15178+ } else if (count == 1) { 15179+ return typefaceSet[0]; 15180+ } 15181+ uint32_t minDiff = 0xFFFFFFFF; 15182+ int index = 0; 15183+ for (int i = 0; i < count; i++) { 15184+ const SkFontStyle& fontStyle = typefaceSet[i]->fontStyle(); 15185+ uint32_t diff = getFontStyleDifference(pattern, fontStyle); 15186+ if (diff < minDiff) { 15187+ minDiff = diff; 15188+ index = i; 15189+ } 15190+ } 15191+ return typefaceSet[index]; 15192+} 15193+ 15194+/*! To get the difference between a font style and the matching font style 15195+ * \param dstStyle the style to be matching 15196+ * \param srcStyle a font style 15197+ * \return The difference value of a specified style with the matching style 15198+ */ 15199+uint32_t FontConfig_OHOS::getFontStyleDifference(const SkFontStyle& dstStyle, 15200+ const SkFontStyle& srcStyle) 15201+{ 15202+ int normalWidth = SkFontStyle::kNormal_Width; 15203+ int dstWidth = dstStyle.width(); 15204+ int srcWidth = srcStyle.width(); 15205+ 15206+ uint32_t widthDiff = 0; 15207+ // The maximum font width is kUltraExpanded_Width i.e. '9'. 15208+ // If dstWidth <= kNormal_Width (5), first check narrower values, then wider values. 15209+ // If dstWidth > kNormal_Width, first check wider values, then narrower values. 15210+ // When dstWidth and srcWidth are at different side of kNormal_Width, 15211+ // the width difference between them should be more than 5 (9/2+1) 15212+ if (dstWidth <= normalWidth) { 15213+ if (srcWidth <= dstWidth) { 15214+ widthDiff = dstWidth - srcWidth; 15215+ } else { 15216+ widthDiff = srcWidth - dstWidth + 5; 15217+ } 15218+ } else { 15219+ if (srcWidth >= dstWidth) { 15220+ widthDiff = srcWidth - dstWidth; 15221+ } else { 15222+ widthDiff = dstWidth - srcWidth + 5; 15223+ } 15224+ } 15225+ 15226+ int diffSlantValue[3][3] = { 15227+ {0, 2, 1}, 15228+ {2, 0, 1}, 15229+ {2, 1, 0} 15230+ }; 15231+ uint32_t slantDiff = diffSlantValue[dstStyle.slant()][srcStyle.slant()]; 15232+ 15233+ int dstWeight = dstStyle.weight(); 15234+ int srcWeight = srcStyle.weight(); 15235+ uint32_t weightDiff = 0; 15236+ // If dstWeight == kNormal_Weight (400), first check kMedium_Weight (500), then smaller values, 15237+ // and then bigger values. 15238+ // If dstWeight == kMedium_Weight, first check kNormal_Weight, then bigger values, and then smaller values. 15239+ // so we set the difference of kNormal_Weight and kMedium_Weight is 50 in order to differ from other cases. 15240+ // If dstWeight < kNormal_Weight, first check smaller values, then bigger values. 15241+ // If dstWeight > kNormal_Weight, first check bigger values, then smaller values. 15242+ // The maximum weight is kExtraBlack_Weight (1000), when dstWeight and srcWeight are at the different 15243+ // side of kNormal_Weight, the weight difference between them should be more than 500 (1000/2) 15244+ if ((dstWeight == SkFontStyle::kNormal_Weight && srcWeight == SkFontStyle::kMedium_Weight) || 15245+ (dstWeight == SkFontStyle::kMedium_Weight && srcWeight == SkFontStyle::kNormal_Weight)) { 15246+ weightDiff = 50; 15247+ } else if (dstWeight <= SkFontStyle::kNormal_Weight) { 15248+ if (srcWeight <= dstWeight) { 15249+ weightDiff = dstWeight - srcWeight; 15250+ } else { 15251+ weightDiff = srcWeight - dstWeight + 500; 15252+ } 15253+ } else if (dstWeight > SkFontStyle::kNormal_Weight) { 15254+ if (srcWeight >= dstWeight) { 15255+ weightDiff = srcWeight - dstWeight; 15256+ } else { 15257+ weightDiff = dstWeight - srcWeight + 500; 15258+ } 15259+ } 15260+ // The first 2 bytes to save weight difference, the third byte to save slant difference, 15261+ // and the fourth byte to save width difference 15262+ uint32_t diff = (widthDiff << 24) + (slantDiff << 16) + weightDiff; 15263+ return diff; 15264+} 15265+ 15266+/*! To get the data of font configuration file 15267+ * \param fname the full name of the font configuration file 15268+ * \param[out] size the size of data returned to the caller 15269+ * \return The pointer of content of the file 15270+ * \note The returned pointer should be freed by the caller 15271+ */ 15272+char* FontConfig_OHOS::getFileData(const char* fname, int& size) 15273+{ 15274+ FILE* fp = fopen(fname, "r"); 15275+ if (fp == nullptr) { 15276+ return nullptr; 15277+ } 15278+ fseek(fp, 0L, SEEK_END); 15279+ size = ftell(fp) + 1; 15280+ rewind(fp); 15281+ void* data = malloc(size); 15282+ if (data == nullptr) { 15283+ fclose(fp); 15284+ return nullptr; 15285+ } 15286+ memset(data, 0, size); 15287+ (void) fread(data, size, 1, fp); 15288+ fclose(fp); 15289+ return (char*)data; 15290+} 15291+ 15292+/*! parse the system font configuration document 15293+ * \param fname the full name of the font configuration document 15294+ * \return NO_ERROR successful 15295+ * \return ERROR_CONFIG_NOT_FOUND config document is not found 15296+ * \return ERROR_CONFIG_FORMAT_NOT_SUPPORTED config document format is not supported 15297+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE wrong type of value in the configuration 15298+ */ 15299+ 15300+int FontConfig_OHOS::parseConfig(const char* fname) 15301+{ 15302+ if (fname == nullptr) { 15303+ fname = OHOS_DEFAULT_CONFIG; 15304+ } 15305+ Json::Value root; 15306+ int err = checkConfigFile(fname, root); 15307+ if (err != NO_ERROR) { 15308+ return err; 15309+ } 15310+ // "fontdir" - optional, the data type should be string 15311+ const char* key = "fontdir"; 15312+ if (root.isMember(key)) { 15313+ if (root[key].isArray()) { 15314+ parseFontDir(root[key]); 15315+ } else { 15316+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key); 15317+ } 15318+ } 15319+ // "generic", "fallback" - necessary, the data type should be array 15320+ const char* keys[] = {"generic", "fallback", nullptr}; 15321+ int index = 0; 15322+ 15323+ while (true) { 15324+ if (keys[index] == nullptr) { 15325+ break; 15326+ } 15327+ key = keys[index++]; 15328+ if (!root.isMember(key)) { 15329+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, key); 15330+ } else if (!root[key].isArray()) { 15331+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::arrayValue, root[key].type()); 15332+ } 15333+ const Json::Value& arr = root[key]; 15334+ for (unsigned int i = 0; i < arr.size(); i++) { 15335+ if (arr[i].isObject()) { 15336+ if (!strcmp(key, "generic")) { 15337+ parseGeneric(arr[i]); 15338+ } else if (!strcmp(key, "fallback")) { 15339+ parseFallback(arr[i]); 15340+ } 15341+ } else { 15342+ SkString errKey; 15343+ errKey.appendf("%s#%d", key, i + 1); 15344+ (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, errKey.c_str(), 15345+ Json::objectValue, arr[i].type()); 15346+ } 15347+ } 15348+ } 15349+ root.clear(); 15350+ return NO_ERROR; 15351+} 15352+ 15353+/*! check the system font configuration document 15354+ * \param fname the full name of the font configuration document 15355+ * \return NO_ERROR successful 15356+ * \return ERROR_CONFIG_NOT_FOUND config document is not found 15357+ * \return ERROR_CONFIG_FORMAT_NOT_SUPPORTED config document format is not supported 15358+ */ 15359+int FontConfig_OHOS::checkConfigFile(const char* fname, Json::Value& root) 15360+{ 15361+ int size = 0; 15362+ char* data = getFileData(fname, size); 15363+ if (data == nullptr) { 15364+ return logErrInfo(ERROR_CONFIG_NOT_FOUND, fname); 15365+ } 15366+ JSONCPP_STRING errs; 15367+ Json::CharReaderBuilder charReaderBuilder; 15368+ std::unique_ptr<Json::CharReader> jsonReader(charReaderBuilder.newCharReader()); 15369+ bool isJson = jsonReader->parse(data, data + size, &root, &errs); 15370+ free((void*)data); 15371+ data = nullptr; 15372+ 15373+ if (!isJson || !errs.empty()) { 15374+ return logErrInfo(ERROR_CONFIG_FORMAT_NOT_SUPPORTED, fname); 15375+ } 15376+ return NO_ERROR; 15377+} 15378+#if ENABLE_DEBUG 15379+/*! To print out the font information 15380+ * \param font the font object to be printed 15381+ */ 15382+void FontConfig_OHOS::dumpFont(const FontInfo& font) const 15383+{ 15384+ LOGI("name=%s, family=%s, weight=%d, width=%d, slant=%d, index=%d, stream=%p\n", 15385+ font.fname.c_str(), font.familyName.c_str(), font.style.weight(), font.style.width(), font.style.slant(), 15386+ font.index, font.stream.get()); 15387+ int count = font.axisSet.axis.size(); 15388+ if (count > 0) { 15389+ SkString str; 15390+ for (unsigned int i = 0; i < count; i++) { 15391+ str.appendU32(SkFixedFloorToInt(font.axisSet.axis[i])); 15392+ if (i < count - 1) { 15393+ str.append(","); 15394+ } 15395+ } 15396+ LOGI("axis={%s}\n", str.c_str()); 15397+ } 15398+} 15399+ 15400+/*! To print out the information of generic font style set 15401+ */ 15402+void FontConfig_OHOS::dumpGeneric() const 15403+{ 15404+ LOGI("\n"); 15405+ for (unsigned int i = 0; i < genericFamilySet.size(); i++) { 15406+ LOGI("[%d] familyName : %s - %d\n", i, genericFamilySet[i]->familyName.c_str(), 15407+ static_cast<int>(genericFamilySet[i]->typefaceSet->size())); 15408+ for (int j = 0; j < genericFamilySet[i]->typefaceSet->size(); j++) { 15409+ if ((*(genericFamilySet[i]->typefaceSet))[j].get()) { 15410+ const FontInfo* font = (*(genericFamilySet[i]->typefaceSet))[j]->getFontInfo(); 15411+ if (font) { 15412+ dumpFont(*font); 15413+ } else { 15414+ LOGE("font [%d] is null\n", j); 15415+ } 15416+ } else { 15417+ LOGE("typefeace [%d] is null\n", j); 15418+ } 15419+ } 15420+ } 15421+} 15422+ 15423+/*! To print out the information of fallback font style set 15424+ */ 15425+void FontConfig_OHOS::dumpFallback() const 15426+{ 15427+ LOGI("\n"); 15428+ int count = 0; 15429+ fallbackForMap.foreach([this, &count](const SkString& key, 15430+ const FallbackSetPos& setIndex) { 15431+ LOGI("[%d] family : %s - %d\n", count++, key.c_str(), setIndex.count); 15432+ for (unsigned int i = setIndex.index; i < setIndex.index + setIndex.count; i++) { 15433+ const TypefaceSet& tpSet = *(fallbackSet[i]->typefaceSet.get()); 15434+ LOGI("[%s] - %d\n", fallbackSet[i]->familyName.c_str(), static_cast<int>(tpSet.size())); 15435+ 15436+ for (unsigned int j = 0; j < tpSet.size(); j++) { 15437+ const FontInfo* font = tpSet[j]->getFontInfo(); 15438+ if (font) { 15439+ this->dumpFont(*font); 15440+ } else { 15441+ LOGE("font [%d] is null\n", j); 15442+ } 15443+ } 15444+ } 15445+ }); 15446+} 15447+#endif 15448+ 15449+/*! To parse 'fontdir' attribute 15450+ * \param root the root node of 'fontdir' 15451+ * \return NO_ERROR successful 15452+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type 15453+ */ 15454+int FontConfig_OHOS::parseFontDir(const Json::Value& root) 15455+{ 15456+ for (unsigned int i = 0; i < root.size(); i++) { 15457+ if (root[i].isString()) { 15458+ const char* dir = root[i].asCString(); 15459+ fontDirSet.emplace_back(SkString(dir)); 15460+ } else { 15461+ SkString text; 15462+ text.appendf("fontdir#%d", i + 1); 15463+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, text.c_str(), Json::stringValue, root[i].type()); 15464+ } 15465+ } 15466+ return NO_ERROR; 15467+} 15468+ 15469+/*! To parse an item of 'generic' family 15470+ * \param root the root node of an item in 'generic' list 15471+ * \return NO_ERROR successful 15472+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type for an attribute 15473+ * \return ERROR_CONFIG_MISSING_TAG missing tag of 'family' or 'alias' 15474+ */ 15475+int FontConfig_OHOS::parseGeneric(const Json::Value& root) 15476+{ 15477+ // "family" - necessary, the data type should be String 15478+ const char* key = "family"; 15479+ if (!root.isMember(key)) { 15480+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, key); 15481+ } else if (!root[key].isString()) { 15482+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::stringValue, root[key].type()); 15483+ } 15484+ SkString familyName = SkString(root[key].asCString()); 15485+ // "alias" - necessary, the data type should be Array 15486+ if (!root.isMember("alias")) { 15487+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, "alias"); 15488+ } 15489+ // "adjust", "variation" - optional 15490+ const char* tags[] = {"alias", "adjust", "variations", "index"}; 15491+ std::vector<AliasInfo> aliasSet; 15492+ std::vector<AdjustInfo> adjustSet; 15493+ std::vector<VariationInfo> variationSet; 15494+ for (unsigned int i = 0; i < sizeof(tags) / sizeof(char*); i++) { 15495+ key = tags[i]; 15496+ if (!root.isMember(key)) { 15497+ continue; 15498+ } 15499+ if (root[key].isArray()) { 15500+ if (!strcmp(key, "index")) { 15501+ parseTtcIndex(root[key], familyName); 15502+ continue; 15503+ } 15504+ const Json::Value& arr = root[key]; 15505+ for (unsigned int j = 0; j < arr.size(); j++) { 15506+ if (arr[j].isObject()) { 15507+ if (!strcmp(key, "alias")) { 15508+ parseAlias(arr[j], aliasSet); 15509+ } else if (!strcmp(key, "adjust")) { 15510+ parseAdjust(arr[j], adjustSet); 15511+ } else { 15512+ parseVariation(arr[j], variationSet); 15513+ } 15514+ } else { 15515+ SkString text; 15516+ text.appendf("%s#%d", key, j + 1); 15517+ (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, text.c_str(), Json::objectValue, 15518+ arr[j].type()); 15519+ } 15520+ } 15521+ } else { 15522+ (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::arrayValue, root[key].type()); 15523+ } 15524+ if (root.size() == 2) { 15525+ break; 15526+ } 15527+ } 15528+ if (aliasSet.size()) { 15529+ aliasMap.set(SkString(familyName), aliasSet); 15530+ } 15531+ if (adjustSet.size()) { 15532+ adjustMap.set(SkString(familyName), adjustSet); 15533+ } 15534+ if (variationSet.size()) { 15535+ variationMap.set(SkString(familyName), variationSet); 15536+ } 15537+ return NO_ERROR; 15538+} 15539+ 15540+/*! To parse an item of 'alias' attribute 15541+ * \param root the root node of an item in an 'alias' list 15542+ * \param[out] aliasSet the value of AliasInfo will be written to and returned to the caller 15543+ * \return NO_ERROR successful 15544+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type for an attribute 15545+ * \return ERROR_CONFIG_MISSING_TAG missing tag of alias name 15546+ */ 15547+int FontConfig_OHOS::parseAlias(const Json::Value& root, std::vector<AliasInfo>& aliasSet) 15548+{ 15549+ if (root.empty()) { 15550+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, "generic-alias-name"); 15551+ } 15552+ Json::Value::Members members = root.getMemberNames(); 15553+ const char* key = members[0].c_str(); 15554+ if (!root[key].isInt()) { 15555+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, "generic-alias-weight", 15556+ Json::intValue, root[key].type()); 15557+ } 15558+ 15559+ SkString aliasName = SkString(key); 15560+ int weight = root[key].asInt(); 15561+ std::unique_ptr<GenericFamily> genericFamily = std::make_unique<GenericFamily>(); 15562+ genericFamily->familyName = SkString(key); 15563+ if (aliasSet.size() == 0 || weight > 0) { 15564+ genericFamily->typefaceSet = std::make_shared<TypefaceSet>(); 15565+ } else { 15566+ int index = aliasSet[0].pos; 15567+ genericFamily->typefaceSet = genericFamilySet[index]->typefaceSet; 15568+ } 15569+ genericNames.set(SkString(genericFamily->familyName), genericFamilySet.size()); 15570+ 15571+ AliasInfo info = {static_cast<int>(genericFamilySet.size()), weight}; 15572+ aliasSet.emplace_back(std::move(info)); 15573+ genericFamilySet.emplace_back(std::move(genericFamily)); 15574+ return NO_ERROR; 15575+} 15576+ 15577+/*! To parse an item of 'adjust' attribute 15578+ * \param root the root node of an item in an 'adjust' list 15579+ * \param[out] adjustSet the value of AdjustInfo will be written to and returned to the caller 15580+ * \return NO_ERROR successful 15581+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type for an attribute 15582+ * \return ERROR_CONFIG_MISSING_TAG missing tag of 'weight' or 'to' 15583+ */ 15584+int FontConfig_OHOS::parseAdjust(const Json::Value& root, std::vector<AdjustInfo>& adjustSet) 15585+{ 15586+ const char* tags[] = {"weight", "to"}; 15587+ int values[2]; // value[0] - to save 'weight', value[1] - to save 'to' 15588+ for (unsigned int i = 0; i < sizeof(tags) / sizeof(char*); i++) { 15589+ const char* key = tags[i]; 15590+ if (!root.isMember(key)) { 15591+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, key); 15592+ } else if (!root[key].isInt()) { 15593+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, 15594+ Json::intValue, root[key].type()); 15595+ } else { 15596+ values[i] = root[key].asInt(); 15597+ } 15598+ } 15599+ AdjustInfo info = {values[0], values[1]}; 15600+ adjustSet.push_back(info); 15601+ return NO_ERROR; 15602+} 15603+ 15604+/*! To parse an item of 'fallback' attribute 15605+ * \param root the root node of an item in 'fallback' list 15606+ * \return NO_ERROR successful 15607+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type for an attribute 15608+ * \return ERROR_CONFIG_MISSING_TAG missing tag of fallbackFor 15609+ */ 15610+int FontConfig_OHOS::parseFallback(const Json::Value& root) 15611+{ 15612+ if (root.empty()) { 15613+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, "fallback-fallbackFor"); 15614+ } 15615+ Json::Value::Members members = root.getMemberNames(); 15616+ const char* key = members[0].c_str(); 15617+ if (!root[key].isArray()) { 15618+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, "fallback-items", 15619+ Json::arrayValue, root[key].type()); 15620+ } 15621+ unsigned int startPos = fallbackSet.size(); 15622+ SkString fallbackFor = SkString(key); 15623+ const Json::Value& fallbackArr = root[key]; 15624+ for (unsigned int i = 0; i < fallbackArr.size(); i++) { 15625+ if (!fallbackArr[i].isObject()) { 15626+ SkString text; 15627+ text.appendf("fallback-%s#%d", key, i + 1); 15628+ (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, text.c_str(), Json::objectValue, 15629+ fallbackArr[i].type()); 15630+ continue; 15631+ } 15632+ parseFallbackItem(fallbackArr[i]); 15633+ } 15634+ FallbackSetPos setPos = {startPos, (unsigned int)(fallbackSet.size() - startPos)}; 15635+ fallbackForMap.set(fallbackFor, setPos); 15636+ return NO_ERROR; 15637+} 15638+ 15639+/*! To parse an item of fallback family 15640+ * \param root the root node of a fallback item 15641+ * \return NO_ERROR successful 15642+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type for an attribute 15643+ * \return ERROR_CONFIG_MISSING_TAG missing tag of language 15644+ */ 15645+int FontConfig_OHOS::parseFallbackItem(const Json::Value& root) 15646+{ 15647+ if (root.empty()) { 15648+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, "fallback-item-lang"); 15649+ } 15650+ Json::Value::Members members = root.getMemberNames(); 15651+ const char* key = nullptr; 15652+ bool hasIndex = false; 15653+ bool hasVariations = false; 15654+ for (unsigned int i = 0; i < members.size(); i++) { 15655+ if (members[i] == "variations") { 15656+ hasVariations = true; 15657+ } else if (members[i] == "index") { 15658+ hasIndex = true; 15659+ } else { 15660+ key = members[i].c_str(); 15661+ } 15662+ } 15663+ if (key == nullptr) { 15664+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, "fallback-item-lang"); 15665+ } 15666+ if (!root[key].isString()) { 15667+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, "fallback-item-family", 15668+ Json::stringValue, root[key].type()); 15669+ } 15670+ SkString lang = SkString(key); 15671+ SkString familyName = SkString(root[key].asCString()); 15672+ if (hasVariations) { 15673+ key = "variations"; 15674+ if (root[key].isArray()) { 15675+ const Json::Value& varArr = root[key]; 15676+ std::vector<VariationInfo> variationSet; 15677+ for (unsigned int i = 0; i < varArr.size(); i++) { 15678+ if (varArr[i].isObject()) { 15679+ parseVariation(varArr[i], variationSet); 15680+ } else { 15681+ SkString text = SkString("variations#"); 15682+ text.appendU32(i + 1); 15683+ (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, text.c_str(), 15684+ Json::objectValue, varArr[i].type()); 15685+ } 15686+ } 15687+ if (variationSet.size()) { 15688+ variationMap.set(SkString(familyName), variationSet); 15689+ } 15690+ } else { 15691+ (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::arrayValue, 15692+ root[key].type()); 15693+ } 15694+ } 15695+ if (hasIndex) { 15696+ key = "index"; 15697+ if (root[key].isArray()) { 15698+ parseTtcIndex(root[key], familyName); 15699+ } else { 15700+ (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::arrayValue, root[key].type()); 15701+ } 15702+ } 15703+ std::unique_ptr<FallbackInfo> fallback = std::make_unique<FallbackInfo>(); 15704+ fallback->familyName = familyName; 15705+ fallback->langs = lang; 15706+ fallback->typefaceSet = std::make_shared<TypefaceSet>(); 15707+ fallbackNames.set(SkString(familyName), fallbackSet.size()); 15708+ fallbackSet.emplace_back(std::move(fallback)); 15709+ return NO_ERROR; 15710+} 15711+ 15712+/*! To parse an item of 'variations' attribute 15713+ * \param root the root node of an item in 'variations' list 15714+ * \param[out] variationSet the value of VariationInfo is written to and returned to the caller 15715+ * \return NO_ERROR successful 15716+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type for an attribute 15717+ * \return ERROR_CONFIG_MISSING_TAG missing tag of 'weight' or 'wght' 15718+ */ 15719+int FontConfig_OHOS::parseVariation(const Json::Value& root, std::vector<VariationInfo>& variationSet) 15720+{ 15721+ const char* key = nullptr; 15722+ const char* tags[] = {"wght", "wdth", "slnt", "weight", "width", "slant"}; 15723+ VariationInfo info; 15724+ for (unsigned int i = 0; i < sizeof(tags) / sizeof(char*); i++) { 15725+ key = tags[i]; 15726+ if ((!strcmp(key, "wght") || !strcmp(key, "weight")) && 15727+ !root.isMember(key)) { 15728+ return logErrInfo(ERROR_CONFIG_MISSING_TAG, key); 15729+ } 15730+ if (!root.isMember(key)) { 15731+ continue; 15732+ } 15733+ if (!strcmp(key, "weight")) { 15734+ if (root[key].isInt()) { 15735+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::intValue, root[key].type()); 15736+ } 15737+ info.weight = root[key].asInt(); 15738+ } else if (!strcmp(key, "width")) { 15739+ if (!root[key].isInt()) { 15740+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::intValue, root[key].type()); 15741+ } 15742+ info.width = root[key].asInt(); 15743+ } else if (!strcmp(key, "slant")) { 15744+ if (!root[key].isString()) { 15745+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::stringValue, root[key].type()); 15746+ } 15747+ const char* str = root[key].asCString(); 15748+ if (!strcmp(str, "normal")) { 15749+ info.slant = static_cast<int>(SkFontStyle::kUpright_Slant); 15750+ } else if (!strcmp(str, "italic")) { 15751+ info.slant = static_cast<int>(SkFontStyle::kItalic_Slant); 15752+ } else if (!strcmp(str, "oblique")) { 15753+ info.slant = static_cast<int>(SkFontStyle::kOblique_Slant); 15754+ } 15755+ } else { 15756+ if (!root[key].isNumeric()) { 15757+ return logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, key, Json::realValue, root[key].type()); 15758+ } 15759+ Coordinate axis; 15760+ axis.axis = SkSetFourByteTag(key[0], key[1], key[2], key[3]); 15761+ axis.value = root[key].asFloat(); 15762+ info.axis.emplace_back(axis); 15763+ } 15764+ } 15765+ variationSet.emplace_back(info); 15766+ return NO_ERROR; 15767+} 15768+ 15769+/*! To parse 'index' attribute 15770+ * \param root the root node of 'index' attribute 15771+ * \param familyName the name of the family which the root node belongs to 15772+ * \return NO_ERROR successful 15773+ * \return ERROR_CONFIG_INVALID_VALUE_TYPE invalid value type for an attribute 15774+ */ 15775+int FontConfig_OHOS::parseTtcIndex(const Json::Value& root, const SkString& familyName) 15776+{ 15777+ unsigned int keyCount = 2; // the value of 'index' is an array with 2 items. 15778+ if (root.size() == keyCount && root[0].isString() && root[1].isNumeric()) { 15779+ TtcIndexInfo item = { SkString(root[0].asCString()), root[1].asInt() }; 15780+ if (item.ttcIndex != 0 && ttcIndexMap.find(item.familyName) == nullptr) { 15781+ ttcIndexMap.set(SkString(item.familyName), {SkString(item.familyName), 0}); 15782+ } 15783+ ttcIndexMap.set(SkString(familyName), item); 15784+ } else { 15785+ int ret = ERROR_CONFIG_INVALID_VALUE_TYPE; 15786+ SkString text; 15787+ const char* key = "index"; 15788+ if (root.size() != keyCount) { 15789+ text.appendf("%s#0", key); 15790+ errSet.emplace_back(ret, text.c_str()); 15791+ LOGE("%s : '%s' size should be 2, but here it's %d\n", errToString(ret), key, root.size()); 15792+ return ret; 15793+ } else if (!root[0].isString()) { 15794+ text.appendf("%s#1", key); 15795+ return logErrInfo(ret, text.c_str(), Json::stringValue, root[0].type()); 15796+ } else { 15797+ text.appendf("%s#2", key); 15798+ return logErrInfo(ret, text.c_str(), Json::intValue, root[1].type()); 15799+ } 15800+ } 15801+ return NO_ERROR; 15802+} 15803+ 15804+/*! To get the axis value and set to 'font' 15805+ * \param axisDefs the axis ranges of a font 15806+ * \param variation the variation data from which axis values are generated 15807+ * \param[out] font the axis values will be written to and returned to the caller 15808+ */ 15809+void FontConfig_OHOS::getAxisValues(const AxisDefinitions& axisDefs, 15810+ const VariationInfo& variation, FontInfo& font) const 15811+{ 15812+ SkFontArguments::VariationPosition position; 15813+ position.coordinateCount = variation.axis.size(); 15814+ position.coordinates = variation.axis.data(); 15815+ 15816+ int count = axisDefs.count(); 15817+ SkFixed axisValues[count]; 15818+ SkTypeface_FreeType::Scanner::computeAxisValues(axisDefs, position, 15819+ axisValues, font.familyName); 15820+ font.axisSet.axis.clear(); 15821+ font.axisSet.range.clear(); 15822+ for (int i = 0; i < count; i++) { 15823+ font.axisSet.axis.emplace_back(axisValues[i]); 15824+ font.axisSet.range.emplace_back(axisDefs[i]); 15825+ } 15826+} 15827+ 15828+/*! To insert a ttc font into a font style set 15829+ * \param count the count of typeface in a ttc font 15830+ * \param font an object of the FontInfo with font information 15831+ * \return true, if the font is a ttc font and added to corresponding font style set 15832+ * \return false, if the font is not a ttc font 15833+ */ 15834+bool FontConfig_OHOS::insertTtcFont(int count, FontInfo& font) 15835+{ 15836+ bool ret = false; 15837+ ttcIndexMap.foreach([this, count, &font, &ret] 15838+ (const SkString& familyName, TtcIndexInfo* info) { 15839+ if (info->familyName == font.familyName && info->ttcIndex < count) { 15840+ SkString specifiedName; 15841+ TypefaceSet* tpSet = this->getTypefaceSet(familyName, specifiedName); 15842+ if (tpSet) { 15843+ FontInfo newFont(font); 15844+ newFont.familyName = familyName; 15845+ newFont.index = info->ttcIndex; 15846+ sk_sp<SkTypeface_OHOS> typeface = sk_make_sp<SkTypeface_OHOS>(specifiedName, newFont); 15847+ tpSet->push_back(std::move(typeface)); 15848+ ret = true; 15849+ } 15850+ } 15851+ }); 15852+ return ret; 15853+} 15854+ 15855+/*! To insert a variable font into a font style set 15856+ * \param axisDefs the axis ranges of a variable font 15857+ * \param font an object of the FontInfo with font information 15858+ * \return true, if the font is a variable and some typefaces are added to the corresponding font style set 15859+ * \return false, if the font is not variable 15860+ */ 15861+bool FontConfig_OHOS::insertVariableFont(const AxisDefinitions& axisDefs, FontInfo& font) 15862+{ 15863+ const SkString& key = font.familyName; 15864+ if (variationMap.find(key) == nullptr || axisDefs.count() == 0) { 15865+ return false; 15866+ } 15867+ SkString specifiedName; 15868+ TypefaceSet* tpSet = getTypefaceSet(key, specifiedName); 15869+ if (tpSet == nullptr) { 15870+ return false; 15871+ } 15872+ const std::vector<VariationInfo>& variationSet = *(variationMap.find(key)); 15873+ for (unsigned int i = 0; i < variationSet.size(); i++) { 15874+ FontInfo newFont(font); 15875+ getAxisValues(axisDefs, variationSet[i], newFont); 15876+ int width = font.style.width(); 15877+ SkFontStyle::Slant slant = font.style.slant(); 15878+ if (variationSet[i].width != -1) { 15879+ width = variationSet[i].width; 15880+ } 15881+ if (variationSet[i].slant != -1) { 15882+ slant = (SkFontStyle::Slant) variationSet[i].slant; 15883+ } 15884+ newFont.style = SkFontStyle(variationSet[i].weight, width, slant); 15885+ sk_sp<SkTypeface_OHOS> typeface = sk_make_sp<SkTypeface_OHOS>(specifiedName, newFont); 15886+ tpSet->push_back(std::move(typeface)); 15887+ } 15888+ return true; 15889+} 15890+ 15891+/*! To get the typeface set of a font style set 15892+ * \param familyName the family name of a font style set 15893+ * \param[out] specifiedName the specified family name of a font style set returned to the caller 15894+ * \return The object of typeface set 15895+ * \n Return null, if the family name is not found in the system 15896+ */ 15897+TypefaceSet* FontConfig_OHOS::getTypefaceSet(const SkString& familyName, 15898+ SkString& specifiedName) const 15899+{ 15900+ if (aliasMap.find(familyName) != nullptr) { 15901+ const std::vector<AliasInfo>& aliasSet = *(aliasMap.find(familyName)); 15902+ if (aliasSet.size()) { 15903+ int index = aliasSet[0].pos; 15904+ specifiedName = genericFamilySet[index]->familyName; 15905+ return genericFamilySet[index]->typefaceSet.get(); 15906+ } 15907+ } else if (fallbackNames.find(familyName) != nullptr) { 15908+ int index = *(fallbackNames.find(familyName)); 15909+ return fallbackSet[index]->typefaceSet.get(); 15910+ } 15911+ return nullptr; 15912+} 15913+ 15914+/*! To load font information from a font file 15915+ * \param scanner a scanner used to parse the font file 15916+ * \param fname the full name of a font file 15917+ * \return NO_ERROR successful 15918+ * \return ERROR_FONT_NOT_EXIST font file is not exist 15919+ * \return ERROR_FONT_INVALID_STREAM the stream is not recognized 15920+ */ 15921+int FontConfig_OHOS::loadFont(const SkTypeface_FreeType::Scanner& scanner, const char* fname) 15922+{ 15923+ std::unique_ptr<SkStreamAsset> stream = SkStream::MakeFromFile(fname); 15924+ int count = 1; 15925+ SkTypeface_FreeType::Scanner::AxisDefinitions axisDefs; 15926+ FontInfo font(fname, 0); 15927+ if (stream == nullptr || 15928+ scanner.recognizedFont(stream.get(), &count) == false || 15929+ scanner.scanFont(stream.get(), 0, &font.familyName, &font.style, 15930+ &font.isFixedWidth, &axisDefs) == false) { 15931+ int err = NO_ERROR; 15932+ if (stream == nullptr) { 15933+ err = ERROR_FONT_NOT_EXIST; 15934+ } else { 15935+ err = ERROR_FONT_INVALID_STREAM; 15936+ } 15937+ LOGE("%s : %s\n", errToString(err), fname); 15938+ char* fnameCopy = strdup(fname); 15939+ errSet.emplace_back(err, basename(fnameCopy)); 15940+ free(fnameCopy); 15941+ return err; 15942+ } 15943+ // for adjustMap - update weight 15944+ if (adjustMap.find(font.familyName) != nullptr) { 15945+ const std::vector<AdjustInfo> adjustSet = *(adjustMap.find(font.familyName)); 15946+ for (unsigned int i = 0; i < adjustSet.size(); i++) { 15947+ if (font.style.weight() == adjustSet[i].origValue) { 15948+ font.style = SkFontStyle(adjustSet[i].newValue, font.style.width(), font.style.slant()); 15949+ break; 15950+ } 15951+ } 15952+ } 15953+ bool ret = false; 15954+ if (count > 1) { 15955+ ret = insertTtcFont(count, font); 15956+ } else if (axisDefs.count() > 0) { 15957+ ret = insertVariableFont(axisDefs, font); 15958+ } 15959+ if (!ret) { 15960+ SkString specifiedName; 15961+ TypefaceSet* tpSet = getTypefaceSet(font.familyName, specifiedName); 15962+ if (tpSet) { 15963+ sk_sp<SkTypeface_OHOS> typeface = sk_make_sp<SkTypeface_OHOS>(specifiedName, font); 15964+ tpSet->push_back(std::move(typeface)); 15965+ } 15966+ } 15967+ return NO_ERROR; 15968+} 15969+ 15970+/*! To scan the system font directories 15971+ * \param fontScanner the scanner used to parse a font file 15972+ * \return NO_ERROR success 15973+ * \return ERROR_DIR_NOT_FOUND a font directory is not exist 15974+ */ 15975+int FontConfig_OHOS::scanFonts(const SkTypeface_FreeType::Scanner& fontScanner) 15976+{ 15977+ int err = NO_ERROR; 15978+ if (fontDirSet.size() == 0) { 15979+ fontDirSet.emplace_back(SkString("/system/fonts/")); 15980+ } 15981+ for (unsigned int i = 0; i < fontDirSet.size(); i++) { 15982+ DIR* dir = opendir(fontDirSet[i].c_str()); 15983+ if (dir == nullptr) { 15984+ err = logErrInfo(ERROR_DIR_NOT_FOUND, fontDirSet[i].c_str()); 15985+ continue; 15986+ } 15987+ struct dirent* node = nullptr; 15988+ while ((node = readdir(dir))) { 15989+ if (node->d_type != DT_REG) { 15990+ continue; 15991+ } 15992+ const char* fname = node->d_name; 15993+ int len = strlen(fname); 15994+ int suffixLen = strlen(".ttf"); 15995+ if (len < suffixLen || (strncmp(fname + len - suffixLen, ".ttf", suffixLen) && 15996+ strncmp(fname + len - suffixLen, ".otf", suffixLen) && 15997+ strncmp(fname + len - suffixLen, ".ttc", suffixLen) && 15998+ strncmp(fname + len - suffixLen, ".otc", suffixLen))) { 15999+ continue; 16000+ } 16001+ len += (fontDirSet[i].size() + 2); // 2 more characters for '/' and '\0' 16002+ char fullname[len]; 16003+ memset(fullname, 0, len); 16004+ strcpy(fullname, fontDirSet[i].c_str()); 16005+ if (fontDirSet[i][fontDirSet[i].size() - 1] != '/') { 16006+ strcat(fullname, "/"); 16007+ } 16008+ strcat(fullname, fname); 16009+ loadFont(fontScanner, fullname); 16010+ } 16011+ closedir(dir); 16012+ } 16013+ fontDirSet.clear(); 16014+ return err; 16015+} 16016+ 16017+/*! To reset the generic family 16018+ * \n 1. To sort the typefaces for each font style set in generic list 16019+ * \n 2. To build typeface set for those font style sets which have single weight value 16020+ */ 16021+void FontConfig_OHOS::resetGenericValue() 16022+{ 16023+ aliasMap.foreach([this](SkString& key, std::vector<AliasInfo>* pAliasSet) { 16024+ std::vector<AliasInfo>& aliasSet = *pAliasSet; 16025+ int index = aliasSet[0].pos; 16026+ if (genericFamilySet[index]->typefaceSet->size() == 0) { 16027+ this->logErrInfo(ERROR_FAMILY_NOT_FOUND, key.c_str()); 16028+ } else { 16029+ sortTypefaceSet(genericFamilySet[index]->typefaceSet); 16030+ for (unsigned int i = 1; i < aliasSet.size(); i++) { 16031+ if (aliasSet[i].weight == 0) { 16032+ continue; 16033+ } 16034+ buildSubTypefaceSet(genericFamilySet[index]->typefaceSet, 16035+ genericFamilySet[index + i]->typefaceSet, 16036+ genericFamilySet[index + i]->familyName, 16037+ aliasSet[i].weight); 16038+ if (genericFamilySet[index + i]->typefaceSet->size() == 0) { 16039+ this->logErrInfo(ERROR_FAMILY_NOT_FOUND, 16040+ genericFamilySet[index + i]->familyName.c_str()); 16041+ } 16042+ } 16043+ } 16044+ }); 16045+ 16046+ aliasMap.reset(); 16047+ adjustMap.reset(); 16048+ variationMap.reset(); 16049+ ttcIndexMap.reset(); 16050+} 16051+ 16052+/*! To build a sub typeface set according to weight from a typeface set 16053+ * \param typefaceSet the parent typeface set 16054+ * \param[out] subSet the sub typeface set returned to the caller 16055+ * \param familyName the family name of the sub typeface set 16056+ * \param weight the weight of the sub typeface set 16057+ */ 16058+void FontConfig_OHOS::buildSubTypefaceSet(const std::shared_ptr<TypefaceSet>& typefaceSet, 16059+ std::shared_ptr<TypefaceSet>& subSet, const SkString& familyName, int weight) 16060+{ 16061+ if (typefaceSet->size() == 0) { 16062+ return; 16063+ } 16064+ for (unsigned int i = 0; i < typefaceSet->size(); i++) { 16065+ const SkTypeface_OHOS* typeface = (*typefaceSet)[i].get(); 16066+ if (typeface && typeface->fontStyle().weight() == weight) { 16067+ const FontInfo* pFont = typeface->getFontInfo(); 16068+ if (pFont == nullptr) { 16069+ continue; 16070+ } 16071+ FontInfo font(*pFont); 16072+ sk_sp<SkTypeface_OHOS> newTypeface = sk_make_sp<SkTypeface_OHOS>(familyName, font); 16073+ subSet->push_back(std::move(newTypeface)); 16074+ } 16075+ } 16076+} 16077+ 16078+/*! To reset the fallback value 16079+ * \n To sort the typefaces for each font style set in fallback list. 16080+ */ 16081+void FontConfig_OHOS::resetFallbackValue() 16082+{ 16083+ for (unsigned int i = 0; i < fallbackSet.size(); i++) { 16084+ if (fallbackSet[i]->typefaceSet->size() == 0) { 16085+ logErrInfo(ERROR_FAMILY_NOT_FOUND, fallbackSet[i]->familyName.c_str()); 16086+ } 16087+ sortTypefaceSet(fallbackSet[i]->typefaceSet); 16088+ } 16089+} 16090+ 16091+/*! To check if an error happened 16092+ * \param err the id of an error 16093+ * \param text the key to indicate the part with the error happened 16094+ * \return false, this kind of error did not happen 16095+ * \return true, the error happened 16096+ */ 16097+bool FontConfig_OHOS::hasError(int err, const SkString& text) const 16098+{ 16099+ for (unsigned int i = 0; i < errSet.size(); i++) { 16100+ if (errSet[i].err == err && errSet[i].text == text) { 16101+ return true; 16102+ } 16103+ } 16104+ return false; 16105+} 16106+ 16107+/*! To get the total count of errors happened 16108+ * \return The count of errors 16109+ */ 16110+int FontConfig_OHOS::getErrorCount() const 16111+{ 16112+ return errSet.size(); 16113+} 16114+ 16115+/*! To sort the typeface set 16116+ * \param typefaceSet the typeface set to be sorted 16117+ */ 16118+void FontConfig_OHOS::sortTypefaceSet(std::shared_ptr<TypefaceSet>& typefaceSet) 16119+{ 16120+ if (typefaceSet.get() == nullptr || typefaceSet->size() <= 1) { 16121+ return; 16122+ } 16123+ TypefaceSet& tpSet = *(typefaceSet.get()); 16124+ for (unsigned int i = 0; i < tpSet.size(); i++) 16125+ for (unsigned int j = 0; j < tpSet.size() - 1; j++) { 16126+ if ((tpSet[j]->fontStyle().weight() > tpSet[j + 1]->fontStyle().weight()) || 16127+ (tpSet[j]->fontStyle().weight() == tpSet[j + 1]->fontStyle().weight() && 16128+ tpSet[j]->fontStyle().slant() > tpSet[j + 1]->fontStyle().slant())) { 16129+ tpSet[j].swap(tpSet[j + 1]); 16130+ } 16131+ } 16132+} 16133+ 16134+/*! To get the display text of an error 16135+ * \param err the id of an error 16136+ * \return The text to explain the error 16137+ */ 16138+const char* FontConfig_OHOS::errToString(int err) 16139+{ 16140+ switch (err) { 16141+ case NO_ERROR: { 16142+ return "successful"; 16143+ } 16144+ case ERROR_CONFIG_NOT_FOUND: { 16145+ return "config file is not found"; 16146+ } 16147+ case ERROR_CONFIG_FORMAT_NOT_SUPPORTED: { 16148+ return "the format of config file is not supported"; 16149+ } 16150+ case ERROR_CONFIG_MISSING_TAG: { 16151+ return "missing tag"; 16152+ } 16153+ case ERROR_CONFIG_INVALID_VALUE_TYPE: { 16154+ return "invalid value type"; 16155+ } 16156+ case ERROR_FONT_NOT_EXIST: { 16157+ return "font file is not exist"; 16158+ } 16159+ case ERROR_FONT_NO_STREAM: { 16160+ return "no font stream"; 16161+ } 16162+ case ERROR_FONT_INVALID_STREAM: { 16163+ return "invalid font stream"; 16164+ } 16165+ case ERROR_FAMILY_NOT_FOUND: { 16166+ return "family is not found"; 16167+ } 16168+ case ERROR_NO_AVAILABLE_FAMILY: { 16169+ return "no available family in the system"; 16170+ } 16171+ case ERROR_DIR_NOT_FOUND: { 16172+ return "no such directory"; 16173+ } 16174+ default: { 16175+ return "unknown error"; 16176+ } 16177+ } 16178+ return "unknown error"; 16179+} 16180+ 16181+/*! To log the error information 16182+ * \param err the id of an error 16183+ * \param key the key which indicates the the part with the error 16184+ * \param expected the expected type of json node. 16185+ * \n It's used only for err 'ERROR_CONFIG_INVALID_VALUE_TYPE' 16186+ * \param actual the actual type of json node. 16187+ * \n It's used only for err 'ERROR_CONFIG_INVALID_VALUE_TYPE' 16188+ * \return err 16189+ */ 16190+int FontConfig_OHOS::logErrInfo(int err, const char* key, Json::ValueType expected, 16191+ Json::ValueType actual) 16192+{ 16193+ errSet.emplace_back(err, key); 16194+ if (err != ERROR_CONFIG_INVALID_VALUE_TYPE) { 16195+ LOGE("%s : %s\n", errToString(err), key); 16196+ } else { 16197+ const char* types[] = { 16198+ "null", 16199+ "int", 16200+ "unit", 16201+ "real", 16202+ "string", 16203+ "boolean", 16204+ "array", 16205+ "object", 16206+ }; 16207+ int size = sizeof(types) / sizeof(char*); 16208+ if ((expected >= 0 && expected < size) && 16209+ (actual >= 0 && actual < size)) { 16210+ LOGE("%s : '%s' should be '%s', but here it's '%s'\n", 16211+ errToString(err), key, types[expected], types[actual]); 16212+ } else { 16213+ LOGE("%s : %s\n", errToString(err), key); 16214+ } 16215+ } 16216+ return err; 16217+} 16218diff --git a/third_party/skia/src/ports/skia_ohos/FontConfig_ohos.h b/third_party/skia/src/ports/skia_ohos/FontConfig_ohos.h 16219new file mode 100644 16220index 0000000000..16edfdc31b 16221--- /dev/null 16222+++ b/third_party/skia/src/ports/skia_ohos/FontConfig_ohos.h 16223@@ -0,0 +1,230 @@ 16224+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 16225+// Use of this source code is governed by a BSD-style license that can be 16226+// found in the LICENSE file. 16227+ 16228+#ifndef FONTCONFIG_OHOS_H 16229+#define FONTCONFIG_OHOS_H 16230+ 16231+#include <json/json.h> 16232+#include <vector> 16233+ 16234+#include "src/core/SkFontDescriptor.h" 16235+#include "src/ports/SkFontHost_FreeType_common.h" 16236+#include "include/core/SkFontStyle.h" 16237+#include "include/core/SkStream.h" 16238+#include "include/core/SkString.h" 16239+#include "include/core/SkTypes.h" 16240+ 16241+#include "FontInfo_ohos.h" 16242+#include "SkTypeface_ohos.h" 16243+ 16244+#ifdef ENABLE_DEBUG 16245+ 16246+#define LOGE(fmt, args...) \ 16247+ printf("E %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) 16248+#define LOGI(fmt, args...) \ 16249+ printf("I %s:%d - " fmt, __FUNCTION__, __LINE__, ##args) 16250+#define LOGW(fmt, args...) \ 16251+ printf("W %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) 16252+ 16253+#else 16254+ 16255+#define LOGE SkDEBUGF 16256+#define LOGI SkDEBUGF 16257+#define LOGW SkDEBUGF 16258+ 16259+#endif 16260+ 16261+struct FontInfo; 16262+struct FallbackInfo; 16263+struct GenericFamily; 16264+struct FallbackSetPos; 16265+ 16266+using TypefaceSet = std::vector<sk_sp<SkTypeface_OHOS>>; 16267+using GenericFamilySet = std::vector<std::unique_ptr<GenericFamily>>; 16268+using FallbackSet = std::vector<std::unique_ptr<FallbackInfo>>; 16269+using FallbackForMap = SkTHashMap<SkString, FallbackSetPos>; 16270+using NamesMap = SkTHashMap<SkString, int>; 16271+using Coordinate = SkFontArguments::VariationPosition::Coordinate; 16272+using AxisDefinitions = SkTypeface_FreeType::Scanner::AxisDefinitions; 16273+ 16274+/*! 16275+ * Error code definition 16276+ */ 16277+namespace ErrorCode { 16278+ 16279+enum { 16280+ NO_ERROR = 0, // no error 16281+ ERROR_CONFIG_NOT_FOUND, // the configuration document is not found 16282+ ERROR_CONFIG_FORMAT_NOT_SUPPORTED, // the formation of configuration is not supported 16283+ ERROR_CONFIG_MISSING_TAG, // missing tag in the configuration 16284+ ERROR_CONFIG_INVALID_VALUE_TYPE, // invalid value type in the configuration 16285+ ERROR_FONT_NOT_EXIST, // the font file is not exist 16286+ ERROR_FONT_INVALID_STREAM, // the stream is not recognized 16287+ ERROR_FONT_NO_STREAM, // no stream in the font data 16288+ ERROR_FAMILY_NOT_FOUND, // the family name is not found in the system 16289+ ERROR_NO_AVAILABLE_FAMILY, // no available family in the system 16290+ ERROR_DIR_NOT_FOUND, // the directory is not exist 16291+}; 16292+ 16293+} /* namespace ErrorCode */ 16294+ 16295+/*! 16296+ * \brief To manage the related information of a 'fallbackFor' family name 16297+ */ 16298+struct FallbackSetPos { 16299+ unsigned int index; // the index of the first font style set in the fallback set for a specified family name 16300+ unsigned int count; // the count of font style sets for a specified family name 16301+}; 16302+ 16303+/*! 16304+ * \brief To manage the information for a generic family item 16305+ */ 16306+struct GenericFamily { 16307+ SkString familyName; // the specified family name of the font style set 16308+ std::shared_ptr<TypefaceSet> typefaceSet; // the typeface set of the font style set 16309+ virtual ~GenericFamily() = default; 16310+}; 16311+ 16312+/*! 16313+ * \brief To manage the information for a fallback family item 16314+ */ 16315+struct FallbackInfo : GenericFamily { 16316+ SkString langs; // the language for which the font style set is 16317+}; 16318+ 16319+/*! 16320+ * \brief To parse the font configuration document and manage the system fonts 16321+ */ 16322+class FontConfig_OHOS { 16323+public: 16324+ explicit FontConfig_OHOS(const SkTypeface_FreeType::Scanner& fontScanner, 16325+ const char* fname = nullptr); 16326+ virtual ~FontConfig_OHOS() = default; 16327+ const FallbackForMap& getFallbackForMap() const; 16328+ const FallbackSet& getFallbackSet() const; 16329+ int getFamilyCount() const; 16330+ int getDefaultFamily(SkString* familyName) const; 16331+ int getFamilyName(int index, SkString* familyName) const; 16332+ int getTypefaceCount(int styleIndex, bool isFallback = false) const; 16333+ int getStyleIndex(const char* familyName, bool& isFallback) const; 16334+ 16335+ SkTypeface_OHOS* getTypeface(int styleIndex, int index, bool isFallback = false) const; 16336+ SkTypeface_OHOS* getTypeface(int styleIndex, const SkFontStyle& style, 16337+ bool isFallback = false) const; 16338+ 16339+#if ENABLE_DEBUG 16340+ void dumpFont(const FontInfo& font) const; 16341+ void dumpGeneric() const; 16342+ void dumpFallback() const; 16343+#endif 16344+ bool hasError(int err, const SkString& text) const; 16345+ int getErrorCount() const; 16346+ 16347+ static sk_sp<SkTypeface_OHOS> matchFontStyle(const TypefaceSet& typefaceSet, const SkFontStyle& pattern); 16348+ 16349+ static const char* errToString(int err); 16350+private: 16351+ struct AliasInfo; 16352+ struct AdjustInfo; 16353+ struct VariationInfo; 16354+ struct TtcIndexInfo; 16355+ using AliasMap = SkTHashMap<SkString, std::vector<AliasInfo>>; 16356+ using AjdustMap = SkTHashMap<SkString, std::vector<AdjustInfo>>; 16357+ using VariationMap = SkTHashMap<SkString, std::vector<VariationInfo>>; 16358+ using TtcIndexMap = SkTHashMap<SkString, TtcIndexInfo>; 16359+ 16360+ /*! 16361+ * \brief To manage the adjust information 16362+ */ 16363+ struct AdjustInfo { 16364+ int origValue; // the real value of the font weight 16365+ int newValue; // the specified value of weight for a font 16366+ }; 16367+ 16368+ /*! 16369+ * \brief To manage the alias information of 16370+ */ 16371+ struct AliasInfo { 16372+ int pos; // the index of a font style set in generic family list. 16373+ int weight; // the weight of the font style set. 0 means no specified weight 16374+ }; 16375+ 16376+ /*! 16377+ * \brief To manage the variation information 16378+ */ 16379+ struct VariationInfo { 16380+ VariationInfo() : weight(-1), width(-1), slant(-1){} 16381+ std::vector<Coordinate> axis; // the axis set such as 'wght', 'wdth' and 'slnt'. 16382+ int weight; // the value of mapping weight 16383+ int width; // the value of mapping width 16384+ int slant; // the value of mapping slant 16385+ }; 16386+ 16387+ /*! 16388+ * \brief To manage the 'index' information for ttc fonts 16389+ */ 16390+ struct TtcIndexInfo { 16391+ SkString familyName; // the family name of the first typeface in a ttc font 16392+ int ttcIndex; // the index of a typeface in a ttc font 16393+ }; 16394+ 16395+ /*! 16396+ * \brief To manage the information of errors happened 16397+ */ 16398+ struct ErrorInfo { 16399+ ErrorInfo(int err, const char* text) : err(err), text(SkString(text)){} 16400+ ErrorInfo(int err, SkString& text) : err(err), text(std::move(text)){} 16401+ int err; // error id 16402+ SkString text; // the part with error 16403+ }; 16404+ 16405+ std::vector<SkString> fontDirSet; // the directories where the fonts are 16406+ 16407+ FallbackForMap fallbackForMap; // a hash table to save the fallbackFor pairs 16408+ GenericFamilySet genericFamilySet; // the font style set list of generic family 16409+ FallbackSet fallbackSet; // the font style set list of fallback family 16410+ 16411+ NamesMap genericNames; // a map to store the index of a family for generic family 16412+ NamesMap fallbackNames; // a map to store the index of a family for fallback family 16413+ 16414+ std::vector<ErrorInfo> errSet; // the errors happened 16415+ AliasMap aliasMap; // to save alias information temporarily 16416+ AjdustMap adjustMap; // to save adjust information temporarily 16417+ VariationMap variationMap; // to save variation information temporarily 16418+ TtcIndexMap ttcIndexMap; // to save 'index' information temporarily 16419+ 16420+ int parseConfig(const char* fname); 16421+ int checkConfigFile(const char* fname, Json::Value& root); 16422+ int parseFontDir(const Json::Value& root); 16423+ int parseGeneric(const Json::Value& root); 16424+ int parseFallback(const Json::Value& root); 16425+ int parseFallbackItem(const Json::Value& root); 16426+ int parseAlias(const Json::Value& root, std::vector<AliasInfo>& aliasSet); 16427+ int parseAdjust(const Json::Value& root, std::vector<AdjustInfo>& adjustSet); 16428+ int parseVariation(const Json::Value& root, std::vector<VariationInfo>& variationSet); 16429+ int parseTtcIndex(const Json::Value& root, const SkString& familyName); 16430+ void getAxisValues(const AxisDefinitions& axisDefinitions, 16431+ const VariationInfo& variation, FontInfo& font) const; 16432+ bool insertTtcFont(int count, FontInfo& font); 16433+ bool insertVariableFont(const AxisDefinitions& axisDefinitions, FontInfo& font); 16434+ TypefaceSet* getTypefaceSet(const SkString& familyName, SkString& specifiedName) const; 16435+ 16436+ int loadFont(const SkTypeface_FreeType::Scanner& scanner, const char* fname); 16437+ int scanFonts(const SkTypeface_FreeType::Scanner& fontScanner); 16438+ void resetGenericValue(); 16439+ void buildSubTypefaceSet(const std::shared_ptr<TypefaceSet>& typefaceSet, 16440+ std::shared_ptr<TypefaceSet>& subSet, const SkString& familyName, int weight); 16441+ void resetFallbackValue(); 16442+ int logErrInfo(int err, const char* key, Json::ValueType expected = Json::nullValue, 16443+ Json::ValueType actual = Json::nullValue); 16444+ static void sortTypefaceSet(std::shared_ptr<TypefaceSet>& typefaceSet); 16445+ static uint32_t getFontStyleDifference(const SkFontStyle& style1, const SkFontStyle& style2); 16446+ static char* getFileData(const char* fname, int& size); 16447+ FontConfig_OHOS(const FontConfig_OHOS&) = delete; 16448+ FontConfig_OHOS& operator = (const FontConfig_OHOS&) = delete; 16449+ FontConfig_OHOS(FontConfig_OHOS&&) = delete; 16450+ FontConfig_OHOS& operator = (FontConfig_OHOS&&) = delete; 16451+}; 16452+ 16453+#endif /* FONTCONFIG_OHOS_H */ 16454diff --git a/third_party/skia/src/ports/skia_ohos/FontInfo_ohos.h b/third_party/skia/src/ports/skia_ohos/FontInfo_ohos.h 16455new file mode 100644 16456index 0000000000..4c80e099af 16457--- /dev/null 16458+++ b/third_party/skia/src/ports/skia_ohos/FontInfo_ohos.h 16459@@ -0,0 +1,147 @@ 16460+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 16461+// Use of this source code is governed by a BSD-style license that can be 16462+// found in the LICENSE file. 16463+ 16464+#ifndef FONTINFO_OHOS_H 16465+#define FONTINFO_OHOS_H 16466+ 16467+#include <vector> 16468+ 16469+#include "include/private/SkFixed.h" 16470+#include "src/core/SkFontDescriptor.h" 16471+#include "src/ports/SkFontHost_FreeType_common.h" 16472+ 16473+/*! 16474+ * \brief To manage the font information 16475+ */ 16476+struct FontInfo { 16477+public: 16478+ /*! Constructor 16479+ * 16480+ */ 16481+ FontInfo() : familyName(""), fname(""), index(0), 16482+ style(SkFontStyle::Normal()), isFixedWidth(false), stream(nullptr) 16483+ { 16484+ memset(&axisSet, 0, sizeof(AxisSet)); 16485+ } 16486+ /*! Copy Constructor 16487+ * \param font an object of FontInfo 16488+ */ 16489+ explicit FontInfo(const FontInfo& font) 16490+ : familyName(font.familyName), fname(font.fname), index(font.index), 16491+ style(font.style), isFixedWidth(font.isFixedWidth), stream(nullptr) 16492+ { 16493+ axisSet.axis = font.axisSet.axis; 16494+ axisSet.range = font.axisSet.range; 16495+ if (font.stream) { 16496+ stream = font.stream->duplicate(); 16497+ } 16498+ } 16499+ 16500+ /*! Move Constructor 16501+ * \param font an object of FontInfo 16502+ */ 16503+ explicit FontInfo(FontInfo&& font) 16504+ : familyName(std::move(font.familyName)), fname(std::move(font.fname)), index(font.index), 16505+ style(font.style), isFixedWidth(font.isFixedWidth), stream(nullptr) 16506+ { 16507+ axisSet.axis = std::move(font.axisSet.axis); 16508+ axisSet.range = std::move(font.axisSet.range); 16509+ if (font.stream) { 16510+ stream = std::move(font.stream); 16511+ } 16512+ } 16513+ 16514+ /*! Constructor 16515+ * \param fname the fullname of font file 16516+ * \param index the index of the typeface in the font file 16517+ */ 16518+ FontInfo(const char* fname, int index) 16519+ : familyName(""), fname(""), index(index), 16520+ style(SkFontStyle::Normal()), isFixedWidth(false), stream(nullptr) 16521+ { 16522+ if (fname) { 16523+ this->fname.set(fname); 16524+ } 16525+ memset(&axisSet, 0, sizeof(axisSet)); 16526+ } 16527+ 16528+ /*! Destructor 16529+ * 16530+ */ 16531+ virtual ~FontInfo() = default; 16532+ 16533+ /*! Copy assignment operator 16534+ * \param font an object of FontInfo 16535+ */ 16536+ FontInfo& operator = (const FontInfo& font) 16537+ { 16538+ if (this == &font) { 16539+ return *this; 16540+ } 16541+ familyName = font.familyName; 16542+ fname = font.fname; 16543+ index = font.index; 16544+ style = font.style; 16545+ isFixedWidth = font.isFixedWidth; 16546+ axisSet.axis = font.axisSet.axis; 16547+ axisSet.range = font.axisSet.range; 16548+ if (font.stream) { 16549+ stream = font.stream->duplicate(); 16550+ } 16551+ return *this; 16552+ } 16553+ 16554+ /*! The move assignment operator 16555+ * \param font an object of FontInfo 16556+ */ 16557+ FontInfo& operator = (FontInfo&& font) 16558+ { 16559+ if (this == &font) { 16560+ return *this; 16561+ } 16562+ familyName = std::move(font.familyName); 16563+ fname = std::move(font.fname); 16564+ index = font.index; 16565+ style = font.style; 16566+ isFixedWidth = font.isFixedWidth; 16567+ axisSet.axis = std::move(font.axisSet.axis); 16568+ axisSet.range = std::move(font.axisSet.range); 16569+ if (font.stream) { 16570+ stream = std::move(font.stream); 16571+ } 16572+ return *this; 16573+ } 16574+ 16575+ /*! To set axis values 16576+ * \param count the count of axis 16577+ * \param axis an array of SkFixed value 16578+ * \param range an array of AxisDefinition 16579+ */ 16580+ void setAxisSet(int count, const SkFixed* axis, 16581+ const SkTypeface_FreeType::Scanner::AxisDefinition* range) 16582+ { 16583+ axisSet.axis.clear(); 16584+ axisSet.range.clear(); 16585+ for (int i = 0; i < count; i++) { 16586+ axisSet.axis.emplace_back(axis[i]); 16587+ axisSet.range.emplace_back(range[i]); 16588+ } 16589+ } 16590+ 16591+ SkString familyName; // the real family name of the font 16592+ SkString fname; // the full name of font file 16593+ int index; // the index of the font in a ttc font 16594+ SkFontStyle style; // the font style 16595+ bool isFixedWidth; // the flag to indicate if the font has fixed width or not 16596+ /*! 16597+ * \brief To manage the axis values for variable font 16598+ */ 16599+ struct AxisSet { 16600+ std::vector<SkFixed> axis; // the axis values 16601+ std::vector<SkTypeface_FreeType::Scanner::AxisDefinition> range; // the axis ranges 16602+ } axisSet; // the axis values for a variable font 16603+ std::unique_ptr<SkStreamAsset> stream; // the data stream of font file 16604+}; 16605+ 16606+#endif /* FONTINFO_OHOS_H */ 16607diff --git a/third_party/skia/src/ports/skia_ohos/SkFontMgr_ohos.cpp b/third_party/skia/src/ports/skia_ohos/SkFontMgr_ohos.cpp 16608new file mode 100644 16609index 0000000000..7fe7c136e3 16610--- /dev/null 16611+++ b/third_party/skia/src/ports/skia_ohos/SkFontMgr_ohos.cpp 16612@@ -0,0 +1,490 @@ 16613+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 16614+// Use of this source code is governed by a BSD-style license that can be 16615+// found in the LICENSE file. 16616+ 16617+#include "SkFontMgr_ohos.h" 16618+ 16619+#include "SkTypeface_ohos.h" 16620+ 16621+using namespace ErrorCode; 16622+ 16623+/*! Constructor 16624+ * \param path the full path of system font configuration document 16625+ */ 16626+SkFontMgr_OHOS::SkFontMgr_OHOS(const char* path) 16627+{ 16628+ fontConfig = std::make_shared<FontConfig_OHOS>(fontScanner, path); 16629+ familyCount = fontConfig->getFamilyCount(); 16630+} 16631+ 16632+/*! To get the count of families 16633+ * \return The count of families in the system 16634+ */ 16635+int SkFontMgr_OHOS::onCountFamilies() const 16636+{ 16637+ return familyCount; 16638+} 16639+ 16640+/*! To get the family name for a font style set 16641+ * \param index the index of a font style set 16642+ * \param[out] familyName the family name returned to the caller 16643+ * \n The family name will be reset to "", if index is out of range 16644+ */ 16645+void SkFontMgr_OHOS::onGetFamilyName(int index, SkString* familyName) const 16646+{ 16647+ if (fontConfig == nullptr || familyName == nullptr) { 16648+ return; 16649+ } 16650+ fontConfig->getFamilyName(index, familyName); 16651+} 16652+ 16653+/*! To create an object of SkFontStyleSet 16654+ * \param index the index of a font style set 16655+ * \return The pointer of SkFontStyleSet 16656+ * \n Return null, if index is out of range 16657+ * \note The caller must call unref() on the returned object if it's not null 16658+ */ 16659+SkFontStyleSet* SkFontMgr_OHOS::onCreateStyleSet(int index) const 16660+{ 16661+ if (fontConfig == nullptr) { 16662+ return nullptr; 16663+ } 16664+ if (index < 0 || index >= this->countFamilies()) { 16665+ return nullptr; 16666+ } 16667+ return new SkFontStyleSet_OHOS(fontConfig, index); 16668+} 16669+ 16670+/*! To get a matched object of SkFontStyleSet 16671+ * \param familyName the family name of a font style set 16672+ * \return The pointer of SkFontStyleSet 16673+ * \n Return the default font style set, if family name is null 16674+ * \n Return null, if family name is not found 16675+ * \note The caller must call unref() on the returned object if it's not null 16676+ */ 16677+SkFontStyleSet* SkFontMgr_OHOS::onMatchFamily(const char familyName[]) const 16678+{ 16679+ if (fontConfig == nullptr) { 16680+ return nullptr; 16681+ } 16682+ // return default system font when familyName is null 16683+ if (familyName == nullptr) { 16684+ return new SkFontStyleSet_OHOS(fontConfig, 0); 16685+ } 16686+ 16687+ bool isFallback = false; 16688+ int index = fontConfig->getStyleIndex(familyName, isFallback); 16689+ if (index == -1) { 16690+ return nullptr; 16691+ } 16692+ return new SkFontStyleSet_OHOS(fontConfig, index, isFallback); 16693+} 16694+ 16695+/*! To get a matched typeface 16696+ * \param familyName the family name of a font style set 16697+ * \param style the font style to be matched 16698+ * \return An object of typeface which is closest matching to 'style' 16699+ * \n Return the typeface in the default font style set, if family name is null 16700+ * \n Return null, if family name is not found 16701+ * \note The caller must call unref() on the returned object if it's not null 16702+ */ 16703+SkTypeface* SkFontMgr_OHOS::onMatchFamilyStyle(const char familyName[], const SkFontStyle& style) const 16704+{ 16705+ if (fontConfig == nullptr) { 16706+ return nullptr; 16707+ } 16708+ bool isFallback = false; 16709+ int styleIndex = 0; 16710+ if (familyName) { 16711+ styleIndex = fontConfig->getStyleIndex(familyName, isFallback); 16712+ } 16713+ return SkSafeRef(fontConfig->getTypeface(styleIndex, style, isFallback)); 16714+} 16715+ 16716+/*! To get a matched typeface 16717+ * \n Use the system fallback to find a typeface for the given character. 16718+ * \param familyName the family name which the typeface is fallback For 16719+ * \param style the font style to be matched 16720+ * \param bcp47 an array of languages which indicate the language of 'character' 16721+ * \param bcp47Count the array size of bcp47 16722+ * \param character a UTF8 value to be matched 16723+ * \return An object of typeface which is for the given character 16724+ * \return Return the typeface in the default fallback set, if familyName is null 16725+ * \return Return null, if the typeface is not found for the given character 16726+ * \note The caller must call unref() on the returned object if it's not null 16727+ */ 16728+SkTypeface* SkFontMgr_OHOS::onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle& style, 16729+ const char* bcp47[], int bcp47Count, SkUnichar character) const 16730+{ 16731+ if (fontConfig == nullptr) { 16732+ return nullptr; 16733+ } 16734+ const FallbackForMap& fallbackForMap = fontConfig->getFallbackForMap(); 16735+ const FallbackSet& fallbackSet = fontConfig->getFallbackSet(); 16736+ SkString defaultFamily(""); 16737+ SkString key = defaultFamily; 16738+ FallbackSetPos* item = nullptr; 16739+ if (familyName == nullptr) { 16740+ item = fallbackForMap.find(defaultFamily); 16741+ } else { 16742+ item = fallbackForMap.find(SkString(familyName)); 16743+ if (item) { 16744+ key = SkString(familyName); 16745+ } else { 16746+ item = fallbackForMap.find(defaultFamily); 16747+ } 16748+ } 16749+ if (item == nullptr) { 16750+ LOGE("%s : '%s' must be a fallback key in the config file\n", 16751+ FontConfig_OHOS::errToString(ERROR_FAMILY_NOT_FOUND), defaultFamily.c_str()); 16752+ return nullptr; 16753+ } 16754+ while (true) { 16755+ if (bcp47Count > 0) { 16756+ SkTypeface* retTp = findTypeface(*item, style, bcp47, bcp47Count, character); 16757+ if (retTp) { 16758+ return retTp; 16759+ } 16760+ if (key == defaultFamily) { 16761+ bcp47Count = 0; 16762+ continue; 16763+ } 16764+ item = fallbackForMap.find(defaultFamily); 16765+ key = defaultFamily; 16766+ } else { 16767+ for (unsigned int i = item->index; i < item->index + item->count && i < fallbackSet.size(); i++) { 16768+ const TypefaceSet& tpSet = *(fallbackSet[i]->typefaceSet.get()); 16769+ if (tpSet.size() > 0 && tpSet[0]->unicharToGlyph(character) != 0) { 16770+ sk_sp<SkTypeface> typeface = FontConfig_OHOS::matchFontStyle(tpSet, style); 16771+ return SkSafeRef(typeface.get()); 16772+ } 16773+ } 16774+ if (key == defaultFamily) { 16775+ break; 16776+ } 16777+ item = fallbackForMap.find(defaultFamily); 16778+ key = defaultFamily; 16779+ } 16780+ } 16781+ return nullptr; 16782+} 16783+ 16784+/*! To find the matched typeface for the given parameters 16785+ * \n Use the system fallback to find a typeface for the given character. 16786+ * \param fallbackItem the fallback items in which to find the typeface 16787+ * \param style the font style to be matched 16788+ * \param bcp47 an array of languages which indicate the language of 'character' 16789+ * \param bcp47Count the array size of bcp47 16790+ * \param character a UTF8 value to be matched 16791+ * \return An object of typeface which is for the given character 16792+ * \return Return null, if the typeface is not found for the given character 16793+ */ 16794+SkTypeface* SkFontMgr_OHOS::findTypeface(const FallbackSetPos& fallbackItem, const SkFontStyle& style, 16795+ const char* bcp47[], int bcp47Count, SkUnichar character) const 16796+{ 16797+ if (bcp47Count == 0) { 16798+ return nullptr; 16799+ } 16800+ 16801+ const FallbackSet& fallbackSet = fontConfig->getFallbackSet(); 16802+ // example bcp47 code : 'zh-Hans' : ('zh' : iso639 code, 'Hans' : iso15924 code) 16803+ // iso639 code will be taken from bcp47 code, so that we can try to match 16804+ // bcp47 or only iso639. Therefore totalCount need to be 'bcp47Count * 2' 16805+ int totalCount = bcp47Count * 2; 16806+ int tps[totalCount]; 16807+ for (int i = 0; i < totalCount; i++) { 16808+ tps[i] = -1; 16809+ } 16810+ // find the families matching the bcp47 list 16811+ for (unsigned int i = fallbackItem.index; i < fallbackItem.index + fallbackItem.count 16812+ && i < fallbackSet.size(); i++) { 16813+ int ret = compareLangs(fallbackSet[i]->langs, bcp47, bcp47Count, tps); 16814+ if (ret == -1) { 16815+ continue; 16816+ } 16817+ tps[ret] = i; 16818+ } 16819+ // match typeface in families 16820+ for (int i = bcp47Count - 1; i >= 0; i--) { 16821+ if (tps[i] == -1) { 16822+ continue; 16823+ } 16824+ const TypefaceSet& tpSet = *(fallbackSet[tps[i]]->typefaceSet.get()); 16825+ if (tpSet.size() > 0 && tpSet[0]->unicharToGlyph(character) != 0) { 16826+ sk_sp<SkTypeface> typeface = FontConfig_OHOS::matchFontStyle(tpSet, style); 16827+ return SkSafeRef(typeface.get()); 16828+ } 16829+ } 16830+ for (int i = totalCount - 1; i >= bcp47Count; i--) { 16831+ if (tps[i] == -1) { 16832+ continue; 16833+ } 16834+ const TypefaceSet& tpSet = *(fallbackSet[tps[i]]->typefaceSet.get()); 16835+ if (tpSet.size() > 0 && tpSet[0]->unicharToGlyph(character) != 0) { 16836+ sk_sp<SkTypeface> typeface = FontConfig_OHOS::matchFontStyle(tpSet, style); 16837+ return SkSafeRef(typeface.get()); 16838+ } 16839+ } 16840+ return nullptr; 16841+} 16842+ 16843+/*! To compare the languages of an typeface with a bcp47 list 16844+ * \param langs the supported languages by an typeface 16845+ * \param bcp47 the array of bcp47 language to be matching 16846+ * \param bcp47Count the array size of bcp47 16847+ * \param tps an array of the index of typeface which is matching one value of bcp47 16848+ * \return The index of language in bcp47, if matching happens 16849+ * \n Return -1, if no language matching happens 16850+ */ 16851+int SkFontMgr_OHOS::compareLangs(const SkString& langs, const char* bcp47[], 16852+ int bcp47Count, const int tps[]) const 16853+{ 16854+ /* 16855+ * zh-Hans : ('zh' : iso639 code, 'Hans' : iso15924 code) 16856+ */ 16857+ if (bcp47 == nullptr || bcp47Count == 0) { 16858+ return -1; 16859+ } 16860+ for (int i = bcp47Count - 1; i >= 0; i--) { 16861+ if (tps[i] != -1) { 16862+ continue; 16863+ } 16864+ if (langs.find(bcp47[i]) != -1) { 16865+ return i; 16866+ } else { 16867+ const char* iso15924 = strrchr(bcp47[i], '-'); 16868+ if (iso15924 == nullptr) { 16869+ continue; 16870+ } 16871+ iso15924++; 16872+ int len = iso15924 - 1 - bcp47[i]; 16873+ SkString country(bcp47[i], len); 16874+ if (langs.find(iso15924) != -1 || 16875+ (strncmp(bcp47[i], "und", strlen("und")) && langs.find(country.c_str()) != -1)) { 16876+ return i + bcp47Count; 16877+ } 16878+ } 16879+ } 16880+ return -1; 16881+} 16882+ 16883+/*! To get a matched typeface 16884+ * \param typeface the given typeface with which the returned object should be in the same style set 16885+ * \param style the font style to be matching 16886+ * \return The object of typeface which is closest matching to the given 'style' 16887+ * \n Return null, if the family name of the given typeface is not found in the system 16888+ * \note The caller must call unref() on the returned object if it's not null 16889+ */ 16890+SkTypeface* SkFontMgr_OHOS::onMatchFaceStyle(const SkTypeface* typeface, const SkFontStyle& style) const 16891+{ 16892+ if (typeface == nullptr) { 16893+ return nullptr; 16894+ } 16895+ SkString familyName; 16896+ typeface->getFamilyName(&familyName); 16897+ return this->onMatchFamilyStyle(familyName.c_str(), style); 16898+} 16899+ 16900+/*! To create a typeface from the specified data and TTC index 16901+ * \param data the data to be parsed 16902+ * \param index the index of typeface. 0 for none 16903+ * \return The object of typeface, if successful 16904+ * \n Return null if the data is not recognized. 16905+ * \note The caller must call unref() on the returned object if it's not null 16906+ */ 16907+sk_sp<SkTypeface> SkFontMgr_OHOS::onMakeFromData(sk_sp<SkData> data, int ttcIndex) const 16908+{ 16909+ if (data == nullptr) { 16910+ return nullptr; 16911+ } 16912+ std::unique_ptr<SkMemoryStream> memoryStream = std::make_unique<SkMemoryStream>(data); 16913+ SkFontArguments args; 16914+ args.setCollectionIndex(ttcIndex); 16915+ return this->makeTypeface(std::move(memoryStream), args, nullptr); 16916+} 16917+ 16918+/*! To create a typeface from the specified stream and TTC index 16919+ * \param data the stream to be parsed 16920+ * \param index the index of typeface. 0 for none 16921+ * \return The object of typeface, if successful 16922+ * \n Return null if the stream is not recognized. 16923+ * \note The caller must call unref() on the returned object if it's not null 16924+ */ 16925+sk_sp<SkTypeface> SkFontMgr_OHOS::onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset> stream, 16926+ int ttcIndex) const 16927+{ 16928+ if (stream == nullptr) { 16929+ return nullptr; 16930+ } 16931+ SkFontArguments args; 16932+ args.setCollectionIndex(ttcIndex); 16933+ return this->makeTypeface(std::move(stream), args, nullptr); 16934+} 16935+ 16936+/*! To create a typeface from the specified stream and font arguments 16937+ * \param data the stream to be parsed 16938+ * \param args the arguments of font 16939+ * \return The object of typeface, if successful 16940+ * \n Return null if the stream is not recognized. 16941+ * \note The caller must call unref() on the returned object if it's not null 16942+ */ 16943+sk_sp<SkTypeface> SkFontMgr_OHOS::onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset> stream, 16944+ const SkFontArguments& args) const 16945+{ 16946+ if (stream == nullptr) { 16947+ return nullptr; 16948+ } 16949+ return this->makeTypeface(std::move(stream), args, nullptr); 16950+} 16951+ 16952+/*! To create a typeface from the specified font data 16953+ * \param fontData the given font data used to create a typeface 16954+ * \return The object of typeface, if successful 16955+ * \n Return null if the typeface cannot be created from the font data. 16956+ * \note The caller must call unref() on the returned object if it's not null 16957+ */ 16958+sk_sp<SkTypeface> SkFontMgr_OHOS::onMakeFromFontData(std::unique_ptr<SkFontData> data) const 16959+{ 16960+ if (fontConfig == nullptr) { 16961+ return nullptr; 16962+ } 16963+ if (data == nullptr || !data->hasStream()) { 16964+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_NO_STREAM)); 16965+ return nullptr; 16966+ } 16967+ 16968+ return makeTypeface(data.get()); 16969+} 16970+ 16971+/*! To create a typeface from the specified font file and TTC index 16972+ * \param path the full path of the given font file 16973+ * \param ttcIndex the index of typeface in a ttc font file. 0 means none. 16974+ * \return The object of typeface, if successful 16975+ * \n Return null if the font file is not found or the content of file is not recognized. 16976+ * \note The caller must call unref() on the returned object if it's not null 16977+ */ 16978+sk_sp<SkTypeface> SkFontMgr_OHOS::onMakeFromFile(const char path[], int ttcIndex) const 16979+{ 16980+ if (fontConfig == nullptr) { 16981+ return nullptr; 16982+ } 16983+ 16984+ std::unique_ptr<SkStreamAsset> stream = SkStreamAsset::MakeFromFile(path); 16985+ if (stream == nullptr) { 16986+ LOGE("%s : %s\n", FontConfig_OHOS::errToString(ERROR_FONT_NOT_EXIST), path); 16987+ return nullptr; 16988+ } 16989+ SkFontArguments args; 16990+ args.setCollectionIndex(ttcIndex); 16991+ return this->makeTypeface(std::move(stream), args, path); 16992+} 16993+ 16994+/*! To get a typeface matching the specified family and style 16995+ * \param familyName the specified name to be matching 16996+ * \param style the specified style to be matching 16997+ * \return The object of typeface which is the closest matching 'style' when the familyName is found 16998+ * \return Return a typeface from the default family, if familyName is not found 16999+ * \return Return null, if there is no any typeface in the system 17000+ * \note The caller must caller unref() on the returned object is it's not null 17001+ */ 17002+sk_sp<SkTypeface> SkFontMgr_OHOS::onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const 17003+{ 17004+ SkTypeface* typeface = this->onMatchFamilyStyle(familyName, style); 17005+ // if familyName is not found, then try the default family 17006+ if (typeface == nullptr && familyName != nullptr) { 17007+ typeface = this->onMatchFamilyStyle(nullptr, style); 17008+ } 17009+ 17010+ if (typeface) { 17011+ return sk_sp<SkTypeface>(typeface); 17012+ } 17013+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_NO_AVAILABLE_FAMILY)); 17014+ return nullptr; 17015+} 17016+ 17017+/*! To make a typeface from the specified stream and font arguments 17018+ * \param stream the specified stream to be parsed to get font information 17019+ * \param args the arguments of index or axis values 17020+ * \param path the fullname of font file 17021+ * \return The object of typeface if successful 17022+ * \n Return null, if the stream is not recognized 17023+ */ 17024+sk_sp<SkTypeface> SkFontMgr_OHOS::makeTypeface(std::unique_ptr<SkStreamAsset> stream, 17025+ const SkFontArguments& args, const char path[]) const 17026+{ 17027+ FontInfo fontInfo; 17028+ int ttcIndex = args.getCollectionIndex(); 17029+ int axisCount = args.getVariationDesignPosition().coordinateCount; 17030+ 17031+ if (path) { 17032+ fontInfo.fname.set(path); 17033+ } 17034+ if (axisCount == 0) { 17035+ if (!fontScanner.scanFont(stream.get(), ttcIndex, &fontInfo.familyName, &fontInfo.style, 17036+ &fontInfo.isFixedWidth, nullptr)) { 17037+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); 17038+ return nullptr; 17039+ } 17040+ } else { 17041+ AxisDefinitions axisDef; 17042+ if (!fontScanner.scanFont(stream.get(), ttcIndex, &fontInfo.familyName, &fontInfo.style, 17043+ &fontInfo.isFixedWidth, &axisDef)) { 17044+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); 17045+ return nullptr; 17046+ } 17047+ if (axisDef.count() > 0) { 17048+ SkFixed axis[axisCount]; 17049+ fontScanner.computeAxisValues(axisDef, args.getVariationDesignPosition(), 17050+ axis, fontInfo.familyName); 17051+ fontInfo.setAxisSet(axisCount, axis, axisDef.data()); 17052+ } 17053+ } 17054+ 17055+ fontInfo.stream = std::move(stream); 17056+ fontInfo.index = ttcIndex; 17057+ return sk_make_sp<SkTypeface_OHOS>(fontInfo); 17058+} 17059+ 17060+/*! To make a typeface from the specified font data 17061+ * \param fontData the given font data used to create a typeface 17062+ * \return The object of typeface, if successful 17063+ * \n Return null, if the font data is not recognized 17064+ */ 17065+sk_sp<SkTypeface> SkFontMgr_OHOS::makeTypeface(SkFontData* fontData) const 17066+{ 17067+ FontInfo fontInfo; 17068+ int ttcIndex = fontData->getIndex(); 17069+ int axisCount = fontData->getAxisCount(); 17070+ SkStreamAsset* stream = fontData->getStream(); 17071+ if (axisCount == 0) { 17072+ if (!fontScanner.scanFont(stream, ttcIndex, &fontInfo.familyName, &fontInfo.style, 17073+ &fontInfo.isFixedWidth, nullptr)) { 17074+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); 17075+ return nullptr; 17076+ } 17077+ } else { 17078+ const SkFixed* axis = fontData->getAxis(); 17079+ AxisDefinitions axisDefs; 17080+ if (!fontScanner.scanFont(stream, ttcIndex, &fontInfo.familyName, &fontInfo.style, 17081+ &fontInfo.isFixedWidth, &axisDefs)) { 17082+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); 17083+ return nullptr; 17084+ } 17085+ if (axisDefs.count() > 0) { 17086+ fontInfo.setAxisSet(axisCount, axis, axisDefs.data()); 17087+ } 17088+ } 17089+ 17090+ fontInfo.stream = fontData->detachStream(); 17091+ fontInfo.index = ttcIndex; 17092+ return sk_make_sp<SkTypeface_OHOS>(fontInfo); 17093+} 17094+ 17095+/*! To create SkFontMgr object for Harmony platform 17096+ * \param fname the full name of system font configuration documents 17097+ * \return The object of SkFontMgr_OHOS 17098+ */ 17099+sk_sp<SkFontMgr> SkFontMgr_New_OHOS(const char* fname) 17100+{ 17101+ return sk_make_sp<SkFontMgr_OHOS>(fname); 17102+} 17103diff --git a/third_party/skia/src/ports/skia_ohos/SkFontMgr_ohos.h b/third_party/skia/src/ports/skia_ohos/SkFontMgr_ohos.h 17104new file mode 100644 17105index 0000000000..9879726589 17106--- /dev/null 17107+++ b/third_party/skia/src/ports/skia_ohos/SkFontMgr_ohos.h 17108@@ -0,0 +1,68 @@ 17109+/* 17110+ * Copyright 2015 Google Inc. 17111+ * 17112+ * Use of this source code is governed by a BSD-style license that can be 17113+ * found in the LICENSE file. 17114+ * 2021.2.10 SkFontMgr on ohos. 17115+ * Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved. 17116+ */ 17117+ 17118+#ifndef SKFONTMGR_OHOS_H 17119+#define SKFONTMGR_OHOS_H 17120+ 17121+#include "src/core/SkFontDescriptor.h" 17122+#include "include/core/SkFontMgr.h" 17123+ 17124+#include "FontConfig_ohos.h" 17125+#include "SkFontStyleSet_ohos.h" 17126+ 17127+/*! 17128+ * \brief To implement the SkFontMgr for ohos platform 17129+ */ 17130+class SkFontMgr_OHOS : public SkFontMgr { 17131+public: 17132+ explicit SkFontMgr_OHOS(const char* path = nullptr); 17133+ virtual ~SkFontMgr_OHOS() override = default; 17134+protected: 17135+ virtual int onCountFamilies() const override; 17136+ virtual void onGetFamilyName(int index, SkString* familyName) const override; 17137+ virtual SkFontStyleSet* onCreateStyleSet(int index)const override; 17138+ 17139+ virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const override; 17140+ 17141+ virtual SkTypeface* onMatchFamilyStyle(const char familyName[], 17142+ const SkFontStyle& style) const override; 17143+ virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle& style, 17144+ const char* bcp47[], int bcp47Count, 17145+ SkUnichar character) const override; 17146+ 17147+ virtual SkTypeface* onMatchFaceStyle(const SkTypeface* typeface, 17148+ const SkFontStyle& style) const override; 17149+ 17150+ virtual sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData> data, int ttcIndex) const override; 17151+ virtual sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset> stream, 17152+ int ttcIndex) const override; 17153+ virtual sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset> stream, 17154+ const SkFontArguments& args) const override; 17155+ virtual sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData> data) const override; 17156+ virtual sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override; 17157+ 17158+ virtual sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override; 17159+ 17160+private: 17161+ std::shared_ptr<FontConfig_OHOS> fontConfig = nullptr; // the pointer of FontConfig_OHOS 17162+ SkTypeface_FreeType::Scanner fontScanner; // the scanner to parse a font file 17163+ int familyCount = 0; // the count of font style sets in generic family list 17164+ 17165+ int compareLangs(const SkString& langs, const char* bcp47[], int bcp47Count, const int tps[]) const; 17166+ sk_sp<SkTypeface> makeTypeface(std::unique_ptr<SkStreamAsset> stream, 17167+ const SkFontArguments& args, const char path[]) const; 17168+ sk_sp<SkTypeface> makeTypeface(SkFontData* fontData) const; 17169+ SkTypeface* findTypeface(const FallbackSetPos& fallbackItem, const SkFontStyle& style, 17170+ const char* bcp47[], int bcp47Count, 17171+ SkUnichar character) const; 17172+}; 17173+ 17174+SK_API sk_sp<SkFontMgr> SkFontMgr_New_OHOS(const char* path); 17175+ 17176+#endif /* SKFONTMGR_OHOS_H */ 17177diff --git a/third_party/skia/src/ports/skia_ohos/SkFontStyleSet_ohos.cpp b/third_party/skia/src/ports/skia_ohos/SkFontStyleSet_ohos.cpp 17178new file mode 100644 17179index 0000000000..23c046136d 17180--- /dev/null 17181+++ b/third_party/skia/src/ports/skia_ohos/SkFontStyleSet_ohos.cpp 17182@@ -0,0 +1,103 @@ 17183+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 17184+// Use of this source code is governed by a BSD-style license that can be 17185+// found in the LICENSE file. 17186+ 17187+#include "SkFontStyleSet_ohos.h" 17188+ 17189+/*! Constructor 17190+ * \param fontConfig the pointer of FontConfig_OHOS 17191+ * \param index the index of the font style set 17192+ * \param isFallback true - the font style is from fallback family 17193+ * \n false - the font style is from generic family 17194+ */ 17195+SkFontStyleSet_OHOS::SkFontStyleSet_OHOS(const std::shared_ptr<FontConfig_OHOS>& fontConfig, 17196+ int index, bool isFallback) 17197+ : fontConfig_(fontConfig), styleIndex(index), isFallback(isFallback) 17198+{ 17199+ if (fontConfig) { 17200+ tpCount = fontConfig_->getTypefaceCount(styleIndex, isFallback); 17201+ } 17202+} 17203+ 17204+/*! To get the count of typeface 17205+ * \return The count of typeface in this font style set 17206+ */ 17207+int SkFontStyleSet_OHOS::count() 17208+{ 17209+ return tpCount; 17210+} 17211+ 17212+/*! To get the font style for the specified typeface 17213+ * \param the index of a typeface 17214+ * \param[out] style the style value returned to the caller 17215+ * \param[out] the style name returned to the caller 17216+ */ 17217+void SkFontStyleSet_OHOS::getStyle(int index, SkFontStyle* style, SkString* styleName) 17218+{ 17219+ if (index < 0 || index >= this->count() || fontConfig_ == nullptr) { 17220+ return; 17221+ } 17222+ 17223+ SkTypeface* typeface = fontConfig_->getTypeface(styleIndex, index, isFallback); 17224+ if (typeface == nullptr) { 17225+ return; 17226+ } 17227+ 17228+ if (style) { 17229+ *style = typeface->fontStyle(); 17230+ } 17231+ if (styleName) { 17232+ const char* names[] = { 17233+ "invisible", 17234+ "thin", 17235+ "extralight", 17236+ "light", 17237+ "normal", 17238+ "medium", 17239+ "semibold", 17240+ "bold", 17241+ "extrabold", 17242+ "black", 17243+ "extrablack" 17244+ }; 17245+ // the value of font weight is between 0 ~ 1000 (refer to SkFontStyle::Weight) 17246+ // the weight is divided by 100 to get the matched name 17247+ unsigned int i = typeface->fontStyle().weight() / 100; 17248+ if (i < sizeof(names) / sizeof(char*)) { 17249+ styleName->set(names[i]); 17250+ } else { 17251+ styleName->reset(); 17252+ } 17253+ } 17254+} 17255+ 17256+/*! To create a typeface 17257+ * \param index the index of the typeface in this font style set 17258+ * \return The object of a typeface, if successful 17259+ * \n Return null, if the 'index' is out of range 17260+ * \note The caller must call unref() on the returned object if it's not null 17261+ */ 17262+SkTypeface* SkFontStyleSet_OHOS::createTypeface(int index) 17263+{ 17264+ if (index < 0 || index >= this->count()) { 17265+ return nullptr; 17266+ } 17267+ if (fontConfig_) { 17268+ return SkSafeRef(fontConfig_->getTypeface(styleIndex, index, isFallback)); 17269+ } 17270+ return nullptr; 17271+} 17272+ 17273+/*! To get the closest matching typeface 17274+ * \param pattern the style value to be matching 17275+ * \return the object of a typeface which is the closest matching to 'pattern' 17276+ * \note The caller must call unref() on the returned object 17277+ */ 17278+SkTypeface* SkFontStyleSet_OHOS::matchStyle(const SkFontStyle& pattern) 17279+{ 17280+ if (fontConfig_) { 17281+ return SkSafeRef(fontConfig_->getTypeface(styleIndex, pattern, isFallback)); 17282+ } 17283+ return nullptr; 17284+} 17285+ 17286diff --git a/third_party/skia/src/ports/skia_ohos/SkFontStyleSet_ohos.h b/third_party/skia/src/ports/skia_ohos/SkFontStyleSet_ohos.h 17287new file mode 100644 17288index 0000000000..b3224c2bd1 17289--- /dev/null 17290+++ b/third_party/skia/src/ports/skia_ohos/SkFontStyleSet_ohos.h 17291@@ -0,0 +1,32 @@ 17292+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 17293+// Use of this source code is governed by a BSD-style license that can be 17294+// found in the LICENSE file. 17295+ 17296+#ifndef SKFONTSTYLESET_OHOS_H 17297+#define SKFONTSTYLESET_OHOS_H 17298+ 17299+#include "include/core/SkFontMgr.h" 17300+ 17301+#include "FontConfig_ohos.h" 17302+#include "SkTypeface_ohos.h" 17303+ 17304+/*! 17305+ * \brief To implement SkFontStyleSet for ohos platform 17306+ */ 17307+class SkFontStyleSet_OHOS : public SkFontStyleSet { 17308+public: 17309+ SkFontStyleSet_OHOS(const std::shared_ptr<FontConfig_OHOS>& fontConfig, 17310+ int index, bool isFallback = false); 17311+ virtual ~SkFontStyleSet_OHOS() override = default; 17312+ virtual int count() override; 17313+ virtual void getStyle(int index, SkFontStyle* style, SkString* styleName) override; 17314+ virtual SkTypeface* createTypeface(int index) override; 17315+ virtual SkTypeface* matchStyle(const SkFontStyle& pattern) override; 17316+private: 17317+ std::shared_ptr<FontConfig_OHOS> fontConfig_ = nullptr; // the object of FontConfig_OHOS 17318+ int styleIndex = 0; // the index of the font style set 17319+ bool isFallback = false; // the flag of font style set. False for fallback family, true for generic family. 17320+ int tpCount = -1; // the typeface count in the font style set 17321+}; 17322+ 17323+#endif /* SKFONTSTYLESET_OHOS_H */ 17324diff --git a/third_party/skia/src/ports/skia_ohos/SkTypeface_ohos.cpp b/third_party/skia/src/ports/skia_ohos/SkTypeface_ohos.cpp 17325new file mode 100644 17326index 0000000000..b453185cfe 17327--- /dev/null 17328+++ b/third_party/skia/src/ports/skia_ohos/SkTypeface_ohos.cpp 17329@@ -0,0 +1,139 @@ 17330+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 17331+// Use of this source code is governed by a BSD-style license that can be 17332+// found in the LICENSE file. 17333+ 17334+#include "SkTypeface_ohos.h" 17335+ 17336+#include "src/core/SkFontDescriptor.h" 17337+#include "src/ports/SkFontHost_FreeType_common.h" 17338+#include "include/private/SkTArray.h" 17339+ 17340+/*! Constructor 17341+ * \param familyName the specified family name for the typeface 17342+ * \param info the font information for the typeface 17343+ */ 17344+SkTypeface_OHOS::SkTypeface_OHOS(const SkString& familyName, FontInfo& info) 17345+ : SkTypeface_FreeType(info.style, info.isFixedWidth), 17346+ specifiedName(familyName) 17347+{ 17348+ fontInfo = std::make_unique<FontInfo>(std::move(info)); 17349+} 17350+ 17351+/*! Constructor 17352+ * \param info the font information for the typeface 17353+ */ 17354+SkTypeface_OHOS::SkTypeface_OHOS(FontInfo& info) 17355+ : SkTypeface_FreeType(info.style, info.isFixedWidth) 17356+{ 17357+ specifiedName.reset(); 17358+ fontInfo = std::make_unique<FontInfo>(std::move(info)); 17359+} 17360+ 17361+/*! To get stream of the typeface 17362+ * \param[out] ttcIndex the index of the typeface in a ttc file returned to the caller 17363+ * \return The stream object of the typeface 17364+ */ 17365+std::unique_ptr<SkStreamAsset> SkTypeface_OHOS::onOpenStream(int* ttcIndex) const 17366+{ 17367+ if (fontInfo) { 17368+ if (ttcIndex) { 17369+ *ttcIndex = fontInfo->index; 17370+ } 17371+ if (fontInfo->stream == nullptr) { 17372+ fontInfo->stream = SkStream::MakeFromFile(fontInfo->fname.c_str()); 17373+ } 17374+ if (fontInfo->stream) { 17375+ return fontInfo->stream->duplicate(); 17376+ } 17377+ } 17378+ return nullptr; 17379+} 17380+ 17381+/*! To make font data from the typeface 17382+ * \return The object of SkFontData 17383+ */ 17384+std::unique_ptr<SkFontData> SkTypeface_OHOS::onMakeFontData() const 17385+{ 17386+ if (fontInfo == nullptr) { 17387+ return nullptr; 17388+ } 17389+ 17390+ if (fontInfo->stream.get() == nullptr) { 17391+ fontInfo->stream = SkStream::MakeFromFile(fontInfo->fname.c_str()); 17392+ } 17393+ if (fontInfo->stream.get() == nullptr) { 17394+ return nullptr; 17395+ } 17396+ return std::make_unique<SkFontData>(fontInfo->stream->duplicate(), fontInfo->index, 17397+ fontInfo->axisSet.axis.data(), fontInfo->axisSet.axis.size()); 17398+} 17399+ 17400+/*! To get the font descriptor of the typeface 17401+ * \param[out] descriptor the font descriptor returned to the caller 17402+ * \param[out] isLocal the false to the caller 17403+ */ 17404+void SkTypeface_OHOS::onGetFontDescriptor(SkFontDescriptor* descriptor, bool* isLocal) const 17405+{ 17406+ if (isLocal) { 17407+ *isLocal = false; 17408+ } 17409+ if (descriptor) { 17410+ SkString familyName; 17411+ onGetFamilyName(&familyName); 17412+ descriptor->setFamilyName(familyName.c_str()); 17413+ descriptor->setStyle(this->fontStyle()); 17414+ } 17415+} 17416+ 17417+/*! To get the family name of the typeface 17418+ * \param[out] familyName the family name returned to the caller 17419+ */ 17420+void SkTypeface_OHOS::onGetFamilyName(SkString* familyName) const 17421+{ 17422+ if (familyName == nullptr) { 17423+ return; 17424+ } 17425+ if (specifiedName.size() > 0) { 17426+ *familyName = specifiedName; 17427+ } else { 17428+ if (fontInfo) { 17429+ *familyName = fontInfo->familyName; 17430+ } 17431+ } 17432+} 17433+ 17434+/*! To clone a typeface from this typeface 17435+ * \param args the specified font arguments from which the new typeface is created 17436+ * \return The object of a new typeface 17437+ * \note The caller must call unref() on the returned object 17438+ */ 17439+sk_sp<SkTypeface> SkTypeface_OHOS::onMakeClone(const SkFontArguments& args) const 17440+{ 17441+ FontInfo info(*(fontInfo.get())); 17442+ info.index = args.getCollectionIndex(); 17443+ unsigned int count = args.getVariationDesignPosition().coordinateCount; 17444+ if (count > 0 && count == fontInfo->axisSet.range.size()) { 17445+ SkFontArguments::VariationPosition position = args.getVariationDesignPosition(); 17446+ SkTypeface_FreeType::Scanner::AxisDefinitions axisDefs; 17447+ for (unsigned int i = 0; i < count; i++) { 17448+ axisDefs.push_back(fontInfo->axisSet.range[i]); 17449+ } 17450+ SkFixed axisValues[count]; 17451+ memset(axisValues, 0, sizeof(axisValues)); 17452+ SkTypeface_FreeType::Scanner::computeAxisValues(axisDefs, position, 17453+ axisValues, fontInfo->familyName); 17454+ info.axisSet.axis.clear(); 17455+ for (unsigned int i = 0; i < count; i++) { 17456+ info.axisSet.axis.emplace_back(axisValues[i]); 17457+ } 17458+ } 17459+ return sk_make_sp<SkTypeface_OHOS>(specifiedName, info); 17460+} 17461+ 17462+/*! To get the font information of the typeface 17463+ * \return The object of FontInfo 17464+ */ 17465+const FontInfo* SkTypeface_OHOS::getFontInfo() const 17466+{ 17467+ return fontInfo.get(); 17468+} 17469diff --git a/third_party/skia/src/ports/skia_ohos/SkTypeface_ohos.h b/third_party/skia/src/ports/skia_ohos/SkTypeface_ohos.h 17470new file mode 100644 17471index 0000000000..fc36fa8dfe 17472--- /dev/null 17473+++ b/third_party/skia/src/ports/skia_ohos/SkTypeface_ohos.h 17474@@ -0,0 +1,34 @@ 17475+// Copyright (c) 2021 Huawei Device Co., Ltd. All rights reserved 17476+// Use of this source code is governed by a BSD-style license that can be 17477+// found in the LICENSE file. 17478+ 17479+#ifndef SKTYPEFACE_OHOS_H 17480+#define SKTYPEFACE_OHOS_H 17481+ 17482+#include "src/ports/SkFontHost_FreeType_common.h" 17483+#include "include/core/SkFontStyle.h" 17484+#include "include/core/SkStream.h" 17485+ 17486+#include "FontInfo_ohos.h" 17487+ 17488+/*! 17489+ * \brief The implementation of SkTypeface for ohos platform 17490+ */ 17491+class SkTypeface_OHOS : public SkTypeface_FreeType { 17492+public: 17493+ SkTypeface_OHOS(const SkString& specifiedName, FontInfo& info); 17494+ explicit SkTypeface_OHOS(FontInfo& info); 17495+ virtual ~SkTypeface_OHOS() override = default; 17496+ const FontInfo* getFontInfo() const; 17497+protected: 17498+ virtual std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override; 17499+ virtual std::unique_ptr<SkFontData> onMakeFontData() const override; 17500+ virtual void onGetFontDescriptor(SkFontDescriptor* descriptor, bool* isLocal) const override; 17501+ virtual void onGetFamilyName(SkString* familyName) const override; 17502+ virtual sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override; 17503+private: 17504+ SkString specifiedName; // specified family name which is defined in the configuration file 17505+ std::unique_ptr<FontInfo> fontInfo; // the font information of this typeface 17506+}; 17507+ 17508+#endif /* SKTYPEFACE_OHOS_H */ 17509diff --git a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc 17510index 6a4438f480..c9f8076689 100644 17511--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc 17512+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc 17513@@ -35,7 +35,7 @@ bool MemoryUsage::IsSupported() { 17514 17515 MemoryUsage GetMemoryUsage() { 17516 MemoryUsage result; 17517-#ifdef __linux__ 17518+#if defined(__linux__) && !defined(__MUSL__) 17519 rusage res; 17520 if (getrusage(RUSAGE_SELF, &res) == 0) { 17521 result.max_rss_kb = res.ru_maxrss; 17522diff --git a/third_party/unrar/BUILD.gn b/third_party/unrar/BUILD.gn 17523index 96756a8a53..a7965ae03a 100644 17524--- a/third_party/unrar/BUILD.gn 17525+++ b/third_party/unrar/BUILD.gn 17526@@ -99,6 +99,9 @@ static_library("unrar") { 17527 # Disables exceptions in unrar, replaces them with process termination. 17528 "UNRAR_NO_EXCEPTIONS", 17529 ] 17530+ if (is_ohos) { 17531+ defines += [ "UNIX_TIME_NS" ] 17532+ } 17533 17534 deps = [ "//base" ] 17535 } 17536diff --git a/third_party/utf/BUILD.gn b/third_party/utf/BUILD.gn 17537index e759fc29d6..cc885e82a0 100644 17538--- a/third_party/utf/BUILD.gn 17539+++ b/third_party/utf/BUILD.gn 17540@@ -53,7 +53,7 @@ static_library("utf") { 17541 # third_party/libphonenumber_metadata already contains its own copy of UTF 17542 # but only on Android. We do not include these files to avoid double linkage 17543 # issues. 17544- if (!is_android) { 17545+ if (!is_android && !is_ohos) { 17546 sources += [ 17547 "src/utf/chartorune.c", 17548 "src/utf/fullrune.c", 17549diff --git a/third_party/webrtc/BUILD.gn b/third_party/webrtc/BUILD.gn 17550index c0b47d5d11..6e795d29a0 100644 17551--- a/third_party/webrtc/BUILD.gn 17552+++ b/third_party/webrtc/BUILD.gn 17553@@ -177,7 +177,7 @@ config("common_inherited_config") { 17554 "WEBRTC_IOS", 17555 ] 17556 } 17557- if (is_linux || is_chromeos) { 17558+ if (is_linux || is_chromeos || is_ohos) { 17559 defines += [ "WEBRTC_LINUX" ] 17560 } 17561 if (is_mac) { 17562@@ -190,10 +190,16 @@ config("common_inherited_config") { 17563 defines += [ "WEBRTC_WIN" ] 17564 } 17565 if (is_android) { 17566- defines += [ 17567- "WEBRTC_LINUX", 17568- "WEBRTC_ANDROID", 17569- ] 17570+ if (use_musl) { 17571+ defines += [ 17572+ "WEBRTC_LINUX", 17573+ ] 17574+ } else { 17575+ defines += [ 17576+ "WEBRTC_LINUX", 17577+ "WEBRTC_ANDROID", 17578+ ] 17579+ } 17580 17581 if (build_with_mozilla) { 17582 defines += [ "WEBRTC_ANDROID_OPENSLES" ] 17583diff --git a/third_party/webrtc/rtc_base/BUILD.gn b/third_party/webrtc/rtc_base/BUILD.gn 17584index 32ef93e5c5..a48e414f9a 100644 17585--- a/third_party/webrtc/rtc_base/BUILD.gn 17586+++ b/third_party/webrtc/rtc_base/BUILD.gn 17587@@ -154,7 +154,7 @@ rtc_library("rtc_base_approved") { 17588 [ "//native_client_sdk/src/libraries/nacl_io" ] 17589 } 17590 17591- if (is_android) { 17592+ if (is_android || is_ohos && !use_musl) { 17593 libs = [ "log" ] 17594 } 17595 17596@@ -307,7 +307,7 @@ rtc_library("logging") { 17597 frameworks = [ "Foundation.framework" ] 17598 } 17599 17600- if (is_android) { 17601+ if (is_android || is_ohos && !use_musl) { 17602 libs += [ "log" ] 17603 } 17604 } 17605@@ -334,7 +334,7 @@ rtc_library("checks") { 17606 "//third_party/abseil-cpp/absl/meta:type_traits", 17607 "//third_party/abseil-cpp/absl/strings", 17608 ] 17609- if (is_android) { 17610+ if (is_android || is_ohos && !use_musl) { 17611 libs += [ "log" ] 17612 } 17613 } 17614@@ -671,7 +671,7 @@ rtc_library("net_helpers") { 17615 "net_helpers.h", 17616 ] 17617 deps = [] 17618- if (is_android) { 17619+ if (is_android || is_ohos) { 17620 deps += [ ":ifaddrs_android" ] 17621 } 17622 if (is_win) { 17623@@ -803,7 +803,7 @@ rtc_library("threading") { 17624 "task_utils:to_queued_task", 17625 "third_party/sigslot", 17626 ] 17627- if (is_android) { 17628+ if (is_android || is_ohos) { 17629 deps += [ ":ifaddrs_android" ] 17630 } 17631 if (is_win) { 17632@@ -857,16 +857,18 @@ rtc_source_set("network_constants") { 17633 deps = [ ":checks" ] 17634 } 17635 17636-if (is_android) { 17637+if (is_android || is_ohos) { 17638 rtc_library("ifaddrs_android") { 17639 sources = [ 17640 "ifaddrs_android.cc", 17641 "ifaddrs_android.h", 17642 ] 17643- libs = [ 17644- "log", 17645- "GLESv2", 17646- ] 17647+ if (!use_musl) { 17648+ libs = [ 17649+ "log", 17650+ # "GLESv2", 17651+ ] 17652+ } 17653 } 17654 } 17655 17656@@ -1062,7 +1064,7 @@ rtc_library("rtc_base") { 17657 configs += [ ":external_ssl_library" ] 17658 } 17659 17660- if (is_android) { 17661+ if (is_android || is_ohos) { 17662 deps += [ ":ifaddrs_android" ] 17663 } 17664 17665diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn 17666index d64cb38bcd..13e15d7c88 100644 17667--- a/third_party/zlib/BUILD.gn 17668+++ b/third_party/zlib/BUILD.gn 17669@@ -108,7 +108,7 @@ if (use_arm_neon_optimizations) { 17670 defines = [ "CRC32_ARMV8_CRC32" ] 17671 if (is_android) { 17672 defines += [ "ARMV8_OS_ANDROID" ] 17673- } else if (is_linux || is_chromeos) { 17674+ } else if (is_linux || is_chromeos || is_ohos) { 17675 defines += [ "ARMV8_OS_LINUX" ] 17676 } else if (is_mac) { 17677 defines += [ "ARMV8_OS_MACOS" ] 17678@@ -335,10 +335,12 @@ component("zlib") { 17679 17680 if (is_android) { 17681 import("//build/config/android/config.gni") 17682- if (defined(android_ndk_root) && android_ndk_root != "") { 17683- deps += [ "//third_party/android_ndk:cpu_features" ] 17684- } else { 17685- assert(false, "CPU detection requires the Android NDK") 17686+ if (!use_musl) { 17687+ if (defined(android_ndk_root) && android_ndk_root != "") { 17688+ deps += [ "//third_party/android_ndk:cpu_features" ] 17689+ } else { 17690+ assert(false, "CPU detection requires the Android NDK") 17691+ } 17692 } 17693 } 17694 17695@@ -385,7 +387,7 @@ static_library("minizip") { 17696 ] 17697 } 17698 17699- if (is_apple || is_android || is_nacl) { 17700+ if (is_apple || is_android || is_nacl || is_ohos) { 17701 # Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We 17702 # use fopen, ftell, and fseek instead on these systems. 17703 defines = [ "USE_FILE32API" ] 17704diff --git a/tools/grit/grit_defines.gni b/tools/grit/grit_defines.gni 17705index 5b92d7a6cd..28a303ca15 100644 17706--- a/tools/grit/grit_defines.gni 17707+++ b/tools/grit/grit_defines.gni 17708@@ -69,6 +69,13 @@ if (is_linux || is_chromeos_lacros) { 17709 ] 17710 } 17711 17712+if (is_ohos) { 17713+ grit_defines += [ 17714+ "-D", 17715+ "is_ohos", 17716+ ] 17717+} 17718+ 17719 if (toolkit_views) { 17720 grit_defines += [ 17721 "-D", 17722diff --git a/tools/perf/BUILD.gn b/tools/perf/BUILD.gn 17723index 89363eb28b..391ce15ff9 100644 17724--- a/tools/perf/BUILD.gn 17725+++ b/tools/perf/BUILD.gn 17726@@ -5,7 +5,9 @@ 17727 # Keep in sync with group("perf_without_chrome"). 17728 group("perf") { 17729 testonly = true 17730- deps = [ "//tools/perf/chrome_telemetry_build:telemetry_chrome_test" ] 17731+ if (!use_musl) { 17732+ deps = [ "//tools/perf/chrome_telemetry_build:telemetry_chrome_test" ] 17733+ } 17734 data = [ 17735 "//tools/perf/", 17736 17737diff --git a/tools/v8_context_snapshot/v8_context_snapshot.gni b/tools/v8_context_snapshot/v8_context_snapshot.gni 17738index 5a2b53f7b5..b7654507fd 100644 17739--- a/tools/v8_context_snapshot/v8_context_snapshot.gni 17740+++ b/tools/v8_context_snapshot/v8_context_snapshot.gni 17741@@ -16,7 +16,7 @@ declare_args() { 17742 # TODO(crbug.com/764576): Enable the feature on more environments. 17743 # Disable in mac and win cross builds since building Blink twice is slow. 17744 use_v8_context_snapshot = 17745- !is_chromeos_ash && !is_android && !is_chromecast && !is_fuchsia && 17746+ !is_chromeos_ash && !is_android && !is_chromecast && !is_fuchsia && !is_ohos && 17747 !(host_os == "mac" && current_cpu == "x86") && 17748 (v8_target_cpu == target_cpu || is_msan) && 17749 !(is_win && host_os != "win") && !(is_mac && host_os != "mac") 17750diff --git a/tools/variations/fieldtrial_to_struct.py b/tools/variations/fieldtrial_to_struct.py 17751index 9ecf389747..e90eff902a 100755 17752--- a/tools/variations/fieldtrial_to_struct.py 17753+++ b/tools/variations/fieldtrial_to_struct.py 17754@@ -41,6 +41,7 @@ _platforms = [ 17755 'linux', 17756 'mac', 17757 'windows', 17758+ 'ohos', 17759 ] 17760 17761 _form_factors = [ 17762diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn 17763index 38f9f4f735..e5d4e5e447 100644 17764--- a/ui/aura/BUILD.gn 17765+++ b/ui/aura/BUILD.gn 17766@@ -256,7 +256,7 @@ static_library("test_support") { 17767 sources += [ "test/ui_controls_factory_aurawin.cc" ] 17768 } 17769 17770- if (is_linux || is_chromeos) { 17771+ if (is_linux || is_chromeos || is_ohos) { 17772 sources += [ "test/ui_controls_factory_aura_linux.cc" ] 17773 } 17774 17775diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn 17776index 5b1b39a6bb..edccf7e485 100644 17777--- a/ui/base/BUILD.gn 17778+++ b/ui/base/BUILD.gn 17779@@ -513,7 +513,7 @@ component("base") { 17780 } 17781 } 17782 17783- if (use_aura && (is_linux || is_chromeos)) { 17784+ if (use_aura && (is_linux || is_chromeos || is_ohos)) { 17785 sources += [ "resource/resource_bundle_auralinux.cc" ] 17786 } 17787 17788@@ -530,7 +530,7 @@ component("base") { 17789 ] 17790 } 17791 17792- if (is_chromeos_ash || (use_aura && (is_linux || is_chromeos_lacros))) { 17793+ if (is_chromeos_ash || (use_aura && (is_linux || is_chromeos_lacros || is_ohos))) { 17794 sources += [ 17795 "dragdrop/os_exchange_data_provider_non_backed.cc", 17796 "dragdrop/os_exchange_data_provider_non_backed.h", 17797@@ -1198,7 +1198,7 @@ if (is_win) { 17798 } 17799 } 17800 17801-if (is_linux || is_chromeos) { 17802+if (is_linux || is_chromeos || is_ohos) { 17803 # This source set defines linux wm role names and must not have any external 17804 # dependencies and be kept as minimal as possible. 17805 source_set("wm_role_names") { 17806diff --git a/ui/base/clipboard/clipboard_constants.cc b/ui/base/clipboard/clipboard_constants.cc 17807index df542333f6..8cc7de6b48 100644 17808--- a/ui/base/clipboard/clipboard_constants.cc 17809+++ b/ui/base/clipboard/clipboard_constants.cc 17810@@ -18,7 +18,7 @@ const char kMimeTypeSvg[] = "image/svg+xml"; 17811 const char kMimeTypeRTF[] = "text/rtf"; 17812 const char kMimeTypePNG[] = "image/png"; 17813 17814-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) 17815+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_OHOS) 17816 const char kMimeTypeLinuxUtf8String[] = "UTF8_STRING"; 17817 const char kMimeTypeLinuxString[] = "STRING"; 17818 const char kMimeTypeLinuxText[] = "TEXT"; 17819diff --git a/ui/base/clipboard/clipboard_constants.h b/ui/base/clipboard/clipboard_constants.h 17820index d0eea2208f..0509ce8d47 100644 17821--- a/ui/base/clipboard/clipboard_constants.h 17822+++ b/ui/base/clipboard/clipboard_constants.h 17823@@ -37,7 +37,7 @@ COMPONENT_EXPORT(UI_BASE_CLIPBOARD_TYPES) extern const char kMimeTypeRTF[]; 17824 COMPONENT_EXPORT(UI_BASE_CLIPBOARD_TYPES) extern const char kMimeTypePNG[]; 17825 17826 // Linux-specific MIME type constants (also used in Fuchsia). 17827-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) 17828+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_OHOS) 17829 COMPONENT_EXPORT(UI_BASE_CLIPBOARD_TYPES) 17830 extern const char kMimeTypeLinuxUtf8String[]; 17831 COMPONENT_EXPORT(UI_BASE_CLIPBOARD_TYPES) 17832diff --git a/ui/base/dragdrop/os_exchange_data_provider_factory.cc b/ui/base/dragdrop/os_exchange_data_provider_factory.cc 17833index 4f5c946a1a..fbaf669cfe 100644 17834--- a/ui/base/dragdrop/os_exchange_data_provider_factory.cc 17835+++ b/ui/base/dragdrop/os_exchange_data_provider_factory.cc 17836@@ -7,7 +7,7 @@ 17837 #include "base/notreached.h" 17838 #include "build/build_config.h" 17839 17840-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 17841+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 17842 #include "ui/base/dragdrop/os_exchange_data_provider_non_backed.h" 17843 #include "ui/base/ui_base_features.h" 17844 #if defined(USE_OZONE) 17845@@ -26,7 +26,7 @@ namespace ui { 17846 17847 namespace { 17848 17849-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 17850+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 17851 std::unique_ptr<OSExchangeDataProvider> CreateProviderForLinux() { 17852 #if defined(USE_OZONE) 17853 // The instance can be nullptr in tests that do not instantiate the platform, 17854@@ -50,7 +50,7 @@ std::unique_ptr<OSExchangeDataProvider> CreateProviderForLinux() { 17855 // static 17856 std::unique_ptr<OSExchangeDataProvider> 17857 OSExchangeDataProviderFactory::CreateProvider() { 17858-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 17859+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 17860 if (features::IsUsingOzonePlatform()) 17861 return CreateProviderForLinux(); 17862 #if defined(USE_X11) 17863diff --git a/ui/base/idle/BUILD.gn b/ui/base/idle/BUILD.gn 17864index 73f2aebff6..dbcd63fee5 100644 17865--- a/ui/base/idle/BUILD.gn 17866+++ b/ui/base/idle/BUILD.gn 17867@@ -56,7 +56,7 @@ component("idle") { 17868 sources += [ "idle_fuchsia.cc" ] 17869 } 17870 17871- if (is_linux) { 17872+ if (is_linux || is_ohos) { 17873 sources += [ "idle_linux.cc" ] 17874 } 17875 17876diff --git a/ui/base/ime/linux/BUILD.gn b/ui/base/ime/linux/BUILD.gn 17877index 672a47ae34..5001af2032 100644 17878--- a/ui/base/ime/linux/BUILD.gn 17879+++ b/ui/base/ime/linux/BUILD.gn 17880@@ -5,7 +5,7 @@ 17881 import("//build/config/chromeos/ui_mode.gni") 17882 import("//build/config/linux/pangocairo/pangocairo.gni") 17883 17884-assert(is_linux || is_chromeos_lacros) 17885+assert(is_linux || is_chromeos_lacros || is_ohos) 17886 17887 component("linux") { 17888 output_name = "ui_base_ime_linux" 17889diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc 17890index 3a309475b8..1032f1e903 100644 17891--- a/ui/base/resource/resource_bundle.cc 17892+++ b/ui/base/resource/resource_bundle.cc 17893@@ -371,10 +371,18 @@ base::FilePath ResourceBundle::GetLocaleFilePath( 17894 return base::FilePath(); 17895 17896 base::FilePath locale_file_path; 17897+#if !defined(OS_OHOS) 17898 if (base::PathService::Get(ui::DIR_LOCALES, &locale_file_path)) { 17899 locale_file_path = 17900 locale_file_path.AppendASCII(app_locale + kPakFileExtension); 17901 } 17902+#else 17903+ if (base::PathService::Get(base::DIR_ASSETS, &locale_file_path)) { 17904+ locale_file_path = 17905+ locale_file_path.AppendASCII(app_locale + kPakFileExtension); 17906+ } 17907+#endif 17908+ 17909 17910 // Note: The delegate GetPathForLocalePack() override is currently only used 17911 // by CastResourceDelegate, which does not call this function prior to 17912diff --git a/ui/color/BUILD.gn b/ui/color/BUILD.gn 17913index b0c1eba7fe..3c487a0743 100644 17914--- a/ui/color/BUILD.gn 17915+++ b/ui/color/BUILD.gn 17916@@ -101,7 +101,7 @@ component("mixers") { 17917 sources += [ "cros/native_color_mixers.cc" ] 17918 } else if (is_fuchsia) { 17919 sources += [ "fuchsia/native_color_mixers.cc" ] 17920- } else if (is_linux || is_chromeos) { 17921+ } else if (is_linux || is_chromeos || is_ohos) { 17922 sources += [ "linux/native_color_mixers.cc" ] 17923 } else if (is_mac) { 17924 frameworks = [ "AppKit.framework" ] 17925diff --git a/ui/events/BUILD.gn b/ui/events/BUILD.gn 17926index 767c19f343..6d317f4c1c 100644 17927--- a/ui/events/BUILD.gn 17928+++ b/ui/events/BUILD.gn 17929@@ -158,6 +158,10 @@ component("events_base") { 17930 "//ui/gfx/geometry", 17931 ] 17932 17933+ if (is_ohos) { 17934+ public_deps += [ "//ui/events/keycodes:x11" ] 17935+ } 17936+ 17937 if (use_x11 || ozone_platform_x11) { 17938 public_deps += [ "//ui/events/keycodes:x11" ] 17939 17940diff --git a/ui/events/keycodes/BUILD.gn b/ui/events/keycodes/BUILD.gn 17941index 6c06b461c6..bd13f2ad9d 100644 17942--- a/ui/events/keycodes/BUILD.gn 17943+++ b/ui/events/keycodes/BUILD.gn 17944@@ -28,6 +28,28 @@ source_set("xkb") { 17945 ] 17946 } 17947 17948+if (is_ohos) { 17949+ component("x11") { 17950+ output_name = "keycodes_x11" 17951+ 17952+ sources = [ 17953+ "keyboard_code_conversion_x.cc", 17954+ "keyboard_code_conversion_x.h", 17955+ "keycodes_x_export.h", 17956+ "keysym_to_unicode.cc", 17957+ "keysym_to_unicode.h", 17958+ ] 17959+ 17960+ defines = [ "KEYCODES_X_IMPLEMENTATION" ] 17961+ 17962+ deps = [ 17963+ ":xkb", 17964+ "//base", 17965+ "//ui/events:dom_keycode_converter", 17966+ ] 17967+ } 17968+} 17969+ 17970 if (use_x11 || ozone_platform_x11) { 17971 component("x11") { 17972 output_name = "keycodes_x11" 17973diff --git a/ui/events/keycodes/dom/keycode_converter.cc b/ui/events/keycodes/dom/keycode_converter.cc 17974index c6ed4ac20a..79c91342d9 100644 17975--- a/ui/events/keycodes/dom/keycode_converter.cc 17976+++ b/ui/events/keycodes/dom/keycode_converter.cc 17977@@ -24,7 +24,7 @@ namespace { 17978 #if defined(OS_WIN) 17979 #define DOM_CODE(usb, evdev, xkb, win, mac, code, id) \ 17980 { usb, win, code } 17981-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) 17982+#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 17983 #define DOM_CODE(usb, evdev, xkb, win, mac, code, id) \ 17984 { usb, xkb, code } 17985 #elif defined(OS_APPLE) 17986diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc 17987index b38af7a801..a5af83c7ca 100644 17988--- a/ui/events/keycodes/keyboard_code_conversion_x.cc 17989+++ b/ui/events/keycodes/keyboard_code_conversion_x.cc 17990@@ -19,8 +19,14 @@ 17991 #include "ui/events/keycodes/keysym_to_unicode.h" 17992 #include "ui/events/keycodes/xkb_keysym.h" 17993 #include "ui/gfx/x/keysyms/keysyms.h" 17994+#if !defined(OS_OHOS) 17995 #include "ui/gfx/x/xinput.h" 17996 #include "ui/gfx/x/xproto.h" 17997+#else 17998+#include "ui/gfx/x/generated_protos/xinput.h" 17999+#include "ui/gfx/x/generated_protos/xproto.h" 18000+#endif 18001+ 18002 #include "ui/gfx/x/xproto_types.h" 18003 18004 #define VKEY_UNSUPPORTED VKEY_UNKNOWN 18005diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn 18006index 181c0c5891..fcd6fe0e43 100644 18007--- a/ui/gfx/BUILD.gn 18008+++ b/ui/gfx/BUILD.gn 18009@@ -350,14 +350,14 @@ component("gfx") { 18010 ] 18011 } 18012 18013- if (is_android || is_fuchsia) { 18014+ if (is_android || is_fuchsia || is_ohos) { 18015 sources += [ 18016 "font_fallback_skia.cc", 18017 "font_render_params_skia.cc", 18018 ] 18019 } 18020 18021- if (is_android || is_fuchsia || is_win || is_mac) { 18022+ if (is_android || is_fuchsia || is_win || is_mac || is_ohos) { 18023 sources += [ 18024 "font_fallback_skia_impl.cc", 18025 "font_fallback_skia_impl.h", 18026@@ -603,7 +603,14 @@ source_set("memory_buffer_sources") { 18027 deps += [ "//build/config/linux/libdrm" ] 18028 } 18029 18030- if (is_linux || is_chromeos || is_android) { 18031+ if (is_ohos) { 18032+ sources += [ 18033+ "linux/native_pixmap_dmabuf.cc", 18034+ "linux/native_pixmap_dmabuf.h", 18035+ ] 18036+ } 18037+ 18038+ if (is_linux || is_chromeos || is_android || is_ohos) { 18039 deps += [ "//third_party/libsync" ] 18040 } 18041 18042diff --git a/ui/gfx/animation/BUILD.gn b/ui/gfx/animation/BUILD.gn 18043index e544b0972f..a570a20e8d 100644 18044--- a/ui/gfx/animation/BUILD.gn 18045+++ b/ui/gfx/animation/BUILD.gn 18046@@ -45,7 +45,7 @@ component("animation") { 18047 sources += [ "animation_win.cc" ] 18048 } 18049 18050- if (is_linux || is_chromeos_lacros) { 18051+ if (is_linux || is_chromeos_lacros || is_ohos) { 18052 sources += [ 18053 "animation_linux.cc", 18054 "animation_settings_provider_linux.cc", 18055diff --git a/ui/gfx/gpu_memory_buffer.cc b/ui/gfx/gpu_memory_buffer.cc 18056index 44b2667960..cd7ece485b 100644 18057--- a/ui/gfx/gpu_memory_buffer.cc 18058+++ b/ui/gfx/gpu_memory_buffer.cc 18059@@ -53,7 +53,7 @@ GpuMemoryBufferHandle GpuMemoryBufferHandle::Clone() const { 18060 handle.region = region.Duplicate(); 18061 handle.offset = offset; 18062 handle.stride = stride; 18063-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) 18064+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_OHOS) 18065 handle.native_pixmap_handle = CloneHandleForIPC(native_pixmap_handle); 18066 #elif defined(OS_MAC) 18067 handle.io_surface = io_surface; 18068diff --git a/ui/gfx/gpu_memory_buffer.h b/ui/gfx/gpu_memory_buffer.h 18069index c3a1f813ca..cea4239a25 100644 18070--- a/ui/gfx/gpu_memory_buffer.h 18071+++ b/ui/gfx/gpu_memory_buffer.h 18072@@ -16,7 +16,7 @@ 18073 #include "ui/gfx/gfx_export.h" 18074 #include "ui/gfx/hdr_metadata.h" 18075 18076-#if defined(USE_OZONE) || defined(OS_LINUX) || defined(OS_CHROMEOS) 18077+#if defined(USE_OZONE) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18078 #include "ui/gfx/native_pixmap_handle.h" 18079 #elif defined(OS_MAC) 18080 #include "ui/gfx/mac/io_surface.h" 18081@@ -70,7 +70,7 @@ struct GFX_EXPORT GpuMemoryBufferHandle { 18082 base::UnsafeSharedMemoryRegion region; 18083 uint32_t offset = 0; 18084 int32_t stride = 0; 18085-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) 18086+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) || defined(OS_OHOS) 18087 NativePixmapHandle native_pixmap_handle; 18088 #elif defined(OS_MAC) 18089 ScopedIOSurface io_surface; 18090diff --git a/ui/gfx/mojom/BUILD.gn b/ui/gfx/mojom/BUILD.gn 18091index 07b61c87c7..5d428cc1bc 100644 18092--- a/ui/gfx/mojom/BUILD.gn 18093+++ b/ui/gfx/mojom/BUILD.gn 18094@@ -303,7 +303,7 @@ mojom("mojom") { 18095 18096 mojom("native_handle_types") { 18097 sources = [ "native_handle_types.mojom" ] 18098- if (is_linux || is_chromeos || use_ozone) { 18099+ if (is_linux || is_chromeos || use_ozone || is_ohos) { 18100 enabled_features = [ "supports_native_pixmap" ] 18101 } 18102 public_deps = [ "//mojo/public/mojom/base" ] 18103diff --git a/ui/gfx/mojom/native_handle_types.mojom b/ui/gfx/mojom/native_handle_types.mojom 18104index 5b7be0a212..98eabee6e8 100644 18105--- a/ui/gfx/mojom/native_handle_types.mojom 18106+++ b/ui/gfx/mojom/native_handle_types.mojom 18107@@ -27,6 +27,8 @@ struct NativePixmapHandle { 18108 uint64 modifier; 18109 [EnableIf=is_chromeos] 18110 uint64 modifier; 18111+ [EnableIf=is_ohos] 18112+ uint64 modifier; 18113 18114 [EnableIf=is_fuchsia] 18115 mojo_base.mojom.UnguessableToken? buffer_collection_id; 18116diff --git a/ui/gfx/mojom/native_handle_types_mojom_traits.cc b/ui/gfx/mojom/native_handle_types_mojom_traits.cc 18117index 15e5b8b976..475191bc53 100644 18118--- a/ui/gfx/mojom/native_handle_types_mojom_traits.cc 18119+++ b/ui/gfx/mojom/native_handle_types_mojom_traits.cc 18120@@ -8,11 +8,11 @@ 18121 18122 namespace mojo { 18123 18124-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(USE_OZONE) 18125+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(USE_OZONE) || defined(OS_OHOS) 18126 mojo::PlatformHandle StructTraits< 18127 gfx::mojom::NativePixmapPlaneDataView, 18128 gfx::NativePixmapPlane>::buffer_handle(gfx::NativePixmapPlane& plane) { 18129-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18130+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18131 return mojo::PlatformHandle(std::move(plane.fd)); 18132 #elif defined(OS_FUCHSIA) 18133 return mojo::PlatformHandle(std::move(plane.vmo)); 18134@@ -28,7 +28,7 @@ bool StructTraits< 18135 out->size = data.size(); 18136 18137 mojo::PlatformHandle handle = data.TakeBufferHandle(); 18138-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18139+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18140 if (!handle.is_fd()) 18141 return false; 18142 out->fd = handle.TakeFD(); 18143@@ -45,7 +45,7 @@ bool StructTraits< 18144 gfx::mojom::NativePixmapHandleDataView, 18145 gfx::NativePixmapHandle>::Read(gfx::mojom::NativePixmapHandleDataView data, 18146 gfx::NativePixmapHandle* out) { 18147-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18148+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18149 out->modifier = data.modifier(); 18150 #endif 18151 18152diff --git a/ui/gfx/mojom/native_handle_types_mojom_traits.h b/ui/gfx/mojom/native_handle_types_mojom_traits.h 18153index 6e9ed3d64e..ee807fd59d 100644 18154--- a/ui/gfx/mojom/native_handle_types_mojom_traits.h 18155+++ b/ui/gfx/mojom/native_handle_types_mojom_traits.h 18156@@ -14,13 +14,13 @@ 18157 #include "mojo/public/cpp/system/platform_handle.h" 18158 #include "ui/gfx/mojom/native_handle_types.mojom-shared.h" 18159 18160-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(USE_OZONE) 18161+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(USE_OZONE) || defined(OS_OHOS) 18162 #include "ui/gfx/native_pixmap_handle.h" 18163 #endif 18164 18165 namespace mojo { 18166 18167-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(USE_OZONE) 18168+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(USE_OZONE) || defined(OS_OHOS) 18169 template <> 18170 struct COMPONENT_EXPORT(GFX_NATIVE_HANDLE_TYPES_SHARED_MOJOM_TRAITS) 18171 StructTraits<gfx::mojom::NativePixmapPlaneDataView, 18172@@ -48,7 +48,7 @@ struct COMPONENT_EXPORT(GFX_NATIVE_HANDLE_TYPES_SHARED_MOJOM_TRAITS) 18173 return pixmap_handle.planes; 18174 } 18175 18176-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18177+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18178 static uint64_t modifier(const gfx::NativePixmapHandle& pixmap_handle) { 18179 return pixmap_handle.modifier; 18180 } 18181diff --git a/ui/gfx/native_pixmap_handle.cc b/ui/gfx/native_pixmap_handle.cc 18182index 137056bcdc..246eaa4b31 100644 18183--- a/ui/gfx/native_pixmap_handle.cc 18184+++ b/ui/gfx/native_pixmap_handle.cc 18185@@ -12,6 +12,10 @@ 18186 #if defined(OS_LINUX) || defined(OS_CHROMEOS) 18187 #include <drm_fourcc.h> 18188 #include "base/posix/eintr_wrapper.h" 18189+#elif defined(OS_OHOS) 18190+#include <drm/drm_fourcc.h> 18191+#include <unistd.h> 18192+#include "base/posix/eintr_wrapper.h" 18193 #endif 18194 18195 #if defined(OS_FUCHSIA) 18196@@ -21,7 +25,7 @@ 18197 18198 namespace gfx { 18199 18200-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18201+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18202 static_assert(NativePixmapHandle::kNoModifier == DRM_FORMAT_MOD_INVALID, 18203 "gfx::NativePixmapHandle::kNoModifier should be an alias for" 18204 "DRM_FORMAT_MOD_INVALID"); 18205@@ -32,7 +36,7 @@ NativePixmapPlane::NativePixmapPlane() : stride(0), offset(0), size(0) {} 18206 NativePixmapPlane::NativePixmapPlane(int stride, 18207 int offset, 18208 uint64_t size 18209-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18210+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18211 , 18212 base::ScopedFD fd 18213 #elif defined(OS_FUCHSIA) 18214@@ -43,7 +47,7 @@ NativePixmapPlane::NativePixmapPlane(int stride, 18215 : stride(stride), 18216 offset(offset), 18217 size(size) 18218-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18219+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18220 , 18221 fd(std::move(fd)) 18222 #elif defined(OS_FUCHSIA) 18223@@ -71,7 +75,7 @@ NativePixmapHandle& NativePixmapHandle::operator=(NativePixmapHandle&& other) = 18224 NativePixmapHandle CloneHandleForIPC(const NativePixmapHandle& handle) { 18225 NativePixmapHandle clone; 18226 for (auto& plane : handle.planes) { 18227-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18228+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18229 DCHECK(plane.fd.is_valid()); 18230 base::ScopedFD fd_dup(HANDLE_EINTR(dup(plane.fd.get()))); 18231 if (!fd_dup.is_valid()) { 18232@@ -97,7 +101,7 @@ NativePixmapHandle CloneHandleForIPC(const NativePixmapHandle& handle) { 18233 #endif 18234 } 18235 18236-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18237+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18238 clone.modifier = handle.modifier; 18239 #endif 18240 18241diff --git a/ui/gfx/native_pixmap_handle.h b/ui/gfx/native_pixmap_handle.h 18242index 1748dd32f7..34ac4c4efd 100644 18243--- a/ui/gfx/native_pixmap_handle.h 18244+++ b/ui/gfx/native_pixmap_handle.h 18245@@ -15,7 +15,7 @@ 18246 #include "build/build_config.h" 18247 #include "ui/gfx/gfx_export.h" 18248 18249-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18250+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18251 #include "base/files/scoped_file.h" 18252 #endif 18253 18254@@ -32,7 +32,7 @@ struct GFX_EXPORT NativePixmapPlane { 18255 NativePixmapPlane(int stride, 18256 int offset, 18257 uint64_t size 18258-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18259+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18260 , 18261 base::ScopedFD fd 18262 #elif defined(OS_FUCHSIA) 18263@@ -53,7 +53,7 @@ struct GFX_EXPORT NativePixmapPlane { 18264 // This is necessary to map the buffers. 18265 uint64_t size; 18266 18267-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18268+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18269 // File descriptor for the underlying memory object (usually dmabuf). 18270 base::ScopedFD fd; 18271 #elif defined(OS_FUCHSIA) 18272@@ -82,7 +82,7 @@ struct GFX_EXPORT NativePixmapHandle { 18273 18274 std::vector<NativePixmapPlane> planes; 18275 18276-#if defined(OS_LINUX) || defined(OS_CHROMEOS) 18277+#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OHOS) 18278 // The modifier is retrieved from GBM library and passed to EGL driver. 18279 // Generally it's platform specific, and we don't need to modify it in 18280 // Chromium code. Also one per plane per entry. 18281diff --git a/ui/gfx/x/connection.h b/ui/gfx/x/connection.h 18282index 761a1ef5d5..43dfe10274 100644 18283--- a/ui/gfx/x/connection.h 18284+++ b/ui/gfx/x/connection.h 18285@@ -12,9 +12,14 @@ 18286 #include "base/optional.h" 18287 #include "base/sequence_checker.h" 18288 #include "ui/events/platform/platform_event_source.h" 18289+#if !defined(OS_OHOS) 18290 #include "ui/gfx/x/extension_manager.h" 18291-#include "ui/gfx/x/xlib_support.h" 18292 #include "ui/gfx/x/xproto.h" 18293+#else 18294+#include "ui/gfx/x/generated_protos/extension_manager.h" 18295+#include "ui/gfx/x/generated_protos/xproto.h" 18296+#endif 18297+#include "ui/gfx/x/xlib_support.h" 18298 18299 typedef struct xcb_connection_t xcb_connection_t; 18300 18301diff --git a/ui/gfx/x/event.h b/ui/gfx/x/event.h 18302index ed4f9b0c0f..000131c4f3 100644 18303--- a/ui/gfx/x/event.h 18304+++ b/ui/gfx/x/event.h 18305@@ -11,7 +11,11 @@ 18306 #include "base/component_export.h" 18307 #include "base/memory/ref_counted_memory.h" 18308 #include "base/memory/scoped_refptr.h" 18309+#if !defined(OS_OHOS) 18310 #include "ui/gfx/x/xproto.h" 18311+#else 18312+#include "ui/gfx/x/generated_protos/xproto.h" 18313+#endif 18314 18315 namespace x11 { 18316 18317diff --git a/ui/gl/features.gni b/ui/gl/features.gni 18318index 1bbc06c627..50f9268f7d 100644 18319--- a/ui/gl/features.gni 18320+++ b/ui/gl/features.gni 18321@@ -14,7 +14,7 @@ declare_args() { 18322 # Should EGL support be compiled? 18323 # Can be overriden to test during bring up of EGL support on other platforms. 18324 use_egl = 18325- is_win || is_android || is_linux || is_chromeos || is_fuchsia || is_mac 18326+ is_win || is_android || is_linux || is_chromeos || is_fuchsia || is_mac || is_ohos 18327 18328 # Should Dawn support be compiled to back the WebGPU implementation? 18329 # Also controls linking Dawn depedencies in such as SPIRV-Tools/SPIRV-Cross. 18330diff --git a/ui/message_center/BUILD.gn b/ui/message_center/BUILD.gn 18331index 807e24d9bb..9fa47d5223 100644 18332--- a/ui/message_center/BUILD.gn 18333+++ b/ui/message_center/BUILD.gn 18334@@ -88,7 +88,7 @@ component("message_center") { 18335 ] 18336 } 18337 18338- if (toolkit_views) { 18339+ if (toolkit_views || is_ohos) { 18340 sources += [ 18341 "views/desktop_message_popup_collection.cc", 18342 "views/desktop_message_popup_collection.h", 18343diff --git a/ui/message_center/dummy_message_center.cc b/ui/message_center/dummy_message_center.cc 18344index db8d9dedf5..c2dc3bfe6d 100644 18345--- a/ui/message_center/dummy_message_center.cc 18346+++ b/ui/message_center/dummy_message_center.cc 18347@@ -9,8 +9,8 @@ 18348 // and link with Android implementations of Chrome which do not have 18349 // notification systems yet. This is to avoid spreading compile-time flags 18350 // everywhere in the code. 18351-#if !(defined(OS_ANDROID) || defined(OS_FUCHSIA)) 18352-#error This file should only be used in Android and Fuchsia. 18353+#if !(defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(OS_OHOS)) 18354+#error This file should only be used in Android and Fuchsia and Ohos. 18355 #endif 18356 18357 namespace message_center { 18358diff --git a/ui/shell_dialogs/BUILD.gn b/ui/shell_dialogs/BUILD.gn 18359index a7ef6364dc..9206f09d60 100644 18360--- a/ui/shell_dialogs/BUILD.gn 18361+++ b/ui/shell_dialogs/BUILD.gn 18362@@ -27,7 +27,7 @@ component("shell_dialogs") { 18363 "shell_dialogs_export.h", 18364 ] 18365 18366- if (is_linux || is_chromeos) { 18367+ if (is_linux || is_chromeos || is_ohos) { 18368 sources += [ 18369 "shell_dialog_linux.cc", 18370 "shell_dialog_linux.h", 18371diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn 18372index 945ca33ebb..cb7acaf7cd 100644 18373--- a/ui/views/BUILD.gn 18374+++ b/ui/views/BUILD.gn 18375@@ -12,7 +12,7 @@ import("//testing/test.gni") 18376 import("//ui/base/ui_features.gni") 18377 import("//ui/views/features.gni") 18378 18379-assert(toolkit_views) 18380+assert(toolkit_views || is_ohos) 18381 18382 config("flags") { 18383 defines = [ "TOOLKIT_VIEWS=1" ] 18384@@ -549,12 +549,12 @@ component("views") { 18385 deps += [ "//ui/base/ime/chromeos" ] 18386 } 18387 18388- if (is_linux || is_chromeos) { 18389+ if (is_linux || is_chromeos || is_ohos) { 18390 public += [ "color_chooser/color_chooser_view.h" ] 18391 sources += [ "color_chooser/color_chooser_view.cc" ] 18392 } 18393 18394- if (is_linux || is_chromeos_lacros) { 18395+ if (is_linux || is_chromeos_lacros || is_ohos) { 18396 sources -= [ "window/window_button_order_provider.cc" ] 18397 public_deps += [ "//ui/base/cursor:theme_manager" ] 18398 deps += [ 18399@@ -833,7 +833,7 @@ component("views") { 18400 ] 18401 deps += [ "//ui/base:hit_test" ] 18402 } 18403- if (is_linux || is_chromeos || is_fuchsia) { 18404+ if (is_linux || is_chromeos || is_fuchsia || is_ohos) { 18405 public += [ 18406 "widget/desktop_aura/desktop_window_tree_host_platform.h", 18407 "widget/desktop_aura/window_move_client_platform.h", 18408diff --git a/ui/views/controls/webview/BUILD.gn b/ui/views/controls/webview/BUILD.gn 18409index e4a99da262..3f6a967ec2 100644 18410--- a/ui/views/controls/webview/BUILD.gn 18411+++ b/ui/views/controls/webview/BUILD.gn 18412@@ -51,7 +51,7 @@ component("webview") { 18413 "//ui/views", 18414 ] 18415 18416- if (is_linux || is_chromeos || is_android || is_fuchsia) { 18417+ if (is_linux || is_chromeos || is_android || is_fuchsia || is_ohos) { 18418 sources += [ "unhandled_keyboard_event_handler_default.cc" ] 18419 } 18420 } 18421diff --git a/ui/views/views_delegate.cc b/ui/views/views_delegate.cc 18422index b238d2791d..69b471d07f 100644 18423--- a/ui/views/views_delegate.cc 18424+++ b/ui/views/views_delegate.cc 18425@@ -90,7 +90,7 @@ bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const { 18426 return false; 18427 } 18428 #elif BUILDFLAG(ENABLE_DESKTOP_AURA) && \ 18429- (defined(OS_LINUX) || defined(OS_CHROMEOS)) 18430+ (defined(OS_LINUX) || defined(OS_CHROMEOS)) || defined(OS_OHOS) 18431 gfx::ImageSkia* ViewsDelegate::GetDefaultWindowIcon() const { 18432 return nullptr; 18433 } 18434diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h 18435index d84acfa918..1348e65b91 100644 18436--- a/ui/views/views_delegate.h 18437+++ b/ui/views/views_delegate.h 18438@@ -137,7 +137,7 @@ class VIEWS_EXPORT ViewsDelegate { 18439 // environment. 18440 virtual bool IsWindowInMetro(gfx::NativeWindow window) const; 18441 #elif BUILDFLAG(ENABLE_DESKTOP_AURA) && \ 18442- (defined(OS_LINUX) || defined(OS_CHROMEOS)) 18443+ (defined(OS_LINUX) || defined(OS_CHROMEOS)) || defined(OS_OHOS) 18444 virtual gfx::ImageSkia* GetDefaultWindowIcon() const; 18445 #endif 18446 18447diff --git a/url/origin.cc b/url/origin.cc 18448index 10099725d7..ce538996af 100644 18449--- a/url/origin.cc 18450+++ b/url/origin.cc 18451@@ -422,11 +422,11 @@ Origin::Nonce& Origin::Nonce::operator=(const Origin::Nonce& other) { 18452 } 18453 18454 // Moving a nonce does NOT trigger lazy-generation of the token. 18455-Origin::Nonce::Nonce(Origin::Nonce&& other) : token_(other.token_) { 18456+Origin::Nonce::Nonce(Origin::Nonce&& other) noexcept : token_(other.token_) { 18457 other.token_ = base::UnguessableToken(); // Reset |other|. 18458 } 18459 18460-Origin::Nonce& Origin::Nonce::operator=(Origin::Nonce&& other) { 18461+Origin::Nonce& Origin::Nonce::operator=(Origin::Nonce&& other) noexcept { 18462 token_ = other.token_; 18463 other.token_ = base::UnguessableToken(); // Reset |other|. 18464 return *this; 18465