refactor: prefer upstream gin::Arguments::ThrowTypeError() over gin_helper (#48368)

* refactor: use gin::Arguments::ThrowTypeError() in AutoUpdater::SetFeedURL()

* refactor: use gin::Arguments::ThrowTypeError() in Browser::Focus()

* refactor: use gin::Arguments::ThrowTypeError() in SystemPreferences::SetUserDefault()

* refactor: use gin::Arguments::ThrowTypeError() in UtilityProcessWrapper::Create()

* refactor: use gin::Arguments::ThrowTypeError() in UtilityProcessWrapper::PostMessage()

* refactor: use gin::Arguments::ThrowTypeError() in ElectronBundleMover::ShouldContinueMove()

* refactor: use gin::Arguments::ThrowTypeError() in OnClientCertificateSelected()

* refactor: use gin::Arguments::ThrowTypeError() in Session::ClearData()

* refactor: use gin::Arguments::ThrowTypeError() in ElectronBrowserContext::DisplayMediaDeviceChosen()

* refactor: use gin::Arguments::ThrowTypeError() in WebContents::ReplaceMisspelling()

* refactor: use gin::Arguments::ThrowTypeError() in WebContents::Print()

* chore: iwyu shell/common/gin_helper/error_thrower.h
This commit is contained in:
Charles Kerr
2025-09-24 19:10:05 -05:00
committed by GitHub
parent b51e82c5fb
commit 6661457cdf
14 changed files with 61 additions and 84 deletions

View File

@@ -3031,23 +3031,24 @@ void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise,
}
} // namespace
void WebContents::Print(gin::Arguments* args) {
auto options = gin_helper::Dictionary::CreateEmpty(args->isolate());
base::Value::Dict settings;
void WebContents::Print(gin::Arguments* const args) {
v8::Isolate* const isolate = args->isolate();
auto options = gin_helper::Dictionary::CreateEmpty(isolate);
if (args->Length() >= 1 && !args->GetNext(&options)) {
gin_helper::ErrorThrower(args->isolate())
.ThrowError("webContents.print(): Invalid print settings specified.");
args->ThrowTypeError(
"webContents.print(): Invalid print settings specified.");
return;
}
printing::CompletionCallback callback;
if (args->Length() == 2 && !args->GetNext(&callback)) {
gin_helper::ErrorThrower(args->isolate())
.ThrowError("webContents.print(): Invalid optional callback provided.");
args->ThrowTypeError(
"webContents.print(): Invalid optional callback provided.");
return;
}
base::Value::Dict settings;
if (options.IsEmptyObject()) {
content::RenderFrameHost* rfh = GetRenderFrameHostToUse(web_contents());
if (!rfh)
@@ -3069,7 +3070,7 @@ void WebContents::Print(gin::Arguments* args) {
options.ValueOrDefault("printBackground", false));
// Set custom margin settings
auto margins = gin_helper::Dictionary::CreateEmpty(args->isolate());
auto margins = gin_helper::Dictionary::CreateEmpty(isolate);
if (options.Get("margins", &margins)) {
printing::mojom::MarginType margin_type =
printing::mojom::MarginType::kDefaultMargins;
@@ -3349,11 +3350,10 @@ void WebContents::ReplaceMisspelling(const std::u16string& word) {
web_contents()->ReplaceMisspelling(word);
}
uint32_t WebContents::FindInPage(gin::Arguments* args) {
uint32_t WebContents::FindInPage(gin::Arguments* const args) {
std::u16string search_text;
if (!args->GetNext(&search_text) || search_text.empty()) {
gin_helper::ErrorThrower(args->isolate())
.ThrowError("Must provide a non-empty search content");
args->ThrowTypeError("Must provide a non-empty search content");
return 0;
}