WebKit2 SPI to disable remote inspection on a WKWebView / WKPage
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Mar 2014 21:46:21 +0000 (21:46 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Mar 2014 21:46:21 +0000 (21:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130371

Reviewed by Dan Bernstein.

* Shared/WebPageCreationParameters.h:
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
Add allowsRemoteInspection bool.

* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/API/C/WKPage.cpp:
(WKPageGetAllowsRemoteInspection):
(WKPageSetAllowsRemoteInspection):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _allowsRemoteInspection]):
(-[WKWebView _setAllowsRemoteInspection:]):
Getter and setter for allowing remote inspection state.

* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::allowsRemoteInspection):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::setAllowsRemoteInspection):
(WebKit::WebPageProxy::creationParameters):
Cached allows remote inspection state, with getter and setter.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setAllowsRemoteInspection):
When setting, call into WebCore to adjust the Page's setting.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165846 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

index 13bdf88..4b23b98 100644 (file)
@@ -1,3 +1,40 @@
+2014-03-18  Joseph Pecoraro  <pecoraro@apple.com>
+
+        WebKit2 SPI to disable remote inspection on a WKWebView / WKPage
+        https://bugs.webkit.org/show_bug.cgi?id=130371
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/WebPageCreationParameters.h:
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        Add allowsRemoteInspection bool.
+
+        * UIProcess/API/C/WKPagePrivate.h:
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageGetAllowsRemoteInspection):
+        (WKPageSetAllowsRemoteInspection):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _allowsRemoteInspection]):
+        (-[WKWebView _setAllowsRemoteInspection:]):
+        Getter and setter for allowing remote inspection state.
+
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::allowsRemoteInspection):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::setAllowsRemoteInspection):
+        (WebKit::WebPageProxy::creationParameters):
+        Cached allows remote inspection state, with getter and setter.
+
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setAllowsRemoteInspection):
+        When setting, call into WebCore to adjust the Page's setting.
+
 2014-03-18  Anders Carlsson  <andersca@apple.com>
 
         REGRESSION: Visited link coloring seems to be completely broken in tip of tree
index ea97a41..b0c711c 100644 (file)
@@ -63,6 +63,9 @@ void WebPageCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
     encoder << backgroundExtendsBeyondPage;
     encoder.encodeEnum(layerHostingMode);
 
+#if ENABLE(REMOTE_INSPECTOR)
+    encoder << allowsRemoteInspection;
+#endif
 #if PLATFORM(MAC)
     encoder << colorSpace;
 #endif
@@ -131,7 +134,12 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre
         return false;
     if (!decoder.decodeEnum(parameters.layerHostingMode))
         return false;
-    
+
+#if ENABLE(REMOTE_INSPECTOR)
+    if (!decoder.decoder(parameters.allowsRemoteInspection))
+        return false;
+#endif
+
 #if PLATFORM(MAC)
     if (!decoder.decode(parameters.colorSpace))
         return false;
index 1e3f7ba..fda7091 100644 (file)
@@ -103,6 +103,10 @@ struct WebPageCreationParameters {
 
     LayerHostingMode layerHostingMode;
 
+#if ENABLE(REMOTE_INSPECTOR)
+    bool allowsRemoteInspection;
+#endif
+
 #if PLATFORM(MAC)
     ColorSpaceData colorSpace;
 #endif
index 8e136b9..53bf4e8 100644 (file)
@@ -1641,6 +1641,26 @@ void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync)
     toImpl(page)->setShouldSendEventsSynchronously(sync);
 }
 
+bool WKPageGetAllowsRemoteInspection(WKPageRef page)
+{
+#if ENABLE(REMOTE_INSPECTOR)
+    return toImpl(page)->allowsRemoteInspection();
+#else
+    UNUSED_PARAM(page);
+    return false;
+#endif    
+}
+
+void WKPageSetAllowsRemoteInspection(WKPageRef page, bool allow)
+{
+#if ENABLE(REMOTE_INSPECTOR)
+    toImpl(page)->setAllowsRemoteInspection(allow);
+#else
+    UNUSED_PARAM(page);
+    UNUSED_PARAM(allow);
+#endif
+}
+
 void WKPageSetMediaVolume(WKPageRef page, float volume)
 {
     toImpl(page)->setMediaVolume(volume);    
index dbcd39f..1c8ed65 100644 (file)
@@ -87,6 +87,9 @@ WK_EXPORT WKImageRef WKPageCreateSnapshotOfVisibleContent(WKPageRef page);
 
 WK_EXPORT void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync);
 
+WK_EXPORT bool WKPageGetAllowsRemoteInspection(WKPageRef page);
+WK_EXPORT void WKPageSetAllowsRemoteInspection(WKPageRef page, bool allow);
+
 WK_EXPORT void WKPageSetMediaVolume(WKPageRef page, float volume);
 WK_EXPORT void WKPageSetMayStartMediaWhenInWindow(WKPageRef page, bool mayStartMedia);
 
index e4fbb70..436bf6c 100644 (file)
@@ -877,6 +877,22 @@ static void releaseNSData(unsigned char*, const void* data)
     [_configuration preferences]->_preferences->setPrivateBrowsingEnabled(privateBrowsingEnabled);
 }
 
+- (BOOL)_allowsRemoteInspection
+{
+#if ENABLE(REMOTE_INSPECTOR)
+    return _page->allowsRemoteInspection();
+#else
+    return NO;
+#endif
+}
+
+- (void)_setAllowsRemoteInspection:(BOOL)allow
+{
+#if ENABLE(REMOTE_INSPECTOR)
+    _page->setAllowsRemoteInspection(allow);
+#endif
+}
+
 static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEvents events)
 {
     WebCore::LayoutMilestones milestones = 0;
index 95f7a98..d6c01cc 100644 (file)
@@ -72,6 +72,8 @@ typedef NS_ENUM(NSInteger, _WKPaginationMode) {
 
 @property (nonatomic, setter=_setPrivateBrowsingEnabled:) BOOL _privateBrowsingEnabled;
 
+@property (nonatomic, setter=_setAllowsRemoteInspection:) BOOL _allowsRemoteInspection;
+
 - (void)_close;
 
 #if TARGET_OS_IPHONE
index f03acfe..0560ae3 100644 (file)
@@ -305,6 +305,9 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_pageID(pageID)
     , m_session(*configuration.session)
     , m_isPageSuspended(false)
+#if ENABLE(REMOTE_INSPECTOR)
+    , m_allowsRemoteInspection(true)
+#endif
 #if PLATFORM(COCOA)
     , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
 #endif
@@ -887,6 +890,19 @@ bool WebPageProxy::canShowMIMEType(const String& mimeType)
     return false;
 }
 
+#if ENABLE(REMOTE_INSPECTOR)
+void WebPageProxy::setAllowsRemoteInspection(bool allow)
+{
+    if (m_allowsRemoteInspection == allow)
+        return;
+
+    m_allowsRemoteInspection = allow;
+
+    if (isValid())
+        m_process->send(Messages::WebPage::SetAllowsRemoteInspection(allow), m_pageID);
+}
+#endif
+
 void WebPageProxy::setDrawsBackground(bool drawsBackground)
 {
     if (m_drawsBackground == drawsBackground)
@@ -4008,7 +4024,9 @@ WebPageCreationParameters WebPageProxy::creationParameters()
     parameters.scrollPinningBehavior = m_scrollPinningBehavior;
     parameters.backgroundExtendsBeyondPage = m_backgroundExtendsBeyondPage;
     parameters.layerHostingMode = m_layerHostingMode;
-
+#if ENABLE(REMOTE_INSPECTOR)
+    parameters.allowsRemoteInspection = m_allowsRemoteInspection;
+#endif
 #if PLATFORM(MAC)
     parameters.colorSpace = m_pageClient.colorSpace();
 #endif
index 625c6c5..350f51c 100644 (file)
@@ -360,6 +360,11 @@ public:
     WebInspectorProxy* inspector();
 #endif
 
+#if ENABLE(REMOTE_INSPECTOR)
+    bool allowsRemoteInspection() const { return m_allowsRemoteInspection; }
+    void setAllowsRemoteInspection(bool);
+#endif
+
 #if ENABLE(VIBRATION)
     WebVibrationProxy* vibration() { return m_vibration.get(); }
 #endif
@@ -1394,6 +1399,10 @@ private:
 
     bool m_isPageSuspended;
 
+#if ENABLE(REMOTE_INSPECTOR)
+    bool m_allowsRemoteInspection;
+#endif
+
 #if PLATFORM(COCOA)
     bool m_isSmartInsertDeleteEnabled;
 #endif
index e72f035..d80ae35 100644 (file)
@@ -1973,6 +1973,13 @@ void WebPage::centerSelectionInVisibleArea()
     m_findController.showFindIndicatorInSelection();
 }
 
+#if ENABLE(REMOTE_INSPECTOR)
+void WebPage::setAllowsRemoteInspection(bool allow)
+{
+    m_page->setRemoteInspectionAllowed(allow);
+}
+#endif
+
 void WebPage::setDrawsBackground(bool drawsBackground)
 {
     if (m_drawsBackground == drawsBackground)
index 6929b8f..579da1f 100644 (file)
@@ -828,6 +828,10 @@ private:
 
     void didRemoveBackForwardItem(uint64_t);
 
+#if ENABLE(REMOTE_INSPECTOR)
+    void setAllowsRemoteInspection(bool);
+#endif
+
     void setDrawsBackground(bool);
     void setDrawsTransparentBackground(bool);
 
index 9c370e5..30b07b2 100644 (file)
@@ -73,6 +73,10 @@ messages -> WebPage LegacyReceiver {
     ApplicationDidBecomeActive()
 #endif
 
+#if ENABLE(REMOTE_INSPECTOR)
+    SetAllowsRemoteInspection(bool allow)
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
     TouchEvent(WebKit::WebTouchEvent event)
     TouchEventSyncForTesting(WebKit::WebTouchEvent event) -> (bool handled)