Changeset 194646 in webkit
- Timestamp:
- Jan 6, 2016, 10:49:17 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r194643 r194646 1 2016-01-06 Brian Burg <bburg@apple.com> 2 3 Add a WebKit SPI for registering an automation controller with RemoteInspector 4 https://bugs.webkit.org/show_bug.cgi?id=151576 5 6 Reviewed by Dan Bernstein and Joseph Pecoraro. 7 8 Given a RemoteInspector endpoint that is instantiated in UIProcess, there 9 should be a way to delegate automation-related functionality and policy to 10 clients of WebKit. 11 12 This class adds a RemoteInspector::Client interface that serves a delegate. 13 This is ultimately delegated via _WKAutomationDelegate, which is an SPI 14 that allows clients to install an Objective-C delegate for automation. 15 16 The setting for whether remote automation is allowed is included in the 17 listing that RemoteInspector sends out. It is updated when RemoteInspector::Client 18 is assigned, or when the client signals that its capabilities have changed. 19 20 * inspector/remote/RemoteInspector.h: 21 * inspector/remote/RemoteInspector.mm: 22 (Inspector::RemoteInspector::setRemoteInspectorClient): Added. 23 (Inspector::RemoteInspector::pushListingsNow): 24 25 In the listing, include whether the application supports remote automation. 26 27 * inspector/remote/RemoteInspectorConstants.h: Add a constant. 28 1 29 2016-01-05 Keith Miller <keith_miller@apple.com> 2 30 -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h
r192753 r194646 1 1 /* 2 * Copyright (C) 2013, 2015 Apple Inc. All Rights Reserved.2 * Copyright (C) 2013, 2015, 2016 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 49 49 class JS_EXPORT_PRIVATE RemoteInspector final : public RemoteInspectorXPCConnection::Client { 50 50 public: 51 class Client { 52 public: 53 virtual ~Client() { } 54 virtual bool remoteAutomationAllowed() const = 0; 55 virtual void requestAutomationSession() = 0; 56 }; 57 51 58 static void startDisabled(); 52 59 static RemoteInspector& singleton(); … … 59 66 60 67 void updateAutomaticInspectionCandidate(RemoteInspectionTarget*); 68 void setRemoteInspectorClient(RemoteInspector::Client*); 61 69 62 70 void setupFailed(unsigned identifier); 63 71 void setupCompleted(unsigned identifier); 64 72 bool waitingForAutomaticInspection(unsigned identifier); 73 void clientCapabilitiesDidChange() { pushListingsSoon(); } 65 74 66 75 bool enabled() const { return m_enabled; } … … 124 133 RefPtr<RemoteInspectorXPCConnection> m_xpcConnection; 125 134 135 RemoteInspector::Client* m_client { nullptr }; 136 126 137 dispatch_queue_t m_xpcQueue; 127 138 unsigned m_nextAvailableIdentifier { 1 }; -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm
r193783 r194646 1 1 /* 2 * Copyright (C) 2013-201 5Apple Inc. All Rights Reserved.2 * Copyright (C) 2013-2016 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 239 239 } 240 240 241 void RemoteInspector::setRemoteInspectorClient(RemoteInspector::Client* client) 242 { 243 ASSERT_ARG(client, client); 244 ASSERT(!m_client); 245 246 std::lock_guard<Lock> lock(m_mutex); 247 m_client = client; 248 249 // Send an updated listing that includes whether the client allows remote automation. 250 pushListingsSoon(); 251 } 252 241 253 void RemoteInspector::sendAutomaticInspectionCandidateMessage() 242 254 { … … 545 557 [message setObject:listings.get() forKey:WIRListingKey]; 546 558 559 BOOL isAllowed = m_client && m_client->remoteAutomationAllowed(); 560 [message setObject:@(isAllowed) forKey:WIRRemoteAutomationEnabledKey]; 561 547 562 m_xpcConnection->sendMessage(WIRListingMessage, message.get()); 548 563 } -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h
r192753 r194646 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved.2 * Copyright (C) 2011, 2016 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 68 68 #define WIRListingMessage @"WIRListingMessage" 69 69 #define WIRListingKey @"WIRListingKey" 70 #define WIRRemoteAutomationEnabledKey @"WIRRemoteAutomationEnabledKey" 70 71 #define WIRDestinationKey @"WIRDestinationKey" 71 72 #define WIRConnectionDiedMessage @"WIRConnectionDiedMessage" -
trunk/Source/WebKit2/ChangeLog
r194637 r194646 1 2016-01-06 Brian Burg <bburg@apple.com> 2 3 Add a WebKit SPI for registering an automation controller with RemoteInspector 4 https://bugs.webkit.org/show_bug.cgi?id=151576 5 6 Reviewed by Dan Bernstein and Joseph Pecoraro. 7 8 _WKAutomationDelegate is a new SPI that allows WKProcessPool clients to decide 9 policy and implement actions for remote automation. 10 11 The SPI's implementation connects the client's delegate to RemoteInspector::Client. 12 This allows the delegate to handle some commands, such as requestAutomationSession, 13 that come over XPC from an external test runner but are not associated with a specific 14 automation target. 15 16 * PlatformMac.cmake: 17 * UIProcess/API/APIAutomationClient.h: Added. Boilerplate for WebKit::AutomationClient. 18 (API::AutomationClient::~AutomationClient): 19 (API::AutomationClient::allowsRemoteAutomation): 20 (API::AutomationClient::requestAutomationSession): 21 * UIProcess/API/Cocoa/WKProcessPool.mm: 22 (-[WKProcessPool _automationDelegate]): Added. 23 (-[WKProcessPool _setAutomationDelegate:]): Added. 24 (-[WKProcessPool _automationCapabilitiesDidChange]): Added. 25 * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: Add delegate. 26 * UIProcess/API/Cocoa/_WKAutomationDelegate.h: Added. 27 28 This is a new delegate SPI of WKProcessPool; it corresponds to AutomationClient. 29 30 * UIProcess/Cocoa/AutomationClient.h: Added. 31 * UIProcess/Cocoa/AutomationClient.mm: Added. 32 33 This implements a bridge between RemoteInspector::Client and _WKAutomationDelegate. 34 Since the delegate can be called from JavaScriptCore, save the delegating 35 WKProcessPool and pass it as the self parameter to delegate methods. 36 37 (WebKit::AutomationClient::AutomationClient): 38 (WebKit::AutomationClient::~AutomationClient): 39 40 This client automatically registers and unregisters as a RemoteInspector::Client. 41 42 (WebKit::AutomationClient::remoteAutomationAllowed): 43 (WebKit::AutomationClient::requestAutomationSession): 44 45 Forward requests from RemoteInspector to the automation delegate. 46 47 * UIProcess/WebProcessPool.cpp: 48 (WebKit::WebProcessPool::WebProcessPool): 49 (WebKit::WebProcessPool::setAutomationClient): Added. 50 (WebKit::WebProcessPool::updateAutomationCapabilities): Added, it notifies RemoteInspector. 51 * UIProcess/WebProcessPool.h: 52 * WebKit2.xcodeproj/project.pbxproj: 53 1 54 2016-01-06 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 55 -
trunk/Source/WebKit2/PlatformMac.cmake
r194272 r194646 190 190 UIProcess/API/mac/WKView.mm 191 191 192 UIProcess/Cocoa/AutomationClient.mm 192 193 UIProcess/Cocoa/DiagnosticLoggingClient.mm 193 194 UIProcess/Cocoa/DownloadClient.mm -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm
r192808 r194646 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if WK_API_ENABLED 30 30 31 #import "AutomationClient.h" 31 32 #import "CacheModel.h" 32 33 #import "DownloadClient.h" … … 38 39 #import "WebProcessMessages.h" 39 40 #import "WebProcessPool.h" 41 #import "_WKAutomationDelegate.h" 40 42 #import "_WKDownloadDelegate.h" 41 43 #import "_WKProcessPoolConfigurationInternal.h" … … 50 52 51 53 @implementation WKProcessPool { 54 WebKit::WeakObjCPtr<id <_WKAutomationDelegate>> _automationDelegate; 52 55 WebKit::WeakObjCPtr<id <_WKDownloadDelegate>> _downloadDelegate; 53 56 … … 220 223 } 221 224 225 - (id <_WKAutomationDelegate>)_automationDelegate 226 { 227 return _automationDelegate.getAutoreleased(); 228 } 229 230 - (void)_setAutomationDelegate:(id <_WKAutomationDelegate>)automationDelegate 231 { 232 _automationDelegate = automationDelegate; 233 _processPool->setAutomationClient(std::make_unique<WebKit::AutomationClient>(self, automationDelegate)); 234 } 235 222 236 - (void)_warmInitialProcess 223 237 { … … 225 239 } 226 240 241 - (void)_automationCapabilitiesDidChange 242 { 243 _processPool->updateAutomationCapabilities(); 244 } 245 227 246 @end 228 247 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
r192015 r194646 29 29 30 30 @class _WKProcessPoolConfiguration; 31 @protocol _WKAutomationDelegate; 31 32 @protocol _WKDownloadDelegate; 32 33 … … 49 50 50 51 @property (nonatomic, weak, setter=_setDownloadDelegate:) id <_WKDownloadDelegate> _downloadDelegate; 52 @property (nonatomic, weak, setter=_setAutomationDelegate:) id <_WKAutomationDelegate> _automationDelegate WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA); 51 53 52 54 + (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL; … … 54 56 55 57 - (void)_warmInitialProcess WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA); 58 - (void)_automationCapabilitiesDidChange WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA); 56 59 57 60 @end -
trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp
r194496 r194646 28 28 29 29 #include "APIArray.h" 30 #include "APIAutomationClient.h" 30 31 #include "APIDownloadClient.h" 31 32 #include "APILegacyContextHistoryClient.h" … … 139 140 , m_processWithPageCache(0) 140 141 , m_defaultPageGroup(WebPageGroup::createNonNull()) 142 , m_automationClient(std::make_unique<API::AutomationClient>()) 141 143 , m_downloadClient(std::make_unique<API::DownloadClient>()) 142 144 , m_historyClient(std::make_unique<API::LegacyContextHistoryClient>()) … … 278 280 } 279 281 282 void WebProcessPool::setAutomationClient(std::unique_ptr<API::AutomationClient> automationClient) 283 { 284 if (!automationClient) 285 m_automationClient = std::make_unique<API::AutomationClient>(); 286 else 287 m_automationClient = WTFMove(automationClient); 288 } 289 280 290 void WebProcessPool::setMaximumNumberOfProcesses(unsigned maximumNumberOfProcesses) 281 291 { … … 1066 1076 } 1067 1077 1078 void WebProcessPool::updateAutomationCapabilities() const 1079 { 1080 #if ENABLE(REMOTE_INSPECTOR) 1081 Inspector::RemoteInspector::singleton().clientCapabilitiesDidChange(); 1082 #endif 1083 } 1084 1068 1085 void WebProcessPool::setHTTPPipeliningEnabled(bool enabled) 1069 1086 { -
trunk/Source/WebKit2/UIProcess/WebProcessPool.h
r194211 r194646 71 71 72 72 namespace API { 73 class AutomationClient; 73 74 class DownloadClient; 74 75 class LegacyContextHistoryClient; … … 135 136 void setHistoryClient(std::unique_ptr<API::LegacyContextHistoryClient>); 136 137 void setDownloadClient(std::unique_ptr<API::DownloadClient>); 138 void setAutomationClient(std::unique_ptr<API::AutomationClient>); 137 139 138 140 void setMaximumNumberOfProcesses(unsigned); // Can only be called when there are no processes running. … … 250 252 void enableProcessTermination(); 251 253 254 void updateAutomationCapabilities() const; 255 252 256 // Defaults to false. 253 257 void setHTTPPipeliningEnabled(bool); … … 417 421 WebContextClient m_client; 418 422 WebContextConnectionClient m_connectionClient; 423 std::unique_ptr<API::AutomationClient> m_automationClient; 419 424 std::unique_ptr<API::DownloadClient> m_downloadClient; 420 425 std::unique_ptr<API::LegacyContextHistoryClient> m_historyClient; -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r194318 r194646 1248 1248 93BDEB01171DD7AF00BFEE1B /* WKPageLoadTypesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 93BDEB00171DD7AF00BFEE1B /* WKPageLoadTypesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1249 1249 93E6A4EE1BC5DD3900F8A0E7 /* _WKHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E6A4ED1BC5DD3900F8A0E7 /* _WKHitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1250 99C81D591C20E1E5005C4C82 /* AutomationClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 99C81D561C20DFBE005C4C82 /* AutomationClient.mm */; }; 1251 99C81D5A1C20E7E2005C4C82 /* AutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D551C20DFBE005C4C82 /* AutomationClient.h */; }; 1252 99C81D5D1C21F38B005C4C82 /* APIAutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */; }; 1253 99E714C51C124A0400665B3A /* _WKAutomationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 99E714C11C1249E600665B3A /* _WKAutomationDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1250 1254 9F54F88F16488E87007DF81A /* ChildProcessMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9F54F88E16488E87007DF81A /* ChildProcessMac.mm */; }; 1251 1255 9F54F8951648AE0F007DF81A /* PluginProcessManagerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9F54F8941648AE0E007DF81A /* PluginProcessManagerMac.mm */; }; … … 3443 3447 93BDEB00171DD7AF00BFEE1B /* WKPageLoadTypesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageLoadTypesPrivate.h; sourceTree = "<group>"; }; 3444 3448 93E6A4ED1BC5DD3900F8A0E7 /* _WKHitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKHitTestResult.h; sourceTree = "<group>"; }; 3449 99C81D551C20DFBE005C4C82 /* AutomationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutomationClient.h; sourceTree = "<group>"; }; 3450 99C81D561C20DFBE005C4C82 /* AutomationClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutomationClient.mm; sourceTree = "<group>"; }; 3451 99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIAutomationClient.h; sourceTree = "<group>"; }; 3452 99E714C11C1249E600665B3A /* _WKAutomationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKAutomationDelegate.h; sourceTree = "<group>"; }; 3445 3453 9F54F88E16488E87007DF81A /* ChildProcessMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ChildProcessMac.mm; sourceTree = "<group>"; }; 3446 3454 9F54F8941648AE0E007DF81A /* PluginProcessManagerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProcessManagerMac.mm; sourceTree = "<group>"; }; … … 4907 4915 children = ( 4908 4916 517DD5BB180DA7C40081660B /* Databases */, 4917 99C81D551C20DFBE005C4C82 /* AutomationClient.h */, 4918 99C81D561C20DFBE005C4C82 /* AutomationClient.mm */, 4909 4919 83891B6A1A68C30B0030F386 /* DiagnosticLoggingClient.h */, 4910 4920 83891B6B1A68C30B0030F386 /* DiagnosticLoggingClient.mm */, … … 5277 5287 37A5E01118BBF937000A081E /* _WKActivatedElementInfo.mm */, 5278 5288 379A873518BBFA4300588AF2 /* _WKActivatedElementInfoInternal.h */, 5289 99E714C11C1249E600665B3A /* _WKAutomationDelegate.h */, 5279 5290 1A5704F61BE01FF400874AF1 /* _WKContextMenuElementInfo.h */, 5280 5291 1A5704F51BE01FF400874AF1 /* _WKContextMenuElementInfo.mm */, … … 6268 6279 BC8A501311765F4500757573 /* cpp */, 6269 6280 BC111B47112F616900337BAB /* mac */, 6281 99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */, 6270 6282 076E884D1A13CADF005E90FC /* APIContextMenuClient.h */, 6271 6283 83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */, … … 7795 7807 834B250F1A831A8D00CFB150 /* NetworkCacheFileSystem.h in Headers */, 7796 7808 E42E06101AA7523B00B11699 /* NetworkCacheIOChannel.h in Headers */, 7809 99E714C51C124A0400665B3A /* _WKAutomationDelegate.h in Headers */, 7797 7810 E4436ECE1A0D040B00EAD204 /* NetworkCacheKey.h in Headers */, 7798 7811 831EEBBD1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.h in Headers */, … … 7916 7929 1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */, 7917 7930 753E3E0E1887398900188496 /* SessionTracker.h in Headers */, 7931 99C81D5A1C20E7E2005C4C82 /* AutomationClient.h in Headers */, 7918 7932 1A6420E512DCE2FF00CAAE2C /* ShareableBitmap.h in Headers */, 7919 7933 51217461164C20E30037A5C1 /* ShareableResource.h in Headers */, … … 8348 8362 7C8EB11718DB6A19007917C2 /* WKPreferencesPrivate.h in Headers */, 8349 8363 BCD597D0112B56AC00EC8C23 /* WKPreferencesRef.h in Headers */, 8364 99C81D5D1C21F38B005C4C82 /* APIAutomationClient.h in Headers */, 8350 8365 762B748D120BC75C00819339 /* WKPreferencesRefPrivate.h in Headers */, 8351 8366 0FCB4E6618BBE3D9000FCFC9 /* WKPrintingView.h in Headers */, … … 10067 10082 0FCB4E5518BBE044000FCFC9 /* WKScrollView.mm in Sources */, 10068 10083 51CD1C661B34B9DC00142CA5 /* WKSecurityOrigin.mm in Sources */, 10084 99C81D591C20E1E5005C4C82 /* AutomationClient.mm in Sources */, 10069 10085 51CD1C5D1B3493AF00142CA5 /* WKSecurityOriginRef.cpp in Sources */, 10070 10086 BC407603124FF0270068F20A /* WKSerializedScriptValue.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.