File: context_menu_content_type.h

package info (click to toggle)
qt6-webengine 6.4.2-final%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,090,536 kB
  • sloc: cpp: 17,808,031; ansic: 5,245,139; javascript: 3,178,881; python: 1,361,176; asm: 648,577; xml: 571,140; java: 196,952; sh: 96,408; objc: 88,289; perl: 70,982; cs: 39,145; fortran: 24,137; makefile: 20,242; pascal: 12,634; sql: 10,875; yacc: 9,671; tcl: 8,385; php: 6,188; lisp: 2,848; lex: 2,263; ada: 727; ruby: 623; awk: 339; sed: 37
file content (77 lines) | stat: -rw-r--r-- 2,385 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_
#define COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_

#include "base/memory/raw_ptr.h"
#include "content/public/browser/context_menu_params.h"
#include "ui/base/models/simple_menu_model.h"

namespace content {
class WebContents;
}

// ContextMenuContentType is a helper to decide which category/group of items
// are relevant for a given WebContents and a context.
//
// Subclasses can override the behavior of showing/hiding a category.
class ContextMenuContentType {
 public:
  ContextMenuContentType(const ContextMenuContentType&) = delete;
  ContextMenuContentType& operator=(const ContextMenuContentType&) = delete;

  virtual ~ContextMenuContentType();

  // Represents a group of menu items.
  // Order matters as they are appended in the enum order.
  enum ItemGroup {
    ITEM_GROUP_CUSTOM,
    ITEM_GROUP_PAGE,
    ITEM_GROUP_FRAME,
    ITEM_GROUP_LINK,
    ITEM_GROUP_SMART_SELECTION,
    ITEM_GROUP_MEDIA_IMAGE,
    ITEM_GROUP_SEARCHWEBFORIMAGE,
    ITEM_GROUP_MEDIA_VIDEO,
    ITEM_GROUP_MEDIA_AUDIO,
    ITEM_GROUP_MEDIA_CANVAS,
    ITEM_GROUP_MEDIA_PLUGIN,
    ITEM_GROUP_MEDIA_FILE,
    ITEM_GROUP_EDITABLE,
    ITEM_GROUP_COPY,
    ITEM_GROUP_SEARCH_PROVIDER,
    ITEM_GROUP_PRINT,
    ITEM_GROUP_ALL_EXTENSION,
    ITEM_GROUP_CURRENT_EXTENSION,
    ITEM_GROUP_DEVELOPER,
    ITEM_GROUP_DEVTOOLS_UNPACKED_EXT,
    ITEM_GROUP_PRINT_PREVIEW,
    ITEM_GROUP_PASSWORD,
    ITEM_GROUP_EXISTING_LINK_TO_TEXT
  };

  // Returns if |group| is enabled.
  virtual bool SupportsGroup(int group);

  ContextMenuContentType(content::WebContents* web_contents,
                         const content::ContextMenuParams& params,
                         bool supports_custom_items);

 protected:
  const content::ContextMenuParams& params() const { return params_; }

  content::WebContents* source_web_contents() const {
    return source_web_contents_;
  }

 private:
  bool SupportsGroupInternal(int group);

  const content::ContextMenuParams params_;
  const raw_ptr<content::WebContents> source_web_contents_;
  const bool supports_custom_items_;
};

#endif  // COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_CONTENT_TYPE_H_