[wk2] Search With [your search provider here] should use NSPerformService in WebKit2/Mac
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2013 19:59:07 +0000 (19:59 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2013 19:59:07 +0000 (19:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111995
<rdar://problem/12975669>

Reviewed by Sam Weinig.

* UIProcess/WebPageProxy.h:
(WebPageProxy): Add searchTheWeb().
* UIProcess/WebPageProxy.messages.in: Add SearchTheWeb message.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::searchTheWeb): Added. Call out to NSPerformService to search with the system default
search provider, in the browser.

* WebProcess/Plugins/PDF/PDFPlugin.h:
(PDFPlugin): Add performWebSearch().
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(-[WKPDFLayerControllerDelegate performWebSearch:]): Added, forward the delegate callback to PDFPlugin.
(WebKit::PDFPlugin::performWebSearch): Added, forward the search string to WebPageProxy.
* WebProcess/WebCoreSupport/WebContextMenuClient.cpp:
(WebKit::WebContextMenuClient::searchWithGoogle): Don't build the old load-Google-in-the-main-frame code on Mac.
* WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
(WebKit::WebContextMenuClient::searchWithGoogle): Instead, send the search string to WebPageProxy.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm

index 2d9d729..854a672 100644 (file)
@@ -1,3 +1,28 @@
+2013-03-11  Tim Horton  <timothy_horton@apple.com>
+
+        [wk2] Search With [your search provider here] should use NSPerformService in WebKit2/Mac
+        https://bugs.webkit.org/show_bug.cgi?id=111995
+        <rdar://problem/12975669>
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/WebPageProxy.h:
+        (WebPageProxy): Add searchTheWeb().
+        * UIProcess/WebPageProxy.messages.in: Add SearchTheWeb message.
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::searchTheWeb): Added. Call out to NSPerformService to search with the system default
+        search provider, in the browser.
+
+        * WebProcess/Plugins/PDF/PDFPlugin.h:
+        (PDFPlugin): Add performWebSearch().
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (-[WKPDFLayerControllerDelegate performWebSearch:]): Added, forward the delegate callback to PDFPlugin.
+        (WebKit::PDFPlugin::performWebSearch): Added, forward the search string to WebPageProxy.
+        * WebProcess/WebCoreSupport/WebContextMenuClient.cpp:
+        (WebKit::WebContextMenuClient::searchWithGoogle): Don't build the old load-Google-in-the-main-frame code on Mac.
+        * WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
+        (WebKit::WebContextMenuClient::searchWithGoogle): Instead, send the search string to WebPageProxy.
+
 2013-03-11  Helder Correia  <helder.correia@nokia.com>
 
         [WK2] Add C API preference: accelerated compositing for overflow scroll
index 5923d75..1d64528 100644 (file)
@@ -953,6 +953,8 @@ private:
 
     // Spotlight.
     void searchWithSpotlight(const String&);
+        
+    void searchTheWeb(const String&);
 
     // Dictionary.
     void didPerformDictionaryLookup(const AttributedString&, const DictionaryPopupInfo&);
index ebc44c5..babfc0e 100644 (file)
@@ -271,6 +271,8 @@ messages -> WebPageProxy {
 
     # Spotlight
     SearchWithSpotlight(WTF::String string)
+
+    SearchTheWeb(WTF::String string)
 #endif
 
 #if PLATFORM(MAC)
index cf41f64..80c157d 100644 (file)
@@ -117,6 +117,15 @@ void WebPageProxy::searchWithSpotlight(const String& string)
     [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:nsStringFromWebCoreString(string)];
 }
     
+void WebPageProxy::searchTheWeb(const String& string)
+{
+    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
+    [pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+    [pasteboard setString:string forType:NSStringPboardType];
+    
+    NSPerformService(@"Search With %WebSearchProvider@", pasteboard);
+}
+    
 CGContextRef WebPageProxy::containingWindowGraphicsContext()
 {
     return m_pageClient->containingWindowGraphicsContext();
index 71add7c..2259ebd 100644 (file)
@@ -79,6 +79,7 @@ public:
     void openWithNativeApplication();
     void writeItemsToPasteboard(NSArray *items, NSArray *types);
     void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
+    void performWebSearch(NSString *);
 
     void focusNextAnnotation();
     void focusPreviousAnnotation();
index 63780a3..5173c2f 100644 (file)
@@ -160,7 +160,7 @@ static const char* annotationStyle =
 
 - (void)performWebSearch:(NSString *)string
 {
-    // FIXME: Implement.
+    _pdfPlugin->performWebSearch(string);
 }
 
 - (void)openWithNativeApplication
@@ -975,6 +975,11 @@ String PDFPlugin::getSelectionString() const
     return [[m_pdfLayerController.get() currentSelection] string];
 }
 
+void PDFPlugin::performWebSearch(NSString *string)
+{
+    webFrame()->page()->send(Messages::WebPageProxy::SearchTheWeb(string));
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(PDFKIT_PLUGIN)
index e21280e..6bf9a47 100644 (file)
@@ -74,10 +74,9 @@ void WebContextMenuClient::downloadURL(const KURL&)
     ASSERT_NOT_REACHED();
 }
 
+#if !PLATFORM(MAC)
 void WebContextMenuClient::searchWithGoogle(const Frame* frame)
 {
-    // FIXME: this should use NSPerformService on Mac to support the system default search provider.
-
     String searchString = frame->editor()->selectedText();
     searchString.stripWhiteSpace();
     String encoded = encodeWithURLEscapeSequences(searchString);
@@ -90,6 +89,7 @@ void WebContextMenuClient::searchWithGoogle(const Frame* frame)
         page->mainFrame()->loader()->urlSelected(KURL(ParsedURLString, url), String(), 0, false, false, MaybeSendReferrer);
     }
 }
+#endif
 
 #if USE(ACCESSIBILITY_CONTEXT_MENUS)
 void WebContextMenuClient::showContextMenu()
index 81f2c34..d858f69 100644 (file)
@@ -61,6 +61,14 @@ void WebContextMenuClient::stopSpeaking()
     m_page->stopSpeaking();
 }
 
+void WebContextMenuClient::searchWithGoogle(const Frame* frame)
+{
+    String searchString = frame->editor()->selectedText();
+    searchString.stripWhiteSpace();
+    
+    m_page->send(Messages::WebPageProxy::SearchTheWeb(searchString));
+}
+
 void WebContextMenuClient::searchWithSpotlight()
 {
     // FIXME: Why do we need to search all the frames like this?