1/* 2 * Copyright (C) 2012 Igalia S.L. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#include "config.h" 21#include "WebKitContextMenuClient.h" 22 23#include "WebKitPrivate.h" 24#include "WebKitWebViewBasePrivate.h" 25#include "WebKitWebViewPrivate.h" 26 27using namespace WebKit; 28 29static void getContextMenuFromProposedMenu(WKPageRef, WKArrayRef proposedMenu, WKArrayRef*, WKHitTestResultRef hitTestResult, WKTypeRef /* userData */, const void* clientInfo) 30{ 31 webkitWebViewPopulateContextMenu(WEBKIT_WEB_VIEW(clientInfo), toImpl(proposedMenu), toImpl(hitTestResult)); 32} 33 34void attachContextMenuClientToView(WebKitWebView* webView) 35{ 36 WKPageContextMenuClientV3 wkContextMenuClient = { 37 { 38 3, // version 39 webView, // clientInfo 40 }, 41 0, // getContextMenuFromProposedMenu_deprecatedForUseWithV0 42 0, // customContextMenuItemSelected 43 0, // contextMenuDismissed 44 getContextMenuFromProposedMenu, 45 0, // showContextMenu 46 0, // hideContextMenu 47 }; 48 WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); 49 WKPageSetPageContextMenuClient(wkPage, &wkContextMenuClient.base); 50} 51 52