File: user_permission_service.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (89 lines) | stat: -rw-r--r-- 3,655 bytes parent folder | download | duplicates (4)
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
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_USER_PERMISSION_SERVICE_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_USER_PERMISSION_SERVICE_H_

#include "build/build_config.h"
#include "components/keyed_service/core/keyed_service.h"

namespace device_signals {

struct UserContext;

// Contains possible outcomes of a signals collection permission check.
// These values are persisted to logs and should not be renumbered. Please
// update the DeviceSignalsUserPermission enum in enums.xml when adding a new
// value here.
enum class UserPermission {
  // Returned when the user is part of an organization that is not affiliated
  // with the organization currently managing the browser.
  kUnaffiliated = 0,

  // Returned when the browser is not managed, but the user is - but the user
  // has not given their consent for device signals to be collected.
  kMissingConsent = 1,

  // Returned when the user is not part of any organization.
  kConsumerUser = 2,

  // Returned when the given user context does not represent the current browser
  // user (e.g. Profile user).
  kUnknownUser = 3,

  // Returned when the no user information was given.
  kMissingUser = 4,

  // Returned when the user is granted permission to the device's signals.
  kGranted = 5,

  // Returned when the current context is currently unsupported, but eventually
  // could be.
  kUnsupported = 6,

  kMaxValue = kUnsupported
};

// Service that can be used to conduct permission checks on given users. The
// users may represent a different user than the profile user, and so the
// permission check is more exhaustive than simple consent check and involves
// validating the affiliation of the user's organization.
class UserPermissionService : public KeyedService {
 public:
  ~UserPermissionService() override = default;

  // Returns true if consent is required based on the current context and is
  // missing.
  virtual bool ShouldCollectConsent() const = 0;

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
  // Will verify whether context-aware signals can be collected
  // on behalf of the user represented by `user_context`. Returns `kGranted` if
  // collection is allowed.
  virtual UserPermission CanUserCollectSignals(
      const UserContext& user_context) const = 0;
#endif  // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX

  // Will verify whether context-aware signals can be collected
  // based on the current context (e.g. browser-wide management, user logged-in
  // to a Profile). Returns `kGranted` if collection is allowed.
  virtual UserPermission CanCollectSignals() const = 0;

  // Variant of `CanCollectSignals` function but checks if context-aware signals
  // can be collected for signals reporting. With current privacy requirements,
  // PII signals collection can only happen when the device is managed and
  // affiliated. Note: `kGranted` means all signals can be collected,
  // `kMissingConsent` means only non-PII signals can be collected.
  virtual UserPermission CanCollectReportSignals() const = 0;

  // Returns whether the user has explicitly agreed to device signals being
  // shared or not. Depending on the current management context, the returned
  // value could be false even though signals can be collected. This function
  // is exposed publicly mostly for debugging purposes.
  virtual bool HasUserConsented() const = 0;
};

}  // namespace device_signals

#endif  // COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_USER_PERMISSION_SERVICE_H_