• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009, 2012 Google 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 are
6  * met:
7  *
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
13  * distribution.
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.
17  *
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.
29  */
30 
31 #ifndef WebContextMenuData_h
32 #define WebContextMenuData_h
33 
34 #include "../platform/WebPoint.h"
35 #include "../platform/WebReferrerPolicy.h"
36 #include "../platform/WebString.h"
37 #include "../platform/WebURL.h"
38 #include "../platform/WebVector.h"
39 #include "WebHistoryItem.h"
40 #include "WebMenuItemInfo.h"
41 #include "WebNode.h"
42 
43 #define WEBCONTEXT_MEDIATYPEFILE_DEFINED
44 
45 namespace blink {
46 
47 // This struct is passed to WebViewClient::ShowContextMenu.
48 struct WebContextMenuData {
49     enum MediaType {
50         // No special node is in context.
51         MediaTypeNone,
52         // An image node is selected.
53         MediaTypeImage,
54         // A video node is selected.
55         MediaTypeVideo,
56         // An audio node is selected.
57         MediaTypeAudio,
58         // A file node is selected.
59         MediaTypeFile,
60         // A plugin node is selected.
61         MediaTypePlugin,
62     };
63     // The type of media the context menu is being invoked on.
64     MediaType mediaType;
65 
66     // The x and y position of the mouse pointer (relative to the webview).
67     WebPoint mousePosition;
68 
69     // The absolute URL of the link that is in context.
70     WebURL linkURL;
71 
72     // The absolute URL of the image/video/audio that is in context.
73     WebURL srcURL;
74 
75     // Whether the image in context is a null.
76     bool hasImageContents;
77 
78     // The absolute URL of the page in context.
79     WebURL pageURL;
80 
81     // The absolute keyword search URL including the %s search tag when the
82     // "Add as search engine..." option is clicked (left empty if not used).
83     WebURL keywordURL;
84 
85     // The absolute URL of the subframe in context.
86     WebURL frameURL;
87 
88     // The encoding for the frame in context.
89     WebString frameEncoding;
90 
91     // History state of the subframe in context.
92     WebHistoryItem frameHistoryItem;
93 
94     enum MediaFlags {
95         MediaNone = 0x0,
96         MediaInError = 0x1,
97         MediaPaused = 0x2,
98         MediaMuted = 0x4,
99         MediaLoop = 0x8,
100         MediaCanSave = 0x10,
101         MediaHasAudio = 0x20,
102         MediaHasVideo = 0x40,
103         MediaControls = 0x80,
104         MediaCanPrint = 0x100,
105         MediaCanRotate = 0x200,
106     };
107 
108     // Extra attributes describing media elements.
109     int mediaFlags;
110 
111     // The raw text of the selection in context.
112     WebString selectedText;
113 
114     // Whether speech input is enabled.
115     bool isSpeechInputEnabled;
116 
117     // Whether spell checking is enabled.
118     bool isSpellCheckingEnabled;
119 
120     // The editable (possibily) misspelled word.
121     WebString misspelledWord;
122 
123     // The identifier of the misspelling.
124     uint32_t misspellingHash;
125 
126     // If misspelledWord is not empty, holds suggestions from the dictionary.
127     WebVector<WebString> dictionarySuggestions;
128 
129     // Whether context is editable.
130     bool isEditable;
131 
132     enum CheckableMenuItemFlags {
133         CheckableMenuItemDisabled = 0x0,
134         CheckableMenuItemEnabled = 0x1,
135         CheckableMenuItemChecked = 0x2,
136     };
137 
138     // Writing direction menu items - values are unions of
139     // CheckableMenuItemFlags.
140     int writingDirectionDefault;
141     int writingDirectionLeftToRight;
142     int writingDirectionRightToLeft;
143 
144     enum EditFlags {
145         CanDoNone = 0x0,
146         CanUndo = 0x1,
147         CanRedo = 0x2,
148         CanCut = 0x4,
149         CanCopy = 0x8,
150         CanPaste = 0x10,
151         CanDelete = 0x20,
152         CanSelectAll = 0x40,
153         CanTranslate = 0x80,
154     };
155 
156     // Which edit operations are available in the context.
157     int editFlags;
158 
159     // Security information for the context.
160     WebCString securityInfo;
161 
162     // The referrer policy applicable to this context.
163     WebReferrerPolicy referrerPolicy;
164 
165     // Custom context menu items provided by the WebCore internals.
166     WebVector<WebMenuItemInfo> customItems;
167 
168     // The node that was clicked.
169     WebNode node;
170 
WebContextMenuDataWebContextMenuData171     WebContextMenuData()
172         : mediaType(MediaTypeNone)
173         , hasImageContents(true)
174         , mediaFlags(MediaNone)
175         , isSpeechInputEnabled(false)
176         , isSpellCheckingEnabled(false)
177         , isEditable(false)
178         , writingDirectionDefault(CheckableMenuItemDisabled)
179         , writingDirectionLeftToRight(CheckableMenuItemEnabled)
180         , writingDirectionRightToLeft(CheckableMenuItemEnabled)
181         , editFlags(0) { }
182 };
183 
184 } // namespace blink
185 
186 #endif
187