1/*
2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef WKPageContextMenuClient_h
27#define WKPageContextMenuClient_h
28
29#include <WebKit/WKBase.h>
30#include <WebKit/WKGeometry.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo);
37typedef void (*WKPageGetContextMenuFromProposedContextMenuCallbackAsync)(WKPageRef page, WKArrayRef proposedMenu, WKContextMenuListenerRef listener, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo);
38typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo);
39typedef void (*WKPageContextMenuDismissedCallback)(WKPageRef page, const void* clientInfo);
40typedef void (*WKPageShowContextMenuCallback)(WKPageRef page, WKPoint menuLocation, WKArrayRef menuItems, const void* clientInfo);
41typedef void (*WKPageHideContextMenuCallback)(WKPageRef page, const void* clientInfo);
42
43// Deprecated
44typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo);
45
46typedef struct WKPageContextMenuClientBase {
47 int version;
48 const void * clientInfo;
49} WKPageContextMenuClientBase;
50
51typedef struct WKPageContextMenuClientV0 {
52 WKPageContextMenuClientBase base;
53
54 // Version 0.
55 WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0 getContextMenuFromProposedMenu_deprecatedForUseWithV0;
56 WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
57} WKPageContextMenuClientV0;
58
59typedef struct WKPageContextMenuClientV1 {
60 WKPageContextMenuClientBase base;
61
62 // Version 0.
63 WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0 getContextMenuFromProposedMenu_deprecatedForUseWithV0;
64 WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
65
66 // Version 1.
67 WKPageContextMenuDismissedCallback contextMenuDismissed;
68} WKPageContextMenuClientV1;
69
70typedef struct WKPageContextMenuClientV2 {
71 WKPageContextMenuClientBase base;
72
73 // Version 0.
74 WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0 getContextMenuFromProposedMenu_deprecatedForUseWithV0;
75 WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
76
77 // Version 1.
78 WKPageContextMenuDismissedCallback contextMenuDismissed;
79
80 // Version 2.
81 WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu;
82} WKPageContextMenuClientV2;
83
84typedef struct WKPageContextMenuClientV3 {
85 WKPageContextMenuClientBase base;
86
87 // Version 0.
88 WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0 getContextMenuFromProposedMenu_deprecatedForUseWithV0;
89 WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
90
91 // Version 1.
92 WKPageContextMenuDismissedCallback contextMenuDismissed;
93
94 // Version 2.
95 WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu;
96
97 // Version 3.
98 WKPageShowContextMenuCallback showContextMenu;
99 WKPageHideContextMenuCallback hideContextMenu;
100} WKPageContextMenuClientV3;
101
102typedef struct WKPageContextMenuClientV4 {
103 WKPageContextMenuClientBase base;
104
105 // Version 0.
106 WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0 getContextMenuFromProposedMenu_deprecatedForUseWithV0;
107 WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
108
109 // Version 1.
110 WKPageContextMenuDismissedCallback contextMenuDismissed;
111
112 // Version 2.
113 WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu;
114
115 // Version 3.
116 WKPageShowContextMenuCallback showContextMenu;
117 WKPageHideContextMenuCallback hideContextMenu;
118
119 // Version 4.
120 WKPageGetContextMenuFromProposedContextMenuCallbackAsync getContextMenuFromProposedMenuAsync;
121
122} WKPageContextMenuClientV4;
123
124#ifdef __cplusplus
125}
126#endif
127
128
129#endif // WKPageContextMenuClient_h
130