refactor: use gin::Arguments in BaseWindow (#48355)

* refactor: make api::Clipboard::GetClipboardBuffer() private

* refactor: move GetClipboadBuffer() into anonymous namespace

* refactor: use gin::Arguments in BaseWindow::MoveAbove()

refactor: use gin::Arguments in BaseWindow::SetAlwaysOnTop()

refactor: use gin::Arguments in BaseWindow::SetIgnoreMouseEvent()

* refactor: use gin::Arguments in BaseWindow::SetProgresBar()

* refactor: use gin::Arguments in BaseWindow::SetVisibleOnAllWorkspaces()

* refactor: use gin::Arguments in BaseWindow::SetVibrancy()

* refactor: use gin::Arguments in BaseWindow::SetAspectRatio()

* refactor: use gin::Arguments in BaseWindow::PreviewFile()

* refactor: use gin::Arguments in BaseWindow::SetThumbarButtons()

* refactor: use gin::Arguments in BaseWindow::SetBounds()

* refactor: use gin::Arguments in BaseWindow::SetContentBounds()

* refactor: use gin::Arguments in BaseWindow::SetSize()

* refactor: use gin::Arguments in BaseWindow::SetContentSize()

* refactor: use gin::Arguments in BaseWindow::SetSheetOffset()

* refactor: use gin::Arguments in BaseWindow::SetPosition()

* refactor: use gin::Arguments in BaseWindow::AddTabbedWindow()

* refactor: use gin::Arguments in BaseWindow::SetParentWindow()

* refactor: use gin::Arguments in BaseWindow::BaseWindow()

* refactor: use gin::Arguments in BaseWindow::SetAccentColor()

* refactor: use gin::Arguments in BaseWindow::SetTitleBarOverlay()
This commit is contained in:
Charles Kerr
2025-09-24 08:39:16 -05:00
committed by GitHub
parent 6bbbc1232e
commit 235fdc41f6
4 changed files with 87 additions and 75 deletions

View File

@@ -123,7 +123,7 @@ BaseWindow::BaseWindow(v8::Isolate* isolate,
#endif #endif
} }
BaseWindow::BaseWindow(gin_helper::Arguments* args, BaseWindow::BaseWindow(gin::Arguments* args,
const gin_helper::Dictionary& options) const gin_helper::Dictionary& options)
: BaseWindow(args->isolate(), options) { : BaseWindow(args->isolate(), options) {
InitWithArgs(args); InitWithArgs(args);
@@ -444,7 +444,7 @@ bool BaseWindow::IsFullscreen() const {
} }
void BaseWindow::SetBounds(const gfx::Rect& bounds, void BaseWindow::SetBounds(const gfx::Rect& bounds,
gin_helper::Arguments* args) { gin::Arguments* const args) {
bool animate = false; bool animate = false;
args->GetNext(&animate); args->GetNext(&animate);
window_->SetBounds(bounds, animate); window_->SetBounds(bounds, animate);
@@ -463,7 +463,7 @@ gfx::Rect BaseWindow::GetNormalBounds() const {
} }
void BaseWindow::SetContentBounds(const gfx::Rect& bounds, void BaseWindow::SetContentBounds(const gfx::Rect& bounds,
gin_helper::Arguments* args) { gin::Arguments* const args) {
bool animate = false; bool animate = false;
args->GetNext(&animate); args->GetNext(&animate);
window_->SetContentBounds(bounds, animate); window_->SetContentBounds(bounds, animate);
@@ -473,7 +473,7 @@ gfx::Rect BaseWindow::GetContentBounds() const {
return window_->GetContentBounds(); return window_->GetContentBounds();
} }
void BaseWindow::SetSize(int width, int height, gin_helper::Arguments* args) { void BaseWindow::SetSize(int width, int height, gin::Arguments* args) {
bool animate = false; bool animate = false;
gfx::Size size = window_->GetMinimumSize(); gfx::Size size = window_->GetMinimumSize();
size.SetToMax(gfx::Size(width, height)); size.SetToMax(gfx::Size(width, height));
@@ -485,12 +485,12 @@ std::array<int, 2U> BaseWindow::GetSize() const {
return ToArray(window_->GetSize()); return ToArray(window_->GetSize());
} }
void BaseWindow::SetContentSize(int width, void BaseWindow::SetContentSize(const int width,
int height, const int height,
gin_helper::Arguments* args) { gin::Arguments* const args) {
bool animate = false; bool animate = false;
args->GetNext(&animate); args->GetNext(&animate);
window_->SetContentSize(gfx::Size(width, height), animate); window_->SetContentSize(gfx::Size{width, height}, animate);
} }
std::array<int, 2U> BaseWindow::GetContentSize() const { std::array<int, 2U> BaseWindow::GetContentSize() const {
@@ -513,7 +513,8 @@ std::array<int, 2U> BaseWindow::GetMaximumSize() const {
return ToArray(window_->GetMaximumSize()); return ToArray(window_->GetMaximumSize());
} }
void BaseWindow::SetSheetOffset(double offsetY, gin_helper::Arguments* args) { void BaseWindow::SetSheetOffset(const double offsetY,
gin::Arguments* const args) {
double offsetX = 0.0; double offsetX = 0.0;
args->GetNext(&offsetX); args->GetNext(&offsetX);
window_->SetSheetOffset(offsetX, offsetY); window_->SetSheetOffset(offsetX, offsetY);
@@ -567,7 +568,7 @@ bool BaseWindow::IsClosable() const {
return window_->IsClosable(); return window_->IsClosable();
} }
void BaseWindow::SetAlwaysOnTop(bool top, gin_helper::Arguments* args) { void BaseWindow::SetAlwaysOnTop(bool top, gin::Arguments* args) {
std::string level = "floating"; std::string level = "floating";
int relative_level = 0; int relative_level = 0;
args->GetNext(&level); args->GetNext(&level);
@@ -586,19 +587,21 @@ void BaseWindow::Center() {
window_->Center(); window_->Center();
} }
void BaseWindow::SetPosition(int x, int y, gin_helper::Arguments* args) { void BaseWindow::SetPosition(const int x,
const int y,
gin::Arguments* const args) {
bool animate = false; bool animate = false;
args->GetNext(&animate); args->GetNext(&animate);
window_->SetPosition(gfx::Point(x, y), animate); window_->SetPosition(gfx::Point{x, y}, animate);
} }
std::array<int, 2U> BaseWindow::GetPosition() const { std::array<int, 2U> BaseWindow::GetPosition() const {
return ToArray(window_->GetPosition()); return ToArray(window_->GetPosition());
} }
void BaseWindow::MoveAbove(const std::string& sourceId, void BaseWindow::MoveAbove(const std::string& sourceId,
gin_helper::Arguments* args) { gin::Arguments* const args) {
if (!window_->MoveAbove(sourceId)) if (!window_->MoveAbove(sourceId))
args->ThrowError("Invalid media source id"); args->ThrowTypeError("Invalid media source id");
} }
void BaseWindow::MoveTop() { void BaseWindow::MoveTop() {
@@ -706,8 +709,7 @@ bool BaseWindow::IsDocumentEdited() const {
return window_->IsDocumentEdited(); return window_->IsDocumentEdited();
} }
void BaseWindow::SetIgnoreMouseEvents(bool ignore, void BaseWindow::SetIgnoreMouseEvents(bool ignore, gin::Arguments* const args) {
gin_helper::Arguments* args) {
gin_helper::Dictionary options; gin_helper::Dictionary options;
bool forward = false; bool forward = false;
args->GetNext(&options) && options.Get("forward", &forward); args->GetNext(&options) && options.Get("forward", &forward);
@@ -759,9 +761,9 @@ void BaseWindow::RemoveMenu() {
} }
void BaseWindow::SetParentWindow(v8::Local<v8::Value> value, void BaseWindow::SetParentWindow(v8::Local<v8::Value> value,
gin_helper::Arguments* args) { gin::Arguments* const args) {
if (IsModal()) { if (IsModal()) {
args->ThrowError("Can not be called for modal window"); args->ThrowTypeError("Can not be called for modal window");
return; return;
} }
@@ -776,7 +778,7 @@ void BaseWindow::SetParentWindow(v8::Local<v8::Value> value,
window_->SetParentWindow(parent->window_.get()); window_->SetParentWindow(parent->window_.get());
parent->child_windows_.Set(isolate(), weak_map_id(), GetWrapper()); parent->child_windows_.Set(isolate(), weak_map_id(), GetWrapper());
} else { } else {
args->ThrowError("Must pass BaseWindow instance or null"); args->ThrowTypeError("Must pass BaseWindow instance or null");
} }
} }
@@ -794,7 +796,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
} }
#endif #endif
void BaseWindow::SetProgressBar(double progress, gin_helper::Arguments* args) { void BaseWindow::SetProgressBar(double progress, gin::Arguments* args) {
gin_helper::Dictionary options; gin_helper::Dictionary options;
std::string mode; std::string mode;
args->GetNext(&options) && options.Get("mode", &mode); args->GetNext(&options) && options.Get("mode", &mode);
@@ -818,7 +820,7 @@ void BaseWindow::SetOverlayIcon(const gfx::Image& overlay,
} }
void BaseWindow::SetVisibleOnAllWorkspaces(bool visible, void BaseWindow::SetVisibleOnAllWorkspaces(bool visible,
gin_helper::Arguments* args) { gin::Arguments* const args) {
gin_helper::Dictionary options; gin_helper::Dictionary options;
bool visibleOnFullScreen = false; bool visibleOnFullScreen = false;
bool skipTransformProcessType = false; bool skipTransformProcessType = false;
@@ -838,9 +840,9 @@ void BaseWindow::SetAutoHideCursor(bool auto_hide) {
window_->SetAutoHideCursor(auto_hide); window_->SetAutoHideCursor(auto_hide);
} }
void BaseWindow::SetVibrancy(v8::Isolate* isolate, void BaseWindow::SetVibrancy(v8::Isolate* const isolate,
v8::Local<v8::Value> value, v8::Local<v8::Value> value,
gin_helper::Arguments* args) { gin::Arguments* const args) {
std::string type = gin::V8ToString(isolate, value); std::string type = gin::V8ToString(isolate, value);
gin_helper::Dictionary options; gin_helper::Dictionary options;
int animation_duration_ms = 0; int animation_duration_ms = 0;
@@ -925,10 +927,11 @@ void BaseWindow::ToggleTabBar() {
window_->ToggleTabBar(); window_->ToggleTabBar();
} }
void BaseWindow::AddTabbedWindow(NativeWindow* window, void BaseWindow::AddTabbedWindow(NativeWindow* const window,
gin_helper::Arguments* args) { gin::Arguments* const args) {
if (!window_->AddTabbedWindow(window)) if (!window_->AddTabbedWindow(window))
args->ThrowError("AddTabbedWindow cannot be called by a window on itself."); args->ThrowTypeError(
"AddTabbedWindow cannot be called by a window on itself.");
} }
v8::Local<v8::Value> BaseWindow::GetTabbingIdentifier() { v8::Local<v8::Value> BaseWindow::GetTabbingIdentifier() {
@@ -955,15 +958,15 @@ bool BaseWindow::IsMenuBarVisible() const {
return window_->IsMenuBarVisible(); return window_->IsMenuBarVisible();
} }
void BaseWindow::SetAspectRatio(double aspect_ratio, void BaseWindow::SetAspectRatio(const double aspect_ratio,
gin_helper::Arguments* args) { gin::Arguments* const args) {
gfx::Size extra_size; gfx::Size extra_size;
args->GetNext(&extra_size); args->GetNext(&extra_size);
window_->SetAspectRatio(aspect_ratio, extra_size); window_->SetAspectRatio(aspect_ratio, extra_size);
} }
void BaseWindow::PreviewFile(const std::string& path, void BaseWindow::PreviewFile(const std::string& path,
gin_helper::Arguments* args) { gin::Arguments* const args) {
std::string display_name; std::string display_name;
if (!args->GetNext(&display_name)) if (!args->GetNext(&display_name))
display_name = path; display_name = path;
@@ -1000,7 +1003,7 @@ bool BaseWindow::IsModal() const {
return window_->is_modal(); return window_->is_modal();
} }
bool BaseWindow::SetThumbarButtons(gin_helper::Arguments* args) { bool BaseWindow::SetThumbarButtons(gin::Arguments* args) {
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)
std::vector<TaskbarHost::ThumbarButton> buttons; std::vector<TaskbarHost::ThumbarButton> buttons;
if (!args->GetNext(&buttons)) { if (!args->GetNext(&buttons)) {
@@ -1092,22 +1095,29 @@ bool BaseWindow::IsSnapped() const {
return window_->IsSnapped(); return window_->IsSnapped();
} }
void BaseWindow::SetAccentColor(gin_helper::Arguments* args) { void BaseWindow::SetAccentColor(gin::Arguments* const args) {
bool accent_color = false; v8::Local<v8::Value> ac_val;
std::string accent_color_string; args->GetNext(&ac_val);
if (args->GetNext(&accent_color_string)) {
std::optional<SkColor> maybe_color = ParseCSSColor(accent_color_string); if (!ac_val.IsEmpty() && ac_val->IsBoolean()) {
if (maybe_color.has_value()) { const bool ac_flag = ac_val->BooleanValue(args->isolate());
window_->SetAccentColor(maybe_color.value()); window_->SetAccentColor(ac_flag);
window_->UpdateWindowAccentColor(window_->IsActive());
return;
}
if (!ac_val.IsEmpty() && ac_val->IsString()) {
std::string ac_str;
gin::ConvertFromV8(args->isolate(), ac_val, &ac_str);
if (const std::optional<SkColor> ac_color = ParseCSSColor(ac_str)) {
window_->SetAccentColor(*ac_color);
window_->UpdateWindowAccentColor(window_->IsActive()); window_->UpdateWindowAccentColor(window_->IsActive());
} }
} else if (args->GetNext(&accent_color)) { return;
window_->SetAccentColor(accent_color); }
window_->UpdateWindowAccentColor(window_->IsActive());
} else { args->ThrowTypeError(
args->ThrowError(
"Invalid accent color value - must be a string or boolean"); "Invalid accent color value - must be a string or boolean");
}
} }
v8::Local<v8::Value> BaseWindow::GetAccentColor() const { v8::Local<v8::Value> BaseWindow::GetAccentColor() const {
@@ -1122,7 +1132,7 @@ v8::Local<v8::Value> BaseWindow::GetAccentColor() const {
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
void BaseWindow::SetTitleBarOverlay(const gin_helper::Dictionary& options, void BaseWindow::SetTitleBarOverlay(const gin_helper::Dictionary& options,
gin_helper::Arguments* args) { gin::Arguments* args) {
static_cast<NativeWindowViews*>(window_.get()) static_cast<NativeWindowViews*>(window_.get())
->SetTitleBarOverlay(options, args); ->SetTitleBarOverlay(options, args);
} }
@@ -1144,7 +1154,7 @@ void BaseWindow::RemoveFromParentChildWindows() {
} }
// static // static
gin_helper::WrappableBase* BaseWindow::New(gin_helper::Arguments* args) { gin_helper::WrappableBase* BaseWindow::New(gin::Arguments* const args) {
auto options = gin_helper::Dictionary::CreateEmpty(args->isolate()); auto options = gin_helper::Dictionary::CreateEmpty(args->isolate());
args->GetNext(&options); args->GetNext(&options);

View File

@@ -19,8 +19,11 @@
#include "shell/common/api/electron_api_native_image.h" #include "shell/common/api/electron_api_native_image.h"
#include "shell/common/gin_helper/trackable_object.h" #include "shell/common/gin_helper/trackable_object.h"
namespace gin_helper { namespace gin {
class Arguments; class Arguments;
} // namespace gin
namespace gin_helper {
class PersistentDictionary; class PersistentDictionary;
template <typename T> template <typename T>
class Handle; class Handle;
@@ -37,7 +40,7 @@ class View;
class BaseWindow : public gin_helper::TrackableObject<BaseWindow>, class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
private NativeWindowObserver { private NativeWindowObserver {
public: public:
static gin_helper::WrappableBase* New(gin_helper::Arguments* args); static gin_helper::WrappableBase* New(gin::Arguments* args);
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype); v8::Local<v8::FunctionTemplate> prototype);
@@ -49,8 +52,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
// Common constructor. // Common constructor.
BaseWindow(v8::Isolate* isolate, const gin_helper::Dictionary& options); BaseWindow(v8::Isolate* isolate, const gin_helper::Dictionary& options);
// Creating independent BaseWindow instance. // Creating independent BaseWindow instance.
BaseWindow(gin_helper::Arguments* args, BaseWindow(gin::Arguments* args, const gin_helper::Dictionary& options);
const gin_helper::Dictionary& options);
~BaseWindow() override; ~BaseWindow() override;
// TrackableObject: // TrackableObject:
@@ -118,13 +120,13 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
bool IsMinimized() const; bool IsMinimized() const;
void SetFullScreen(bool fullscreen); void SetFullScreen(bool fullscreen);
bool IsFullscreen() const; bool IsFullscreen() const;
void SetBounds(const gfx::Rect& bounds, gin_helper::Arguments* args); void SetBounds(const gfx::Rect& bounds, gin::Arguments* args);
gfx::Rect GetBounds() const; gfx::Rect GetBounds() const;
void SetSize(int width, int height, gin_helper::Arguments* args); void SetSize(int width, int height, gin::Arguments* args);
std::array<int, 2U> GetSize() const; std::array<int, 2U> GetSize() const;
void SetContentSize(int width, int height, gin_helper::Arguments* args); void SetContentSize(int width, int height, gin::Arguments* args);
std::array<int, 2U> GetContentSize() const; std::array<int, 2U> GetContentSize() const;
void SetContentBounds(const gfx::Rect& bounds, gin_helper::Arguments* args); void SetContentBounds(const gfx::Rect& bounds, gin::Arguments* args);
gfx::Rect GetContentBounds() const; gfx::Rect GetContentBounds() const;
bool IsNormal() const; bool IsNormal() const;
gfx::Rect GetNormalBounds() const; gfx::Rect GetNormalBounds() const;
@@ -132,11 +134,11 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
std::array<int, 2U> GetMinimumSize() const; std::array<int, 2U> GetMinimumSize() const;
void SetMaximumSize(int width, int height); void SetMaximumSize(int width, int height);
std::array<int, 2U> GetMaximumSize() const; std::array<int, 2U> GetMaximumSize() const;
void SetSheetOffset(double offsetY, gin_helper::Arguments* args); void SetSheetOffset(double offsetY, gin::Arguments* args);
void SetResizable(bool resizable); void SetResizable(bool resizable);
bool IsResizable() const; bool IsResizable() const;
void SetMovable(bool movable); void SetMovable(bool movable);
void MoveAbove(const std::string& sourceId, gin_helper::Arguments* args); void MoveAbove(const std::string& sourceId, gin::Arguments* args);
void MoveTop(); void MoveTop();
bool IsMovable() const; bool IsMovable() const;
void SetMinimizable(bool minimizable); void SetMinimizable(bool minimizable);
@@ -147,10 +149,10 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
bool IsFullScreenable() const; bool IsFullScreenable() const;
void SetClosable(bool closable); void SetClosable(bool closable);
bool IsClosable() const; bool IsClosable() const;
void SetAlwaysOnTop(bool top, gin_helper::Arguments* args); void SetAlwaysOnTop(bool top, gin::Arguments* args);
bool IsAlwaysOnTop() const; bool IsAlwaysOnTop() const;
void Center(); void Center();
void SetPosition(int x, int y, gin_helper::Arguments* args); void SetPosition(int x, int y, gin::Arguments* args);
std::array<int, 2U> GetPosition() const; std::array<int, 2U> GetPosition() const;
void SetTitle(const std::string& title); void SetTitle(const std::string& title);
std::string GetTitle() const; std::string GetTitle() const;
@@ -177,25 +179,25 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
std::string GetRepresentedFilename() const; std::string GetRepresentedFilename() const;
void SetDocumentEdited(bool edited); void SetDocumentEdited(bool edited);
bool IsDocumentEdited() const; bool IsDocumentEdited() const;
void SetIgnoreMouseEvents(bool ignore, gin_helper::Arguments* args); void SetIgnoreMouseEvents(bool ignore, gin::Arguments* args);
void SetContentProtection(bool enable); void SetContentProtection(bool enable);
bool IsContentProtected() const; bool IsContentProtected() const;
void SetFocusable(bool focusable); void SetFocusable(bool focusable);
bool IsFocusable() const; bool IsFocusable() const;
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu); void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
void RemoveMenu(); void RemoveMenu();
void SetParentWindow(v8::Local<v8::Value> value, gin_helper::Arguments* args); void SetParentWindow(v8::Local<v8::Value> value, gin::Arguments* args);
std::string GetMediaSourceId() const; std::string GetMediaSourceId() const;
v8::Local<v8::Value> GetNativeWindowHandle(); v8::Local<v8::Value> GetNativeWindowHandle();
void SetProgressBar(double progress, gin_helper::Arguments* args); void SetProgressBar(double progress, gin::Arguments* args);
void SetOverlayIcon(const gfx::Image& overlay, void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description); const std::string& description);
void SetVisibleOnAllWorkspaces(bool visible, gin_helper::Arguments* args); void SetVisibleOnAllWorkspaces(bool visible, gin::Arguments* args);
bool IsVisibleOnAllWorkspaces() const; bool IsVisibleOnAllWorkspaces() const;
void SetAutoHideCursor(bool auto_hide); void SetAutoHideCursor(bool auto_hide);
virtual void SetVibrancy(v8::Isolate* isolate, virtual void SetVibrancy(v8::Isolate* isolate,
v8::Local<v8::Value> value, v8::Local<v8::Value> value,
gin_helper::Arguments* args); gin::Arguments* args);
virtual void SetBackgroundMaterial(const std::string& material); virtual void SetBackgroundMaterial(const std::string& material);
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
@@ -218,14 +220,14 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
void MergeAllWindows(); void MergeAllWindows();
void MoveTabToNewWindow(); void MoveTabToNewWindow();
void ToggleTabBar(); void ToggleTabBar();
void AddTabbedWindow(NativeWindow* window, gin_helper::Arguments* args); void AddTabbedWindow(NativeWindow* window, gin::Arguments* args);
v8::Local<v8::Value> GetTabbingIdentifier(); v8::Local<v8::Value> GetTabbingIdentifier();
void SetAutoHideMenuBar(bool auto_hide); void SetAutoHideMenuBar(bool auto_hide);
bool IsMenuBarAutoHide() const; bool IsMenuBarAutoHide() const;
void SetMenuBarVisibility(bool visible); void SetMenuBarVisibility(bool visible);
bool IsMenuBarVisible() const; bool IsMenuBarVisible() const;
void SetAspectRatio(double aspect_ratio, gin_helper::Arguments* args); void SetAspectRatio(double aspect_ratio, gin::Arguments* args);
void PreviewFile(const std::string& path, gin_helper::Arguments* args); void PreviewFile(const std::string& path, gin::Arguments* args);
void CloseFilePreview(); void CloseFilePreview();
void SetGTKDarkThemeEnabled(bool use_dark_theme); void SetGTKDarkThemeEnabled(bool use_dark_theme);
@@ -236,7 +238,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
bool IsModal() const; bool IsModal() const;
// Extra APIs added in JS. // Extra APIs added in JS.
bool SetThumbarButtons(gin_helper::Arguments* args); bool SetThumbarButtons(gin::Arguments* args);
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
void SetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon); void SetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon);
void SetIconImpl(v8::Isolate* isolate, void SetIconImpl(v8::Isolate* isolate,
@@ -255,13 +257,13 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
bool SetThumbnailToolTip(const std::string& tooltip); bool SetThumbnailToolTip(const std::string& tooltip);
void SetAppDetails(const gin_helper::Dictionary& options); void SetAppDetails(const gin_helper::Dictionary& options);
bool IsSnapped() const; bool IsSnapped() const;
void SetAccentColor(gin_helper::Arguments* args); void SetAccentColor(gin::Arguments* args);
v8::Local<v8::Value> GetAccentColor() const; v8::Local<v8::Value> GetAccentColor() const;
#endif #endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
void SetTitleBarOverlay(const gin_helper::Dictionary& options, void SetTitleBarOverlay(const gin_helper::Dictionary& options,
gin_helper::Arguments* args); gin::Arguments* args);
#endif #endif
[[nodiscard]] constexpr int32_t GetID() const { return weak_map_id(); } [[nodiscard]] constexpr int32_t GetID() const { return weak_map_id(); }

View File

@@ -451,10 +451,10 @@ NativeWindowViews::~NativeWindowViews() {
void NativeWindowViews::SetTitleBarOverlay( void NativeWindowViews::SetTitleBarOverlay(
const gin_helper::Dictionary& options, const gin_helper::Dictionary& options,
gin_helper::Arguments* args) { gin::Arguments* args) {
// Ensure WCO is already enabled on this window // Ensure WCO is already enabled on this window
if (!IsWindowControlsOverlayEnabled()) { if (!IsWindowControlsOverlayEnabled()) {
args->ThrowError("Titlebar overlay is not enabled"); args->ThrowTypeError("Titlebar overlay is not enabled");
return; return;
} }
@@ -465,7 +465,7 @@ void NativeWindowViews::SetTitleBarOverlay(
// Parse the string as a CSS color // Parse the string as a CSS color
SkColor color; SkColor color;
if (!content::ParseCssColorString(val, &color)) { if (!content::ParseCssColorString(val, &color)) {
args->ThrowError("Could not parse color as CSS color"); args->ThrowTypeError("Could not parse color as CSS color");
return; return;
} }
@@ -479,7 +479,7 @@ void NativeWindowViews::SetTitleBarOverlay(
// Parse the string as a CSS color // Parse the string as a CSS color
SkColor color; SkColor color;
if (!content::ParseCssColorString(val, &color)) { if (!content::ParseCssColorString(val, &color)) {
args->ThrowError("Could not parse symbol color as CSS color"); args->ThrowTypeError("Could not parse symbol color as CSS color");
return; return;
} }

View File

@@ -25,9 +25,9 @@
#include "shell/browser/ui/win/taskbar_host.h" #include "shell/browser/ui/win/taskbar_host.h"
#endif #endif
namespace gin_helper { namespace gin {
class Arguments; class Arguments;
} // namespace gin_helper } // namespace gin
namespace electron { namespace electron {
@@ -158,7 +158,7 @@ class NativeWindowViews : public NativeWindow,
void DecrementChildModals(); void DecrementChildModals();
void SetTitleBarOverlay(const gin_helper::Dictionary& options, void SetTitleBarOverlay(const gin_helper::Dictionary& options,
gin_helper::Arguments* args); gin::Arguments* args);
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)
// Catch-all message handling and filtering. Called before // Catch-all message handling and filtering. Called before