Skip to content

Commit 2404cdc

Browse files
Rename macOS FLEPlugin* to FlutterPlugin* (flutter#9074)
As another step toward aligning the macOS plugin API with the iOS plugin API, and with its final form, rename the plugin-related classes from FLEPlugin* to FlutterPlugin*. This makes the names of the clasess the same between iOS and macOS. Eventually they should actually merge, with annotations/ifdefs for platform differences, but for now since the macOS version uses the same method names and is simply a subset of the iOS APIs (with one to-be-stabilized method that is macOS-specific) doing the merge later won't be a breaking change. Doing this now allows for building out plugin tooling and plugin implementations on macOS without creating a growing body of code that will experience a breaking change later. See: flutter#31735 flutter#32718
1 parent 509a43f commit 2404cdc

File tree

8 files changed

+36
-32
lines changed

8 files changed

+36
-32
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,12 @@ FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.h
714714
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.mm
715715
FILE: ../../../flutter/shell/platform/darwin/macos/framework/FlutterMacOS.podspec
716716
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEOpenGLContextHandling.h
717-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEPlugin.h
718-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEPluginRegistrar.h
719717
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEReshapeListener.h
720718
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEView.h
721719
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEViewController.h
722720
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterMacOS.h
721+
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginMacOS.h
722+
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h
723723
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Info.plist
724724
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.h
725725
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.mm

shell/platform/darwin/macos/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ _flutter_framework_dir = "$root_out_dir/$_flutter_framework_filename"
3131
# the Flutter engine source root.
3232
_flutter_framework_headers = [
3333
"framework/Headers/FlutterMacOS.h",
34+
"framework/Headers/FlutterPluginMacOS.h",
35+
"framework/Headers/FlutterPluginRegistrarMacOS.h",
3436
"framework/Headers/FLEOpenGLContextHandling.h",
35-
"framework/Headers/FLEPlugin.h",
36-
"framework/Headers/FLEPluginRegistrar.h",
3737
"framework/Headers/FLEReshapeListener.h",
3838
"framework/Headers/FLEView.h",
3939
"framework/Headers/FLEViewController.h",

shell/platform/darwin/macos/framework/Headers/FLEViewController.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#import <Cocoa/Cocoa.h>
66

77
#import "FLEOpenGLContextHandling.h"
8-
#import "FLEPluginRegistrar.h"
98
#import "FLEReshapeListener.h"
9+
#import "FlutterPluginRegistrarMacOS.h"
1010

1111
#if defined(FLUTTER_FRAMEWORK)
1212
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterBinaryMessenger.h"
@@ -36,8 +36,8 @@ typedef NS_ENUM(NSInteger, FlutterMouseTrackingMode) {
3636
*/
3737
FLUTTER_EXPORT
3838
@interface FLEViewController : NSViewController <FlutterBinaryMessenger,
39-
FLEPluginRegistrar,
40-
FLEPluginRegistry,
39+
FlutterPluginRegistrar,
40+
FlutterPluginRegistry,
4141
FLEReshapeListener>
4242

4343
/**

shell/platform/darwin/macos/framework/Headers/FlutterMacOS.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// found in the LICENSE file.
44

55
#import "FLEOpenGLContextHandling.h"
6-
#import "FLEPlugin.h"
7-
#import "FLEPluginRegistrar.h"
86
#import "FLEReshapeListener.h"
97
#import "FLEView.h"
108
#import "FLEViewController.h"
119
#import "FlutterBinaryMessenger.h"
1210
#import "FlutterChannels.h"
1311
#import "FlutterCodecs.h"
1412
#import "FlutterMacros.h"
13+
#import "FlutterPluginMacOS.h"
14+
#import "FlutterPluginRegistrarMacOS.h"

shell/platform/darwin/macos/framework/Headers/FLEPlugin.h renamed to shell/platform/darwin/macos/framework/Headers/FlutterPluginMacOS.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,34 @@
1414
#import "FlutterMacros.h"
1515
#endif
1616

17-
@protocol FLEPluginRegistrar;
17+
// TODO: Merge this file and FlutterPluginRegistrarMacOS.h with the iOS FlutterPlugin.h, sharing
18+
// all but the platform-specific methods.
19+
20+
@protocol FlutterPluginRegistrar;
1821

1922
/**
2023
* Implemented by the platform side of a Flutter plugin.
2124
*
2225
* Defines a set of optional callback methods and a method to set up the plugin
2326
* and register it to be called by other application components.
2427
*
25-
* Currently FLEPlugin has very limited functionality, but is expected to expand over time to
26-
* more closely match the functionality of FlutterPlugin.
28+
* Currently the macOS version of FlutterPlugin has very limited functionality, but is expected to
29+
* expand over time to more closely match the functionality of the iOS FlutterPlugin.
2730
*/
2831
FLUTTER_EXPORT
29-
@protocol FLEPlugin <NSObject>
32+
@protocol FlutterPlugin <NSObject>
3033

3134
/**
3235
* Creates an instance of the plugin to register with |registrar| using the desired
33-
* FLEPluginRegistrar methods.
36+
* FlutterPluginRegistrar methods.
3437
*/
35-
+ (void)registerWithRegistrar:(nonnull id<FLEPluginRegistrar>)registrar;
38+
+ (void)registerWithRegistrar:(nonnull id<FlutterPluginRegistrar>)registrar;
3639

3740
@optional
3841

3942
/**
4043
* Called when a message is sent from Flutter on a channel that a plugin instance has subscribed
41-
* to via -[FLEPluginRegistrar addMethodCallDelegate:channel:].
44+
* to via -[FlutterPluginRegistrar addMethodCallDelegate:channel:].
4245
*
4346
* The |result| callback must be called exactly once, with one of:
4447
* - FlutterMethodNotImplemented, if the method call is unknown.

shell/platform/darwin/macos/framework/Headers/FLEPluginRegistrar.h renamed to shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#import <Cocoa/Cocoa.h>
66

7-
#import "FLEPlugin.h"
7+
#import "FlutterPluginMacOS.h"
88

99
#if defined(FLUTTER_FRAMEWORK)
1010
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterBinaryMessenger.h"
@@ -16,36 +16,36 @@
1616
#import "FlutterMacros.h"
1717
#endif
1818

19-
// TODO: Merge this file and FLEPlugin.h with FlutterPlugin.h, sharing all but
19+
// TODO: Merge this file and FlutterPluginMacOS.h with the iOS FlutterPlugin.h, sharing all but
2020
// the platform-specific methods.
2121

2222
/**
2323
* The protocol for an object managing registration for a plugin. It provides access to application
2424
* context, as as allowing registering for callbacks for handling various conditions.
2525
*
26-
* Currently FLEPluginRegistrar has very limited functionality, but is expected to expand over time
27-
* to more closely match the functionality of FlutterPluginRegistrar.
26+
* Currently the macOS PluginRegistrar has very limited functionality, but is expected to expand
27+
* over time to more closely match the functionality of FlutterPluginRegistrar.
2828
*/
2929
FLUTTER_EXPORT
30-
@protocol FLEPluginRegistrar <NSObject>
30+
@protocol FlutterPluginRegistrar <NSObject>
3131

3232
/**
3333
* The binary messenger used for creating channels to communicate with the Flutter engine.
3434
*/
3535
@property(nonnull, readonly) id<FlutterBinaryMessenger> messenger;
3636

3737
/**
38-
* The view displaying Flutter content.
38+
* The view displaying Flutter content. May return |nil|, for instance in a headless environment.
3939
*
40-
* WARNING: If/when multiple Flutter views within the same application are supported (#98), this
40+
* WARNING: If/when multiple Flutter views within the same application are supported (#30701), this
4141
* API will change.
4242
*/
4343
@property(nullable, readonly) NSView* view;
4444

4545
/**
4646
* Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|.
4747
*/
48-
- (void)addMethodCallDelegate:(nonnull id<FLEPlugin>)delegate
48+
- (void)addMethodCallDelegate:(nonnull id<FlutterPlugin>)delegate
4949
channel:(nonnull FlutterMethodChannel*)channel;
5050

5151
@end
@@ -66,13 +66,13 @@ FLUTTER_EXPORT
6666
* Specifically, callbacks registered by the plugin via the registrar may be
6767
* relayed directly to the underlying iOS application objects.
6868
*/
69-
@protocol FLEPluginRegistry <NSObject>
69+
@protocol FlutterPluginRegistry <NSObject>
7070

7171
/**
7272
* Returns a registrar for registering a plugin.
7373
*
7474
* @param pluginKey The unique key identifying the plugin.
7575
*/
76-
- (nonnull id<FLEPluginRegistrar>)registrarForPlugin:(nonnull NSString*)pluginKey;
76+
- (nonnull id<FlutterPluginRegistrar>)registrarForPlugin:(nonnull NSString*)pluginKey;
7777

7878
@end

shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Responsible for bridging the native macOS text input system with the Flutter framework text
1414
* editing classes, via system channels.
1515
*
16-
* This is not an FLEPlugin since it needs access to FLEViewController internals, so needs to be
16+
* This is not an FlutterPlugin since it needs access to FLEViewController internals, so needs to be
1717
* managed differently.
1818
*/
1919
@interface FLETextInputPlugin : NSResponder

shell/platform/darwin/macos/framework/Source/FLEViewController.mm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ @implementation FLEViewController {
240240
// A mapping of channel names to the registered handlers for those channels.
241241
NSMutableDictionary<NSString*, FlutterBinaryMessageHandler>* _messageHandlers;
242242

243-
// The plugin used to handle text input. This is not an FLEPlugin, so must be owned separately.
243+
// The plugin used to handle text input. This is not an FlutterPlugin, so must be owned
244+
// separately.
244245
FLETextInputPlugin* _textInputPlugin;
245246

246247
// A message channel for passing key events to the Flutter engine. This should be replaced with
@@ -653,22 +654,22 @@ - (void)setMessageHandlerOnChannel:(nonnull NSString*)channel
653654
_messageHandlers[channel] = [handler copy];
654655
}
655656

656-
#pragma mark - FLEPluginRegistrar
657+
#pragma mark - FlutterPluginRegistrar
657658

658659
- (id<FlutterBinaryMessenger>)messenger {
659660
return self;
660661
}
661662

662-
- (void)addMethodCallDelegate:(nonnull id<FLEPlugin>)delegate
663+
- (void)addMethodCallDelegate:(nonnull id<FlutterPlugin>)delegate
663664
channel:(nonnull FlutterMethodChannel*)channel {
664665
[channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
665666
[delegate handleMethodCall:call result:result];
666667
}];
667668
}
668669

669-
#pragma mark - FLEPluginRegistry
670+
#pragma mark - FlutterPluginRegistry
670671

671-
- (id<FLEPluginRegistrar>)registrarForPlugin:(NSString*)pluginName {
672+
- (id<FlutterPluginRegistrar>)registrarForPlugin:(NSString*)pluginName {
672673
// Currently, the view controller acts as the registrar for all plugins, so the
673674
// name is ignored.
674675
return self;

0 commit comments

Comments
 (0)