Flutter Engine
dart_io.cc
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 #include "flutter/lib/io/dart_io.h"
6 
7 #include "flutter/fml/logging.h"
8 #include "third_party/dart/runtime/include/bin/dart_io_api.h"
9 #include "third_party/dart/runtime/include/dart_api.h"
12 
13 using tonic::LogIfError;
14 using tonic::ToDart;
15 
16 namespace flutter {
17 
18 void DartIO::InitForIsolate(bool may_insecurely_connect_to_all_domains,
19  std::string domain_network_policy) {
20  Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
21  Dart_Handle result = Dart_SetNativeResolver(io_lib, dart::bin::LookupIONative,
22  dart::bin::LookupIONativeSymbol);
23  FML_CHECK(!LogIfError(result));
24 
25  Dart_Handle embedder_config_type =
26  Dart_GetNonNullableType(io_lib, ToDart("_EmbedderConfig"), 0, nullptr);
27  FML_CHECK(!LogIfError(embedder_config_type));
28 
29  Dart_Handle allow_insecure_connections_result = Dart_SetField(
30  embedder_config_type, ToDart("_mayInsecurelyConnectToAllDomains"),
31  ToDart(may_insecurely_connect_to_all_domains));
32  FML_CHECK(!LogIfError(allow_insecure_connections_result));
33 
34  Dart_Handle dart_args[1];
35  dart_args[0] = ToDart(domain_network_policy);
36  Dart_Handle set_domain_network_policy_result = Dart_Invoke(
37  embedder_config_type, ToDart("_setDomainPolicies"), 1, dart_args);
38  FML_CHECK(!LogIfError(set_domain_network_policy_result));
39 }
40 
41 } // namespace flutter
#define FML_CHECK(condition)
Definition: logging.h:68
static void InitForIsolate(bool may_insecurely_connect_to_all_domains, std::string domain_network_policy)
Definition: dart_io.cc:18
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15