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 // 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 171 WebContextMenuData() 172 : mediaType(MediaTypeNone) 173 , hasImageContents(true) 174 , mediaFlags(MediaNone) 175 , isSpellCheckingEnabled(false) 176 , isEditable(false) 177 , writingDirectionDefault(CheckableMenuItemDisabled) 178 , writingDirectionLeftToRight(CheckableMenuItemEnabled) 179 , writingDirectionRightToLeft(CheckableMenuItemEnabled) 180 , editFlags(0) { } 181 }; 182 183 } // namespace blink 184 185 #endif 186