2016-04-24 12:13:46 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_API_ATOM_API_SYSTEM_PREFERENCES_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_SYSTEM_PREFERENCES_H_
|
|
|
|
|
2016-04-25 05:25:14 +00:00
|
|
|
#include <string>
|
|
|
|
|
2016-04-24 12:13:46 +00:00
|
|
|
#include "atom/browser/api/event_emitter.h"
|
2016-04-25 05:25:14 +00:00
|
|
|
#include "base/callback.h"
|
2016-04-24 12:13:46 +00:00
|
|
|
#include "native_mate/handle.h"
|
|
|
|
|
2016-05-18 05:40:19 +00:00
|
|
|
namespace base {
|
|
|
|
class DictionaryValue;
|
|
|
|
}
|
|
|
|
|
2016-04-24 12:13:46 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
|
|
|
class SystemPreferences : public mate::EventEmitter<SystemPreferences> {
|
|
|
|
public:
|
|
|
|
static mate::Handle<SystemPreferences> Create(v8::Isolate* isolate);
|
|
|
|
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
2016-08-02 09:08:12 +00:00
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
2016-04-24 12:13:46 +00:00
|
|
|
|
2016-04-25 03:35:09 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
bool IsAeroGlassEnabled();
|
2016-04-25 05:25:14 +00:00
|
|
|
#elif defined(OS_MACOSX)
|
2016-06-21 00:48:42 +00:00
|
|
|
using NotificationCallback = base::Callback<
|
|
|
|
void(const std::string&, const base::DictionaryValue&)>;
|
|
|
|
|
2016-04-25 05:25:14 +00:00
|
|
|
int SubscribeNotification(const std::string& name,
|
2016-05-18 05:40:19 +00:00
|
|
|
const NotificationCallback& callback);
|
2016-04-25 05:25:14 +00:00
|
|
|
void UnsubscribeNotification(int id);
|
2016-06-21 00:48:42 +00:00
|
|
|
int SubscribeLocalNotification(const std::string& name,
|
|
|
|
const NotificationCallback& callback);
|
|
|
|
void UnsubscribeLocalNotification(int request_id);
|
2016-04-25 06:35:52 +00:00
|
|
|
v8::Local<v8::Value> GetUserDefault(const std::string& name,
|
|
|
|
const std::string& type);
|
2016-08-03 02:27:56 +00:00
|
|
|
// On 10.7+, back and forward swipe gestures can be triggered using a scroll
|
|
|
|
// gesture, if enabled in System Preferences. This function returns true if
|
|
|
|
// the feature is supported and enabled, and false otherwise.
|
|
|
|
bool IsSwipeTrackingFromScrollEventsEnabled();
|
2016-04-25 03:35:09 +00:00
|
|
|
#endif
|
|
|
|
bool IsDarkMode();
|
|
|
|
|
2016-04-24 12:13:46 +00:00
|
|
|
protected:
|
|
|
|
explicit SystemPreferences(v8::Isolate* isolate);
|
|
|
|
~SystemPreferences() override;
|
|
|
|
|
2016-06-21 00:48:42 +00:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
int DoSubscribeNotification(const std::string& name,
|
|
|
|
const NotificationCallback& callback,
|
|
|
|
bool is_local);
|
|
|
|
void DoUnsubscribeNotification(int request_id, bool is_local);
|
|
|
|
#endif
|
|
|
|
|
2016-04-24 12:13:46 +00:00
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SystemPreferences);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_SYSTEM_PREFERENCES_H_
|