1 /* 2 * Copyright (C) 2009 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 "WebMenuItemInfo.h" 35 #include "WebPoint.h" 36 #include "WebString.h" 37 #include "WebURL.h" 38 #include "WebVector.h" 39 40 namespace WebKit { 41 42 // This struct is passed to WebViewClient::ShowContextMenu. 43 struct WebContextMenuData { 44 enum MediaType { 45 // No special node is in context. 46 MediaTypeNone, 47 // An image node is selected. 48 MediaTypeImage, 49 // A video node is selected. 50 MediaTypeVideo, 51 // An audio node is selected. 52 MediaTypeAudio, 53 }; 54 // The type of media the context menu is being invoked on. 55 MediaType mediaType; 56 57 // The x and y position of the mouse pointer (relative to the webview). 58 WebPoint mousePosition; 59 60 // The absolute URL of the link that is in context. 61 WebURL linkURL; 62 63 // The absolute URL of the image/video/audio that is in context. 64 WebURL srcURL; 65 66 // The absolute URL of the page in context. 67 WebURL pageURL; 68 69 // The absolute URL of the subframe in context. 70 WebURL frameURL; 71 72 // The encoding for the frame in context. 73 WebString frameEncoding; 74 75 enum MediaFlags { 76 MediaNone = 0x0, 77 MediaInError = 0x1, 78 MediaPaused = 0x2, 79 MediaMuted = 0x4, 80 MediaLoop = 0x8, 81 MediaCanSave = 0x10, 82 MediaHasAudio = 0x20, 83 }; 84 85 // Extra attributes describing media elements. 86 int mediaFlags; 87 88 // The raw text of the selection in context. 89 WebString selectedText; 90 91 // Whether spell checking is enabled. 92 bool isSpellCheckingEnabled; 93 94 // The editable (possibily) misspelled word. 95 WebString misspelledWord; 96 97 // Whether context is editable. 98 bool isEditable; 99 100 enum CheckableMenuItemFlags { 101 CheckableMenuItemDisabled = 0x0, 102 CheckableMenuItemEnabled = 0x1, 103 CheckableMenuItemChecked = 0x2, 104 }; 105 106 // Writing direction menu items - values are unions of 107 // CheckableMenuItemFlags. 108 // Currently only used on OS X. 109 int writingDirectionDefault; 110 int writingDirectionLeftToRight; 111 int writingDirectionRightToLeft; 112 113 enum EditFlags { 114 CanDoNone = 0x0, 115 CanUndo = 0x1, 116 CanRedo = 0x2, 117 CanCut = 0x4, 118 CanCopy = 0x8, 119 CanPaste = 0x10, 120 CanDelete = 0x20, 121 CanSelectAll = 0x40, 122 }; 123 124 // Which edit operations are available in the context. 125 int editFlags; 126 127 // Security information for the context. 128 WebCString securityInfo; 129 130 // Custom context menu items provided by the WebCore internals. 131 WebVector<WebMenuItemInfo> customItems; 132 }; 133 134 } // namespace WebKit 135 136 #endif 137