未验证 提交 709fc6e0 编写于 作者: S stuartmorgan 提交者: GitHub

Adds PluginRegistry to the C++ client wrapper API (#12287)

Makes the plugin registration structure consistent with macOS. This will
be used in generated plugin registrant files rather than a specific
implemenation class, so this helps unblock the creation of generated
registrants on Windows and Linux.
上级 d54ed1f1
...@@ -687,6 +687,7 @@ FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/include/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_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/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_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_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/include/flutter/standard_method_codec.h
FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/json_message_codec.cc FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/json_message_codec.cc
......
...@@ -17,6 +17,7 @@ core_cpp_client_wrapper_includes = ...@@ -17,6 +17,7 @@ core_cpp_client_wrapper_includes =
"include/flutter/method_codec.h", "include/flutter/method_codec.h",
"include/flutter/method_result.h", "include/flutter/method_result.h",
"include/flutter/plugin_registrar.h", "include/flutter/plugin_registrar.h",
"include/flutter/plugin_registry.h",
"include/flutter/standard_message_codec.h", "include/flutter/standard_message_codec.h",
"include/flutter/standard_method_codec.h", "include/flutter/standard_method_codec.h",
], ],
......
// 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 <string>
#include <flutter_plugin_registrar.h>
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_
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "flutter_window.h" #include "flutter_window.h"
#include "plugin_registrar.h" #include "plugin_registrar.h"
#include "plugin_registry.h"
namespace flutter { namespace flutter {
...@@ -40,14 +41,14 @@ struct WindowProperties { ...@@ -40,14 +41,14 @@ struct WindowProperties {
// requires control of the application's event loop, and is thus useful // requires control of the application's event loop, and is thus useful
// primarily for building a simple one-window shell hosting a Flutter // primarily for building a simple one-window shell hosting a Flutter
// application. The final implementation and API will be very different. // application. The final implementation and API will be very different.
class FlutterWindowController { class FlutterWindowController : public PluginRegistry {
public: public:
// There must be only one instance of this class in an application at any // 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, // given time, as Flutter does not support multiple engines in one process,
// or multiple views in one engine. // or multiple views in one engine.
explicit FlutterWindowController(const std::string& icu_data_path); explicit FlutterWindowController(const std::string& icu_data_path);
~FlutterWindowController(); virtual ~FlutterWindowController();
// Prevent copying. // Prevent copying.
FlutterWindowController(FlutterWindowController const&) = delete; FlutterWindowController(FlutterWindowController const&) = delete;
...@@ -68,13 +69,6 @@ class FlutterWindowController { ...@@ -68,13 +69,6 @@ class FlutterWindowController {
const std::string& assets_path, const std::string& assets_path,
const std::vector<std::string>& arguments); const std::vector<std::string>& 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 // The FlutterWindow managed by this controller, if any. Returns nullptr
// before CreateWindow is called, and after RunEventLoop returns; // before CreateWindow is called, and after RunEventLoop returns;
FlutterWindow* window() { return window_.get(); } FlutterWindow* window() { return window_.get(); }
...@@ -89,6 +83,10 @@ class FlutterWindowController { ...@@ -89,6 +83,10 @@ class FlutterWindowController {
// Deprecated. Use RunEventLoopWithTimeout. // Deprecated. Use RunEventLoopWithTimeout.
void RunEventLoop(); void RunEventLoop();
// flutter::PluginRegistry:
FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin(
const std::string& plugin_name) override;
private: private:
// The path to the ICU data file. Set at creation time since it is the same // The path to the ICU data file. Set at creation time since it is the same
// for any window created. // for any window created.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <vector> #include <vector>
#include "plugin_registrar.h" #include "plugin_registrar.h"
#include "plugin_registry.h"
namespace flutter { namespace flutter {
...@@ -19,7 +20,7 @@ namespace flutter { ...@@ -19,7 +20,7 @@ namespace flutter {
// This is the primary wrapper class for the desktop C API. // 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 // 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. // methods in the C API directly, as this class will do that internally.
class FlutterViewController { class FlutterViewController : public PluginRegistry {
public: public:
// There must be only one instance of this class in an application at any // 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, // given time, as Flutter does not support multiple engines in one process,
...@@ -41,19 +42,12 @@ class FlutterViewController { ...@@ -41,19 +42,12 @@ class FlutterViewController {
const std::string& assets_path, const std::string& assets_path,
const std::vector<std::string>& arguments); const std::vector<std::string>& arguments);
~FlutterViewController(); virtual ~FlutterViewController();
// Prevent copying. // Prevent copying.
FlutterViewController(FlutterViewController const&) = delete; FlutterViewController(FlutterViewController const&) = delete;
FlutterViewController& operator=(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. // Return backing HWND for manipulation in host application.
HWND GetNativeWindow(); HWND GetNativeWindow();
...@@ -61,6 +55,10 @@ class FlutterViewController { ...@@ -61,6 +55,10 @@ class FlutterViewController {
// loop. // loop.
void ProcessMessages(); void ProcessMessages();
// flutter::PluginRegistry:
FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin(
const std::string& plugin_name) override;
private: private:
// The path to the ICU data file. Set at creation time since it is the same // The path to the ICU data file. Set at creation time since it is the same
// for any view created. // for any view created.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册