mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: add tabbingIdentifier property to BrowserWindow (#39980)
feat: add tabbingIdentifier property to BrowserWindow
This commit is contained in:
@@ -953,6 +953,14 @@ void BaseWindow::AddTabbedWindow(NativeWindow* window,
|
||||
args->ThrowError("AddTabbedWindow cannot be called by a window on itself.");
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> BaseWindow::GetTabbingIdentifier() {
|
||||
auto tabbing_id = window_->GetTabbingIdentifier();
|
||||
if (!tabbing_id.has_value())
|
||||
return v8::Undefined(isolate());
|
||||
|
||||
return gin::ConvertToV8(isolate(), tabbing_id.value());
|
||||
}
|
||||
|
||||
void BaseWindow::SetAutoHideMenuBar(bool auto_hide) {
|
||||
window_->SetAutoHideMenuBar(auto_hide);
|
||||
}
|
||||
@@ -1305,6 +1313,7 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("moveTabToNewWindow", &BaseWindow::MoveTabToNewWindow)
|
||||
.SetMethod("toggleTabBar", &BaseWindow::ToggleTabBar)
|
||||
.SetMethod("addTabbedWindow", &BaseWindow::AddTabbedWindow)
|
||||
.SetProperty("tabbingIdentifier", &BaseWindow::GetTabbingIdentifier)
|
||||
.SetMethod("setWindowButtonVisibility",
|
||||
&BaseWindow::SetWindowButtonVisibility)
|
||||
.SetMethod("_getWindowButtonVisibility",
|
||||
|
||||
@@ -198,9 +198,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
||||
bool GetWindowButtonVisibility() const;
|
||||
void SetWindowButtonPosition(absl::optional<gfx::Point> position);
|
||||
absl::optional<gfx::Point> GetWindowButtonPosition() const;
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
bool IsHiddenInMissionControl();
|
||||
void SetHiddenInMissionControl(bool hidden);
|
||||
#endif
|
||||
@@ -215,6 +213,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
||||
void MoveTabToNewWindow();
|
||||
void ToggleTabBar();
|
||||
void AddTabbedWindow(NativeWindow* window, gin_helper::Arguments* args);
|
||||
v8::Local<v8::Value> GetTabbingIdentifier();
|
||||
void SetAutoHideMenuBar(bool auto_hide);
|
||||
bool IsMenuBarAutoHide();
|
||||
void SetMenuBarVisibility(bool visible);
|
||||
|
||||
@@ -481,6 +481,10 @@ bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
|
||||
return true; // for non-Mac platforms
|
||||
}
|
||||
|
||||
absl::optional<std::string> NativeWindow::GetTabbingIdentifier() const {
|
||||
return ""; // for non-Mac platforms
|
||||
}
|
||||
|
||||
void NativeWindow::SetVibrancy(const std::string& type) {
|
||||
vibrancy_ = type;
|
||||
}
|
||||
|
||||
@@ -256,6 +256,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual void MoveTabToNewWindow();
|
||||
virtual void ToggleTabBar();
|
||||
virtual bool AddTabbedWindow(NativeWindow* window);
|
||||
virtual absl::optional<std::string> GetTabbingIdentifier() const;
|
||||
|
||||
// Toggle the menu bar.
|
||||
virtual void SetAutoHideMenuBar(bool auto_hide);
|
||||
|
||||
@@ -145,6 +145,7 @@ class NativeWindowMac : public NativeWindow,
|
||||
void MoveTabToNewWindow() override;
|
||||
void ToggleTabBar() override;
|
||||
bool AddTabbedWindow(NativeWindow* window) override;
|
||||
absl::optional<std::string> GetTabbingIdentifier() const override;
|
||||
void SetAspectRatio(double aspect_ratio,
|
||||
const gfx::Size& extra_size) override;
|
||||
void PreviewFile(const std::string& path,
|
||||
|
||||
@@ -1643,6 +1643,13 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
||||
return true;
|
||||
}
|
||||
|
||||
absl::optional<std::string> NativeWindowMac::GetTabbingIdentifier() const {
|
||||
if ([window_ tabbingMode] == NSWindowTabbingModeDisallowed)
|
||||
return absl::nullopt;
|
||||
|
||||
return base::SysNSStringToUTF8([window_ tabbingIdentifier]);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAspectRatio(double aspect_ratio,
|
||||
const gfx::Size& extra_size) {
|
||||
NativeWindow::SetAspectRatio(aspect_ratio, extra_size);
|
||||
|
||||
Reference in New Issue
Block a user