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)
commit310bc70b543434916399f3bdb1f8139967e6e827
tree970163615a3c29f3ef20328210f5015cbae59909
parent2152e95f65ac97ce11c1a64ae85c6060550fb84c
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:

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