[cr149] WebString::FromUTF8 renamed to FromUTF8

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/98defbb5fe4cd74acc53e9f8d3b3ad9443adda65

commit 98defbb5fe4cd74acc53e9f8d3b3ad9443adda65
Author: Kent Tamura <tkent@chromium.org>
Date:   Wed Apr 15 01:28:25 2026 -0700

    Reland "Remove blink::WebString::FromUTF8()"

    This is a reland of commit 64bea51a34e9a0f68769c2275e939d986f918495

    Differences from the original commit:
    Update `FromUTF8()` in the following files too:
    * chromecast/renderer/activity_filtering_websocket_handshake_throttle.cc
    * components/translate/content/renderer/translate_agent.cc
    * third_party/blink/renderer/core/script_tools/model_context_test.cc

    Original change's description:
    > Remove blink::WebString::FromUTF8()
    >
    > We prefer FromUtf8().
    > This CL has no behavior changes.
    >
    > Bug: 492927412
    > Change-Id: I3976e85012e2189dd4377a7cd49148771970d158
    > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7760402
    > Commit-Queue: Fredrik Söderquist <fs@opera.com>
    > Owners-Override: Kent Tamura <tkent@chromium.org>
    > Auto-Submit: Kent Tamura <tkent@chromium.org>
    > Reviewed-by: Fredrik Söderquist <fs@opera.com>
    > Cr-Commit-Position: refs/heads/main@{#1614316}

    Bug: 492927412
    Change-Id: I36fa1420e10759ad581bf8d2ccf7552831e10205
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7760406
    Reviewed-by: Fredrik Söderquist <fs@opera.com>
    Commit-Queue: Kent Tamura <tkent@chromium.org>
    Commit-Queue: Fredrik Söderquist <fs@opera.com>
    Owners-Override: Kent Tamura <tkent@chromium.org>
    Auto-Submit: Kent Tamura <tkent@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1614993}
This commit is contained in:
Claudio DeSouza
2026-05-22 16:24:56 -04:00
committed by Max Karolinskiy
parent aad5b0bfa2
commit 92d5f95f44
6 changed files with 19 additions and 19 deletions
@@ -85,10 +85,10 @@ TEST_F(BraveFontWhitelistRenderViewTest, MAYBE_FontLocalSource) {
LoadHTMLWithUrlOverride(kFontLocalSourceHTML, GURL("http://b.test/").spec());
blink::WebDocument document = GetMainFrame()->GetDocument();
blink::WebElement p1 =
document.GetElementById(blink::WebString::FromUTF8("test1"));
document.GetElementById(blink::WebString::FromUtf8("test1"));
ASSERT_FALSE(p1.IsNull());
blink::WebElement p2 =
document.GetElementById(blink::WebString::FromUTF8("test2"));
document.GetElementById(blink::WebString::FromUtf8("test2"));
ASSERT_FALSE(p2.IsNull());
// If the width of both spans is the same, that means they were both blocked
@@ -235,7 +235,7 @@ void DistillPageTextViaSiteScript(
std::string script = absl::StrFormat("{%s\ndistill()}", script_content);
blink::WebScriptSource source =
blink::WebScriptSource(blink::WebString::FromUTF8(script));
blink::WebScriptSource(blink::WebString::FromUtf8(script));
auto on_script_executed =
[](base::OnceCallback<void(const std::optional<std::string>&)> callback,
@@ -474,7 +474,7 @@ void CosmeticFiltersJSHandler::InjectStylesheet(const std::string& stylesheet) {
blink::WebStyleSheetKey* style_sheet_key = nullptr;
blink::WebString stylesheet_webstring =
blink::WebString::FromUTF8(stylesheet);
blink::WebString::FromUtf8(stylesheet);
web_frame->GetDocument().InsertStyleSheet(
stylesheet_webstring, style_sheet_key, blink::WebCssOrigin::kUser);
}
@@ -601,7 +601,7 @@ void CosmeticFiltersJSHandler::LaunchContentPicker() {
}
web_frame->ExecuteScriptInIsolatedWorld(
isolated_world_id_,
blink::WebScriptSource(blink::WebString::FromUTF8(
blink::WebScriptSource(blink::WebString::FromUtf8(
LoadDataResource(IDR_COSMETIC_FILTERS_ELEMENT_PICKER_BUNDLE_JS))),
blink::BackForwardCacheAware::kAllow);
}
@@ -701,7 +701,7 @@ void CosmeticFiltersJSHandler::ApplyRules(bool de_amp_enabled) {
if (!scriptlet_script.empty()) {
web_frame->ExecuteScriptInIsolatedWorld(
isolated_world_id_,
blink::WebScriptSource(blink::WebString::FromUTF8(scriptlet_script)),
blink::WebScriptSource(blink::WebString::FromUtf8(scriptlet_script)),
blink::BackForwardCacheAware::kAllow);
}
@@ -721,7 +721,7 @@ void CosmeticFiltersJSHandler::ApplyRules(bool de_amp_enabled) {
web_frame->ExecuteScriptInIsolatedWorld(
isolated_world_id_,
blink::WebScriptSource(blink::WebString::FromUTF8(pre_init_script)),
blink::WebScriptSource(blink::WebString::FromUtf8(pre_init_script)),
blink::BackForwardCacheAware::kAllow);
ExecuteObservingBundleEntryPoint();
@@ -737,7 +737,7 @@ void CosmeticFiltersJSHandler::ApplyRules(bool de_amp_enabled) {
web_frame->ExecuteScriptInIsolatedWorldAndReturnValue(
isolated_world_id_,
blink::WebScriptSource(
blink::WebString::FromUTF8(*procedural_actions_script)),
blink::WebString::FromUtf8(*procedural_actions_script)),
blink::BackForwardCacheAware::kAllow);
if (!v8_stylesheet.IsEmpty() && v8_stylesheet->IsString()) {
v8::Local<v8::String> v8_str = v8_stylesheet.As<v8::String>();
@@ -796,7 +796,7 @@ void CosmeticFiltersJSHandler::CSSRulesRoutine(
web_frame->ExecuteScriptInIsolatedWorld(
isolated_world_id_,
blink::WebScriptSource(
blink::WebString::FromUTF8(new_selectors_script)),
blink::WebString::FromUtf8(new_selectors_script)),
blink::BackForwardCacheAware::kAllow);
}
}
@@ -874,7 +874,7 @@ void CosmeticFiltersJSHandler::OnHiddenClassIdSelectors(
web_frame->ExecuteScriptInIsolatedWorld(
isolated_world_id_,
blink::WebScriptSource(
blink::WebString::FromUTF8(new_selectors_script)),
blink::WebString::FromUtf8(new_selectors_script)),
blink::BackForwardCacheAware::kAllow);
}
@@ -899,7 +899,7 @@ void CosmeticFiltersJSHandler::ExecuteObservingBundleEntryPoint() {
web_frame->ExecuteScriptInIsolatedWorld(
isolated_world_id_,
blink::WebScriptSource(blink::WebString::FromUTF8(*s_observing_script)),
blink::WebScriptSource(blink::WebString::FromUtf8(*s_observing_script)),
blink::BackForwardCacheAware::kAllow);
// kObservingScriptletEntryPoint was called by `s_observing_script`.
@@ -909,7 +909,7 @@ void CosmeticFiltersJSHandler::ExecuteObservingBundleEntryPoint() {
web_frame->ExecuteScriptInIsolatedWorld(
isolated_world_id_,
blink::WebScriptSource(
blink::WebString::FromUTF8(kObservingScriptletEntryPoint)),
blink::WebString::FromUtf8(kObservingScriptletEntryPoint)),
blink::BackForwardCacheAware::kAllow);
}
@@ -45,7 +45,7 @@ void EnsureIsolatedWorldInitialized(int world_id) {
info.security_origin =
blink::WebSecurityOrigin::Create(GURL(kSecurityOrigin));
info.content_security_policy =
blink::WebString::FromUTF8(kContentSecurityPolicy);
blink::WebString::FromUtf8(kContentSecurityPolicy);
blink::SetIsolatedWorldInfo(world_id, info);
}
@@ -81,7 +81,7 @@ v8::Local<v8::Value> RunScript(v8::Local<v8::Context> context,
blink::WebConsoleMessage::LogWebConsoleMessage(
context, blink::WebConsoleMessage(
blink::mojom::ConsoleMessageLevel::kError,
blink::WebString::FromUTF8(
blink::WebString::FromUtf8(
CreateExceptionString(context, try_catch))));
return v8::Undefined(v8::Isolate::GetCurrent());
}
@@ -91,7 +91,7 @@ v8::Local<v8::Value> RunScript(v8::Local<v8::Context> context,
blink::WebConsoleMessage::LogWebConsoleMessage(
context, blink::WebConsoleMessage(
blink::mojom::ConsoleMessageLevel::kError,
blink::WebString::FromUTF8(
blink::WebString::FromUtf8(
CreateExceptionString(context, try_catch))));
return v8::Undefined(v8::Isolate::GetCurrent());
}
@@ -132,7 +132,7 @@ v8::MaybeLocal<v8::Value> LoadScriptWithSafeBuiltins(
if (func_as_value.IsEmpty() || func_as_value->IsUndefined()) {
web_frame->AddMessageToConsole(
blink::WebConsoleMessage(blink::mojom::ConsoleMessageLevel::kError,
blink::WebString::FromUTF8("Bad source")));
blink::WebString::FromUtf8("Bad source")));
return v8::MaybeLocal<v8::Value>();
}
@@ -33,7 +33,7 @@ void ProcessAttributeRequests(
for (const auto& request : requests) {
if (request->sub_selector) {
auto web_sub_selector =
blink::WebString::FromUTF8(*request->sub_selector);
blink::WebString::FromUtf8(*request->sub_selector);
sub_element = element.QuerySelector(web_sub_selector);
element_to_query = &*sub_element;
}
@@ -42,7 +42,7 @@ void ProcessAttributeRequests(
if (request->attribute == kTextContentAttributeName) {
attribute_value = element_to_query->TextContent().Utf8();
} else {
auto attribute_name = blink::WebString::FromUTF8(request->attribute);
auto attribute_name = blink::WebString::FromUtf8(request->attribute);
auto web_attribute_value =
element_to_query->GetAttribute(attribute_name);
if (!web_attribute_value.IsNull()) {
@@ -78,7 +78,7 @@ void BlinkDocumentExtractor::QueryElementAttributes(
blink::WebDocument document = render_frame_->GetWebFrame()->GetDocument();
std::vector<mojom::AttributeResultPtr> results;
for (const auto& request : requests) {
auto selector = blink::WebString::FromUTF8(request->root_selector);
auto selector = blink::WebString::FromUtf8(request->root_selector);
auto elements = document.QuerySelectorAll(selector);
ProcessAttributeRequests(request->root_selector,
request->attribute_requests, elements, results);