1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_UPDATER_WIN_GROUP_POLICY_MANAGER_H_
6 #define CHROME_UPDATER_WIN_GROUP_POLICY_MANAGER_H_
7 
8 #include <memory>
9 #include <string>
10 
11 #include "base/strings/string16.h"
12 #include "base/win/registry.h"
13 #include "chrome/updater/policy_manager.h"
14 
15 namespace updater {
16 
17 // The GroupPolicyManager returns policies for domain-joined machines.
18 class GroupPolicyManager : public PolicyManagerInterface {
19  public:
20   GroupPolicyManager();
21   GroupPolicyManager(const GroupPolicyManager&) = delete;
22   GroupPolicyManager& operator=(const GroupPolicyManager&) = delete;
23   ~GroupPolicyManager() override;
24 
25   // Overrides for PolicyManagerInterface.
26   std::string source() const override;
27 
28   bool IsManaged() const override;
29 
30   bool GetLastCheckPeriodMinutes(int* minutes) const override;
31   bool GetUpdatesSuppressedTimes(
32       UpdatesSuppressedTimes* suppressed_times) const override;
33   bool GetDownloadPreferenceGroupPolicy(
34       std::string* download_preference) const override;
35   bool GetPackageCacheSizeLimitMBytes(int* cache_size_limit) const override;
36   bool GetPackageCacheExpirationTimeDays(int* cache_life_limit) const override;
37 
38   bool GetEffectivePolicyForAppInstalls(const std::string& app_id,
39                                         int* install_policy) const override;
40   bool GetEffectivePolicyForAppUpdates(const std::string& app_id,
41                                        int* update_policy) const override;
42   bool GetTargetChannel(const std::string& app_id,
43                         std::string* channel) const override;
44   bool GetTargetVersionPrefix(
45       const std::string& app_id,
46       std::string* target_version_prefix) const override;
47   bool IsRollbackToTargetVersionAllowed(const std::string& app_id,
48                                         bool* rollback_allowed) const override;
49   bool GetProxyMode(std::string* proxy_mode) const override;
50   bool GetProxyPacUrl(std::string* proxy_pac_url) const override;
51   bool GetProxyServer(std::string* proxy_server) const override;
52 
53  private:
54   bool ReadValue(const base::char16* name, std::string* value) const;
55   bool ReadValueDW(const base::char16* name, int* value) const;
56 
57   base::win::RegKey key_;
58 };
59 
60 }  // namespace updater
61 
62 #endif  // CHROME_UPDATER_WIN_GROUP_POLICY_MANAGER_H_
63