2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef WebContextMenuData_h
32 #define WebContextMenuData_h
34 #include "../platform/WebPoint.h"
35 #include "../platform/WebReferrerPolicy.h"
36 #include "../platform/WebString.h"
37 #include "../platform/WebURL.h"
38 #include "../platform/WebURLResponse.h"
39 #include "../platform/WebVector.h"
40 #include "WebHistoryItem.h"
41 #include "WebMenuItemInfo.h"
44 #define WEBCONTEXT_MEDIATYPEFILE_DEFINED
48 // This struct is passed to WebViewClient::ShowContextMenu.
49 struct WebContextMenuData
{
51 // No special node is in context.
53 // An image node is selected.
55 // A video node is selected.
57 // An audio node is selected.
59 // A canvas node is selected.
61 // A file node is selected.
63 // A plugin node is selected.
65 MediaTypeLast
= MediaTypePlugin
67 // The type of media the context menu is being invoked on.
70 // The x and y position of the mouse pointer (relative to the webview).
71 WebPoint mousePosition
;
73 // The absolute URL of the link that is in context.
76 // The absolute URL of the image/video/audio that is in context.
79 // Whether the image in context is a null.
80 bool hasImageContents
;
82 // If |media_type| is MediaTypeImage and |has_image_contents| is true, then
83 // this contains the image's WebURLResponse.
84 WebURLResponse imageResponse
;
86 // The absolute URL of the page in context.
89 // The absolute keyword search URL including the %s search tag when the
90 // "Add as search engine..." option is clicked (left empty if not used).
93 // The absolute URL of the subframe in context.
96 // The encoding for the frame in context.
97 WebString frameEncoding
;
99 // History state of the subframe in context.
100 WebHistoryItem frameHistoryItem
;
109 MediaHasAudio
= 0x20,
110 MediaCanToggleControls
= 0x40,
111 MediaControls
= 0x80,
112 MediaCanPrint
= 0x100,
113 MediaCanRotate
= 0x200,
116 // Extra attributes describing media elements.
119 // The text of the link that is in the context.
122 // The raw text of the selection in context.
123 WebString selectedText
;
125 // Title attribute or alt attribute (if title is not available) of the selection in context.
128 // Whether spell checking is enabled.
129 bool isSpellCheckingEnabled
;
131 // Suggested filename for saving file.
132 WebString suggestedFilename
;
134 // The editable (possibily) misspelled word.
135 WebString misspelledWord
;
137 // The identifier of the misspelling.
138 uint32_t misspellingHash
;
140 // If misspelledWord is not empty, holds suggestions from the dictionary.
141 WebVector
<WebString
> dictionarySuggestions
;
143 // Whether context is editable.
146 enum InputFieldType
{
147 // Not an input field.
149 // type = text, tel, search, number, email, url
150 InputFieldTypePlainText
,
152 InputFieldTypePassword
,
155 InputFieldTypeLast
= InputFieldTypeOther
158 // If this node is an input field, the type of that field.
159 InputFieldType inputFieldType
;
161 enum CheckableMenuItemFlags
{
162 CheckableMenuItemDisabled
= 0x0,
163 CheckableMenuItemEnabled
= 0x1,
164 CheckableMenuItemChecked
= 0x2,
167 // Writing direction menu items - values are unions of
168 // CheckableMenuItemFlags.
169 int writingDirectionDefault
;
170 int writingDirectionLeftToRight
;
171 int writingDirectionRightToLeft
;
185 // Which edit operations are available in the context.
188 // Security information for the context.
189 WebCString securityInfo
;
191 // The referrer policy applicable to this context.
192 WebReferrerPolicy referrerPolicy
;
194 // Custom context menu items provided by the WebCore internals.
195 WebVector
<WebMenuItemInfo
> customItems
;
197 // The node that was clicked.
201 : mediaType(MediaTypeNone
)
202 , hasImageContents(true)
203 , mediaFlags(MediaNone
)
204 , isSpellCheckingEnabled(false)
207 , writingDirectionDefault(CheckableMenuItemDisabled
)
208 , writingDirectionLeftToRight(CheckableMenuItemEnabled
)
209 , writingDirectionRightToLeft(CheckableMenuItemEnabled
)