Upstream version 7.36.149.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 WebContents;
16 }
17
18 namespace extensions {
19 class Extension;
20 }
21
22 // ContextMenuContentType is a helper to decide which category/group of items
23 // are relevant for a given WebContents and a context.
24 //
25 // Subclasses can override the behavior of showing/hiding a category.
26 class ContextMenuContentType {
27  public:
28   virtual ~ContextMenuContentType();
29
30   // Represents a group of menu items.
31   // Order matters as they are appended in the enum order.
32   enum ItemGroup {
33     ITEM_GROUP_CUSTOM,
34     ITEM_GROUP_PAGE,
35     ITEM_GROUP_FRAME,
36     ITEM_GROUP_LINK,
37     ITEM_GROUP_MEDIA_IMAGE,
38     ITEM_GROUP_SEARCHWEBFORIMAGE,
39     ITEM_GROUP_MEDIA_VIDEO,
40     ITEM_GROUP_MEDIA_AUDIO,
41     ITEM_GROUP_MEDIA_CANVAS,
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       const content::ContextMenuParams& params);
58
59   // Returns if |group| is enabled.
60   virtual bool SupportsGroup(int group);
61
62  protected:
63   ContextMenuContentType(content::WebContents* web_contents,
64                          const content::ContextMenuParams& params,
65                          bool supports_custom_items);
66
67   const content::ContextMenuParams& params() const { return params_; }
68
69   const extensions::Extension* GetExtension() const;
70
71  private:
72   friend class ContextMenuContentTypeFactory;
73   friend class ContextMenuContentTypeTest;
74
75   bool SupportsGroupInternal(int group);
76
77   const content::ContextMenuParams params_;
78   content::WebContents* source_web_contents_;
79   Profile* profile_;
80   const bool supports_custom_items_;
81
82   DISALLOW_COPY_AND_ASSIGN(ContextMenuContentType);
83 };
84
85 #endif  // CHROME_BROWSER_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_