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 canvas node is selected. 59 MediaTypeCanvas, 60 // A file node is selected. 61 MediaTypeFile, 62 // A plugin node is selected. 63 MediaTypePlugin, 64 MediaTypeLast = MediaTypePlugin 65 }; 66 // The type of media the context menu is being invoked on. 67 MediaType mediaType; 68 69 // The x and y position of the mouse pointer (relative to the webview). 70 WebPoint mousePosition; 71 72 // The absolute URL of the link that is in context. 73 WebURL linkURL; 74 75 // The absolute URL of the image/video/audio that is in context. 76 WebURL srcURL; 77 78 // Whether the image in context is a null. 79 bool hasImageContents; 80 81 // The absolute URL of the page in context. 82 WebURL pageURL; 83 84 // The absolute keyword search URL including the %s search tag when the 85 // "Add as search engine..." option is clicked (left empty if not used). 86 WebURL keywordURL; 87 88 // The absolute URL of the subframe in context. 89 WebURL frameURL; 90 91 // The encoding for the frame in context. 92 WebString frameEncoding; 93 94 // History state of the subframe in context. 95 WebHistoryItem frameHistoryItem; 96 97 enum MediaFlags { 98 MediaNone = 0x0, 99 MediaInError = 0x1, 100 MediaPaused = 0x2, 101 MediaMuted = 0x4, 102 MediaLoop = 0x8, 103 MediaCanSave = 0x10, 104 MediaHasAudio = 0x20, 105 MediaCanToggleControls = 0x40, 106 MediaControls = 0x80, 107 MediaCanPrint = 0x100, 108 MediaCanRotate = 0x200, 109 }; 110 111 // Extra attributes describing media elements. 112 int mediaFlags; 113 114 // The raw text of the selection in context. 115 WebString selectedText; 116 117 // Whether spell checking is enabled. 118 bool isSpellCheckingEnabled; 119 120 // Suggested filename for saving file. 121 WebString suggestedFilename; 122 123 // The editable (possibily) misspelled word. 124 WebString misspelledWord; 125 126 // The identifier of the misspelling. 127 uint32_t misspellingHash; 128 129 // If misspelledWord is not empty, holds suggestions from the dictionary. 130 WebVector<WebString> dictionarySuggestions; 131 132 // Whether context is editable. 133 bool isEditable; 134 135 enum CheckableMenuItemFlags { 136 CheckableMenuItemDisabled = 0x0, 137 CheckableMenuItemEnabled = 0x1, 138 CheckableMenuItemChecked = 0x2, 139 }; 140 141 // Writing direction menu items - values are unions of 142 // CheckableMenuItemFlags. 143 int writingDirectionDefault; 144 int writingDirectionLeftToRight; 145 int writingDirectionRightToLeft; 146 147 enum EditFlags { 148 CanDoNone = 0x0, 149 CanUndo = 0x1, 150 CanRedo = 0x2, 151 CanCut = 0x4, 152 CanCopy = 0x8, 153 CanPaste = 0x10, 154 CanDelete = 0x20, 155 CanSelectAll = 0x40, 156 CanTranslate = 0x80, 157 }; 158 159 // Which edit operations are available in the context. 160 int editFlags; 161 162 // Security information for the context. 163 WebCString securityInfo; 164 165 // The referrer policy applicable to this context. 166 WebReferrerPolicy referrerPolicy; 167 168 // Custom context menu items provided by the WebCore internals. 169 WebVector<WebMenuItemInfo> customItems; 170 171 // The node that was clicked. 172 WebNode node; 173 WebContextMenuDataWebContextMenuData174 WebContextMenuData() 175 : mediaType(MediaTypeNone) 176 , hasImageContents(true) 177 , mediaFlags(MediaNone) 178 , isSpellCheckingEnabled(false) 179 , misspellingHash(0) 180 , isEditable(false) 181 , writingDirectionDefault(CheckableMenuItemDisabled) 182 , writingDirectionLeftToRight(CheckableMenuItemEnabled) 183 , writingDirectionRightToLeft(CheckableMenuItemEnabled) 184 , editFlags(0) { } 185 }; 186 187 } // namespace blink 188 189 #endif 190