- Revision
- 293995
- Author
- alanc...@apple.com
- Date
- 2022-05-09 17:16:39 -0700 (Mon, 09 May 2022)
Log Message
Cherry-pick r292888. rdar://problem/80059355
[iOS] [WK2] Managed pasteboard should function for all managed domains
https://bugs.webkit.org/show_bug.cgi?id=239319
rdar://80059355
Reviewed by Kate Cheney.
Source/WebCore/PAL:
Add an SPI method on `MCProfileConnection`.
* pal/spi/ios/ManagedConfigurationSPI.h:
Source/WebKit:
Unless a WebKit client has specified a data owner for the web view that is not _UIDataOwnerUndefined, fall back
to _UIDataOwnerEnterprise when the current domain of the WKWebView is managed (that is, `-[MCProfileConnection
isURLManaged:]` returns YES for the web view's current URL). This allows managed pasteboard to work for all
WebKit clients, if the current URL is managed.
Test: UIPasteboardTests.PerformAsDataOwnerWithManagedURL
* Platform/spi/ios/UIKitSPI.h:
Drive-by fix: move the staged declarations of `-_dataOwnerForCopy` and `-_dataOwnerForPaste` out of the IPI
section, and into the non-internal SDK section.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _dataOwnerForPasteboard:]):
Tools:
Add a new API test to verify that we fall back to consulting `-[MCProfileConnection isURLManaged:]` when
determining the data owner for copy and paste, unless a data owner is already explicitly set on a view in the
responder chain (specifically, the WKWebView).
* TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
(+[TestUIPasteboard _performAsDataOwner:block:]):
(-[TestMCProfileConnection isURLManaged:]):
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/249658@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-613-branch/Source/WebCore/PAL/ChangeLog (293994 => 293995)
--- branches/safari-613-branch/Source/WebCore/PAL/ChangeLog 2022-05-10 00:06:59 UTC (rev 293994)
+++ branches/safari-613-branch/Source/WebCore/PAL/ChangeLog 2022-05-10 00:16:39 UTC (rev 293995)
@@ -1,3 +1,62 @@
+2022-05-06 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r292888. rdar://problem/80059355
+
+ [iOS] [WK2] Managed pasteboard should function for all managed domains
+ https://bugs.webkit.org/show_bug.cgi?id=239319
+ rdar://80059355
+
+ Reviewed by Kate Cheney.
+
+ Source/WebCore/PAL:
+
+ Add an SPI method on `MCProfileConnection`.
+
+ * pal/spi/ios/ManagedConfigurationSPI.h:
+
+ Source/WebKit:
+
+ Unless a WebKit client has specified a data owner for the web view that is not _UIDataOwnerUndefined, fall back
+ to _UIDataOwnerEnterprise when the current domain of the WKWebView is managed (that is, `-[MCProfileConnection
+ isURLManaged:]` returns YES for the web view's current URL). This allows managed pasteboard to work for all
+ WebKit clients, if the current URL is managed.
+
+ Test: UIPasteboardTests.PerformAsDataOwnerWithManagedURL
+
+ * Platform/spi/ios/UIKitSPI.h:
+
+ Drive-by fix: move the staged declarations of `-_dataOwnerForCopy` and `-_dataOwnerForPaste` out of the IPI
+ section, and into the non-internal SDK section.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _dataOwnerForPasteboard:]):
+
+ Tools:
+
+ Add a new API test to verify that we fall back to consulting `-[MCProfileConnection isURLManaged:]` when
+ determining the data owner for copy and paste, unless a data owner is already explicitly set on a view in the
+ responder chain (specifically, the WKWebView).
+
+ * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+ (+[TestUIPasteboard _performAsDataOwner:block:]):
+ (-[TestMCProfileConnection isURLManaged:]):
+ (TestWebKitAPI::TEST):
+
+ Canonical link: https://commits.webkit.org/249658@main
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-04-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] [WK2] Managed pasteboard should function for all managed domains
+ https://bugs.webkit.org/show_bug.cgi?id=239319
+ rdar://80059355
+
+ Reviewed by Kate Cheney.
+
+ Add an SPI method on `MCProfileConnection`.
+
+ * pal/spi/ios/ManagedConfigurationSPI.h:
+
2022-04-19 Alan Coon <alanc...@apple.com>
Cherry-pick r290997. rdar://problem/79950080
Modified: branches/safari-613-branch/Source/WebCore/PAL/pal/spi/ios/ManagedConfigurationSPI.h (293994 => 293995)
--- branches/safari-613-branch/Source/WebCore/PAL/pal/spi/ios/ManagedConfigurationSPI.h 2022-05-10 00:06:59 UTC (rev 293994)
+++ branches/safari-613-branch/Source/WebCore/PAL/pal/spi/ios/ManagedConfigurationSPI.h 2022-05-10 00:16:39 UTC (rev 293995)
@@ -56,9 +56,12 @@
@interface MCProfileConnection : NSObject
@end
+@class NSURL;
+
@interface MCProfileConnection ()
+ (MCProfileConnection *)sharedConnection;
- (MCRestrictedBoolType)effectiveBoolValueForSetting:(NSString *)feature;
+- (BOOL)isURLManaged:(NSURL *)url;
@end
#endif
Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (293994 => 293995)
--- branches/safari-613-branch/Source/WebKit/ChangeLog 2022-05-10 00:06:59 UTC (rev 293994)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog 2022-05-10 00:16:39 UTC (rev 293995)
@@ -1,3 +1,73 @@
+2022-05-06 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r292888. rdar://problem/80059355
+
+ [iOS] [WK2] Managed pasteboard should function for all managed domains
+ https://bugs.webkit.org/show_bug.cgi?id=239319
+ rdar://80059355
+
+ Reviewed by Kate Cheney.
+
+ Source/WebCore/PAL:
+
+ Add an SPI method on `MCProfileConnection`.
+
+ * pal/spi/ios/ManagedConfigurationSPI.h:
+
+ Source/WebKit:
+
+ Unless a WebKit client has specified a data owner for the web view that is not _UIDataOwnerUndefined, fall back
+ to _UIDataOwnerEnterprise when the current domain of the WKWebView is managed (that is, `-[MCProfileConnection
+ isURLManaged:]` returns YES for the web view's current URL). This allows managed pasteboard to work for all
+ WebKit clients, if the current URL is managed.
+
+ Test: UIPasteboardTests.PerformAsDataOwnerWithManagedURL
+
+ * Platform/spi/ios/UIKitSPI.h:
+
+ Drive-by fix: move the staged declarations of `-_dataOwnerForCopy` and `-_dataOwnerForPaste` out of the IPI
+ section, and into the non-internal SDK section.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _dataOwnerForPasteboard:]):
+
+ Tools:
+
+ Add a new API test to verify that we fall back to consulting `-[MCProfileConnection isURLManaged:]` when
+ determining the data owner for copy and paste, unless a data owner is already explicitly set on a view in the
+ responder chain (specifically, the WKWebView).
+
+ * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+ (+[TestUIPasteboard _performAsDataOwner:block:]):
+ (-[TestMCProfileConnection isURLManaged:]):
+ (TestWebKitAPI::TEST):
+
+ Canonical link: https://commits.webkit.org/249658@main
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-04-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] [WK2] Managed pasteboard should function for all managed domains
+ https://bugs.webkit.org/show_bug.cgi?id=239319
+ rdar://80059355
+
+ Reviewed by Kate Cheney.
+
+ Unless a WebKit client has specified a data owner for the web view that is not _UIDataOwnerUndefined, fall back
+ to _UIDataOwnerEnterprise when the current domain of the WKWebView is managed (that is, `-[MCProfileConnection
+ isURLManaged:]` returns YES for the web view's current URL). This allows managed pasteboard to work for all
+ WebKit clients, if the current URL is managed.
+
+ Test: UIPasteboardTests.PerformAsDataOwnerWithManagedURL
+
+ * Platform/spi/ios/UIKitSPI.h:
+
+ Drive-by fix: move the staged declarations of `-_dataOwnerForCopy` and `-_dataOwnerForPaste` out of the IPI
+ section, and into the non-internal SDK section.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _dataOwnerForPasteboard:]):
+
2022-05-02 Alan Coon <alanc...@apple.com>
Apply patch. rdar://problem/92617943
Modified: branches/safari-613-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h (293994 => 293995)
--- branches/safari-613-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-05-10 00:06:59 UTC (rev 293994)
+++ branches/safari-613-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-05-10 00:16:39 UTC (rev 293995)
@@ -163,6 +163,13 @@
UIPreviewItemTypeAttachment,
};
+typedef NS_ENUM(NSInteger, _UIDataOwner) {
+ _UIDataOwnerUndefined,
+ _UIDataOwnerUser,
+ _UIDataOwnerEnterprise,
+ _UIDataOwnerShared,
+};
+
@class UIPreviewItemController;
@protocol UIPreviewItemDelegate <NSObject>
@@ -471,7 +478,10 @@
- (void)_wheelChangedWithEvent:(UIEvent *)event;
- (void)_beginPinningInputViews;
- (void)_endPinningInputViews;
-
+#if HAVE(PASTEBOARD_DATA_OWNER)
+@property (nonatomic, setter=_setDataOwnerForCopy:) _UIDataOwner _dataOwnerForCopy;
+@property (nonatomic, setter=_setDataOwnerForPaste:) _UIDataOwner _dataOwnerForPaste;
+#endif
@end
@class FBSDisplayConfiguration;
@@ -1344,15 +1354,6 @@
#define UIWKDocumentRequestMarkedTextRects (1 << 5)
#define UIWKDocumentRequestSpatialAndCurrentSelection (1 << 6)
-#if HAVE(PASTEBOARD_DATA_OWNER)
-
-@interface UIResponder (Staging_73852335)
-@property (nonatomic, setter=_setDataOwnerForCopy:) _UIDataOwner _dataOwnerForCopy;
-@property (nonatomic, setter=_setDataOwnerForPaste:) _UIDataOwner _dataOwnerForPaste;
-@end
-
-#endif
-
@interface UITextInteractionAssistant (IPI)
@property (nonatomic, readonly) BOOL inGesture;
@property (nonatomic, readonly) UITextInteraction *interactions;
Modified: branches/safari-613-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (293994 => 293995)
--- branches/safari-613-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-05-10 00:06:59 UTC (rev 293994)
+++ branches/safari-613-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-05-10 00:16:39 UTC (rev 293995)
@@ -7878,18 +7878,23 @@
- (WebCore::DataOwnerType)_dataOwnerForPasteboard:(WebKit::PasteboardAccessIntent)intent
{
- if (![self respondsToSelector:@selector(_dataOwnerForPaste)]) {
- // FIXME: Remove this once the relevant bots have fix for <rdar://problem/73852335>.
+ auto specifiedType = [&] {
+ if (intent == WebKit::PasteboardAccessIntent::Read)
+ return coreDataOwnerType(self._dataOwnerForPaste);
+
+ if (intent == WebKit::PasteboardAccessIntent::Write)
+ return coreDataOwnerType(self._dataOwnerForCopy);
+
+ ASSERT_NOT_REACHED();
return WebCore::DataOwnerType::Undefined;
- }
+ }();
- if (intent == WebKit::PasteboardAccessIntent::Read)
- return coreDataOwnerType(self._dataOwnerForPaste);
+ if (specifiedType != WebCore::DataOwnerType::Undefined)
+ return specifiedType;
- if (intent == WebKit::PasteboardAccessIntent::Write)
- return coreDataOwnerType(self._dataOwnerForCopy);
+ if ([[PAL::getMCProfileConnectionClass() sharedConnection] isURLManaged:[_webView URL]])
+ return WebCore::DataOwnerType::Enterprise;
- ASSERT_NOT_REACHED();
return WebCore::DataOwnerType::Undefined;
}
Modified: branches/safari-613-branch/Tools/ChangeLog (293994 => 293995)
--- branches/safari-613-branch/Tools/ChangeLog 2022-05-10 00:06:59 UTC (rev 293994)
+++ branches/safari-613-branch/Tools/ChangeLog 2022-05-10 00:16:39 UTC (rev 293995)
@@ -1,3 +1,67 @@
+2022-05-06 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r292888. rdar://problem/80059355
+
+ [iOS] [WK2] Managed pasteboard should function for all managed domains
+ https://bugs.webkit.org/show_bug.cgi?id=239319
+ rdar://80059355
+
+ Reviewed by Kate Cheney.
+
+ Source/WebCore/PAL:
+
+ Add an SPI method on `MCProfileConnection`.
+
+ * pal/spi/ios/ManagedConfigurationSPI.h:
+
+ Source/WebKit:
+
+ Unless a WebKit client has specified a data owner for the web view that is not _UIDataOwnerUndefined, fall back
+ to _UIDataOwnerEnterprise when the current domain of the WKWebView is managed (that is, `-[MCProfileConnection
+ isURLManaged:]` returns YES for the web view's current URL). This allows managed pasteboard to work for all
+ WebKit clients, if the current URL is managed.
+
+ Test: UIPasteboardTests.PerformAsDataOwnerWithManagedURL
+
+ * Platform/spi/ios/UIKitSPI.h:
+
+ Drive-by fix: move the staged declarations of `-_dataOwnerForCopy` and `-_dataOwnerForPaste` out of the IPI
+ section, and into the non-internal SDK section.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _dataOwnerForPasteboard:]):
+
+ Tools:
+
+ Add a new API test to verify that we fall back to consulting `-[MCProfileConnection isURLManaged:]` when
+ determining the data owner for copy and paste, unless a data owner is already explicitly set on a view in the
+ responder chain (specifically, the WKWebView).
+
+ * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+ (+[TestUIPasteboard _performAsDataOwner:block:]):
+ (-[TestMCProfileConnection isURLManaged:]):
+ (TestWebKitAPI::TEST):
+
+ Canonical link: https://commits.webkit.org/249658@main
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-04-14 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] [WK2] Managed pasteboard should function for all managed domains
+ https://bugs.webkit.org/show_bug.cgi?id=239319
+ rdar://80059355
+
+ Reviewed by Kate Cheney.
+
+ Add a new API test to verify that we fall back to consulting `-[MCProfileConnection isURLManaged:]` when
+ determining the data owner for copy and paste, unless a data owner is already explicitly set on a view in the
+ responder chain (specifically, the WKWebView).
+
+ * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+ (+[TestUIPasteboard _performAsDataOwner:block:]):
+ (-[TestMCProfileConnection isURLManaged:]):
+ (TestWebKitAPI::TEST):
+
2022-04-22 Alan Coon <alanc...@apple.com>
Cherry-pick r292274. rdar://problem/80544133
Modified: branches/safari-613-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm (293994 => 293995)
--- branches/safari-613-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm 2022-05-10 00:06:59 UTC (rev 293994)
+++ branches/safari-613-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm 2022-05-10 00:16:39 UTC (rev 293995)
@@ -28,6 +28,7 @@
#if PLATFORM(IOS_FAMILY)
#import "ClassMethodSwizzler.h"
+#import "InstanceMethodSwizzler.h"
#import "PlatformUtilities.h"
#import "TestWKWebView.h"
#import "UIKitSPI.h"
@@ -35,7 +36,7 @@
#import <UIKit/UIPasteboard.h>
#import <WebKit/WKPreferencesPrivate.h>
#import <WebKit/WKWebViewPrivate.h>
-#import <wtf/SoftLinking.h>
+#import <pal/ios/ManagedConfigurationSoftLink.h>
typedef void (^DataLoadCompletionBlock)(NSData *, NSError *);
@@ -67,6 +68,18 @@
@end
+@interface TestMCProfileConnection : NSObject
+@end
+
+@implementation TestMCProfileConnection
+
+- (BOOL)isURLManaged:(NSURL *)url
+{
+ return [url.lastPathComponent isEqualToString:@"simple.html"];
+}
+
+@end
+
#endif // HAVE(PASTEBOARD_DATA_OWNER)
#endif // PLATFORM(IOS)
@@ -411,6 +424,36 @@
EXPECT_WK_STREQ([webView contentsAsString], "Foo bar\n");
}
+TEST(UIPasteboardTests, PerformAsDataOwnerWithManagedURL)
+{
+ auto pasteboardSwizzler = ClassMethodSwizzler {
+ UIPasteboard.class,
+ @selector(_performAsDataOwner:block:),
+ [TestUIPasteboard methodForSelector:@selector(_performAsDataOwner:block:)]
+ };
+
+ auto managedConfigurationSwizzler = InstanceMethodSwizzler {
+ PAL::getMCProfileConnectionClass(),
+ @selector(isURLManaged:),
+ [TestMCProfileConnection instanceMethodForSelector:@selector(isURLManaged:)]
+ };
+
+ {
+ auto source = setUpWebViewForPasteboardTests(@"simple");
+ [source selectAll:nil];
+ [source copy:nil];
+ [source waitForNextPresentationUpdate];
+ EXPECT_EQ(gLastKnownDataOwner, _UIDataOwnerEnterprise);
+ }
+ {
+ auto destination = setUpWebViewForPasteboardTests(@"autofocus-contenteditable");
+ [destination _setDataOwnerForPaste:_UIDataOwnerUser];
+ [destination paste:nil];
+ [destination waitForNextPresentationUpdate];
+ EXPECT_EQ(gLastKnownDataOwner, _UIDataOwnerUser);
+ }
+}
+
#endif // HAVE(PASTEBOARD_DATA_OWNER)
#endif // PLATFORM(IOS)