diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 5d04beaa2c0fea7e07c8bc8589135dcb6021f521..1b5a87cb144ab78e15dd4a10ce8e8b4cabbdea43 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -687,6 +687,7 @@ FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/flutter/ FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_codec.h FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_result.h FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h +FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registry.h FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/json_message_codec.cc diff --git a/shell/platform/common/cpp/client_wrapper/core_wrapper_files.gni b/shell/platform/common/cpp/client_wrapper/core_wrapper_files.gni index 80750627b6b0195d0ea44e0d39eff011cb5156f3..ce91be78667170ae5e46ced010b1e1fa09e3b71f 100644 --- a/shell/platform/common/cpp/client_wrapper/core_wrapper_files.gni +++ b/shell/platform/common/cpp/client_wrapper/core_wrapper_files.gni @@ -17,6 +17,7 @@ core_cpp_client_wrapper_includes = "include/flutter/method_codec.h", "include/flutter/method_result.h", "include/flutter/plugin_registrar.h", + "include/flutter/plugin_registry.h", "include/flutter/standard_message_codec.h", "include/flutter/standard_method_codec.h", ], diff --git a/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registry.h b/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registry.h new file mode 100644 index 0000000000000000000000000000000000000000..823fe1ac17e4d1a973ba3e448a3f3a9dafe7249a --- /dev/null +++ b/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registry.h @@ -0,0 +1,37 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRY_H_ +#define FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRY_H_ + +#include + +#include + +namespace flutter { + +// Vends PluginRegistrars for named plugins. +// +// Plugins are identified by unique string keys, typically the name of the +// plugin's main class. +class PluginRegistry { + public: + PluginRegistry() = default; + virtual ~PluginRegistry() = default; + + // Prevent copying. + PluginRegistry(PluginRegistry const&) = delete; + PluginRegistry& operator=(PluginRegistry const&) = delete; + + // Returns the FlutterDesktopPluginRegistrarRef to register a plugin with the + // given name. + // + // The name must be unique across the application. + virtual FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( + const std::string& plugin_name) = 0; +}; + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRY_H_ diff --git a/shell/platform/glfw/client_wrapper/include/flutter/flutter_window_controller.h b/shell/platform/glfw/client_wrapper/include/flutter/flutter_window_controller.h index 95da9cb657fa21bd21227d990399d64ef83bd94e..cd4bd58ed0d94a1c91d6682a99555be1ab43de63 100644 --- a/shell/platform/glfw/client_wrapper/include/flutter/flutter_window_controller.h +++ b/shell/platform/glfw/client_wrapper/include/flutter/flutter_window_controller.h @@ -14,6 +14,7 @@ #include "flutter_window.h" #include "plugin_registrar.h" +#include "plugin_registry.h" namespace flutter { @@ -40,14 +41,14 @@ struct WindowProperties { // requires control of the application's event loop, and is thus useful // primarily for building a simple one-window shell hosting a Flutter // application. The final implementation and API will be very different. -class FlutterWindowController { +class FlutterWindowController : public PluginRegistry { public: // There must be only one instance of this class in an application at any // given time, as Flutter does not support multiple engines in one process, // or multiple views in one engine. explicit FlutterWindowController(const std::string& icu_data_path); - ~FlutterWindowController(); + virtual ~FlutterWindowController(); // Prevent copying. FlutterWindowController(FlutterWindowController const&) = delete; @@ -68,13 +69,6 @@ class FlutterWindowController { const std::string& assets_path, const std::vector& arguments); - // Returns the FlutterDesktopPluginRegistrarRef to register a plugin with the - // given name. - // - // The name must be unique across the application. - FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( - const std::string& plugin_name); - // The FlutterWindow managed by this controller, if any. Returns nullptr // before CreateWindow is called, and after RunEventLoop returns; FlutterWindow* window() { return window_.get(); } @@ -89,6 +83,10 @@ class FlutterWindowController { // Deprecated. Use RunEventLoopWithTimeout. void RunEventLoop(); + // flutter::PluginRegistry: + FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( + const std::string& plugin_name) override; + private: // The path to the ICU data file. Set at creation time since it is the same // for any window created. diff --git a/shell/platform/windows/client_wrapper/include/flutter/flutter_view_controller.h b/shell/platform/windows/client_wrapper/include/flutter/flutter_view_controller.h index cdf782271e36cd0d32bcf2e0f29c76a16245d2c1..69ce1bafdaf2b8579146deabc54486706c495a14 100644 --- a/shell/platform/windows/client_wrapper/include/flutter/flutter_view_controller.h +++ b/shell/platform/windows/client_wrapper/include/flutter/flutter_view_controller.h @@ -11,6 +11,7 @@ #include #include "plugin_registrar.h" +#include "plugin_registry.h" namespace flutter { @@ -19,7 +20,7 @@ namespace flutter { // This is the primary wrapper class for the desktop C API. // If you use this class, you should not call any of the setup or teardown // methods in the C API directly, as this class will do that internally. -class FlutterViewController { +class FlutterViewController : public PluginRegistry { public: // There must be only one instance of this class in an application at any // given time, as Flutter does not support multiple engines in one process, @@ -41,19 +42,12 @@ class FlutterViewController { const std::string& assets_path, const std::vector& arguments); - ~FlutterViewController(); + virtual ~FlutterViewController(); // Prevent copying. FlutterViewController(FlutterViewController const&) = delete; FlutterViewController& operator=(FlutterViewController const&) = delete; - // Returns the FlutterDesktopPluginRegistrarRef to register a plugin with the - // given name. - // - // The name must be unique across the application. - FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( - const std::string& plugin_name); - // Return backing HWND for manipulation in host application. HWND GetNativeWindow(); @@ -61,6 +55,10 @@ class FlutterViewController { // loop. void ProcessMessages(); + // flutter::PluginRegistry: + FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( + const std::string& plugin_name) override; + private: // The path to the ICU data file. Set at creation time since it is the same // for any view created.