WebContextMenuClient.cpp [plain text]
#include "WebContextMenuClient.h"
#include "WebElementPropertyBag.h"
#include "WebLocalizableStrings.h"
#include "WebView.h"
#include <WebCore/ContextMenuController.h>
#include <WebCore/Editor.h>
#include <WebCore/Event.h>
#include <WebCore/Frame.h>
#include <WebCore/FrameLoader.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/Page.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/UserGestureIndicator.h>
using namespace WebCore;
WebContextMenuClient::WebContextMenuClient(WebView* webView)
: m_webView(webView)
{
}
void WebContextMenuClient::contextMenuDestroyed()
{
delete this;
}
void WebContextMenuClient::downloadURL(const URL& url)
{
m_webView->downloadURL(url);
}
void WebContextMenuClient::searchWithGoogle(const Frame* frame)
{
String searchString = frame->editor().selectedText();
searchString.stripWhiteSpace();
String encoded = encodeWithURLEscapeSequences(searchString);
encoded.replace("%20"_s, "+"_s);
String url = "https://www.google.com/search?q=" + encoded + "&ie=UTF-8&oe=UTF-8";
if (Page* page = frame->page()) {
UserGestureIndicator indicator(ProcessingUserGesture);
page->mainFrame().loader().urlSelected(URL { URL { }, url }, { }, nullptr, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, ShouldOpenExternalURLsPolicy::ShouldNotAllow);
}
}
void WebContextMenuClient::lookUpInDictionary(Frame*)
{
notImplemented();
}
void WebContextMenuClient::speak(const String&)
{
notImplemented();
}
void WebContextMenuClient::stopSpeaking()
{
notImplemented();
}
bool WebContextMenuClient::isSpeaking()
{
notImplemented();
return false;
}