@@ -23,14 +23,16 @@ namespace electron {
2323
2424namespace api {
2525
26- NativeTheme::NativeTheme (v8::Isolate* isolate, ui::NativeTheme* theme)
27- : theme_(theme) {
28- theme_->AddObserver (this );
26+ NativeTheme::NativeTheme (v8::Isolate* isolate,
27+ ui::NativeTheme* ui_theme,
28+ ui::NativeTheme* web_theme)
29+ : ui_theme_(ui_theme), web_theme_(web_theme) {
30+ ui_theme_->AddObserver (this );
2931 Init (isolate);
3032}
3133
3234NativeTheme::~NativeTheme () {
33- theme_ ->RemoveObserver (this );
35+ ui_theme_ ->RemoveObserver (this );
3436}
3537
3638void NativeTheme::OnNativeThemeUpdatedOnUI () {
@@ -44,7 +46,8 @@ void NativeTheme::OnNativeThemeUpdated(ui::NativeTheme* theme) {
4446}
4547
4648void NativeTheme::SetThemeSource (ui::NativeTheme::ThemeSource override ) {
47- theme_->set_theme_source (override );
49+ ui_theme_->set_theme_source (override );
50+ web_theme_->set_theme_source (override );
4851#if defined(OS_MACOSX)
4952 // Update the macOS appearance setting for this new override value
5053 UpdateMacOSAppearanceForOverrideValue (override );
@@ -59,15 +62,15 @@ void NativeTheme::SetThemeSource(ui::NativeTheme::ThemeSource override) {
5962}
6063
6164ui::NativeTheme::ThemeSource NativeTheme::GetThemeSource () const {
62- return theme_ ->theme_source ();
65+ return ui_theme_ ->theme_source ();
6366}
6467
6568bool NativeTheme::ShouldUseDarkColors () {
66- return theme_ ->ShouldUseDarkColors ();
69+ return ui_theme_ ->ShouldUseDarkColors ();
6770}
6871
6972bool NativeTheme::ShouldUseHighContrastColors () {
70- return theme_ ->UsesHighContrastColors ();
73+ return ui_theme_ ->UsesHighContrastColors ();
7174}
7275
7376#if defined(OS_MACOSX)
@@ -92,8 +95,11 @@ bool NativeTheme::ShouldUseInvertedColorScheme() {
9295
9396// static
9497v8::Local<v8::Value> NativeTheme::Create (v8::Isolate* isolate) {
95- ui::NativeTheme* theme = ui::NativeTheme::GetInstanceForNativeUi ();
96- return gin::CreateHandle (isolate, new NativeTheme (isolate, theme)).ToV8 ();
98+ ui::NativeTheme* ui_theme = ui::NativeTheme::GetInstanceForNativeUi ();
99+ ui::NativeTheme* web_theme = ui::NativeTheme::GetInstanceForWeb ();
100+ return gin::CreateHandle (isolate,
101+ new NativeTheme (isolate, ui_theme, web_theme))
102+ .ToV8 ();
97103}
98104
99105// static
0 commit comments