If there are no services available, do not show the service controls UI
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 May 2014 01:18:52 +0000 (01:18 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 May 2014 01:18:52 +0000 (01:18 +0000)
<rdar://problem/16735665> and https://bugs.webkit.org/show_bug.cgi?id=132410

Reviewed by Tim Horton.

Add a lightweight class that lazily polls the appropriate APIs for whether or not appropriate services
are installed and usable on the system:
* UIProcess/mac/ServicesController.h: Added.
(WebKit::ServicesController::imageServicesExist):
(WebKit::ServicesController::selectionServicesExist):
* UIProcess/mac/ServicesController.mm: Added.
(WebKit::ServicesController::shared):
(WebKit::ServicesController::ServicesController):
(WebKit::ServicesController::refreshExistingServices):
(WebKit::ServicesController::refreshExistingServicesTimerFired):

Add "image services exist" and "selection services exist" parameters:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:

* UIProcess/WebContext.cpp:
(WebKit::WebContext::createNewWebProcess):
(WebKit::WebContext::refreshExistingServices): Called when the context menu proxy realizes that
  services no longer exist.
* UIProcess/WebContext.h:

Each WebProcess hangs on to its own copy of the flags for whether or not the services exist:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::setEnabledServices):
* WebProcess/WebProcess.h:
(WebKit::WebProcess::imageServicesExist):
(WebKit::WebProcess::selectionServicesExist):

* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::setupServicesMenu): If the menu creation failed, the set of services
  on the system must have changed. So ask the WebContext to refresh them.

* WebProcess/WebPage/SelectionOverlayController.cpp:
(WebKit::SelectionOverlayController::selectionRectsDidChange): If services don't exist, don't create an
  overlay (and destroy any existing overlay!)

* WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:
(WebKit::SelectionOverlayController::drawRect): If services don't exist, don't draw, and destroy the overlay.

* WebProcess/WebProcess.messages.in:
* WebKit2.xcodeproj/project.pbxproj:

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

14 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/mac/ServicesController.h [new file with mode: 0644]
Source/WebKit2/UIProcess/mac/ServicesController.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/SelectionOverlayController.cpp
Source/WebKit2/WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in

index 5ad6b52..8a58c57 100644 (file)
@@ -1,3 +1,57 @@
+2014-04-30  Brady Eidson  <beidson@apple.com>
+
+        If there are no services available, do not show the service controls UI
+        <rdar://problem/16735665> and https://bugs.webkit.org/show_bug.cgi?id=132410
+
+        Reviewed by Tim Horton.
+
+        Add a lightweight class that lazily polls the appropriate APIs for whether or not appropriate services
+        are installed and usable on the system:
+        * UIProcess/mac/ServicesController.h: Added.
+        (WebKit::ServicesController::imageServicesExist):
+        (WebKit::ServicesController::selectionServicesExist):
+        * UIProcess/mac/ServicesController.mm: Added.
+        (WebKit::ServicesController::shared):
+        (WebKit::ServicesController::ServicesController):
+        (WebKit::ServicesController::refreshExistingServices):
+        (WebKit::ServicesController::refreshExistingServicesTimerFired):
+
+        Add "image services exist" and "selection services exist" parameters:
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::createNewWebProcess):
+        (WebKit::WebContext::refreshExistingServices): Called when the context menu proxy realizes that
+          services no longer exist.
+        * UIProcess/WebContext.h:
+
+        Each WebProcess hangs on to its own copy of the flags for whether or not the services exist:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        (WebKit::WebProcess::initializeWebProcess):
+        (WebKit::WebProcess::setEnabledServices):
+        * WebProcess/WebProcess.h:
+        (WebKit::WebProcess::imageServicesExist):
+        (WebKit::WebProcess::selectionServicesExist):
+
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::setupServicesMenu): If the menu creation failed, the set of services
+          on the system must have changed. So ask the WebContext to refresh them.
+
+        * WebProcess/WebPage/SelectionOverlayController.cpp:
+        (WebKit::SelectionOverlayController::selectionRectsDidChange): If services don't exist, don't create an
+          overlay (and destroy any existing overlay!)
+
+        * WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:
+        (WebKit::SelectionOverlayController::drawRect): If services don't exist, don't draw, and destroy the overlay.
+
+        * WebProcess/WebProcess.messages.in:
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2014-04-30  Gavin Barraclough  <baraclough@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=132415
index cb1fb72..bdc9886 100644 (file)
@@ -48,6 +48,10 @@ WebProcessCreationParameters::WebProcessCreationParameters()
     , usesNetworkProcess(false)
 #endif
     , memoryCacheDisabled(false)
+#if ENABLE(SERVICE_CONTROLS)
+    , hasImageServices(false)
+    , hasSelectionServices(false)
+#endif
 {
 }
 
@@ -129,6 +133,11 @@ void WebProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
     encoder << plugInAutoStartOriginHashes;
     encoder << plugInAutoStartOrigins;
     encoder << memoryCacheDisabled;
+
+#if ENABLE(SERVICE_CONTROLS)
+    encoder << hasImageServices;
+    encoder << hasSelectionServices;
+#endif
 }
 
 bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProcessCreationParameters& parameters)
@@ -274,6 +283,13 @@ bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProc
     if (!decoder.decode(parameters.memoryCacheDisabled))
         return false;
 
+#if ENABLE(SERVICE_CONTROLS)
+    if (!decoder.decode(parameters.hasImageServices))
+        return false;
+    if (!decoder.decode(parameters.hasSelectionServices))
+        return false;
+#endif
+
     return true;
 }
 
index 9272e19..df14022 100644 (file)
@@ -155,6 +155,11 @@ struct WebProcessCreationParameters {
     Vector<String> plugInAutoStartOrigins;
 
     bool memoryCacheDisabled;
+
+#if ENABLE(SERVICE_CONTROLS)
+    bool hasImageServices;
+    bool hasSelectionServices;
+#endif
 };
 
 } // namespace WebKit
index 2c6bbad..ccb1188 100644 (file)
 #include "NetworkProcessProxy.h"
 #endif
 
+#if ENABLE(SERVICE_CONTROLS)
+#include "ServicesController.h"
+#endif
+
 #if ENABLE(CUSTOM_PROTOCOLS)
 #include "CustomProtocolManagerMessages.h"
 #endif
@@ -616,6 +620,12 @@ WebProcessProxy& WebContext::createNewWebProcess()
 
     parameters.memoryCacheDisabled = m_memoryCacheDisabled;
 
+#if ENABLE(SERVICE_CONTROLS)
+    parameters.hasImageServices = ServicesController::shared().hasImageServices();
+    parameters.hasSelectionServices = ServicesController::shared().hasSelectionServices();
+    ServicesController::shared().refreshExistingServices(this);
+#endif
+
     // Add any platform specific parameters
     platformInitializeWebProcess(parameters);
 
@@ -1292,6 +1302,14 @@ void WebContext::didGetStatistics(const StatisticsData& statisticsData, uint64_t
 
     request->completedRequest(requestID, statisticsData);
 }
+
+#if ENABLE(SERVICE_CONTROLS)
+void WebContext::refreshExistingServices()
+{
+    ServicesController::shared().refreshExistingServices(this);
+}
+#endif
+
     
 void WebContext::garbageCollectJavaScriptObjects()
 {
index 52b2575..2545c50 100644 (file)
@@ -338,6 +338,10 @@ public:
 
     void setMemoryCacheDisabled(bool);
 
+#if ENABLE(SERVICE_CONTROLS)
+    void refreshExistingServices();
+#endif
+
 private:
     void platformInitialize();
 
@@ -386,7 +390,7 @@ private:
 #endif
 
     void didGetStatistics(const StatisticsData&, uint64_t callbackID);
-        
+
     // Implemented in generated WebContextMessageReceiver.cpp
     void didReceiveWebContextMessage(IPC::Connection*, IPC::MessageDecoder&);
     void didReceiveSyncWebContextMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
diff --git a/Source/WebKit2/UIProcess/mac/ServicesController.h b/Source/WebKit2/UIProcess/mac/ServicesController.h
new file mode 100644 (file)
index 0000000..fa64357
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ServicesController_h
+#define ServicesController_h
+
+#if ENABLE(SERVICE_CONTROLS)
+
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+class WebContext;
+
+class ServicesController {
+    WTF_MAKE_NONCOPYABLE(ServicesController);
+    friend class NeverDestroyed<ServicesController>;
+public:
+    static ServicesController& shared();
+
+    bool hasImageServices() const { return m_hasImageServices; }
+    bool hasSelectionServices() const { return m_hasSelectionServices; }
+
+    void refreshExistingServices(WebContext*);
+
+private:
+    ServicesController();
+
+    void refreshExistingServicesTimerFired();
+
+    RunLoop::Timer<ServicesController> m_refreshExistingServicesTimer;
+
+    bool m_hasImageServices;
+    bool m_hasSelectionServices;
+
+    HashSet<RefPtr<WebContext>> m_contextsToNotify;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(SERVICE_CONTROLS)
+#endif // ServicesController_h
diff --git a/Source/WebKit2/UIProcess/mac/ServicesController.mm b/Source/WebKit2/UIProcess/mac/ServicesController.mm
new file mode 100644 (file)
index 0000000..c5465ed
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ServicesController.h"
+
+#if ENABLE(SERVICE_CONTROLS)
+
+#import "WebContext.h"
+#import "WebProcessMessages.h"
+#import <wtf/NeverDestroyed.h>
+
+#if __has_include(<AppKit/NSSharingService_Private.h>)
+#import <AppKit/NSSharingService_Private.h>
+#else
+typedef enum {
+    NSSharingServicePickerStyleMenu = 0,
+    NSSharingServicePickerStyleRollover = 1,
+    NSSharingServicePickerStyleTextSelection = 2,
+    NSSharingServicePickerStyleDataDetector = 3
+} NSSharingServicePickerStyle;
+
+@interface NSSharingServicePicker (Details)
+@property NSSharingServicePickerStyle style;
+- (NSMenu *)menu;
+@end
+#endif
+
+namespace WebKit {
+
+ServicesController& ServicesController::shared()
+{
+    static NeverDestroyed<ServicesController> sharedController;
+    return sharedController;
+}
+
+ServicesController::ServicesController()
+    : m_refreshExistingServicesTimer(RunLoop::main(), this, &ServicesController::refreshExistingServicesTimerFired)
+    , m_hasImageServices(false)
+    , m_hasSelectionServices(false)
+{
+    m_refreshExistingServicesTimer.startOneShot(0);
+}
+
+void ServicesController::refreshExistingServices(WebContext* context)
+{
+    ASSERT(context);
+
+    m_contextsToNotify.add(context);
+    m_refreshExistingServicesTimer.startOneShot(0);
+}
+
+void ServicesController::refreshExistingServicesTimerFired()
+{
+    static NeverDestroyed<NSImage *> image([[NSImage alloc] init]);
+    RetainPtr<NSSharingServicePicker>  picker = adoptNS([[NSSharingServicePicker alloc] initWithItems:@[ image ]]);
+    [picker setStyle:NSSharingServicePickerStyleRollover];
+
+    bool hasImageServices = picker.get().menu;
+
+    static NeverDestroyed<NSAttributedString *> attributedString([[NSAttributedString alloc] initWithString:@"a"]);
+    picker = adoptNS([[NSSharingServicePicker alloc] initWithItems:@[ attributedString ]]);
+    [picker setStyle:NSSharingServicePickerStyleTextSelection];
+
+    bool hasSelectionServices = picker.get().menu;
+
+    bool notifyContexts = (hasImageServices != m_hasImageServices) || (hasSelectionServices != m_hasSelectionServices);
+    m_hasSelectionServices = hasSelectionServices;
+    m_hasImageServices = hasImageServices;
+
+    if (notifyContexts) {
+        for (const RefPtr<WebContext>& context : m_contextsToNotify)
+            context->sendToAllProcesses(Messages::WebProcess::SetEnabledServices(m_hasImageServices, m_hasSelectionServices));
+    }
+
+    m_contextsToNotify.clear();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(SERVICE_CONTROLS)
index ace852e..18649ec 100644 (file)
@@ -32,7 +32,9 @@
 #import "PageClientImpl.h"
 #import "ShareableBitmap.h"
 #import "StringUtilities.h"
+#import "WebContext.h"
 #import "WebContextMenuItemData.h"
+#import "WebProcessProxy.h"
 #import "WKView.h"
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/IntRect.h>
@@ -396,6 +398,12 @@ void WebContextMenuProxyMac::setupServicesMenu(const ContextMenuContextData& con
     [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setIncludeEditorServices:includeEditorServices];
 
     m_servicesMenu = [picker menu];
+
+    // If there is no services menu, then the existing services on the system have changed.
+    // Ask the UIProcess to refresh that list of services.
+    // If <rdar://problem/16776831> is resolved then we can more accurately keep the list up to date without this call.
+    if (!m_servicesMenu)
+        m_page->process().context().refreshExistingServices();
 }
 
 void WebContextMenuProxyMac::clearServicesMenu()
index fa9968c..e17a378 100644 (file)
                513A164C1630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 513A16491630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp */; };
                513A164D1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = 513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */; };
                514BDED316C98EDD00E4E25E /* StatisticsRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 514BDED216C98EDD00E4E25E /* StatisticsRequest.h */; };
+               514D9F5719119D35000063A7 /* ServicesController.h in Headers */ = {isa = PBXBuildFile; fileRef = 514D9F5519119D35000063A7 /* ServicesController.h */; };
+               514D9F5819119D35000063A7 /* ServicesController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514D9F5619119D35000063A7 /* ServicesController.mm */; };
                5153569C1291B1D2000749DC /* WebPageContextMenuClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5153569A1291B1D2000749DC /* WebPageContextMenuClient.cpp */; };
                5153569D1291B1D2000749DC /* WebPageContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 5153569B1291B1D2000749DC /* WebPageContextMenuClient.h */; };
                51578B831209ECEF00A37C4A /* APIData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51578B821209ECEF00A37C4A /* APIData.h */; };
                513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkConnectionToWebProcess.h; path = NetworkProcess/NetworkConnectionToWebProcess.h; sourceTree = "<group>"; };
                513A164B1630A9BF005D7D22 /* NetworkConnectionToWebProcess.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NetworkConnectionToWebProcess.messages.in; path = NetworkProcess/NetworkConnectionToWebProcess.messages.in; sourceTree = "<group>"; };
                514BDED216C98EDD00E4E25E /* StatisticsRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StatisticsRequest.h; sourceTree = "<group>"; };
+               514D9F5519119D35000063A7 /* ServicesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServicesController.h; sourceTree = "<group>"; };
+               514D9F5619119D35000063A7 /* ServicesController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ServicesController.mm; sourceTree = "<group>"; };
                5153569A1291B1D2000749DC /* WebPageContextMenuClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageContextMenuClient.cpp; sourceTree = "<group>"; };
                5153569B1291B1D2000749DC /* WebPageContextMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageContextMenuClient.h; sourceTree = "<group>"; };
                51578B821209ECEF00A37C4A /* APIData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIData.h; sourceTree = "<group>"; };
                                E18E6909169B563F009B6670 /* SecItemShimProxy.cpp */,
                                E18E690A169B563F009B6670 /* SecItemShimProxy.h */,
                                E18E690D169B57DF009B6670 /* SecItemShimProxy.messages.in */,
+                               514D9F5519119D35000063A7 /* ServicesController.h */,
+                               514D9F5619119D35000063A7 /* ServicesController.mm */,
                                1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */,
                                1AF05D8514688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h */,
                                1AF05D8414688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.mm */,
                                BC032DAB10F437D10058C15A /* Connection.h in Headers */,
                                5136183E163126DA00A99DDE /* ConnectionStack.h in Headers */,
                                1AC1415118AC47EE006C602C /* WKWebViewConfigurationPrivate.h in Headers */,
+                               514D9F5719119D35000063A7 /* ServicesController.h in Headers */,
                                CDC3830C17212282008A2FC3 /* CookieStorageShimLibrary.h in Headers */,
                                515E7730184015800007203F /* UniqueIDBDatabase.h in Headers */,
                                B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */,
                                BC111A5D112F4FBB00337BAB /* WebDragClient.cpp in Sources */,
                                C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */,
                                BCA0EFA012332642007D3CFB /* WebEditCommandProxy.cpp in Sources */,
+                               514D9F5819119D35000063A7 /* ServicesController.mm in Sources */,
                                BC111A5E112F4FBB00337BAB /* WebEditorClient.cpp in Sources */,
                                C5237F6012441CA300780472 /* WebEditorClientMac.mm in Sources */,
                                BC575613126E0138006F0F12 /* APIError.cpp in Sources */,
index d3b21e9..8e03f5b 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(SERVICE_CONTROLS)
 
 #include "WebPage.h"
+#include "WebProcess.h"
 #include <WebCore/NotImplemented.h>
 
 using namespace WebCore;
@@ -91,10 +92,11 @@ void SelectionOverlayController::selectionRectsDidChange(const Vector<LayoutRect
 
     m_currentSelectionRects = rects;
 
-    if (m_currentSelectionRects.isEmpty())
-        destroyOverlay();
-    else
+    if (WebProcess::shared().hasSelectionServices() && !m_currentSelectionRects.isEmpty())
         createOverlayIfNeeded();
+    else
+        destroyOverlay();
+
 #else
     UNUSED_PARAM(rects);
 #endif
index d2d8976..777aeaa 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(SERVICE_CONTROLS)
 
+#import "WebProcess.h"
 #import <WebCore/FrameView.h>
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/MainFrame.h>
@@ -59,6 +60,11 @@ void SelectionOverlayController::drawRect(PageOverlay* overlay, WebCore::Graphic
     if (m_currentSelectionRects.isEmpty())
         return;
 
+    if (!WebProcess::shared().hasSelectionServices()) {
+        destroyOverlay();
+        return;
+    }
+
     if (!m_currentHighlight) {
         Vector<CGRect> cgRects;
         cgRects.reserveCapacity(m_currentSelectionRects.size());
index e26ef15..ee95d16 100644 (file)
@@ -167,6 +167,10 @@ WebProcess::WebProcess()
 #if ENABLE(NETSCAPE_PLUGIN_API)
     , m_pluginProcessConnectionManager(PluginProcessConnectionManager::create())
 #endif
+#if ENABLE(SERVICE_CONTROLS)
+    , m_hasImageServices(false)
+    , m_hasSelectionServices(false)
+#endif
     , m_nonVisibleProcessCleanupTimer(this, &WebProcess::nonVisibleProcessCleanupTimerFired)
 {
     // Initialize our platform strategies.
@@ -359,6 +363,10 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame
         m_plugInAutoStartOrigins.add(parameters.plugInAutoStartOrigins[i]);
 
     setMemoryCacheDisabled(parameters.memoryCacheDisabled);
+
+#if ENABLE(SERVICE_CONTROLS)
+    setEnabledServices(parameters.hasImageServices, parameters.hasSelectionServices);
+#endif
 }
 
 #if ENABLE(NETWORK_PROCESS)
@@ -1173,4 +1181,12 @@ void WebProcess::setMemoryCacheDisabled(bool disabled)
         memoryCache()->setDisabled(disabled);
 }
 
+#if ENABLE(SERVICE_CONTROLS)
+void WebProcess::setEnabledServices(bool hasImageServices, bool hasSelectionServices)
+{
+    m_hasImageServices = hasImageServices;
+    m_hasSelectionServices = hasSelectionServices;
+}
+#endif
+
 } // namespace WebKit
index db0c889..2e2989a 100644 (file)
@@ -183,6 +183,11 @@ public:
 
     RefPtr<API::Object> apiObjectByConvertingFromHandles(API::Object*);
 
+#if ENABLE(SERVICE_CONTROLS)
+    bool hasImageServices() const { return m_hasImageServices; }
+    bool hasSelectionServices() const { return m_hasSelectionServices; }
+#endif
+
 private:
     WebProcess();
 
@@ -242,6 +247,10 @@ private:
 
     void setMemoryCacheDisabled(bool);
 
+#if ENABLE(SERVICE_CONTROLS)
+    void setEnabledServices(bool hasImageServices, bool hasSelectionServices);
+#endif
+
     void postInjectedBundleMessage(const IPC::DataReference& messageData);
     void setInjectedBundleParameter(const String& key, const IPC::DataReference&);
 
@@ -325,6 +334,11 @@ private:
     RefPtr<PluginProcessConnectionManager> m_pluginProcessConnectionManager;
 #endif
 
+#if ENABLE(SERVICE_CONTROLS)
+    bool m_hasImageServices;
+    bool m_hasSelectionServices;
+#endif
+
     HashSet<uint64_t> m_pagesInWindows;
     WebCore::Timer<WebProcess> m_nonVisibleProcessCleanupTimer;
 };
index a6fa5e0..8de7915 100644 (file)
@@ -88,4 +88,8 @@ messages -> WebProcess LegacyReceiver {
 #endif
 
     SetMemoryCacheDisabled(bool disabled);
+
+#if ENABLE(SERVICE_CONTROLS)
+    SetEnabledServices(bool hasImageServices, bool hasSelectionServices)
+#endif
 }