File: menu_util.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (97 lines) | stat: -rw-r--r-- 3,624 bytes parent folder | download | duplicates (6)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_APPS_APP_SERVICE_MENU_UTIL_H_
#define CHROME_BROWSER_APPS_APP_SERVICE_MENU_UTIL_H_

#include <stdint.h>

#include <string>
#include <string_view>
#include <vector>

#include "chrome/browser/apps/app_service/app_shortcut_item.h"
#include "components/services/app_service/public/cpp/menu.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/models/menu_separator_types.h"
#include "ui/menus/simple_menu_model.h"

class Profile;

namespace gfx {
class ImageSkia;
}

namespace ui {
class SimpleMenuModel;
}  // namespace ui

namespace apps {

// ElementIdentifier associated with the item added by
// PopulateLaunchNewItemFromMenuItem() below.
DECLARE_ELEMENT_IDENTIFIER_VALUE(kLaunchNewMenuItem);

// Adds a command menu item to |menu_items|.
void AddCommandItem(uint32_t command_id,
                    uint32_t string_id,
                    MenuItems& menu_items);

// Adds a separator of the specified type to |menu_items|.
void AddSeparator(ui::MenuSeparatorType separator_type, MenuItems& menu_items);

// Adds a shortcut command menu item to |menu_items|.
void AddShortcutCommandItem(int command_id,
                            const std::string& shortcut_id,
                            const std::string& label,
                            const gfx::ImageSkia& icon,
                            MenuItems& menu_items);

// Adds a LAUNCH_NEW menu item to |menu_items|, and create radio items for the
// submenu.
void CreateOpenNewSubmenu(uint32_t string_id, MenuItems& menu_items);

// Returns true if the open menu item can be added, when |menu_type| is Shelf,
// and the app identified by |app_id| is not running, otherwise returns false.
bool ShouldAddOpenItem(const std::string& app_id,
                       MenuType menu_type,
                       Profile* profile);

// Returns true if the close menu item can be added, when |menu_type| is Shelf,
// and the app identified by |app_id| is running, otherwise returns false.
bool ShouldAddCloseItem(const std::string& app_id,
                        MenuType menu_type,
                        Profile* profile);

// Populates the LAUNCH_NEW menu item to a simple menu model |model| from
// |menu_item|. Also sets initial string id value to |launch_new_string_id|.
void PopulateLaunchNewItemFromMenuItem(const MenuItemPtr& menu_item,
                                       ui::SimpleMenuModel* model,
                                       ui::SimpleMenuModel* submenu,
                                       int* launch_new_string_id);

// Populates the menu item to a simple menu model |model| from menu item
// |menu_item|.
void PopulateItemFromMenuItem(const MenuItemPtr& menu_item,
                              ui::SimpleMenuModel* model,
                              apps::AppShortcutItems* arc_shortcut_items);

// Convert |menu_type| to string. Useful to pass |menu_type| enum as string id.
std::string_view MenuTypeToString(MenuType menu_type);

// Convert |menu_type| string to enum. Useful to pass |menu_type| enum as string
// id.
MenuType MenuTypeFromString(std::string_view menu_type);

// Returns the browser menu items for the given |menu_type|.
MenuItems CreateBrowserMenuItems(const Profile* profile);

ui::ColorId GetColorIdForMenuItemIcon();

// Converts `USE_LAUNCH_TYPE_*` commands to associated string ids.
uint32_t StringIdForUseLaunchTypeCommand(uint32_t command_id);

}  // namespace apps

#endif  // CHROME_BROWSER_APPS_APP_SERVICE_MENU_UTIL_H_