Home | History | Annotate | Download | only in glue
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef WEBKIT_GLUE_CONTEXT_MENU_H_
      6 #define WEBKIT_GLUE_CONTEXT_MENU_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/string16.h"
     12 #include "googleurl/src/gurl.h"
     13 #include "webkit/glue/webmenuitem.h"
     14 
     15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
     16 
     17 namespace webkit_glue {
     18 
     19 struct CustomContextMenuContext {
     20   bool is_pepper_menu;
     21   int request_id;
     22   // The routing ID of the render widget on which the context menu is shown.
     23   // It could also be |kCurrentRenderWidget|, which means the render widget that
     24   // the corresponding ViewHostMsg_ContextMenu is sent to.
     25   int32 render_widget_id;
     26   static const int32 kCurrentRenderWidget;
     27 
     28   CustomContextMenuContext();
     29 };
     30 
     31 }  // namespace webkit_glue
     32 
     33 // TODO(viettrungluu): Put this in the webkit_glue namespace.
     34 // Parameters structure for ViewHostMsg_ContextMenu.
     35 // FIXME(beng): This would be more useful in the future and more efficient
     36 //              if the parameters here weren't so literally mapped to what
     37 //              they contain for the ContextMenu task. It might be better
     38 //              to make the string fields more generic so that this object
     39 //              could be used for more contextual actions.
     40 struct ContextMenuParams {
     41   // This is the type of Context Node that the context menu was invoked on.
     42   WebKit::WebContextMenuData::MediaType media_type;
     43 
     44   // These values represent the coordinates of the mouse when the context menu
     45   // was invoked.  Coords are relative to the associated RenderView's origin.
     46   int x;
     47   int y;
     48 
     49   // This is the URL of the link that encloses the node the context menu was
     50   // invoked on.
     51   GURL link_url;
     52 
     53   // The link URL to be used ONLY for "copy link address". We don't validate
     54   // this field in the frontend process.
     55   GURL unfiltered_link_url;
     56 
     57   // This is the source URL for the element that the context menu was
     58   // invoked on.  Example of elements with source URLs are img, audio, and
     59   // video.
     60   GURL src_url;
     61 
     62   // This is true if the context menu was invoked on a blocked image.
     63   bool is_image_blocked;
     64 
     65   // This is the URL of the top level page that the context menu was invoked
     66   // on.
     67   GURL page_url;
     68 
     69   // This is the URL of the subframe that the context menu was invoked on.
     70   GURL frame_url;
     71 
     72   // This is the history item state of the subframe that the context menu was
     73   // invoked on.
     74   std::string frame_content_state;
     75 
     76   // These are the parameters for the media element that the context menu
     77   // was invoked on.
     78   int media_flags;
     79 
     80   // This is the text of the selection that the context menu was invoked on.
     81   string16 selection_text;
     82 
     83   // The misspelled word under the cursor, if any. Used to generate the
     84   // |dictionary_suggestions| list.
     85   string16 misspelled_word;
     86 
     87   // Suggested replacements for a misspelled word under the cursor.
     88   // This vector gets populated in the render process host
     89   // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
     90   // and populating dictionary_suggestions if the type is EDITABLE
     91   // and the misspelled_word is not empty.
     92   std::vector<string16> dictionary_suggestions;
     93 
     94   // If editable, flag for whether spell check is enabled or not.
     95   bool spellcheck_enabled;
     96 
     97   // Whether context is editable.
     98   bool is_editable;
     99 
    100 #if defined(OS_MACOSX)
    101   // Writing direction menu items.
    102   // Currently only used on OS X.
    103   int writing_direction_default;
    104   int writing_direction_left_to_right;
    105   int writing_direction_right_to_left;
    106 #endif  // OS_MACOSX
    107 
    108   // These flags indicate to the browser whether the renderer believes it is
    109   // able to perform the corresponding action.
    110   int edit_flags;
    111 
    112   // The security info for the resource we are showing the menu on.
    113   std::string security_info;
    114 
    115   // The character encoding of the frame on which the menu is invoked.
    116   std::string frame_charset;
    117 
    118   webkit_glue::CustomContextMenuContext custom_context;
    119   std::vector<WebMenuItem> custom_items;
    120 
    121   ContextMenuParams();
    122   ContextMenuParams(const WebKit::WebContextMenuData& data);
    123   ~ContextMenuParams();
    124 };
    125 
    126 #endif  // WEBKIT_GLUE_CONTEXT_MENU_H_
    127