diff --git a/patch/patch.cfg b/patch/patch.cfg index 467aa88f0..7e27525c1 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -512,6 +512,10 @@ patches = [ # win: Add SHA256 implementation for Sid::FromNamedCapability using the # Crypto API. # https://github.com/chromiumembedded/cef/issues/3791 + # + # win: Disable use of Rust for JSON parsing with cef_sandbox. + # Enables the fallback to C++ that was removed in + # https://crrev.com/9ddc1624637c8cfa8ef50a95abd779e0ba4d67f6 'name': 'base_sandbox_2743', }, { diff --git a/patch/patches/base_sandbox_2743.patch b/patch/patches/base_sandbox_2743.patch index 2a817812b..5c2be268d 100644 --- a/patch/patches/base_sandbox_2743.patch +++ b/patch/patches/base_sandbox_2743.patch @@ -87,6 +87,116 @@ index 2158b648ca58a..8a8cb13b2fd74 100644 #include "base/hash/sha1_nacl.h" #else #include "base/hash/sha1_boringssl.h" +diff --git base/json/json_reader.cc base/json/json_reader.cc +index b3db0dea0fff6..e53ff0049559a 100644 +--- base/json/json_reader.cc ++++ base/json/json_reader.cc +@@ -12,8 +12,9 @@ + #include "base/logging.h" + #include "base/metrics/histogram_macros.h" + #include "build/build_config.h" ++#include "cef/libcef/features/features.h" + +-#if !BUILDFLAG(IS_NACL) ++#if !(BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + #include "base/strings/string_view_rust.h" + #include "third_party/rust/serde_json_lenient/v0_2/wrapper/functions.h" + #include "third_party/rust/serde_json_lenient/v0_2/wrapper/lib.rs.h" +@@ -23,7 +24,7 @@ namespace base { + + // TODO(crbug.com/40811643): Move the C++ parser into components/nacl to just + // run in-process there. Don't compile base::JSONReader on NaCL at all. +-#if !BUILDFLAG(IS_NACL) ++#if !(BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + + namespace { + using serde_json_lenient::ContextPointer; +@@ -134,16 +135,16 @@ JSONReader::Result DecodeJSONInRust(std::string_view json, + + } // anonymous namespace + +-#endif // !BUILDFLAG(IS_NACL) ++#endif // !(BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + + // static + std::optional JSONReader::Read(std::string_view json, + int options, + size_t max_depth) { +-#if BUILDFLAG(IS_NACL) ++#if (BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + internal::JSONParser parser(options, max_depth); + return parser.Parse(json); +-#else // BUILDFLAG(IS_NACL) ++#else // (BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + SCOPED_UMA_HISTOGRAM_TIMER_MICROS(kSecurityJsonParsingTime); + if (UsingRust()) { + JSONReader::Result result = DecodeJSONInRust(json, options, max_depth); +@@ -155,7 +156,7 @@ std::optional JSONReader::Read(std::string_view json, + internal::JSONParser parser(options, max_depth); + return parser.Parse(json); + } +-#endif // BUILDFLAG(IS_NACL) ++#endif // (BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + } + + // static +@@ -173,7 +174,7 @@ std::optional JSONReader::ReadDict(std::string_view json, + JSONReader::Result JSONReader::ReadAndReturnValueWithError( + std::string_view json, + int options) { +-#if BUILDFLAG(IS_NACL) ++#if (BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + internal::JSONParser parser(options); + auto value = parser.Parse(json); + if (!value) { +@@ -185,7 +186,7 @@ JSONReader::Result JSONReader::ReadAndReturnValueWithError( + } + + return std::move(*value); +-#else // BUILDFLAG(IS_NACL) ++#else // (BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + SCOPED_UMA_HISTOGRAM_TIMER_MICROS(kSecurityJsonParsingTime); + if (UsingRust()) { + return DecodeJSONInRust(json, options, internal::kAbsoluteMaxDepth); +@@ -202,7 +203,7 @@ JSONReader::Result JSONReader::ReadAndReturnValueWithError( + + return std::move(*value); + } +-#endif // BUILDFLAG(IS_NACL) ++#endif // (BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + } + + // static +@@ -213,7 +214,7 @@ bool JSONReader::UsingRust() { + if (!base::FeatureList::GetInstance()) { + return false; + } +-#if BUILDFLAG(IS_NACL) ++#if (BUILDFLAG(IS_NACL) || BUILDFLAG(IS_CEF_SANDBOX_BUILD)) + return false; + #else + return base::FeatureList::IsEnabled(base::features::kUseRustJsonParser); +diff --git base/logging.cc base/logging.cc +index 508ce135131aa..4158b7d5273b0 100644 +--- base/logging.cc ++++ base/logging.cc +@@ -60,6 +60,7 @@ + #include "base/vlog.h" + #include "build/build_config.h" + #include "build/chromeos_buildflags.h" ++#include "cef/libcef/features/features.h" + #include "third_party/abseil-cpp/absl/base/internal/raw_logging.h" + #include "third_party/abseil-cpp/absl/cleanup/cleanup.h" + +@@ -526,7 +527,7 @@ bool BaseInitLoggingImpl(const LoggingSettings& settings) { + } + #endif + +-#if !BUILDFLAG(IS_NACL) ++#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_CEF_SANDBOX_BUILD) + // Connects Rust logging with the //base logging functionality. + internal::init_rust_log_crate(); + #endif diff --git base/metrics/crc32.cc base/metrics/crc32.cc index 83e3cee2579ab..8238767ab9126 100644 --- base/metrics/crc32.cc diff --git a/tools/gn_args.py b/tools/gn_args.py index 9173c60c5..6d0c3a73c 100644 --- a/tools/gn_args.py +++ b/tools/gn_args.py @@ -544,10 +544,6 @@ def GetConfigArgsSandbox(platform, args, is_debug, cpu): # Enable base target customizations necessary for distribution of the # cef_sandbox static library. 'is_cef_sandbox_build': True, - - # Disable use of rust for JSON parsing. This avoids a dependency on - # rust libraries. - 'enable_rust_json': False, } if platform == 'windows':