Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / renderer_context_menu / context_menu_content_type.h
1 // Copyright 2014 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 CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
7
8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
9 #include "content/public/common/context_menu_params.h"
10 #include "ui/base/models/simple_menu_model.h"
11
12 class Profile;
13
14 namespace content {
15 class RenderFrameHost;
16 class WebContents;
17 }
18
19 namespace extensions {
20 class Extension;
21 }
22
23 // ContextMenuContentType is a helper to decide which category/group of items
24 // are relevant for a given RenderFrameHost and a context.
25 //
26 // Subclasses can override the behavior of showing/hiding a category.
27 class ContextMenuContentType {
28  public:
29   virtual ~ContextMenuContentType();
30
31   // Represents a group of menu items.
32   // Order matters as they are appended in the enum order.
33   enum ItemGroup {
34     ITEM_GROUP_CUSTOM,
35     ITEM_GROUP_PAGE,
36     ITEM_GROUP_FRAME,
37     ITEM_GROUP_LINK,
38     ITEM_GROUP_MEDIA_IMAGE,
39     ITEM_GROUP_SEARCHWEBFORIMAGE,
40     ITEM_GROUP_MEDIA_VIDEO,
41     ITEM_GROUP_MEDIA_AUDIO,
42     ITEM_GROUP_MEDIA_PLUGIN,
43     ITEM_GROUP_MEDIA_FILE,
44     ITEM_GROUP_EDITABLE,
45     ITEM_GROUP_COPY,
46     ITEM_GROUP_SEARCH_PROVIDER,
47     ITEM_GROUP_PRINT,
48     ITEM_GROUP_ALL_EXTENSION,
49     ITEM_GROUP_CURRENT_EXTENSION,
50     ITEM_GROUP_DEVELOPER,
51     ITEM_GROUP_DEVTOOLS_UNPACKED_EXT,
52     ITEM_GROUP_PRINT_PREVIEW
53   };
54
55   static ContextMenuContentType* Create(
56       content::WebContents* web_contents,
57       content::RenderFrameHost* render_frame_host,
58       const content::ContextMenuParams& params);
59
60   // Returns if |group| is enabled.
61   virtual bool SupportsGroup(int group);
62
63  protected:
64   ContextMenuContentType(content::RenderFrameHost* render_frame_host,
65                          const content::ContextMenuParams& params,
66                          bool supports_custom_items);
67
68   const content::ContextMenuParams& params() const { return params_; }
69
70   const extensions::Extension* GetExtension() const;
71
72  private:
73   friend class ContextMenuContentTypeFactory;
74   friend class ContextMenuContentTypeTest;
75
76   bool SupportsGroupInternal(int group);
77
78   const content::ContextMenuParams params_;
79   content::WebContents* source_web_contents_;
80   Profile* profile_;
81   const bool supports_custom_items_;
82
83   DISALLOW_COPY_AND_ASSIGN(ContextMenuContentType);
84 };
85
86 #endif  // CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_