Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
settings_plugin.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_H_
7
8#include <Windows.h>
9
10#include <memory>
11
12#include "flutter/fml/macros.h"
13#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
14#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
15#include "flutter/shell/platform/windows/event_watcher.h"
16#include "flutter/shell/platform/windows/task_runner.h"
17#include "rapidjson/document.h"
18
19namespace flutter {
20
21// Abstract settings plugin.
22//
23// Used to look up and notify Flutter of user-configured system settings.
24// These are typically set in the control panel.
26 public:
28
29 explicit SettingsPlugin(BinaryMessenger* messenger, TaskRunner* task_runner);
30
31 virtual ~SettingsPlugin();
32
33 // Sends settings (e.g., platform brightness) to the engine.
34 void SendSettings();
35
36 // Start watching settings changes and notify the engine of the update.
37 virtual void StartWatching();
38
39 // Stop watching settings change. The `SettingsPlugin` destructor will call
40 // this automatically.
41 virtual void StopWatching();
42
43 // Update the high contrast status of the system.
44 virtual void UpdateHighContrastMode(bool is_high_contrast);
45
46 protected:
47 // Returns `true` if the user uses 24 hour time.
48 virtual bool GetAlwaysUse24HourFormat();
49
50 // Returns the user-preferred text scale factor.
51 virtual float GetTextScaleFactor();
52
53 // Returns the user-preferred brightness.
55
56 // Starts watching brightness changes.
58
59 // Starts watching text scale factor changes.
60 virtual void WatchTextScaleFactorChanged();
61
62 bool is_high_contrast_ = false;
63
64 private:
65 std::unique_ptr<BasicMessageChannel<rapidjson::Document>> channel_;
66
67 HKEY preferred_brightness_reg_hkey_ = nullptr;
68 HKEY text_scale_factor_reg_hkey_ = nullptr;
69
70 std::unique_ptr<EventWatcher> preferred_brightness_changed_watcher_;
71 std::unique_ptr<EventWatcher> text_scale_factor_changed_watcher_;
72
73 TaskRunner* task_runner_;
74
76};
77
78} // namespace flutter
79
80#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_SETTINGS_PLUGIN_H_
virtual void UpdateHighContrastMode(bool is_high_contrast)
virtual void WatchPreferredBrightnessChanged()
virtual bool GetAlwaysUse24HourFormat()
virtual PlatformBrightness GetPreferredBrightness()
virtual void WatchTextScaleFactorChanged()
virtual float GetTextScaleFactor()
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27