fix: revert macOS content protection logic refactor (#46889)
Revert "refactor: use upstream content protection logic on macOS (#46813)"
This reverts commit 34adb976b6
.
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
This commit is contained in:
parent
ec4eafecae
commit
621c6b4148
6 changed files with 30 additions and 17 deletions
|
@ -26,7 +26,6 @@
|
||||||
#include "shell/common/options_switches.h"
|
#include "shell/common/options_switches.h"
|
||||||
#include "ui/base/hit_test.h"
|
#include "ui/base/hit_test.h"
|
||||||
#include "ui/compositor/compositor.h"
|
#include "ui/compositor/compositor.h"
|
||||||
#include "ui/views/widget/native_widget_private.h"
|
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
|
|
||||||
#if !BUILDFLAG(IS_MAC)
|
#if !BUILDFLAG(IS_MAC)
|
||||||
|
@ -815,20 +814,6 @@ void NativeWindow::HandlePendingFullscreenTransitions() {
|
||||||
SetFullScreen(next_transition);
|
SetFullScreen(next_transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetContentProtection(bool enable) {
|
|
||||||
#if !BUILDFLAG(IS_LINUX)
|
|
||||||
widget()->native_widget_private()->SetAllowScreenshots(!enable);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NativeWindow::IsContentProtected() const {
|
|
||||||
#if !BUILDFLAG(IS_LINUX)
|
|
||||||
return !widget()->native_widget_private()->AreScreenshotsAllowed();
|
|
||||||
#else // Not implemented on Linux
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NativeWindow::IsTranslucent() const {
|
bool NativeWindow::IsTranslucent() const {
|
||||||
// Transparent windows are translucent
|
// Transparent windows are translucent
|
||||||
if (transparent()) {
|
if (transparent()) {
|
||||||
|
|
|
@ -186,8 +186,8 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
virtual void SetDocumentEdited(bool edited) {}
|
virtual void SetDocumentEdited(bool edited) {}
|
||||||
virtual bool IsDocumentEdited() const;
|
virtual bool IsDocumentEdited() const;
|
||||||
virtual void SetIgnoreMouseEvents(bool ignore, bool forward) = 0;
|
virtual void SetIgnoreMouseEvents(bool ignore, bool forward) = 0;
|
||||||
void SetContentProtection(bool enable);
|
virtual void SetContentProtection(bool enable) = 0;
|
||||||
bool IsContentProtected() const;
|
virtual bool IsContentProtected() const = 0;
|
||||||
virtual void SetFocusable(bool focusable) {}
|
virtual void SetFocusable(bool focusable) {}
|
||||||
virtual bool IsFocusable() const;
|
virtual bool IsFocusable() const;
|
||||||
virtual void SetMenu(ElectronMenuModel* menu) {}
|
virtual void SetMenu(ElectronMenuModel* menu) {}
|
||||||
|
|
|
@ -109,6 +109,8 @@ class NativeWindowMac : public NativeWindow,
|
||||||
void SetIgnoreMouseEvents(bool ignore, bool forward) override;
|
void SetIgnoreMouseEvents(bool ignore, bool forward) override;
|
||||||
bool IsHiddenInMissionControl() const override;
|
bool IsHiddenInMissionControl() const override;
|
||||||
void SetHiddenInMissionControl(bool hidden) override;
|
void SetHiddenInMissionControl(bool hidden) override;
|
||||||
|
void SetContentProtection(bool enable) override;
|
||||||
|
bool IsContentProtected() const override;
|
||||||
void SetFocusable(bool focusable) override;
|
void SetFocusable(bool focusable) override;
|
||||||
bool IsFocusable() const override;
|
bool IsFocusable() const override;
|
||||||
void SetParentWindow(NativeWindow* parent) override;
|
void SetParentWindow(NativeWindow* parent) override;
|
||||||
|
|
|
@ -1171,6 +1171,15 @@ void NativeWindowMac::SetIgnoreMouseEvents(bool ignore, bool forward) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::SetContentProtection(bool enable) {
|
||||||
|
[window_
|
||||||
|
setSharingType:enable ? NSWindowSharingNone : NSWindowSharingReadOnly];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeWindowMac::IsContentProtected() const {
|
||||||
|
return [window_ sharingType] == NSWindowSharingNone;
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetFocusable(bool focusable) {
|
void NativeWindowMac::SetFocusable(bool focusable) {
|
||||||
// No known way to unfocus the window if it had the focus. Here we do not
|
// No known way to unfocus the window if it had the focus. Here we do not
|
||||||
// want to call Focus(false) because it moves the window to the back, i.e.
|
// want to call Focus(false) because it moves the window to the back, i.e.
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "ui/ozone/public/ozone_platform.h"
|
#include "ui/ozone/public/ozone_platform.h"
|
||||||
#include "ui/views/background.h"
|
#include "ui/views/background.h"
|
||||||
#include "ui/views/controls/webview/webview.h"
|
#include "ui/views/controls/webview/webview.h"
|
||||||
|
#include "ui/views/widget/native_widget_private.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
#include "ui/views/window/client_view.h"
|
#include "ui/views/window/client_view.h"
|
||||||
#include "ui/wm/core/shadow_types.h"
|
#include "ui/wm/core/shadow_types.h"
|
||||||
|
@ -1324,6 +1325,20 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowViews::SetContentProtection(bool enable) {
|
||||||
|
#if BUILDFLAG(IS_WIN)
|
||||||
|
widget()->native_widget_private()->SetAllowScreenshots(!enable);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeWindowViews::IsContentProtected() const {
|
||||||
|
#if BUILDFLAG(IS_WIN)
|
||||||
|
return !widget()->native_widget_private()->AreScreenshotsAllowed();
|
||||||
|
#else // Not implemented on Linux
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetFocusable(bool focusable) {
|
void NativeWindowViews::SetFocusable(bool focusable) {
|
||||||
widget()->widget_delegate()->SetCanActivate(focusable);
|
widget()->widget_delegate()->SetCanActivate(focusable);
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
|
|
|
@ -115,6 +115,8 @@ class NativeWindowViews : public NativeWindow,
|
||||||
void SetOpacity(const double opacity) override;
|
void SetOpacity(const double opacity) override;
|
||||||
double GetOpacity() const override;
|
double GetOpacity() const override;
|
||||||
void SetIgnoreMouseEvents(bool ignore, bool forward) override;
|
void SetIgnoreMouseEvents(bool ignore, bool forward) override;
|
||||||
|
void SetContentProtection(bool enable) override;
|
||||||
|
bool IsContentProtected() const override;
|
||||||
void SetFocusable(bool focusable) override;
|
void SetFocusable(bool focusable) override;
|
||||||
bool IsFocusable() const override;
|
bool IsFocusable() const override;
|
||||||
void SetMenu(ElectronMenuModel* menu_model) override;
|
void SetMenu(ElectronMenuModel* menu_model) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue