diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index c03eb600e458..22fc75e3bf6c 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -1067,9 +1067,9 @@ std::string Session::RegisterPreloadScript( }); if (it != preload_scripts.end()) { - thrower.ThrowError(base::StringPrintf( - "Cannot register preload script with existing ID '%s'", - new_preload_script.id.c_str())); + thrower.ThrowError( + absl::StrFormat("Cannot register preload script with existing ID '%s'", + new_preload_script.id)); return ""; } @@ -1080,8 +1080,8 @@ std::string Session::RegisterPreloadScript( << new_preload_script.file_path; } else { thrower.ThrowError( - base::StringPrintf("Preload script must have absolute path: %s", - new_preload_script.file_path.value().c_str())); + absl::StrFormat("Preload script must have absolute path: %s", + new_preload_script.file_path.value())); return ""; } } @@ -1110,9 +1110,8 @@ void Session::UnregisterPreloadScript(gin_helper::ErrorThrower thrower, } // If the script is not found, throw an error - thrower.ThrowError(base::StringPrintf( - "Cannot unregister preload script with non-existing ID '%s'", - script_id.c_str())); + thrower.ThrowError(absl::StrFormat( + "Cannot unregister preload script with non-existing ID '%s'", script_id)); } std::vector Session::GetPreloadScripts() const { diff --git a/shell/browser/ui/devtools_ui_theme_data_source.cc b/shell/browser/ui/devtools_ui_theme_data_source.cc index 6715fdf3868e..68dcc7b5a355 100644 --- a/shell/browser/ui/devtools_ui_theme_data_source.cc +++ b/shell/browser/ui/devtools_ui_theme_data_source.cc @@ -22,6 +22,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "net/base/url_util.h" +#include "third_party/abseil-cpp/absl/strings/str_format.h" #include "ui/base/webui/web_ui_util.h" #include "ui/color/color_provider.h" #include "ui/color/color_provider_utils.h" @@ -157,17 +158,16 @@ void ThemeDataSource::SendColorsCss( for (ui::ColorId id = start; id < end; ++id) { const SkColor color = color_provider.GetColor(id); std::string css_id_to_color_mapping = - base::StringPrintf("%s:%s;", color_css_name.Run(id).c_str(), - ui::ConvertSkColorToCSSColor(color).c_str()); + absl::StrFormat("%s:%s;", color_css_name.Run(id), + ui::ConvertSkColorToCSSColor(color)); base::StrAppend(&css_string, {css_id_to_color_mapping}); if (generate_rgb_vars) { // Also generate a r,g,b string for each color so apps can construct // colors with their own opacities in css. const std::string css_rgb_color_str = color_utils::SkColorToRgbString(color); - const std::string css_id_to_rgb_color_mapping = - base::StringPrintf("%s-rgb:%s;", color_css_name.Run(id).c_str(), - css_rgb_color_str.c_str()); + const std::string css_id_to_rgb_color_mapping = absl::StrFormat( + "%s-rgb:%s;", color_css_name.Run(id), css_rgb_color_str); base::StrAppend(&css_string, {css_id_to_rgb_color_mapping}); } } diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 772591b521a8..119b869c9f25 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -24,6 +24,7 @@ #include "shell/common/node_includes.h" #include "shell/common/world_ids.h" #include "shell/renderer/preload_realm_context.h" +#include "third_party/abseil-cpp/absl/strings/str_format.h" #include "third_party/blink/public/web/web_blob.h" #include "third_party/blink/public/web/web_element.h" #include "third_party/blink/public/web/web_local_frame.h" @@ -944,7 +945,7 @@ v8::Local ExecuteInWorld(v8::Isolate* isolate, if (!maybe_target_context.ToLocal(&target_context)) { isolate->ThrowException(v8::Exception::Error(gin::StringToV8( isolate, - base::StringPrintf("Failed to get context for world %d", world_id)))); + absl::StrFormat("Failed to get context for world %d", world_id)))); return v8::Undefined(isolate); } @@ -956,8 +957,7 @@ v8::Local ExecuteInWorld(v8::Isolate* isolate, v8::MaybeLocal maybe_compiled_script; { v8::TryCatch try_catch(isolate); - std::string return_func_code = - base::StringPrintf("(%s)", function_str.c_str()); + std::string return_func_code = absl::StrFormat("(%s)", function_str); maybe_compiled_script = v8::Script::Compile( target_context, gin::StringToV8(isolate, return_func_code)); if (try_catch.HasCaught()) { @@ -1021,7 +1021,7 @@ v8::Local ExecuteInWorld(v8::Isolate* isolate, v8::Local arg; if (!args_array->Get(source_context, i).ToLocal(&arg)) { gin_helper::ErrorThrower(isolate).ThrowError( - base::StringPrintf("Failed to get argument at index %d", i)); + absl::StrFormat("Failed to get argument at index %d", i)); return v8::Undefined(isolate); } @@ -1031,7 +1031,7 @@ v8::Local ExecuteInWorld(v8::Isolate* isolate, &object_cache); if (proxied_arg.IsEmpty()) { gin_helper::ErrorThrower(isolate).ThrowError( - base::StringPrintf("Failed to proxy argument at index %d", i)); + absl::StrFormat("Failed to proxy argument at index %d", i)); return v8::Undefined(isolate); } proxied_args.push_back(proxied_arg.ToLocalChecked());