9 #include "flutter/fml/logging.h"
10 #include "flutter/fml/platform/win/wstring_conversion.h"
20 static constexpr
char kTypeKey[] =
"type";
21 static constexpr
char kDataKey[] =
"data";
22 static constexpr
char kMessageKey[] =
"message";
23 static constexpr
char kAnnounceValue[] =
"announce";
27 void 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(
104 std::wstring wide_text = fml::Utf8ToWideString(
message);
105 view->AnnounceAlert(wide_text);