Skip to content

Commit

Permalink
fix: add missing dict.SetHidden("simple", true); for @electron/remote
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Aug 14, 2023
1 parent d5f31c2 commit 8f4cf13
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 16 deletions.
4 changes: 4 additions & 0 deletions shell/browser/api/electron_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ struct Converter<JumpListItem> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const JumpListItem& val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("type", val.type);

switch (val.type) {
Expand Down Expand Up @@ -339,6 +340,7 @@ struct Converter<Browser::LaunchItem> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
Browser::LaunchItem val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("name", val.name);
dict.Set("path", val.path);
dict.Set("args", val.args);
Expand Down Expand Up @@ -372,6 +374,7 @@ struct Converter<Browser::LoginItemSettings> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
Browser::LoginItemSettings val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("openAtLogin", val.open_at_login);
dict.Set("openAsHidden", val.open_as_hidden);
dict.Set("restoreState", val.restore_state);
Expand Down Expand Up @@ -1264,6 +1267,7 @@ v8::Local<v8::Value> App::GetJumpListSettings() {

v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("minItems", min_items);
dict.Set("removedItems", gin::ConvertToV8(isolate, removed_items));
return dict.GetHandle();
Expand Down
1 change: 1 addition & 0 deletions shell/browser/api/electron_api_base_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ void BaseWindow::OnWindowWillResize(const gfx::Rect& new_bounds,
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
gin_helper::Dictionary info = gin::Dictionary::CreateEmpty(isolate);
info.SetHidden("simple", true);
info.Set("edge", edge);

if (Emit("will-resize", new_bounds, info)) {
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ResolvePromiseObject(gin_helper::Promise<gin_helper::Dictionary> promise,
v8::Isolate* isolate = promise.isolate();
v8::HandleScope handle_scope(isolate);
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);

dict.SetHidden("simple", true);
dict.Set("response", result);
dict.Set("checkboxChecked", checkbox_checked);

Expand Down
3 changes: 2 additions & 1 deletion shell/browser/api/electron_api_notification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ struct Converter<electron::NotificationAction> {

static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
electron::NotificationAction val) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("text", val.text);
dict.Set("type", val.type);
return ConvertToV8(isolate, dict);
Expand Down
1 change: 1 addition & 0 deletions shell/browser/api/electron_api_printing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct Converter<printing::PrinterBasicInfo> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const printing::PrinterBasicInfo& val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("name", val.printer_name);
dict.Set("displayName", val.display_name);
dict.Set("description", val.printer_description);
Expand Down
1 change: 1 addition & 0 deletions shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
gin_helper::Dictionary result = gin::Dictionary::CreateEmpty(isolate);
result.SetHidden("simple", true);
result.Set("requestId", request_id);
result.Set("matches", number_of_matches);
result.Set("selectionArea", selection_rect);
Expand Down
1 change: 1 addition & 0 deletions shell/browser/lib/bluetooth_chooser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
v8::Isolate* isolate,
const electron::BluetoothChooser::DeviceInfo& val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("deviceName", val.device_name);
dict.Set("deviceId", val.device_id);
return gin::ConvertToV8(isolate, dict);
Expand Down
4 changes: 3 additions & 1 deletion shell/browser/login_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/net_converter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"

using content::BrowserThread;

Expand Down Expand Up @@ -56,7 +57,8 @@ void LoginHandler::EmitEvent(
return;
}

auto details = gin::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary details = gin::Dictionary::CreateEmpty(isolate);
details.SetHidden("simple", true);
details.Set("url", url);

// These parameters aren't documented, and I'm not sure that they're useful,
Expand Down
1 change: 1 addition & 0 deletions shell/common/api/electron_api_asar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ static void SplitPath(const v8::FunctionCallbackInfo<v8::Value>& args) {
}

gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
base::FilePath asar_path, file_path;
if (asar::GetAsarArchivePath(path, &asar_path, &file_path, true)) {
dict.Set("isAsar", true);
Expand Down
1 change: 1 addition & 0 deletions shell/common/api/electron_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ void ElectronBindings::DidReceiveMemoryDump(
global_dump->process_dumps()) {
if (target_pid == dump.pid()) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
const auto& osdump = dump.os_dump();
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
dict.Set("residentSet", osdump.resident_set_kb);
Expand Down
7 changes: 6 additions & 1 deletion shell/common/gin_converters/blink_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ v8::Local<v8::Value> Converter<blink::WebKeyboardEvent>::ToV8(
v8::Isolate* isolate,
const blink::WebKeyboardEvent& in) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);

dict.SetHidden("simple", true);
dict.Set("type", in.GetType());
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.dom_key));
dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString(
Expand Down Expand Up @@ -469,6 +469,7 @@ Converter<blink::mojom::ContextMenuDataInputFieldType>::ToV8(

v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("canUndo",
!!(editFlags & blink::ContextMenuDataEditFlags::kCanUndo));
dict.Set("canRedo",
Expand Down Expand Up @@ -498,6 +499,7 @@ v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) {

v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("inError", !!(mediaFlags & blink::ContextMenuData::kMediaInError));
dict.Set("isPaused", !!(mediaFlags & blink::ContextMenuData::kMediaPaused));
dict.Set("isMuted", !!(mediaFlags & blink::ContextMenuData::kMediaMuted));
Expand All @@ -523,6 +525,7 @@ v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStat>::ToV8(
v8::Isolate* isolate,
const blink::WebCacheResourceTypeStat& stat) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("count", static_cast<uint32_t>(stat.count));
dict.Set("size", static_cast<double>(stat.size));
dict.Set("liveSize", static_cast<double>(stat.decoded_size));
Expand All @@ -533,6 +536,7 @@ v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStats>::ToV8(
v8::Isolate* isolate,
const blink::WebCacheResourceTypeStats& stats) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("images", stats.images);
dict.Set("scripts", stats.scripts);
dict.Set("cssStyleSheets", stats.css_style_sheets);
Expand Down Expand Up @@ -566,6 +570,7 @@ v8::Local<v8::Value> Converter<blink::mojom::Referrer>::ToV8(
v8::Isolate* isolate,
const blink::mojom::Referrer& val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("url", ConvertToV8(isolate, val.url));
dict.Set("policy", ConvertToV8(isolate, val.policy));
return gin::ConvertToV8(isolate, dict);
Expand Down
1 change: 1 addition & 0 deletions shell/common/gin_converters/content_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ v8::Local<v8::Value> Converter<content::Referrer>::ToV8(
v8::Isolate* isolate,
const content::Referrer& val) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("url", ConvertToV8(isolate, val.url));
dict.Set("policy", ConvertToV8(isolate, val.policy));
return gin::ConvertToV8(isolate, dict);
Expand Down
4 changes: 3 additions & 1 deletion shell/common/gin_converters/extension_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"

namespace gin {

// static
v8::Local<v8::Value> Converter<const extensions::Extension*>::ToV8(
v8::Isolate* isolate,
const extensions::Extension* extension) {
auto dict = gin::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("id", extension->id());
dict.Set("name", extension->name());
dict.Set("path", extension->path());
Expand Down
5 changes: 3 additions & 2 deletions shell/common/gin_converters/file_dialog_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "shell/browser/api/electron_api_browser_window.h"
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/native_window_converter.h"
#include "shell/common/gin_helper/dictionary.h"

namespace gin {

Expand All @@ -27,8 +28,8 @@ bool Converter<file_dialog::Filter>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> Converter<file_dialog::Filter>::ToV8(
v8::Isolate* isolate,
const file_dialog::Filter& in) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);

gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("name", in.first);
dict.Set("extensions", in.second);

Expand Down
23 changes: 14 additions & 9 deletions shell/common/gin_converters/net_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/std_converter.h"
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h"

Expand Down Expand Up @@ -59,7 +60,8 @@ bool CertFromData(const std::string& data,
v8::Local<v8::Value> Converter<net::AuthChallengeInfo>::ToV8(
v8::Isolate* isolate,
const net::AuthChallengeInfo& val) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("isProxy", val.is_proxy);
dict.Set("scheme", val.scheme);
dict.Set("host", val.challenger.host());
Expand All @@ -72,7 +74,7 @@ v8::Local<v8::Value> Converter<net::AuthChallengeInfo>::ToV8(
v8::Local<v8::Value> Converter<scoped_refptr<net::X509Certificate>>::ToV8(
v8::Isolate* isolate,
const scoped_refptr<net::X509Certificate>& val) {
gin::Dictionary dict(isolate, v8::Object::New(isolate));
gin_helper::Dictionary dict(isolate, v8::Object::New(isolate));
std::string encoded_data;
net::X509Certificate::GetPEMEncoded(val->cert_buffer(), &encoded_data);

Expand Down Expand Up @@ -142,8 +144,8 @@ bool Converter<scoped_refptr<net::X509Certificate>>::FromV8(
v8::Local<v8::Value> Converter<net::CertPrincipal>::ToV8(
v8::Isolate* isolate,
const net::CertPrincipal& val) {
gin::Dictionary dict(isolate, v8::Object::New(isolate));

gin_helper::Dictionary dict(isolate, v8::Object::New(isolate));
dict.SetHidden("simple", true);
dict.Set("commonName", val.common_name);
dict.Set("organizations", val.organization_names);
dict.Set("organizationUnits", val.organization_unit_names);
Expand Down Expand Up @@ -610,7 +612,8 @@ bool Converter<scoped_refptr<network::ResourceRequestBody>>::FromV8(
v8::Local<v8::Value> Converter<network::ResourceRequest>::ToV8(
v8::Isolate* isolate,
const network::ResourceRequest& val) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("method", val.method);
dict.Set("url", val.url.spec());
dict.Set("referrer", val.referrer.spec());
Expand All @@ -624,7 +627,8 @@ v8::Local<v8::Value> Converter<network::ResourceRequest>::ToV8(
v8::Local<v8::Value> Converter<electron::VerifyRequestParams>::ToV8(
v8::Isolate* isolate,
electron::VerifyRequestParams val) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("hostname", val.hostname);
dict.Set("certificate", val.certificate);
dict.Set("validatedCertificate", val.validated_certificate);
Expand All @@ -638,7 +642,8 @@ v8::Local<v8::Value> Converter<electron::VerifyRequestParams>::ToV8(
v8::Local<v8::Value> Converter<net::HttpVersion>::ToV8(
v8::Isolate* isolate,
const net::HttpVersion& val) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("major", static_cast<uint32_t>(val.major_value()));
dict.Set("minor", static_cast<uint32_t>(val.minor_value()));
return ConvertToV8(isolate, dict);
Expand All @@ -648,8 +653,8 @@ v8::Local<v8::Value> Converter<net::HttpVersion>::ToV8(
v8::Local<v8::Value> Converter<net::RedirectInfo>::ToV8(
v8::Isolate* isolate,
const net::RedirectInfo& val) {
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);

gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("statusCode", val.status_code);
dict.Set("newMethod", val.new_method);
dict.Set("newUrl", val.new_url);
Expand Down
1 change: 1 addition & 0 deletions shell/common/gin_converters/serial_port_info_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct Converter<device::mojom::SerialPortInfoPtr> {
v8::Isolate* isolate,
const device::mojom::SerialPortInfoPtr& port) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetHidden("simple", true);
dict.Set("portId", port->token.ToString());
dict.Set("portName", port->path.BaseName().LossyDisplayName());
if (port->display_name && !port->display_name->empty())
Expand Down

0 comments on commit 8f4cf13

Please sign in to comment.