File: extension_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 (103 lines) | stat: -rw-r--r-- 3,642 bytes parent folder | download | duplicates (5)
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
98
99
100
101
102
103
// Copyright 2013 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_EXTENSIONS_EXTENSION_UTIL_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_

#include <memory>
#include <string>

#include "base/values.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/constants.h"

static_assert(BUILDFLAG(ENABLE_EXTENSIONS_CORE));

namespace base {
class CommandLine;
}

namespace content {
class BrowserContext;
}

namespace extensions {
class PermissionSet;
}

namespace user_prefs {
class PrefRegistrySyncable;
}

class Profile;

namespace extensions {

class Extension;

namespace util {

// Returns true if the extension associated with `extension_id` has isolated
// storage. This can be either because it is an app that requested this in its
// manifest, or because it is a policy-installed app or extension running on
// the Chrome OS sign-in profile.
bool HasIsolatedStorage(const std::string& extension_id,
                        content::BrowserContext* context);
bool HasIsolatedStorage(const Extension& extension,
                        content::BrowserContext* context);

// Sets whether `extension_id` can run in an incognito window. Reloads the
// extension if it's enabled since this permission is applied at loading time
// only. Note that an ExtensionService must exist.
void SetIsIncognitoEnabled(const std::string& extension_id,
                           content::BrowserContext* context,
                           bool enabled);

// Sets whether `extension_id` can inject scripts into pages with file URLs.
// Reloads the extension if it's enabled since this permission is applied at
// loading time only. Note than an ExtensionService must exist.
void SetAllowFileAccess(const std::string& extension_id,
                        content::BrowserContext* context,
                        bool allow);

// Sets the name, id, and icon resource path of the given extension into the
// returned dictionary.
base::Value::Dict GetExtensionInfo(const Extension* extension);

// Returns a PermissionSet configured with the permissions that should be
// displayed in an extension installation prompt for the specified `extension`.
std::unique_ptr<const PermissionSet> GetInstallPromptPermissionSetForExtension(
    const Extension* extension,
    Profile* profile);

// Returns all profiles affected by permissions of an extension running in
// "spanning" (rather than "split) mode.
std::vector<content::BrowserContext*> GetAllRelatedProfiles(
    Profile* profile,
    const Extension& extension);

// Sets whether the given `profile` is in developer mode and notifies
// relevant subsystems.
void SetDeveloperModeForProfile(Profile* profile, bool in_developer_mode);

// Returns the extension name to be used in UI surfaces. Name will be truncated
// if its very long, preventing extension name to spoof or break UI surfaces
// (see crbug.com/40063885).
std::u16string GetFixupExtensionNameForUIDisplay(
    const std::u16string& extension_name);
std::u16string GetFixupExtensionNameForUIDisplay(
    const std::string& extension_name);

// Registers miscellaneous chrome-level extension-related prefs.
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);

// Returns true if extensions have been disabled (e.g. via a command-line flag
// or preference).
bool AreExtensionsDisabled(const base::CommandLine& command_line,
                           content::BrowserContext* context);

}  // namespace util
}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_