Changeset 197621 in webkit
- Timestamp:
- Mar 5, 2016 4:40:09 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r197620 r197621 1 2016-03-05 Timothy Hatcher <timothy@apple.com> 2 3 Implement the Automation protocol commands by tracking WebPageProxy objects 4 that are controlled by automation and assigning them a UUID handle. 5 6 https://bugs.webkit.org/show_bug.cgi?id=154953 7 rdar://problem/24947489 8 9 Reviewed by Brian Burg. 10 11 * UIProcess/API/APIAutomationSessionClient.h: 12 (API::AutomationSessionClient::didRequestNewWindow): 13 Return a WebPageProxy instead of void so it can be assigned a UUID handle. 14 15 * UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h: 16 Return a WKPageRef from _automationSessionDidRequestNewWindow:. 17 18 * UIProcess/Automation/WebAutomationSession.cpp: 19 (WebKit::WebAutomationSession::webPageProxyForHandle): 20 (WebKit::WebAutomationSession::handleForWebPageProxy): 21 (WebKit::WebAutomationSession::getBrowsingContexts): 22 (WebKit::WebAutomationSession::createBrowsingContext): 23 (WebKit::WebAutomationSession::closeBrowsingContext): 24 (WebKit::WebAutomationSession::switchToBrowsingContext): 25 26 * UIProcess/Automation/WebAutomationSession.h: 27 Added new methods and maps to track pages and handles. 28 29 * UIProcess/Cocoa/AutomationSessionClient.h: 30 * UIProcess/Cocoa/AutomationSessionClient.mm: 31 (WebKit::AutomationSessionClient::didRequestNewWindow): 32 Return a WebPageProxy from the WKPageRef. 33 34 * UIProcess/WebPageProxy.h: Make setFocus public. 35 36 * UIProcess/WebProcessPool.cpp: 37 (WebKit::WebProcessPool::setAutomationSession): 38 Set the WebProcessPool on the WebAutomationSession so it can be used to find 39 WebPageProxy objects controlled by automation. 40 1 41 2016-03-05 Timothy Hatcher <timothy@apple.com> 2 42 -
trunk/Source/WebKit2/UIProcess/API/APIAutomationSessionClient.h
r196848 r197621 31 31 namespace WebKit { 32 32 class WebAutomationSession; 33 class WebPageProxy; 33 34 } 34 35 … … 41 42 virtual String sessionIdentifier() const { return String(); } 42 43 virtual void didDisconnectFromRemote(WebKit::WebAutomationSession*) { } 43 virtual void didRequestNewWindow(WebKit::WebAutomationSession*) {}44 virtual WebKit::WebPageProxy* didRequestNewWindow(WebKit::WebAutomationSession*) { return nullptr; } 44 45 }; 45 46 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h
r196848 r197621 29 29 30 30 #import <Foundation/Foundation.h> 31 #import <WebKit/WKBase.h> 31 32 32 33 @class _WKAutomationSession; … … 34 35 @protocol _WKAutomationSessionDelegate <NSObject> 35 36 @optional 36 - ( void)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession;37 - (WKPageRef)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession; 37 38 - (void)_automationSessionDidDisconnectFromRemote:(_WKAutomationSession *)automationSession; 38 39 @end -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
r197620 r197621 29 29 #include "APIAutomationSessionClient.h" 30 30 #include "InspectorProtocolObjects.h" 31 #include "WebProcessPool.h" 31 32 #include <JavaScriptCore/InspectorBackendDispatcher.h> 32 33 #include <JavaScriptCore/InspectorFrontendRouter.h> 34 #include <WebCore/UUID.h> 35 #include <wtf/HashMap.h> 33 36 34 37 using namespace Inspector; … … 98 101 #endif // ENABLE(REMOTE_INSPECTOR) 99 102 103 WebPageProxy* WebAutomationSession::webPageProxyForHandle(const String& handle) 104 { 105 auto iter = m_handleWebPageMap.find(handle); 106 if (iter == m_handleWebPageMap.end()) 107 return nullptr; 108 return WebProcessProxy::webPage(iter->value); 109 } 110 111 String WebAutomationSession::handleForWebPageProxy(WebPageProxy* webPageProxy) 112 { 113 auto iter = m_webPageHandleMap.find(webPageProxy->pageID()); 114 if (iter != m_webPageHandleMap.end()) 115 return iter->value; 116 117 String handle = WebCore::createCanonicalUUIDString().convertToASCIIUppercase(); 118 119 auto firstAddResult = m_webPageHandleMap.add(webPageProxy->pageID(), handle); 120 RELEASE_ASSERT(firstAddResult.isNewEntry); 121 122 auto secondAddResult = m_handleWebPageMap.add(handle, webPageProxy->pageID()); 123 RELEASE_ASSERT(secondAddResult.isNewEntry); 124 125 return handle; 126 } 127 100 128 // Inspector::AutomationBackendDispatcherHandler API 101 129 102 130 void WebAutomationSession::getBrowsingContexts(Inspector::ErrorString& errorString, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>>& contexts) 103 131 { 104 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented); 132 contexts = Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>::create(); 133 134 for (auto& process : m_processPool->processes()) { 135 for (auto& page : process->pages()) { 136 if (!page->isControlledByAutomation()) 137 continue; 138 139 String handle = handleForWebPageProxy(page); 140 141 auto browsingContext = Inspector::Protocol::Automation::BrowsingContext::create() 142 .setHandle(handleForWebPageProxy(page)) 143 .setActive(m_activeBrowsingContextHandle == handle) 144 .release(); 145 146 contexts->addItem(browsingContext.copyRef()); 147 } 148 } 105 149 } 106 150 107 151 void WebAutomationSession::createBrowsingContext(Inspector::ErrorString& errorString, String* handle) 108 152 { 109 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented); 153 ASSERT(m_client); 154 if (!m_client) 155 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError); 156 157 WebPageProxy* page = m_client->didRequestNewWindow(this); 158 if (!page) 159 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError); 160 161 m_activeBrowsingContextHandle = *handle = handleForWebPageProxy(page); 110 162 } 111 163 112 164 void WebAutomationSession::closeBrowsingContext(Inspector::ErrorString& errorString, const String& handle) 113 165 { 114 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented); 166 WebPageProxy* page = webPageProxyForHandle(handle); 167 if (!page) 168 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 169 170 if (handle == m_activeBrowsingContextHandle) 171 m_activeBrowsingContextHandle = emptyString(); 172 173 // FIXME: Verify this is enough. We still might want to go through the AutomationSessionClient 174 // to get closer to a user pressing the close button. 175 page->tryClose(); 115 176 } 116 177 117 178 void WebAutomationSession::switchToBrowsingContext(Inspector::ErrorString& errorString, const String& handle) 118 179 { 119 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented); 180 WebPageProxy* page = webPageProxyForHandle(handle); 181 if (!page) 182 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 183 184 m_activeBrowsingContextHandle = handle; 185 186 // FIXME: Verify this is enough. We still might want to go through the AutomationSessionClient 187 // to get closer a user pressing focusing the window / page. 188 page->setFocus(true); 120 189 } 121 190 -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h
r197620 r197621 47 47 48 48 class WebAutomationSessionClient; 49 class WebPageProxy; 50 class WebProcessPool; 49 51 50 52 class WebAutomationSession final : public API::ObjectImpl<API::Object::Type::AutomationSession> … … 55 57 { 56 58 public: 59 typedef HashMap<uint64_t, String> WebPageHandleMap; 60 typedef HashMap<String, uint64_t> HandleWebPageMap; 61 57 62 WebAutomationSession(); 58 63 ~WebAutomationSession(); … … 62 67 void setSessionIdentifier(const String& sessionIdentifier) { m_sessionIdentifier = sessionIdentifier; } 63 68 String sessionIdentifier() const { return m_sessionIdentifier; } 69 70 WebKit::WebProcessPool* processPool() const { return m_processPool; } 71 void setProcessPool(WebKit::WebProcessPool* processPool) { m_processPool = processPool; } 64 72 65 73 #if ENABLE(REMOTE_INSPECTOR) … … 78 86 79 87 private: 88 WebKit::WebPageProxy* webPageProxyForHandle(const String&); 89 String handleForWebPageProxy(WebKit::WebPageProxy*); 90 91 WebKit::WebProcessPool* m_processPool { nullptr }; 80 92 std::unique_ptr<API::AutomationSessionClient> m_client; 81 93 String m_sessionIdentifier { ASCIILiteral("Untitled Session") }; … … 83 95 Ref<Inspector::BackendDispatcher> m_backendDispatcher; 84 96 Ref<Inspector::AutomationBackendDispatcher> m_domainDispatcher; 97 98 WebPageHandleMap m_webPageHandleMap; 99 HandleWebPageMap m_handleWebPageMap; 100 String m_activeBrowsingContextHandle; 85 101 86 102 #if ENABLE(REMOTE_INSPECTOR) -
trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.h
r197563 r197621 44 44 private: 45 45 // From API::AutomationSessionClient 46 voiddidRequestNewWindow(WebKit::WebAutomationSession*) override;46 WebPageProxy* didRequestNewWindow(WebKit::WebAutomationSession*) override; 47 47 void didDisconnectFromRemote(WebKit::WebAutomationSession *) override; 48 48 -
trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.mm
r196848 r197621 29 29 #if WK_API_ENABLED 30 30 31 #import "WKSharedAPICast.h" 31 32 #import "WebAutomationSession.h" 33 #import "WebPageProxy.h" 32 34 #import "_WKAutomationSessionDelegate.h" 33 35 #import "_WKAutomationSessionInternal.h" … … 42 44 } 43 45 44 voidAutomationSessionClient::didRequestNewWindow(WebAutomationSession* session)46 WebPageProxy* AutomationSessionClient::didRequestNewWindow(WebAutomationSession* session) 45 47 { 46 48 if (m_delegateMethods.didRequestNewWindow) 47 [m_delegate.get() _automationSessionDidRequestNewWindow:wrapper(*session)]; 49 return toImpl([m_delegate.get() _automationSessionDidRequestNewWindow:wrapper(*session)]); 50 return nullptr; 48 51 } 49 52 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r197564 r197621 1091 1091 void didRestoreScrollPosition(); 1092 1092 1093 void setFocus(bool focused); 1094 1093 1095 private: 1094 1096 WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&); … … 1327 1329 void requestCheckingOfString(uint64_t requestID, const WebCore::TextCheckingRequestData&); 1328 1330 1329 void setFocus(bool focused);1330 1331 void takeFocus(uint32_t direction); 1331 1332 void setToolTip(const String&); -
trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp
r197592 r197621 1121 1121 1122 1122 #if ENABLE(REMOTE_INSPECTOR) 1123 if (m_automationSession) 1123 if (m_automationSession) { 1124 1124 m_automationSession->init(); 1125 m_automationSession->setProcessPool(this); 1126 } 1125 1127 #endif 1126 1128 }
Note: See TracChangeset
for help on using the changeset viewer.