|
16 | 16 | #include "base/mac/scoped_cftyperef.h" |
17 | 17 | #include "base/numerics/ranges.h" |
18 | 18 | #include "base/strings/sys_string_conversions.h" |
| 19 | +#include "base/task/post_task.h" |
19 | 20 | #include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h" |
20 | 21 | #include "content/public/browser/browser_accessibility_state.h" |
| 22 | +#include "content/public/browser/browser_task_traits.h" |
| 23 | +#include "content/public/browser/browser_thread.h" |
21 | 24 | #include "content/public/browser/desktop_media_id.h" |
22 | 25 | #include "shell/browser/native_browser_view_mac.h" |
23 | 26 | #include "shell/browser/ui/cocoa/electron_native_widget_mac.h" |
@@ -324,6 +327,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { |
324 | 327 | NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options, |
325 | 328 | NativeWindow* parent) |
326 | 329 | : NativeWindow(options, parent), root_view_(new RootViewMac(this)) { |
| 330 | + ui::NativeTheme::GetInstanceForNativeUi()->AddObserver(this); |
| 331 | + |
327 | 332 | int width = 800, height = 600; |
328 | 333 | options.Get(options::kWidth, &width); |
329 | 334 | options.Get(options::kHeight, &height); |
@@ -509,6 +514,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { |
509 | 514 | } |
510 | 515 |
|
511 | 516 | NativeWindowMac::~NativeWindowMac() { |
| 517 | + ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this); |
512 | 518 | if (wheel_event_monitor_) |
513 | 519 | [NSEvent removeMonitor:wheel_event_monitor_]; |
514 | 520 | } |
@@ -700,6 +706,12 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { |
700 | 706 | exiting_fullscreen_ = flag; |
701 | 707 | } |
702 | 708 |
|
| 709 | +void NativeWindowMac::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) { |
| 710 | + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, |
| 711 | + base::BindOnce(&NativeWindowMac::RepositionTrafficLights, |
| 712 | + base::Unretained(this))); |
| 713 | +} |
| 714 | + |
703 | 715 | bool NativeWindowMac::IsEnabled() { |
704 | 716 | return [window_ attachedSheet] == nil; |
705 | 717 | } |
|
0 commit comments