refactor: ginify SystemPreferences (#24675)
This commit is contained in:
parent
3f45fc24bb
commit
362da77c0a
6 changed files with 76 additions and 70 deletions
|
@ -7,7 +7,7 @@
|
|||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/gin_helper/function_template_extensions.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "ui/gfx/animation/animation.h"
|
||||
#include "ui/gfx/color_utils.h"
|
||||
|
@ -17,8 +17,9 @@ namespace electron {
|
|||
|
||||
namespace api {
|
||||
|
||||
SystemPreferences::SystemPreferences(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
gin::WrapperInfo SystemPreferences::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
|
||||
SystemPreferences::SystemPreferences() {
|
||||
#if defined(OS_WIN)
|
||||
InitializeWindow();
|
||||
#endif
|
||||
|
@ -61,15 +62,13 @@ v8::Local<v8::Value> SystemPreferences::GetAnimationSettings(
|
|||
|
||||
// static
|
||||
gin::Handle<SystemPreferences> SystemPreferences::Create(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new SystemPreferences(isolate));
|
||||
return gin::CreateHandle(isolate, new SystemPreferences());
|
||||
}
|
||||
|
||||
// static
|
||||
void SystemPreferences::BuildPrototype(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "SystemPreferences"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin::ObjectTemplateBuilder SystemPreferences::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
return gin_helper::EventEmitterMixin<
|
||||
SystemPreferences>::GetObjectTemplateBuilder(isolate)
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
.SetMethod("getColor", &SystemPreferences::GetColor)
|
||||
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
|
||||
|
@ -125,6 +124,10 @@ void SystemPreferences::BuildPrototype(
|
|||
&SystemPreferences::GetAnimationSettings);
|
||||
}
|
||||
|
||||
const char* SystemPreferences::GetTypeName() {
|
||||
return "SystemPreferences";
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace electron
|
||||
|
@ -140,9 +143,6 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
v8::Isolate* isolate = context->GetIsolate();
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.Set("systemPreferences", SystemPreferences::Create(isolate));
|
||||
dict.Set("SystemPreferences", SystemPreferences::GetConstructor(isolate)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue