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