5#include "flutter/shell/platform/windows/accessibility_plugin.h"
9#include "flutter/fml/logging.h"
10#include "flutter/fml/platform/win/wstring_conversion.h"
11#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
12#include "flutter/shell/platform/windows/flutter_windows_engine.h"
13#include "flutter/shell/platform/windows/flutter_windows_view.h"
20static constexpr char kTypeKey[] =
"type";
21static constexpr char kDataKey[] =
"data";
22static constexpr char kMessageKey[] =
"message";
23static constexpr char kAnnounceValue[] =
"announce";
27void HandleMessage(AccessibilityPlugin* plugin,
const EncodableValue&
message) {
28 const auto*
map = std::get_if<EncodableMap>(&
message);
30 FML_LOG(
ERROR) <<
"Accessibility message must be a map.";
33 const auto& type_itr =
map->find(EncodableValue{
kTypeKey});
34 const auto& data_itr =
map->find(EncodableValue{kDataKey});
35 if (type_itr ==
map->end()) {
36 FML_LOG(
ERROR) <<
"Accessibility message must have a 'type' property.";
39 if (data_itr ==
map->end()) {
40 FML_LOG(
ERROR) <<
"Accessibility message must have a 'data' property.";
43 const auto*
type = std::get_if<std::string>(&type_itr->second);
44 const auto*
data = std::get_if<EncodableMap>(&data_itr->second);
46 FML_LOG(
ERROR) <<
"Accessibility message 'type' property must be a string.";
50 FML_LOG(
ERROR) <<
"Accessibility message 'data' property must be a map.";
54 if (
type->compare(kAnnounceValue) == 0) {
55 const auto& message_itr =
data->find(EncodableValue{kMessageKey});
56 if (message_itr ==
data->end()) {
59 const auto*
message = std::get_if<std::string>(&message_itr->second);
66 FML_LOG(WARNING) <<
"Accessibility message type '" << *
type
67 <<
"' is not supported.";
81 channel.SetMessageHandler(
105 view->AnnounceAlert(wide_text);
AccessibilityPlugin(FlutterWindowsEngine *engine)
virtual void Announce(const std::string_view message)
static void SetUp(BinaryMessenger *binary_messenger, AccessibilityPlugin *plugin)
FlutterWindowsView * view(FlutterViewId view_id) const
bool semantics_enabled() const
static const StandardMessageCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
static constexpr char kAccessibilityChannelName[]
#define FML_LOG(severity)
constexpr FlutterViewId kImplicitViewId
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
constexpr char kTypeKey[]
std::function< void(const T &reply)> MessageReply
std::wstring Utf8ToWideString(const std::string_view str)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>