File: manager.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 (150 lines) | stat: -rw-r--r-- 6,218 bytes parent folder | download | duplicates (3)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// 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_UPDATER_POLICY_MANAGER_H_
#define CHROME_UPDATER_POLICY_MANAGER_H_

#include <optional>
#include <string>
#include <vector>

#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "chrome/updater/constants.h"

namespace updater {

// Updates are suppressed if the current time falls between the start time and
// the duration. The duration does not account for daylight savings time.
// For instance, if the start time is 22:00 hours, and with a duration of 8
// hours, the updates will be suppressed for 8 hours regardless of whether
// daylight savings time changes happen in between.
class UpdatesSuppressedTimes {
 public:
  friend constexpr bool operator==(const UpdatesSuppressedTimes&,
                                   const UpdatesSuppressedTimes&) = default;

  bool valid() const;

  // Returns true if and only if the `hour`:`minute` wall clock time falls
  // within this suppression period.
  bool contains(int hour, int minute) const;

  int start_hour_ = kPolicyNotSet;
  int start_minute_ = kPolicyNotSet;
  int duration_minute_ = kPolicyNotSet;
};

// The Policy Manager Interface is implemented by policy managers such as Group
// Policy and Device Management.
class PolicyManagerInterface
    : public base::RefCountedThreadSafe<PolicyManagerInterface> {
 public:
  // This is human-readable string that indicates the policy manager being
  // queried.
  virtual std::string source() const = 0;

  // This method returns |true| if the current policy manager determines that
  // its policies are operational. For instance, the Device Management Policy
  // Manager will return |true| for this method if the machine is joined to
  // a DM server.
  virtual bool HasActiveDevicePolicies() const = 0;

  // Whether the cloud policy overrides the platform policy.
  // This policy affects Windows only.
  // The policy value from device management provider takes precedence if this
  // policy has conflict values.
  virtual std::optional<bool> CloudPolicyOverridesPlatformPolicy() const = 0;

  // Returns the policy for how often the Updater should check for updates.
  // Returns the time interval between update checks.
  // 0 indicates updates are disabled.
  virtual std::optional<base::TimeDelta> GetLastCheckPeriod() const = 0;

  // For domain-joined machines, checks the current time against the times that
  // updates are suppressed.
  virtual std::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
      const = 0;

  // Returns the policy for the download preference.
  virtual std::optional<std::string> GetDownloadPreference() const = 0;

  // Returns the policy for the package cache size limit in megabytes.
  virtual std::optional<int> GetPackageCacheSizeLimitMBytes() const = 0;

  // Returns the policy for the package cache expiration in days.
  virtual std::optional<int> GetPackageCacheExpirationTimeDays() const = 0;

  // Returns kPolicyEnabled if installation of the specified app is allowed.
  // Otherwise, returns kPolicyDisabled.
  virtual std::optional<int> GetEffectivePolicyForAppInstalls(
      const std::string& app_id) const = 0;

  // Returns kPolicyEnabled if updates of the specified app is allowed.
  // Otherwise, returns one of kPolicyDisabled, kPolicyManualUpdatesOnly, or
  // kPolicyAutomaticUpdatesOnly.
  virtual std::optional<int> GetEffectivePolicyForAppUpdates(
      const std::string& app_id) const = 0;

  // Returns the target version prefix for the app.
  // Examples:
  // * "" (or not configured): update to latest version available.
  // * "55.": update to any minor version of 55 (e.g. 55.24.34 or 55.60.2).
  // * "55.2.": update to any minor version of 55.2 (e.g. 55.2.34 or 55.2.2).
  // * "55.24.34": update to this specific version only.
  virtual std::optional<std::string> GetTargetVersionPrefix(
      const std::string& app_id) const = 0;

  // Returns whether the RollbackToTargetVersion policy has been set for the
  // app. If RollbackToTargetVersion is set, the TargetVersionPrefix policy
  // governs the version to rollback clients with higher versions to.
  virtual std::optional<bool> IsRollbackToTargetVersionAllowed(
      const std::string& app_id) const = 0;

  // Returns one of kPolicyRolloutDefault, kPolicyRolloutFast, or
  // kPolicyRolloutSlow, indicating the preference for participating in app
  // gradual rollouts, skipping gradual rollouts, or holding back from gradual
  // rollouts, respectively. Applies to major revisions of apps only.
  virtual std::optional<int> GetMajorVersionRolloutPolicy(
      const std::string& app_id) const = 0;

  // Returns one of kPolicyRolloutDefault, kPolicyRolloutFast, or
  // kPolicyRolloutSlow, indicating the preference for participating in app
  // gradual rollouts, skipping gradual rollouts, or holding back from gradual
  // rollouts, respectively. Applies to minor revisions of apps only.
  virtual std::optional<int> GetMinorVersionRolloutPolicy(
      const std::string& app_id) const = 0;

  // Returns a proxy mode such as |auto_detect|.
  virtual std::optional<std::string> GetProxyMode() const = 0;

  // Returns a proxy PAC URL.
  virtual std::optional<std::string> GetProxyPacUrl() const = 0;

  // Returns a proxy server.
  virtual std::optional<std::string> GetProxyServer() const = 0;

  // Returns a channel, for example {stable|beta|dev}.
  virtual std::optional<std::string> GetTargetChannel(
      const std::string& app_id) const = 0;

  // Returns a list of apps that need to be downloaded and installed by the
  // updater.
  virtual std::optional<std::vector<std::string>> GetForceInstallApps()
      const = 0;

  // Returns all apps that have some policy set.
  virtual std::optional<std::vector<std::string>> GetAppsWithPolicy() const = 0;

 protected:
  friend class base::RefCountedThreadSafe<PolicyManagerInterface>;
  virtual ~PolicyManagerInterface() = default;
};

scoped_refptr<PolicyManagerInterface> GetDefaultValuesPolicyManager();

}  // namespace updater

#endif  // CHROME_UPDATER_POLICY_MANAGER_H_