Flutter Windows Embedder
plugin_registrar.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 
6 
7 #include <iostream>
8 #include <map>
9 
10 #include "binary_messenger_impl.h"
13 #include "texture_registrar_impl.h"
14 
15 namespace flutter {
16 
17 // ===== PluginRegistrar =====
18 
20  : registrar_(registrar) {
21  auto core_messenger = FlutterDesktopPluginRegistrarGetMessenger(registrar_);
22  messenger_ = std::make_unique<BinaryMessengerImpl>(core_messenger);
23 
24  auto texture_registrar =
26  texture_registrar_ =
27  std::make_unique<TextureRegistrarImpl>(texture_registrar);
28 }
29 
31  // This must always be the first call.
32  ClearPlugins();
33 
34  // Explicitly cleared to facilitate testing of destruction order.
35  messenger_.reset();
36 }
37 
38 void PluginRegistrar::AddPlugin(std::unique_ptr<Plugin> plugin) {
39  plugins_.insert(std::move(plugin));
40 }
41 
43  plugins_.clear();
44 }
45 
46 // ===== PluginRegistrarManager =====
47 
48 // static
50  static PluginRegistrarManager* instance = new PluginRegistrarManager();
51  return instance;
52 }
53 
54 PluginRegistrarManager::PluginRegistrarManager() = default;
55 
56 // static
57 void PluginRegistrarManager::OnRegistrarDestroyed(
59  GetInstance()->registrars()->erase(registrar);
60 }
61 
62 } // namespace flutter
engine_method_result.h
plugin_registrar.h
FlutterDesktopPluginRegistrarGetMessenger
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows.cc:337
flutter::PluginRegistrar::ClearPlugins
void ClearPlugins()
Definition: plugin_registrar.cc:42
flutter::PluginRegistrar::texture_registrar
TextureRegistrar * texture_registrar()
Definition: plugin_registrar.h:47
FlutterDesktopRegistrarGetTextureRegistrar
FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar(FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows.cc:422
binary_messenger_impl.h
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::PluginRegistrar::AddPlugin
void AddPlugin(std::unique_ptr< Plugin > plugin)
Definition: plugin_registrar.cc:38
flutter::PluginRegistrar::PluginRegistrar
PluginRegistrar(FlutterDesktopPluginRegistrarRef core_registrar)
Definition: plugin_registrar.cc:19
method_channel.h
flutter::PluginRegistrar::~PluginRegistrar
virtual ~PluginRegistrar()
Definition: plugin_registrar.cc:30
flutter::PluginRegistrarManager
Definition: plugin_registrar.h:86
texture_registrar_impl.h
FlutterDesktopPluginRegistrar
Definition: window_state.h:23
flutter::PluginRegistrarManager::GetInstance
static PluginRegistrarManager * GetInstance()
Definition: plugin_registrar.cc:49