mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: narrow or remove gin arguments (#48300)
* refactor: narrow App:SetJumpList() arg from gin::Arguments* to v8::Isolate* * refactor: narrow WebContents::AddWorkSpace() arg from gin::Arguments* to v8::Isolate* * refactor: narrow ShowMessageBox() arg from gin::Arguments* to v8::Isolate* * refactor: narrow ShowOpenDialog() arg from gin::Arguments* to v8::Isolate* * refactor: remove unused gin::Arguments* arg from OverrideGlobalPropertyFromIsolatedWorld() * refactor: narrow WebContents::StartDrag() arg from gin::Arguments* to v8::Isolate* * refactor: narrow NetLog::StopLogging() arg from gin::Arguments* to v8::Isolate* * refactor: narrow Protocol::IsProtocolHandled() arg from gin::Arguments* to v8::Isolate*
This commit is contained in:
@@ -1241,14 +1241,13 @@ v8::Local<v8::Value> App::GetJumpListSettings() {
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
||||
gin::Arguments* args) {
|
||||
JumpListResult App::SetJumpList(v8::Isolate* const isolate,
|
||||
v8::Local<v8::Value> val) {
|
||||
std::vector<JumpListCategory> categories;
|
||||
bool delete_jump_list = val->IsNull();
|
||||
if (!delete_jump_list &&
|
||||
!gin::ConvertFromV8(args->isolate(), val, &categories)) {
|
||||
gin_helper::ErrorThrower(args->isolate())
|
||||
.ThrowTypeError("Argument must be null or an array of categories");
|
||||
if (!delete_jump_list && !gin::ConvertFromV8(isolate, val, &categories)) {
|
||||
gin_helper::ErrorThrower{isolate}.ThrowTypeError(
|
||||
"Argument must be null or an array of categories");
|
||||
return JumpListResult::kArgumentError;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ class App final : public gin::Wrappable<App>,
|
||||
v8::Local<v8::Value> GetJumpListSettings();
|
||||
|
||||
// Set or remove a custom Jump List for the application.
|
||||
JumpListResult SetJumpList(v8::Local<v8::Value> val, gin::Arguments* args);
|
||||
JumpListResult SetJumpList(v8::Isolate* isolate, v8::Local<v8::Value> val);
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
std::unique_ptr<ProcessSingleton> process_singleton_;
|
||||
|
||||
@@ -42,9 +42,8 @@ void ResolvePromiseObject(gin_helper::Promise<gin_helper::Dictionary> promise,
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> ShowMessageBox(
|
||||
const electron::MessageBoxSettings& settings,
|
||||
gin::Arguments* args) {
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
v8::Isolate* const isolate,
|
||||
const electron::MessageBoxSettings& settings) {
|
||||
gin_helper::Promise<gin_helper::Dictionary> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
@@ -62,9 +61,9 @@ void ShowOpenDialogSync(const file_dialog::DialogSettings& settings,
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> ShowOpenDialog(
|
||||
const file_dialog::DialogSettings& settings,
|
||||
gin::Arguments* args) {
|
||||
gin_helper::Promise<gin_helper::Dictionary> promise(args->isolate());
|
||||
v8::Isolate* const isolate,
|
||||
const file_dialog::DialogSettings& settings) {
|
||||
gin_helper::Promise<gin_helper::Dictionary> promise{isolate};
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
file_dialog::ShowOpenDialog(settings, std::move(promise));
|
||||
return handle;
|
||||
|
||||
@@ -194,8 +194,8 @@ bool NetLog::IsCurrentlyLogging() const {
|
||||
return !!net_log_exporter_;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> NetLog::StopLogging(gin::Arguments* args) {
|
||||
gin_helper::Promise<void> promise(args->isolate());
|
||||
v8::Local<v8::Promise> NetLog::StopLogging(v8::Isolate* const isolate) {
|
||||
gin_helper::Promise<void> promise{isolate};
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
if (net_log_exporter_) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class NetLog final : public gin_helper::DeprecatedWrappable<NetLog> {
|
||||
|
||||
v8::Local<v8::Promise> StartLogging(base::FilePath log_path,
|
||||
gin::Arguments* args);
|
||||
v8::Local<v8::Promise> StopLogging(gin::Arguments* args);
|
||||
v8::Local<v8::Promise> StopLogging(v8::Isolate* isolate);
|
||||
bool IsCurrentlyLogging() const;
|
||||
|
||||
// gin_helper::Wrappable
|
||||
|
||||
@@ -251,24 +251,23 @@ bool Protocol::IsProtocolIntercepted(const std::string& scheme) {
|
||||
return protocol_registry_->FindIntercepted(scheme) != nullptr;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme,
|
||||
gin::Arguments* args) {
|
||||
util::EmitWarning(args->isolate(),
|
||||
v8::Local<v8::Promise> Protocol::IsProtocolHandled(v8::Isolate* const isolate,
|
||||
const std::string& scheme) {
|
||||
util::EmitWarning(isolate,
|
||||
"The protocol.isProtocolHandled API is deprecated, "
|
||||
"use protocol.isProtocolRegistered "
|
||||
"or protocol.isProtocolIntercepted instead.",
|
||||
"ProtocolDeprecateIsProtocolHandled");
|
||||
return gin_helper::Promise<bool>::ResolvedPromise(
|
||||
args->isolate(),
|
||||
IsProtocolRegistered(scheme) || IsProtocolIntercepted(scheme) ||
|
||||
// The |isProtocolHandled| should return true for builtin
|
||||
// schemes, however with NetworkService it is impossible to
|
||||
// know which schemes are registered until a real network
|
||||
// request is sent.
|
||||
// So we have to test against a hard-coded builtin schemes
|
||||
// list make it work with old code. We should deprecate
|
||||
// this API with the new |isProtocolRegistered| API.
|
||||
base::Contains(kBuiltinSchemes, scheme));
|
||||
isolate, IsProtocolRegistered(scheme) || IsProtocolIntercepted(scheme) ||
|
||||
// The |isProtocolHandled| should return true for builtin
|
||||
// schemes, however with NetworkService it is impossible to
|
||||
// know which schemes are registered until a real network
|
||||
// request is sent.
|
||||
// So we have to test against a hard-coded builtin schemes
|
||||
// list make it work with old code. We should deprecate
|
||||
// this API with the new |isProtocolRegistered| API.
|
||||
base::Contains(kBuiltinSchemes, scheme));
|
||||
}
|
||||
|
||||
void Protocol::HandleOptionalCallback(gin::Arguments* args, Error error) {
|
||||
|
||||
@@ -89,8 +89,8 @@ class Protocol final : public gin_helper::DeprecatedWrappable<Protocol>,
|
||||
bool IsProtocolIntercepted(const std::string& scheme);
|
||||
|
||||
// Old async version of IsProtocolRegistered.
|
||||
v8::Local<v8::Promise> IsProtocolHandled(const std::string& scheme,
|
||||
gin::Arguments* args);
|
||||
v8::Local<v8::Promise> IsProtocolHandled(v8::Isolate* isolate,
|
||||
const std::string& scheme);
|
||||
|
||||
// Helper for converting old registration APIs to new RegisterProtocol API.
|
||||
template <ProtocolType type>
|
||||
|
||||
@@ -3259,21 +3259,19 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(const base::Value& settings) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebContents::AddWorkSpace(gin::Arguments* args,
|
||||
void WebContents::AddWorkSpace(v8::Isolate* const isolate,
|
||||
const base::FilePath& path) {
|
||||
if (path.empty()) {
|
||||
gin_helper::ErrorThrower(args->isolate())
|
||||
.ThrowError("path cannot be empty");
|
||||
gin_helper::ErrorThrower{isolate}.ThrowError("path cannot be empty");
|
||||
return;
|
||||
}
|
||||
DevToolsAddFileSystem(std::string(), path);
|
||||
}
|
||||
|
||||
void WebContents::RemoveWorkSpace(gin::Arguments* args,
|
||||
void WebContents::RemoveWorkSpace(v8::Isolate* const isolate,
|
||||
const base::FilePath& path) {
|
||||
if (path.empty()) {
|
||||
gin_helper::ErrorThrower(args->isolate())
|
||||
.ThrowError("path cannot be empty");
|
||||
gin_helper::ErrorThrower{isolate}.ThrowError("path cannot be empty");
|
||||
return;
|
||||
}
|
||||
DevToolsRemoveFileSystem(path);
|
||||
@@ -3508,8 +3506,8 @@ void WebContents::EndFrameSubscription() {
|
||||
frame_subscriber_.reset();
|
||||
}
|
||||
|
||||
void WebContents::StartDrag(const gin_helper::Dictionary& item,
|
||||
gin::Arguments* args) {
|
||||
void WebContents::StartDrag(v8::Isolate* const isolate,
|
||||
const gin_helper::Dictionary& item) {
|
||||
base::FilePath file;
|
||||
std::vector<base::FilePath> files;
|
||||
if (!item.Get("files", &files) && item.Get("file", &file)) {
|
||||
@@ -3518,13 +3516,13 @@ void WebContents::StartDrag(const gin_helper::Dictionary& item,
|
||||
|
||||
v8::Local<v8::Value> icon_value;
|
||||
if (!item.Get("icon", &icon_value)) {
|
||||
gin_helper::ErrorThrower(args->isolate())
|
||||
.ThrowError("'icon' parameter is required");
|
||||
gin_helper::ErrorThrower{isolate}.ThrowError(
|
||||
"'icon' parameter is required");
|
||||
return;
|
||||
}
|
||||
|
||||
NativeImage* icon = nullptr;
|
||||
if (!NativeImage::TryConvertNativeImage(args->isolate(), icon_value, &icon) ||
|
||||
if (!NativeImage::TryConvertNativeImage(isolate, icon_value, &icon) ||
|
||||
icon->image().IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -3534,8 +3532,8 @@ void WebContents::StartDrag(const gin_helper::Dictionary& item,
|
||||
base::CurrentThread::ScopedAllowApplicationTasksInNativeNestedLoop allow;
|
||||
DragFileItems(files, icon->image(), web_contents()->GetNativeView());
|
||||
} else {
|
||||
gin_helper::ErrorThrower(args->isolate())
|
||||
.ThrowError("Must specify either 'file' or 'files' option");
|
||||
gin_helper::ErrorThrower{isolate}.ThrowError(
|
||||
"Must specify either 'file' or 'files' option");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -267,8 +267,8 @@ class WebContents final : public ExclusiveAccessContext,
|
||||
void SetNextChildWebPreferences(const gin_helper::Dictionary);
|
||||
|
||||
// DevTools workspace api.
|
||||
void AddWorkSpace(gin::Arguments* args, const base::FilePath& path);
|
||||
void RemoveWorkSpace(gin::Arguments* args, const base::FilePath& path);
|
||||
void AddWorkSpace(v8::Isolate* isolate, const base::FilePath& path);
|
||||
void RemoveWorkSpace(v8::Isolate* isolate, const base::FilePath& path);
|
||||
|
||||
// Editing commands.
|
||||
void Undo();
|
||||
@@ -303,7 +303,7 @@ class WebContents final : public ExclusiveAccessContext,
|
||||
void EndFrameSubscription();
|
||||
|
||||
// Dragging native items.
|
||||
void StartDrag(const gin_helper::Dictionary& item, gin::Arguments* args);
|
||||
void StartDrag(v8::Isolate* isolate, const gin_helper::Dictionary& item);
|
||||
|
||||
// Captures the page with |rect|, |callback| would be called when capturing is
|
||||
// done.
|
||||
|
||||
Reference in New Issue
Block a user