refactor: remove stray .c_str() calls for absl::StrFormat() (#47576)

refactor: remove stray .c_str() calls for absl::StrFormat()

StrFormat() understands std::string, std::string_view

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-06-26 08:18:10 -05:00 committed by GitHub
commit 33d23f5e00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 27 additions and 34 deletions

View file

@ -215,7 +215,7 @@ bool CollectFramesForInjection(const api::scripting::InjectionTarget& target,
ExtensionApiFrameIdMap::DocumentIdFromString(id);
if (!document_id) {
*error_out = absl::StrFormat("Invalid document id %s", id.c_str());
*error_out = absl::StrFormat("Invalid document id %s", id);
return false;
}
@ -227,7 +227,7 @@ bool CollectFramesForInjection(const api::scripting::InjectionTarget& target,
// request.
if (!frame || content::WebContents::FromRenderFrameHost(frame) != tab) {
*error_out = absl::StrFormat("No document with id %s in tab with id %d",
id.c_str(), target.tab_id);
id, target.tab_id);
return false;
}
@ -499,8 +499,8 @@ ExtensionFunction::ResponseAction ScriptingExecuteScriptFunction::Run() {
args_expression = base::JoinString(string_args, ",");
}
std::string code_to_execute = absl::StrFormat(
"(%s)(%s)", injection_.func->c_str(), args_expression.c_str());
std::string code_to_execute =
absl::StrFormat("(%s)(%s)", *injection_.func, args_expression);
std::vector<mojom::JSSourcePtr> sources;
sources.push_back(mojom::JSSource::New(std::move(code_to_execute), GURL()));