Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4903531
Add macOS support to example app
stuartmorgan-g Apr 11, 2023
2d412c0
darwinify
stuartmorgan-g Apr 11, 2023
2f64c9d
Manually change includes; needs Pigeon fix
stuartmorgan-g Apr 11, 2023
f96790c
Add missing entitlements
stuartmorgan-g Apr 12, 2023
ce8c088
Automatic changes from running
stuartmorgan-g Apr 12, 2023
e3e5949
Get minimal PoC running
stuartmorgan-g Apr 13, 2023
c5cd904
Add another TODO with issue reference
stuartmorgan-g Apr 13, 2023
363a6d5
Merge branch 'main' into webview-macos
stuartmorgan-g Jun 13, 2023
ee1f657
Remove the args hack
stuartmorgan-g Jun 13, 2023
18985c5
Update minimum version
stuartmorgan-g Jun 13, 2023
1912347
Update availability annotations
stuartmorgan-g Jun 13, 2023
c70fb10
Merge branch 'main' into webview-macos
stuartmorgan-g Sep 6, 2023
e99093d
Remove the publish workaround
stuartmorgan-g Sep 6, 2023
3969dcc
Remove obsolete stub
stuartmorgan-g Sep 6, 2023
6f703af
Enable valuePublishedByPlugin codepath
stuartmorgan-g Sep 6, 2023
10df466
Comment some ifdefs
stuartmorgan-g Sep 7, 2023
29c5a6e
Change the way UIView removal works
stuartmorgan-g Sep 7, 2023
4c1ff63
Use AppKitView
stuartmorgan-g Sep 11, 2023
56a8e5d
Merge branch 'main' into webview-macos
stuartmorgan-g Dec 1, 2023
6f41e08
Merge branch 'main' into webview-macos
stuartmorgan-g Feb 26, 2024
3c98078
Resolve UIView issue
stuartmorgan-g Feb 26, 2024
aa15792
Add back background color on iOS
stuartmorgan-g Feb 26, 2024
b530bf9
Merge branch 'main' into webview-macos
stuartmorgan-g Feb 28, 2024
ab3169f
Unit test WIP
stuartmorgan-g Feb 29, 2024
aa3987e
Merge branch 'main' into webview-macos
stuartmorgan-g Apr 29, 2024
35769a4
Update Pigeon for enum fix
stuartmorgan-g Apr 29, 2024
6f36af7
Reconstify
stuartmorgan-g Apr 29, 2024
81107c0
Update Dart tests
stuartmorgan-g Apr 29, 2024
f89b1ad
Move privacy manifest
stuartmorgan-g Apr 29, 2024
38eb5ed
Fix analysis warnings
stuartmorgan-g Apr 29, 2024
88415cc
Merge branch 'main' into webview-macos
stuartmorgan-g May 30, 2024
c5bca19
Skip unsupported integration tests
stuartmorgan-g May 30, 2024
8b75132
Missing licenses
stuartmorgan-g May 30, 2024
5b7bc0f
Move and add native unit tests
stuartmorgan-g May 30, 2024
3aaac0c
Version bump
stuartmorgan-g May 30, 2024
3b27394
Fix unused function error
stuartmorgan-g May 30, 2024
c14d5db
Disable unit test parallelization
stuartmorgan-g Jun 3, 2024
ec9a0ea
Skip ogg tests
stuartmorgan-g Jun 3, 2024
128a326
Skip legacy version of ogg tests as well
stuartmorgan-g Jun 4, 2024
8317f1b
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 6, 2024
bfb5fdd
Switch OCMock dependency to SPM
stuartmorgan-g Aug 6, 2024
1007b4c
Fix doc comment
stuartmorgan-g Aug 6, 2024
2b2e697
Re-bump version for merge
stuartmorgan-g Aug 6, 2024
c59ee3d
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 7, 2024
ad794b4
Require 3.24
stuartmorgan-g Aug 7, 2024
df24e12
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 19, 2024
68d4f1d
Merge branch 'main' into webview-macos
stuartmorgan-g Aug 20, 2024
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 @@ -2,9 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <WebKit/WebKit.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

NS_ASSUME_NONNULL_BEGIN

@interface FLTWebViewFlutterPlugin : NSObject <FlutterPlugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ - (instancetype)initWithManager:(FWFInstanceManager *)manager {
return self;
}

#pragma mark FlutterPlatformViewFactory

- (NSObject<FlutterMessageCodec> *)createArgsCodec {
return [FlutterStandardMessageCodec sharedInstance];
}

// The FlutterPlatformViewFactory protocol is slightly different on iOS and
// macOS.
#if TARGET_OS_IOS

- (NSObject<FlutterPlatformView> *)createWithFrame:(CGRect)frame
viewIdentifier:(int64_t)viewId
arguments:(id _Nullable)args {
Expand All @@ -50,6 +56,17 @@ - (instancetype)initWithManager:(FWFInstanceManager *)manager {
return webView;
}

#else

- (nonnull NSView *)createWithViewIdentifier:(int64_t)viewId arguments:(nullable id)args {
NSNumber *identifier = (NSNumber *)args;
FWFWebView *webView =
(FWFWebView *)[self.instanceManager instanceForIdentifier:identifier.longValue];
return webView;
}

#endif

@end

@implementation FLTWebViewFlutterPlugin
Expand Down Expand Up @@ -88,8 +105,10 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
SetUpFWFWKUIDelegateHostApi(registrar.messenger, [[FWFUIDelegateHostApiImpl alloc]
initWithBinaryMessenger:registrar.messenger
instanceManager:instanceManager]);
#if TARGET_OS_IOS
SetUpFWFUIViewHostApi(registrar.messenger,
[[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]);
#endif
SetUpFWFWKUserContentControllerHostApi(
registrar.messenger,
[[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]);
Expand All @@ -106,10 +125,12 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
SetUpFWFNSUrlHostApi(registrar.messenger,
[[FWFURLHostApiImpl alloc] initWithBinaryMessenger:registrar.messenger
instanceManager:instanceManager]);
#if TARGET_OS_IOS
SetUpFWFUIScrollViewDelegateHostApi(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a macos version of scroll view delegate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT the only way to implement scroll functionality on the macOS version of WKWebView without mucking around with internal view details is JS.

registrar.messenger,
[[FWFScrollViewDelegateHostApiImpl alloc] initWithBinaryMessenger:registrar.messenger
instanceManager:instanceManager]);
#endif
SetUpFWFNSUrlCredentialHostApi(
registrar.messenger,
[[FWFURLCredentialHostApiImpl alloc] initWithBinaryMessenger:registrar.messenger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ extern FWFWKSecurityOriginData *FWFWKSecurityOriginDataFromNativeWKSecurityOrigi
*
* @return A WKPermissionDecision or -1 if data could not be converted.
*/
API_AVAILABLE(ios(15.0))
API_AVAILABLE(ios(15.0), macos(12))
extern WKPermissionDecision FWFNativeWKPermissionDecisionFromData(
FWFWKPermissionDecisionData *data);

Expand All @@ -189,7 +189,7 @@ extern WKPermissionDecision FWFNativeWKPermissionDecisionFromData(
*
* @return A FWFWKMediaCaptureTypeData or nil if data could not be converted.
*/
API_AVAILABLE(ios(15.0))
API_AVAILABLE(ios(15.0), macos(12))
extern FWFWKMediaCaptureTypeData *FWFWKMediaCaptureTypeDataFromNativeWKMediaCaptureType(
WKMediaCaptureType type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

#import "FWFDataConverters.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

NSURLRequest *_Nullable FWFNativeNSURLRequestFromRequestData(FWFNSUrlRequestData *data) {
NSURL *url = [NSURL URLWithString:data.url];
Expand Down Expand Up @@ -83,7 +87,7 @@ NSHTTPCookiePropertyKey _Nullable FWFNativeNSHTTPCookiePropertyKeyFromEnumData(
case FWFNSHttpCookiePropertyKeyEnumPort:
return NSHTTPCookiePort;
case FWFNSHttpCookiePropertyKeyEnumSameSitePolicy:
if (@available(iOS 13.0, *)) {
if (@available(iOS 13.0, macOS 10.15, *)) {
return NSHTTPCookieSameSitePolicy;
} else {
return nil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <WebKit/WebKit.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

#import "FWFGeneratedWebKitApis.h"
#import "FWFInstanceManager.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

#import "FWFGeneratedWebKitApis.h"
#import "FWFInstanceManager.h"
#import "FWFObjectHostApi.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

#import "FWFGeneratedWebKitApis.h"
#import "FWFInstanceManager.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif
#import <WebKit/WebKit.h>

#import "FWFGeneratedWebKitApis.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <WebKit/WebKit.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

#import "FWFGeneratedWebKitApis.h"
#import "FWFInstanceManager.h"
#import "FWFObjectHostApi.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Using directory structure to remove platform-specific files doesn't work
// well with umbrella headers and module maps, so just no-op the file for
// other platforms instead.
#if TARGET_OS_IOS

#import <Flutter/Flutter.h>
#import <WebKit/WebKit.h>
#import "FWFObjectHostApi.h"
Expand Down Expand Up @@ -44,3 +49,5 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Using directory structure to remove platform-specific files doesn't work
// well with umbrella headers and module maps, so just no-op the file for
// other platforms instead.
#if TARGET_OS_IOS

#import "FWFScrollViewDelegateHostApi.h"
#import "FWFWebViewHostApi.h"

Expand Down Expand Up @@ -88,3 +93,5 @@ - (void)createWithIdentifier:(NSInteger)identifier error:(FlutterError *_Nullabl
[self.instanceManager addDartCreatedInstance:uiScrollViewDelegate withIdentifier:identifier];
}
@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <WebKit/WebKit.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

#import "FWFGeneratedWebKitApis.h"
#import "FWFInstanceManager.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,65 @@ - (instancetype)initWithInstanceManager:(FWFInstanceManager *)instanceManager {
return self;
}

#if TARGET_OS_IOS
- (UIScrollView *)scrollViewForIdentifier:(NSInteger)identifier {
return (UIScrollView *)[self.instanceManager instanceForIdentifier:identifier];
}
#endif

- (void)createFromWebViewWithIdentifier:(NSInteger)identifier
webViewIdentifier:(NSInteger)webViewIdentifier
error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
#if TARGET_OS_IOS
WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewIdentifier];
[self.instanceManager addDartCreatedInstance:webView.scrollView withIdentifier:identifier];
#else
*error = [FlutterError errorWithCode:@"UnavailableApi"
message:@"scrollView is unavailable on macOS"
details:nil];
#endif
}

- (NSArray<NSNumber *> *)
contentOffsetForScrollViewWithIdentifier:(NSInteger)identifier
error:(FlutterError *_Nullable *_Nonnull)error {
#if TARGET_OS_IOS
CGPoint point = [[self scrollViewForIdentifier:identifier] contentOffset];
return @[ @(point.x), @(point.y) ];
#else
return @[ @(0), @(0) ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this function be called by macOS? if not, maybe use API_AVAILABLE annotation? same below

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we'd need a way to do Pigeon annotations that would generated those annotations in the generated code, since otherwise the generated code would appear to always call it.

#endif
}

- (void)scrollByForScrollViewWithIdentifier:(NSInteger)identifier
x:(double)x
y:(double)y
error:(FlutterError *_Nullable *_Nonnull)error {
#if TARGET_OS_IOS
UIScrollView *scrollView = [self scrollViewForIdentifier:identifier];
CGPoint contentOffset = scrollView.contentOffset;
[scrollView setContentOffset:CGPointMake(contentOffset.x + x, contentOffset.y + y)];
#endif
}

- (void)setContentOffsetForScrollViewWithIdentifier:(NSInteger)identifier
toX:(double)x
y:(double)y
error:(FlutterError *_Nullable *_Nonnull)error {
#if TARGET_OS_IOS
[[self scrollViewForIdentifier:identifier] setContentOffset:CGPointMake(x, y)];
#endif
}

- (void)setDelegateForScrollViewWithIdentifier:(NSInteger)identifier
uiScrollViewDelegateIdentifier:(nullable NSNumber *)uiScrollViewDelegateIdentifier
error:(FlutterError *_Nullable *_Nonnull)error {
#if TARGET_OS_IOS
[[self scrollViewForIdentifier:identifier]
setDelegate:uiScrollViewDelegateIdentifier
? (FWFScrollViewDelegate *)[self.instanceManager
instanceForIdentifier:uiScrollViewDelegateIdentifier.longValue]
: nil];
#endif
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <WebKit/WebKit.h>

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

#import "FWFGeneratedWebKitApis.h"
#import "FWFInstanceManager.h"
#import "FWFObjectHostApi.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (void)requestMediaCapturePermissionForDelegateWithIdentifier:(FWFUIDelegate *)
type:(WKMediaCaptureType)type
completion:
(void (^)(WKPermissionDecision))completion
API_AVAILABLE(ios(15.0)) {
API_AVAILABLE(ios(15.0), macos(12)) {
[self
requestMediaCapturePermissionForDelegateWithIdentifier:[self identifierForDelegate:instance]
webViewIdentifier:
Expand Down Expand Up @@ -177,7 +177,7 @@ - (void)webView:(WKWebView *)webView
initiatedByFrame:(WKFrameInfo *)frame
type:(WKMediaCaptureType)type
decisionHandler:(void (^)(WKPermissionDecision))decisionHandler
API_AVAILABLE(ios(15.0)) {
API_AVAILABLE(ios(15.0), macos(12)) {
[self.UIDelegateAPI
requestMediaCapturePermissionForDelegateWithIdentifier:self
webView:webView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Using directory structure to remove platform-specific files doesn't work
// well with umbrella headers and module maps, so just no-op the file for
// other platforms instead.
#if TARGET_OS_IOS

#import <Flutter/Flutter.h>

#import "FWFGeneratedWebKitApis.h"
Expand All @@ -19,3 +24,5 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Using directory structure to remove platform-specific files doesn't work
// well with umbrella headers and module maps, so just no-op the file for
// other platforms instead.
#if TARGET_OS_IOS

#import "FWFUIViewHostApi.h"

@interface FWFUIViewHostApiImpl ()
Expand Down Expand Up @@ -42,3 +47,5 @@ - (void)setOpaqueForViewWithIdentifier:(NSInteger)identifier
[[self viewForIdentifier:identifier] setOpaque:opaque];
}
@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Flutter/Flutter.h>
#import <Foundation/Foundation.h>
#import "FWFGeneratedWebKitApis.h"
#import "FWFInstanceManager.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

NS_ASSUME_NONNULL_BEGIN

/**
Expand Down
Loading