refactor: add gin_helper::Dictionary::CreateEmpty() helper (#39547)
This commit is contained in:
parent
9937a2bbe8
commit
09190085c0
29 changed files with 66 additions and 64 deletions
|
@ -202,7 +202,7 @@ struct Converter<JumpListItem> {
|
|||
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const JumpListItem& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("type", val.type);
|
||||
|
||||
switch (val.type) {
|
||||
|
@ -338,7 +338,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);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("name", val.name);
|
||||
dict.Set("path", val.path);
|
||||
dict.Set("args", val.args);
|
||||
|
@ -371,7 +371,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);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("openAtLogin", val.open_at_login);
|
||||
dict.Set("openAsHidden", val.open_as_hidden);
|
||||
dict.Set("restoreState", val.restore_state);
|
||||
|
@ -1263,7 +1263,7 @@ v8::Local<v8::Value> App::GetJumpListSettings() {
|
|||
}
|
||||
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("minItems", min_items);
|
||||
dict.Set("removedItems", gin::ConvertToV8(isolate, removed_items));
|
||||
return dict.GetHandle();
|
||||
|
@ -1344,8 +1344,8 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
|||
int processor_count = base::SysInfo::NumberOfProcessors();
|
||||
|
||||
for (const auto& process_metric : app_metrics_) {
|
||||
gin_helper::Dictionary pid_dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
gin_helper::Dictionary cpu_dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto pid_dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
auto cpu_dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
pid_dict.SetHidden("simple", true);
|
||||
cpu_dict.SetHidden("simple", true);
|
||||
|
@ -1382,7 +1382,7 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
|||
#if !BUILDFLAG(IS_LINUX)
|
||||
auto memory_info = process_metric.second->GetMemoryInfo();
|
||||
|
||||
gin_helper::Dictionary memory_dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto memory_dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
memory_dict.SetHidden("simple", true);
|
||||
memory_dict.Set("workingSetSize",
|
||||
static_cast<double>(memory_info.working_set_size >> 10));
|
||||
|
@ -1534,7 +1534,7 @@ v8::Local<v8::Value> App::GetDockAPI(v8::Isolate* isolate) {
|
|||
// Initialize the Dock API, the methods are bound to "dock" which exists
|
||||
// for the lifetime of "app"
|
||||
auto browser = base::Unretained(Browser::Get());
|
||||
gin_helper::Dictionary dock_obj = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dock_obj = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dock_obj.SetMethod("bounce", &DockBounce);
|
||||
dock_obj.SetMethod(
|
||||
"cancelBounce",
|
||||
|
|
|
@ -212,7 +212,7 @@ void BaseWindow::OnWindowWillResize(const gfx::Rect& new_bounds,
|
|||
bool* prevent_default) {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
gin_helper::Dictionary info = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto info = gin::Dictionary::CreateEmpty(isolate);
|
||||
info.Set("edge", edge);
|
||||
|
||||
if (Emit("will-resize", new_bounds, info)) {
|
||||
|
|
|
@ -39,8 +39,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
|
|||
: BaseWindow(args->isolate(), options) {
|
||||
// Use options.webPreferences in WebContents.
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
gin_helper::Dictionary web_preferences =
|
||||
gin::Dictionary::CreateEmpty(isolate);
|
||||
auto web_preferences = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
options.Get(options::kWebPreferences, &web_preferences);
|
||||
|
||||
bool transparent = false;
|
||||
|
|
|
@ -151,7 +151,7 @@ struct Converter<electron::api::DesktopCapturer::Source> {
|
|||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const electron::api::DesktopCapturer::Source& source) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
content::DesktopMediaID id = source.media_list_source.id;
|
||||
dict.Set("name", base::UTF16ToUTF8(source.media_list_source.name));
|
||||
dict.Set("id", id.ToString());
|
||||
|
|
|
@ -29,7 +29,7 @@ void ResolvePromiseObject(gin_helper::Promise<gin_helper::Dictionary> promise,
|
|||
bool checkbox_checked) {
|
||||
v8::Isolate* isolate = promise.isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
dict.Set("response", result);
|
||||
dict.Set("checkboxChecked", checkbox_checked);
|
||||
|
|
|
@ -20,7 +20,7 @@ struct Converter<in_app_purchase::PaymentDiscount> {
|
|||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const in_app_purchase::PaymentDiscount& paymentDiscount) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("identifier", paymentDiscount.identifier);
|
||||
dict.Set("keyIdentifier", paymentDiscount.keyIdentifier);
|
||||
|
@ -35,7 +35,7 @@ template <>
|
|||
struct Converter<in_app_purchase::Payment> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const in_app_purchase::Payment& payment) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("productIdentifier", payment.productIdentifier);
|
||||
dict.Set("quantity", payment.quantity);
|
||||
|
@ -51,7 +51,7 @@ template <>
|
|||
struct Converter<in_app_purchase::Transaction> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const in_app_purchase::Transaction& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("transactionIdentifier", val.transactionIdentifier);
|
||||
dict.Set("transactionDate", val.transactionDate);
|
||||
|
@ -71,7 +71,7 @@ struct Converter<in_app_purchase::ProductSubscriptionPeriod> {
|
|||
v8::Isolate* isolate,
|
||||
const in_app_purchase::ProductSubscriptionPeriod&
|
||||
productSubscriptionPeriod) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("numberOfUnits", productSubscriptionPeriod.numberOfUnits);
|
||||
dict.Set("unit", productSubscriptionPeriod.unit);
|
||||
|
@ -84,7 +84,7 @@ struct Converter<in_app_purchase::ProductDiscount> {
|
|||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const in_app_purchase::ProductDiscount& productDiscount) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("identifier", productDiscount.identifier);
|
||||
dict.Set("type", productDiscount.type);
|
||||
|
@ -104,7 +104,7 @@ template <>
|
|||
struct Converter<in_app_purchase::Product> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const in_app_purchase::Product& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("productIdentifier", val.productIdentifier);
|
||||
dict.Set("localizedDescription", val.localizedDescription);
|
||||
|
|
|
@ -36,7 +36,7 @@ struct Converter<electron::NotificationAction> {
|
|||
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
electron::NotificationAction val) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("text", val.text);
|
||||
dict.Set("type", val.type);
|
||||
return ConvertToV8(isolate, dict);
|
||||
|
|
|
@ -24,7 +24,7 @@ template <>
|
|||
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);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("name", val.printer_name);
|
||||
dict.Set("displayName", val.display_name);
|
||||
dict.Set("description", val.printer_description);
|
||||
|
|
|
@ -35,7 +35,7 @@ SystemPreferences::~SystemPreferences() = default;
|
|||
|
||||
v8::Local<v8::Value> SystemPreferences::GetAnimationSettings(
|
||||
v8::Isolate* isolate) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("shouldRenderRichAnimation",
|
||||
gfx::Animation::ShouldRenderRichAnimation());
|
||||
|
|
|
@ -50,7 +50,7 @@ struct Converter<network::mojom::HttpRawHeaderPairPtr> {
|
|||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const network::mojom::HttpRawHeaderPairPtr& pair) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("key", pair->key);
|
||||
dict.Set("value", pair->value);
|
||||
return dict.GetHandle();
|
||||
|
@ -709,7 +709,7 @@ void SimpleURLLoaderWrapper::OnResponseStarted(
|
|||
const network::mojom::URLResponseHead& response_head) {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("statusCode", response_head.headers->response_code());
|
||||
dict.Set("statusMessage", response_head.headers->GetStatusText());
|
||||
dict.Set("httpVersion", response_head.headers->GetHttpVersion());
|
||||
|
|
|
@ -1504,7 +1504,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);
|
||||
auto result = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
result.Set("requestId", request_id);
|
||||
result.Set("matches", number_of_matches);
|
||||
result.Set("selectionArea", selection_rect);
|
||||
|
|
|
@ -105,7 +105,7 @@ v8::Local<v8::Promise> Browser::GetApplicationInfoForProtocol(
|
|||
const GURL& url) {
|
||||
gin_helper::Promise<gin_helper::Dictionary> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
NSString* ns_app_path = GetAppPathForProtocol(url);
|
||||
|
||||
|
|
|
@ -113,8 +113,7 @@ void OnIconDataAvailable(const base::FilePath& app_path,
|
|||
gfx::Image icon) {
|
||||
if (!icon.IsEmpty()) {
|
||||
v8::HandleScope scope(promise.isolate());
|
||||
gin_helper::Dictionary dict =
|
||||
gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(promise.isolate());
|
||||
|
||||
dict.Set("path", app_path);
|
||||
dict.Set("name", app_display_name);
|
||||
|
@ -270,7 +269,7 @@ void GetFileIcon(const base::FilePath& path,
|
|||
gfx::Image* icon =
|
||||
icon_manager->LookupIconFromFilepath(normalized_path, icon_size, 1.0f);
|
||||
if (icon) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("icon", *icon);
|
||||
dict.Set("name", app_display_name);
|
||||
dict.Set("path", normalized_path);
|
||||
|
|
|
@ -14,7 +14,7 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
|
|||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const electron::BluetoothChooser::DeviceInfo& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("deviceName", val.device_name);
|
||||
dict.Set("deviceId", val.device_id);
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
|
|
|
@ -26,7 +26,7 @@ struct Converter<device::mojom::SerialPortInfoPtr> {
|
|||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const device::mojom::SerialPortInfoPtr& port) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("portId", port->token.ToString());
|
||||
dict.Set("portName", port->path.BaseName().LossyDisplayName());
|
||||
if (port->display_name && !port->display_name->empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue