WebKit/chromium/public/WebContextMenuData.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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     // Whether the image in context has been blocked.
       
    67     bool isImageBlocked;
       
    68 
       
    69     // The absolute URL of the page in context.
       
    70     WebURL pageURL;
       
    71 
       
    72     // The absolute URL of the subframe in context.
       
    73     WebURL frameURL;
       
    74 
       
    75     // The encoding for the frame in context.
       
    76     WebString frameEncoding;
       
    77 
       
    78     enum MediaFlags {
       
    79         MediaNone = 0x0,
       
    80         MediaInError = 0x1,
       
    81         MediaPaused = 0x2,
       
    82         MediaMuted = 0x4,
       
    83         MediaLoop = 0x8,
       
    84         MediaCanSave = 0x10,
       
    85         MediaHasAudio = 0x20,
       
    86         MediaHasVideo = 0x40,
       
    87         MediaControls = 0x80,
       
    88     };
       
    89 
       
    90     // Extra attributes describing media elements.
       
    91     int mediaFlags;
       
    92 
       
    93     // The raw text of the selection in context.
       
    94     WebString selectedText;
       
    95 
       
    96     // Whether spell checking is enabled.
       
    97     bool isSpellCheckingEnabled;
       
    98 
       
    99     // The editable (possibily) misspelled word.
       
   100     WebString misspelledWord;
       
   101 
       
   102     // Whether context is editable.
       
   103     bool isEditable;
       
   104 
       
   105     enum CheckableMenuItemFlags {
       
   106         CheckableMenuItemDisabled = 0x0,
       
   107         CheckableMenuItemEnabled = 0x1,
       
   108         CheckableMenuItemChecked = 0x2,
       
   109     };
       
   110 
       
   111     // Writing direction menu items - values are unions of
       
   112     // CheckableMenuItemFlags.
       
   113     // Currently only used on OS X.
       
   114     int writingDirectionDefault;
       
   115     int writingDirectionLeftToRight;
       
   116     int writingDirectionRightToLeft;
       
   117 
       
   118     enum EditFlags {
       
   119         CanDoNone = 0x0,
       
   120         CanUndo = 0x1,
       
   121         CanRedo = 0x2,
       
   122         CanCut = 0x4,
       
   123         CanCopy = 0x8,
       
   124         CanPaste = 0x10,
       
   125         CanDelete = 0x20,
       
   126         CanSelectAll = 0x40,
       
   127         CanTranslate = 0x80,
       
   128     };
       
   129 
       
   130     // Which edit operations are available in the context.
       
   131     int editFlags;
       
   132 
       
   133     // Security information for the context.
       
   134     WebCString securityInfo;
       
   135 
       
   136     // Custom context menu items provided by the WebCore internals.
       
   137     WebVector<WebMenuItemInfo> customItems;
       
   138 
       
   139     WebContextMenuData()
       
   140         : mediaType(MediaTypeNone)
       
   141         , isImageBlocked(false)
       
   142         , mediaFlags(MediaNone)
       
   143         , isSpellCheckingEnabled(false)
       
   144         , isEditable(false)
       
   145         , writingDirectionDefault(CheckableMenuItemDisabled)
       
   146         , writingDirectionLeftToRight(CheckableMenuItemEnabled)
       
   147         , writingDirectionRightToLeft(CheckableMenuItemEnabled)
       
   148         , editFlags(0) { }
       
   149 };
       
   150 
       
   151 } // namespace WebKit
       
   152 
       
   153 #endif