2019-08-14 20:42:55 +00:00
|
|
|
// Copyright (c) 2019 Slack Technologies, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-09-16 21:23:13 +00:00
|
|
|
#ifndef SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_
|
|
|
|
#define SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_
|
2019-08-14 20:42:55 +00:00
|
|
|
|
2019-10-21 07:05:40 +00:00
|
|
|
#include "shell/browser/api/event_emitter_deprecated.h"
|
2019-09-05 17:57:04 +00:00
|
|
|
#include "ui/native_theme/native_theme.h"
|
2019-08-14 20:42:55 +00:00
|
|
|
#include "ui/native_theme/native_theme_observer.h"
|
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
|
|
|
class NativeTheme : public mate::EventEmitter<NativeTheme>,
|
|
|
|
public ui::NativeThemeObserver {
|
|
|
|
public:
|
|
|
|
static v8::Local<v8::Value> Create(v8::Isolate* isolate);
|
|
|
|
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
NativeTheme(v8::Isolate* isolate, ui::NativeTheme* theme);
|
|
|
|
~NativeTheme() override;
|
|
|
|
|
2019-09-05 17:57:04 +00:00
|
|
|
void SetThemeSource(ui::NativeTheme::ThemeSource override);
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
void UpdateMacOSAppearanceForOverrideValue(
|
|
|
|
ui::NativeTheme::ThemeSource override);
|
|
|
|
#endif
|
|
|
|
ui::NativeTheme::ThemeSource GetThemeSource() const;
|
2019-08-14 20:42:55 +00:00
|
|
|
bool ShouldUseDarkColors();
|
|
|
|
bool ShouldUseHighContrastColors();
|
|
|
|
bool ShouldUseInvertedColorScheme();
|
|
|
|
|
|
|
|
// ui::NativeThemeObserver:
|
|
|
|
void OnNativeThemeUpdated(ui::NativeTheme* theme) override;
|
2019-09-16 23:08:01 +00:00
|
|
|
void OnNativeThemeUpdatedOnUI();
|
2019-08-14 20:42:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ui::NativeTheme* theme_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(NativeTheme);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2019-10-02 00:30:55 +00:00
|
|
|
namespace gin {
|
2019-09-05 17:57:04 +00:00
|
|
|
|
|
|
|
template <>
|
|
|
|
struct Converter<ui::NativeTheme::ThemeSource> {
|
|
|
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
|
|
|
const ui::NativeTheme::ThemeSource& val);
|
|
|
|
static bool FromV8(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Value> val,
|
|
|
|
ui::NativeTheme::ThemeSource* out);
|
|
|
|
};
|
|
|
|
|
2019-10-02 00:30:55 +00:00
|
|
|
} // namespace gin
|
2019-09-05 17:57:04 +00:00
|
|
|
|
2019-09-16 21:23:13 +00:00
|
|
|
#endif // SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_
|