Home | History | Annotate | Download | only in public
      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 "WebHistoryItem.h"
     35 #include "WebMenuItemInfo.h"
     36 #include "WebNode.h"
     37 #include "WebPoint.h"
     38 #include "WebString.h"
     39 #include "WebURL.h"
     40 #include "WebVector.h"
     41 
     42 #define WEBCONTEXT_MEDIATYPEFILE_DEFINED
     43 
     44 namespace WebKit {
     45 
     46 // This struct is passed to WebViewClient::ShowContextMenu.
     47 struct WebContextMenuData {
     48     enum MediaType {
     49         // No special node is in context.
     50         MediaTypeNone,
     51         // An image node is selected.
     52         MediaTypeImage,
     53         // A video node is selected.
     54         MediaTypeVideo,
     55         // An audio node is selected.
     56         MediaTypeAudio,
     57         // A file node is selected.
     58         MediaTypeFile,
     59         // A plugin node is selected.
     60         MediaTypePlugin,
     61     };
     62     // The type of media the context menu is being invoked on.
     63     MediaType mediaType;
     64 
     65     // The x and y position of the mouse pointer (relative to the webview).
     66     WebPoint mousePosition;
     67 
     68     // The absolute URL of the link that is in context.
     69     WebURL linkURL;
     70 
     71     // The absolute URL of the image/video/audio that is in context.
     72     WebURL srcURL;
     73 
     74     // Whether the image in context has been blocked.
     75     bool isImageBlocked;
     76 
     77     // The absolute URL of the page in context.
     78     WebURL pageURL;
     79 
     80     // The absolute URL of the subframe in context.
     81     WebURL frameURL;
     82 
     83     // The encoding for the frame in context.
     84     WebString frameEncoding;
     85 
     86     // History state of the subframe in context.
     87     WebHistoryItem frameHistoryItem;
     88 
     89     enum MediaFlags {
     90         MediaNone = 0x0,
     91         MediaInError = 0x1,
     92         MediaPaused = 0x2,
     93         MediaMuted = 0x4,
     94         MediaLoop = 0x8,
     95         MediaCanSave = 0x10,
     96         MediaHasAudio = 0x20,
     97         MediaHasVideo = 0x40,
     98         MediaControlRootElement = 0x80,
     99         MediaCanPrint = 0x100,
    100     };
    101 
    102     // Extra attributes describing media elements.
    103     int mediaFlags;
    104 
    105     // The raw text of the selection in context.
    106     WebString selectedText;
    107 
    108     // Whether spell checking is enabled.
    109     bool isSpellCheckingEnabled;
    110 
    111     // The editable (possibily) misspelled word.
    112     WebString misspelledWord;
    113 
    114     // If misspelledWord is not empty, holds suggestions from the dictionary.
    115     WebVector<WebString> dictionarySuggestions;
    116 
    117     // Whether context is editable.
    118     bool isEditable;
    119 
    120     enum CheckableMenuItemFlags {
    121         CheckableMenuItemDisabled = 0x0,
    122         CheckableMenuItemEnabled = 0x1,
    123         CheckableMenuItemChecked = 0x2,
    124     };
    125 
    126     // Writing direction menu items - values are unions of
    127     // CheckableMenuItemFlags.
    128     // Currently only used on OS X.
    129     int writingDirectionDefault;
    130     int writingDirectionLeftToRight;
    131     int writingDirectionRightToLeft;
    132 
    133     enum EditFlags {
    134         CanDoNone = 0x0,
    135         CanUndo = 0x1,
    136         CanRedo = 0x2,
    137         CanCut = 0x4,
    138         CanCopy = 0x8,
    139         CanPaste = 0x10,
    140         CanDelete = 0x20,
    141         CanSelectAll = 0x40,
    142         CanTranslate = 0x80,
    143     };
    144 
    145     // Which edit operations are available in the context.
    146     int editFlags;
    147 
    148     // Security information for the context.
    149     WebCString securityInfo;
    150 
    151     // Custom context menu items provided by the WebCore internals.
    152     WebVector<WebMenuItemInfo> customItems;
    153 
    154     // The node that was clicked.
    155     WebNode node;
    156 
    157     WebContextMenuData()
    158         : mediaType(MediaTypeNone)
    159         , isImageBlocked(false)
    160         , mediaFlags(MediaNone)
    161         , isSpellCheckingEnabled(false)
    162         , isEditable(false)
    163         , writingDirectionDefault(CheckableMenuItemDisabled)
    164         , writingDirectionLeftToRight(CheckableMenuItemEnabled)
    165         , writingDirectionRightToLeft(CheckableMenuItemEnabled)
    166         , editFlags(0) { }
    167 };
    168 
    169 } // namespace WebKit
    170 
    171 #endif
    172