File: supervised_user_extensions_delegate.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 (119 lines) | stat: -rw-r--r-- 5,127 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// 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 EXTENSIONS_BROWSER_SUPERVISED_USER_EXTENSIONS_DELEGATE_H_
#define EXTENSIONS_BROWSER_SUPERVISED_USER_EXTENSIONS_DELEGATE_H_

#include "base/functional/callback.h"
#include "extensions/common/extension.h"

namespace content {
class WebContents;
}  // namespace content

namespace gfx {
class ImageSkia;
}  // namespace gfx

// These enum values represent the supervised user flows that lead to
// displaying the Extensions parent approval dialog.
// These values are logged to UMA. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(SupervisedUserExtensionParentApprovalEntryPoint)
enum class SupervisedUserExtensionParentApprovalEntryPoint : int {
  // Recorded when the dialog appears as part of installing a new extension
  // from Webstore.
  kOnWebstoreInstallation = 0,
  // Recorded when the dialog appears on enabling an existing extension which
  // is missing parent approval from the extension management page.
  kOnExtensionManagementSetEnabledOperation = 1,
  // Recorded the dialog appears on enabling an existing disabled/terminated
  // extension which is missing parent approval through the extension enable
  // flow.
  kOnTerminatedExtensionEnableFlowOperation = 2,
  // Add future entries above this comment, in sync with
  // "SupervisedUserExtensionParentApprovalEntryPoint" in
  // src/tools/metrics/histograms/metadata/families/enums.xml.
  // Update kMaxValue to the last value.
  kMaxValue = kOnTerminatedExtensionEnableFlowOperation
};
// LINT.ThenChange(//tools/metrics/histograms/metadata/families/enums.xml:SupervisedUserExtensionParentApprovalEntryPoint)

namespace extensions {

class SupervisedUserExtensionsDelegate {
 public:
  // Result of the extension approval flow.
  enum class ExtensionApprovalResult {
    kApproved,  // Extension installation was approved.
    kCanceled,  // Extension approval flow was canceled.
    kFailed,    // Extension approval failed due to an error.
    kBlocked,   // Extension installation has been blocked by a parent.
  };

  using ExtensionApprovalDoneCallback =
      base::OnceCallback<void(ExtensionApprovalResult)>;

  virtual ~SupervisedUserExtensionsDelegate() = default;

  // Updates registration of management policy provider for supervised users.
  virtual void UpdateManagementPolicyRegistration() = 0;

  // Returns true if the primary account is a supervised child.
  virtual bool IsChild() const = 0;

  // Returns true if the parent has already approved the `extension`.
  virtual bool IsExtensionAllowedByParent(
      const extensions::Extension& extension) const = 0;

  // If the current user is a child, the child user has a custodian/parent, and
  // the parent has enabled the "Permissions for sites, apps and extensions"
  // toggle, then display the Parent Permission Dialog. If the setting is
  // disabled, the extension install blocked dialog is shown. When the flow is
  // complete call `extension_approval_callback`.
  // The icon must be supplied for installing new extensions because they are
  // fetched via a network request.
  // The extension approval dialog entry point indicates who invokes this method
  // and is persistent in metrics.
  virtual void RequestToAddExtensionOrShowError(
      const extensions::Extension& extension,
      content::WebContents* web_contents,
      const gfx::ImageSkia& icon,
      SupervisedUserExtensionParentApprovalEntryPoint
          extension_approval_entry_point,
      ExtensionApprovalDoneCallback extension_approval_callback) = 0;

  // Similar to RequestToAddExtensionOrShowError except for enabling already
  // installed extensions. The icon is fetched from local resources.
  virtual void RequestToEnableExtensionOrShowError(
      const extensions::Extension& extension,
      content::WebContents* web_contents,
      SupervisedUserExtensionParentApprovalEntryPoint
          extension_approval_entry_point,
      ExtensionApprovalDoneCallback extension_approval_callback) = 0;

  // Returns true if the primary account represents a supervised child account
  // who may install extensions with parent permission.
  virtual bool CanInstallExtensions() const = 0;

  // Updates the set of approved extensions to add approval for `extension`.
  virtual void AddExtensionApproval(const extensions::Extension& extension) = 0;

  // Checks if the given `extension` escalated permissions and records the
  // corresponding metrics.
  virtual void MaybeRecordPermissionsIncreaseMetrics(
      const extensions::Extension& extension) = 0;

  // Updates the set of approved extensions to remove approval for `extension`.
  virtual void RemoveExtensionApproval(
      const extensions::Extension& extension) = 0;

  // Records when an extension has been enabled or disabled by parental
  // controls.
  virtual void RecordExtensionEnablementUmaMetrics(bool enabled) const = 0;
};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_SUPERVISED_USER_EXTENSIONS_DELEGATE_H_