Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class PluginRegistrarManager {
auto insert_result =
registrars_.emplace(registrar_ref, std::make_unique<T>(registrar_ref));
auto& registrar_pair = *(insert_result.first);
FlutterDesktopRegistrarSetDestructionHandler(registrar_pair.first,
OnRegistrarDestroyed);
FlutterDesktopPluginRegistrarSetDestructionHandler(registrar_pair.first,
OnRegistrarDestroyed);
return static_cast<T*>(registrar_pair.second.get());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace flutter {

PluginRegistrar::PluginRegistrar(FlutterDesktopPluginRegistrarRef registrar)
: registrar_(registrar) {
auto core_messenger = FlutterDesktopRegistrarGetMessenger(registrar_);
auto core_messenger = FlutterDesktopPluginRegistrarGetMessenger(registrar_);
messenger_ = std::make_unique<BinaryMessengerImpl>(core_messenger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,24 @@ class TestApi : public testing::StubFlutterApi {
last_message_callback_set_ = callback;
}

void RegistrarSetDestructionHandler(
FlutterDesktopOnRegistrarDestroyed callback) override {
void PluginRegistrarSetDestructionHandler(
FlutterDesktopOnPluginRegistrarDestroyed callback) override {
last_destruction_callback_set_ = callback;
}

const uint8_t* last_data_sent() { return last_data_sent_; }
FlutterDesktopMessageCallback last_message_callback_set() {
return last_message_callback_set_;
}
FlutterDesktopOnRegistrarDestroyed last_destruction_callback_set() {
FlutterDesktopOnPluginRegistrarDestroyed last_destruction_callback_set() {
return last_destruction_callback_set_;
}

private:
const uint8_t* last_data_sent_ = nullptr;
FlutterDesktopMessageCallback last_message_callback_set_ = nullptr;
FlutterDesktopOnRegistrarDestroyed last_destruction_callback_set_ = nullptr;
FlutterDesktopOnPluginRegistrarDestroyed last_destruction_callback_set_ =
nullptr;
};

// A PluginRegistrar whose destruction can be watched for by tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ ScopedStubFlutterApi::~ScopedStubFlutterApi() {

// Forwarding dummy implementations of the C API.

FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger(
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar) {
// The stub ignores this, so just return an arbitrary non-zero value.
return reinterpret_cast<FlutterDesktopMessengerRef>(1);
}

void FlutterDesktopRegistrarSetDestructionHandler(
void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
if (s_stub_implementation) {
s_stub_implementation->RegistrarSetDestructionHandler(callback);
s_stub_implementation->PluginRegistrarSetDestructionHandler(callback);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class StubFlutterApi {

virtual ~StubFlutterApi() {}

// Called for FlutterDesktopRegistrarSetDestructionHandler.
virtual void RegistrarSetDestructionHandler(
FlutterDesktopOnRegistrarDestroyed callback) {}
// Called for FlutterDesktopPluginRegistrarSetDestructionHandler.
virtual void PluginRegistrarSetDestructionHandler(
FlutterDesktopOnPluginRegistrarDestroyed callback) {}

// Called for FlutterDesktopMessengerSend.
virtual bool MessengerSend(const char* channel,
Expand Down
9 changes: 5 additions & 4 deletions shell/platform/common/cpp/public/flutter_plugin_registrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ extern "C" {
typedef struct FlutterDesktopPluginRegistrar* FlutterDesktopPluginRegistrarRef;

// Function pointer type for registrar destruction callback.
typedef void (*FlutterDesktopOnRegistrarDestroyed)(
typedef void (*FlutterDesktopOnPluginRegistrarDestroyed)(
FlutterDesktopPluginRegistrarRef);

// Returns the engine messenger associated with this registrar.
FLUTTER_EXPORT FlutterDesktopMessengerRef
FlutterDesktopRegistrarGetMessenger(FlutterDesktopPluginRegistrarRef registrar);
FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar);

// Registers a callback to be called when the plugin registrar is destroyed.
FLUTTER_EXPORT void FlutterDesktopRegistrarSetDestructionHandler(
FLUTTER_EXPORT void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback);
FlutterDesktopOnPluginRegistrarDestroyed callback);

#if defined(__cplusplus)
} // extern "C"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PluginRegistrarGlfw : public PluginRegistrar {
explicit PluginRegistrarGlfw(FlutterDesktopPluginRegistrarRef core_registrar)
: PluginRegistrar(core_registrar) {
window_ = std::make_unique<FlutterWindow>(
FlutterDesktopRegistrarGetWindow(core_registrar));
FlutterDesktopPluginRegistrarGetWindow(core_registrar));
}

virtual ~PluginRegistrarGlfw() = default;
Expand All @@ -39,7 +39,8 @@ class PluginRegistrarGlfw : public PluginRegistrar {
// If set, then the parent window should disable input callbacks
// while waiting for the handler for messages on that channel to run.
void EnableInputBlockingForChannel(const std::string& channel) {
FlutterDesktopRegistrarEnableInputBlocking(registrar(), channel.c_str());
FlutterDesktopPluginRegistrarEnableInputBlocking(registrar(),
channel.c_str());
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ FlutterDesktopPluginRegistrarRef FlutterDesktopGetPluginRegistrar(
return reinterpret_cast<FlutterDesktopPluginRegistrarRef>(2);
}

void FlutterDesktopRegistrarEnableInputBlocking(
void FlutterDesktopPluginRegistrarEnableInputBlocking(
FlutterDesktopPluginRegistrarRef registrar,
const char* channel) {
if (s_stub_implementation) {
s_stub_implementation->RegistrarEnableInputBlocking(channel);
s_stub_implementation->PluginRegistrarEnableInputBlocking(channel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class StubFlutterGlfwApi {
// Called for FlutterDesktopShutDownEngine.
virtual bool ShutDownEngine() { return true; }

// Called for FlutterDesktopRegistrarEnableInputBlocking.
virtual void RegistrarEnableInputBlocking(const char* channel) {}
// Called for FlutterDesktopPluginRegistrarEnableInputBlocking.
virtual void PluginRegistrarEnableInputBlocking(const char* channel) {}
};

// A test helper that owns a stub implementation, making it the test stub for
Expand Down
12 changes: 6 additions & 6 deletions shell/platform/glfw/flutter_glfw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct FlutterDesktopPluginRegistrar {
FlutterDesktopEngineState* engine;

// Callback to be called on registrar destruction.
FlutterDesktopOnRegistrarDestroyed destruction_handler;
FlutterDesktopOnPluginRegistrarDestroyed destruction_handler;
};

// State associated with the messenger used to communicate with the engine.
Expand Down Expand Up @@ -963,24 +963,24 @@ bool FlutterDesktopShutDownEngine(FlutterDesktopEngineRef engine) {
return (result == kSuccess);
}

void FlutterDesktopRegistrarEnableInputBlocking(
void FlutterDesktopPluginRegistrarEnableInputBlocking(
FlutterDesktopPluginRegistrarRef registrar,
const char* channel) {
registrar->engine->message_dispatcher->EnableInputBlockingForChannel(channel);
}

FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger(
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar) {
return registrar->engine->messenger.get();
}

void FlutterDesktopRegistrarSetDestructionHandler(
void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
registrar->destruction_handler = callback;
}

FlutterDesktopWindowRef FlutterDesktopRegistrarGetWindow(
FlutterDesktopWindowRef FlutterDesktopPluginRegistrarGetWindow(
FlutterDesktopPluginRegistrarRef registrar) {
FlutterDesktopWindowControllerState* controller =
registrar->engine->window_controller;
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/glfw/public/flutter_glfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ FLUTTER_EXPORT bool FlutterDesktopShutDownEngine(
// Returns the window associated with this registrar's engine instance.
//
// This is a GLFW shell-specific extension to flutter_plugin_registrar.h
FLUTTER_EXPORT FlutterDesktopWindowRef
FlutterDesktopRegistrarGetWindow(FlutterDesktopPluginRegistrarRef registrar);
FLUTTER_EXPORT FlutterDesktopWindowRef FlutterDesktopPluginRegistrarGetWindow(
FlutterDesktopPluginRegistrarRef registrar);

// Enables input blocking on the given channel.
//
Expand All @@ -235,7 +235,7 @@ FlutterDesktopRegistrarGetWindow(FlutterDesktopPluginRegistrarRef registrar);
// default of disabled.
//
// This is a GLFW shell-specific extension to flutter_plugin_registrar.h
FLUTTER_EXPORT void FlutterDesktopRegistrarEnableInputBlocking(
FLUTTER_EXPORT void FlutterDesktopPluginRegistrarEnableInputBlocking(
FlutterDesktopPluginRegistrarRef registrar,
const char* channel);

Expand Down
6 changes: 3 additions & 3 deletions shell/platform/windows/flutter_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ void FlutterDesktopResyncOutputStreams() {

// Implementations of common/cpp/ API methods.

FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger(
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar) {
return registrar->engine->messenger();
}

void FlutterDesktopRegistrarSetDestructionHandler(
void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
registrar->engine->SetPluginRegistrarDestructionCallback(callback);
}

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/flutter_windows_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ FlutterDesktopPluginRegistrarRef FlutterWindowsEngine::GetRegistrar() {
}

void FlutterWindowsEngine::SetPluginRegistrarDestructionCallback(
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
plugin_registrar_destruction_callback_ = callback;
}

Expand Down
5 changes: 3 additions & 2 deletions shell/platform/windows/flutter_windows_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FlutterWindowsEngine {

// Sets |callback| to be called when the plugin registrar is destroyed.
void SetPluginRegistrarDestructionCallback(
FlutterDesktopOnRegistrarDestroyed callback);
FlutterDesktopOnPluginRegistrarDestroyed callback);

FLUTTER_API_SYMBOL(FlutterEngine) engine() { return engine_; }

Expand Down Expand Up @@ -115,7 +115,8 @@ class FlutterWindowsEngine {

// A callback to be called when the engine (and thus the plugin registrar)
// is being destroyed.
FlutterDesktopOnRegistrarDestroyed plugin_registrar_destruction_callback_;
FlutterDesktopOnPluginRegistrarDestroyed
plugin_registrar_destruction_callback_;

// The manager for WindowProc delegate registration and callbacks.
std::unique_ptr<Win32WindowProcDelegateManager> window_proc_delegate_manager_;
Expand Down