| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 |
| 9 #include <userenv.h> | 10 #include <userenv.h> |
| 10 | 11 |
| 11 #include <memory> | 12 #include <memory> |
| 12 | 13 |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 17 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/win/object_watcher.h" | 19 #include "base/win/object_watcher.h" |
| 19 #include "components/policy/core/common/async_policy_loader.h" | 20 #include "components/policy/core/common/async_policy_loader.h" |
| 20 #include "components/policy/core/common/policy_types.h" | 21 #include "components/policy/core/common/policy_types.h" |
| 21 #include "components/policy/policy_export.h" | 22 #include "components/policy/policy_export.h" |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 class SequencedTaskRunner; | 25 class SequencedTaskRunner; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace policy { | 28 namespace policy { |
| 28 | 29 |
| 29 class AppliedGPOListProvider; | 30 class AppliedGPOListProvider; |
| 30 class PolicyLoadStatusSample; | 31 class PolicyLoadStatusSampler; |
| 31 class PolicyMap; | 32 class PolicyMap; |
| 32 class RegistryDict; | 33 class RegistryDict; |
| 33 | 34 |
| 34 // Interface for mocking out GPO enumeration in tests. | 35 // Interface for mocking out GPO enumeration in tests. |
| 35 class POLICY_EXPORT AppliedGPOListProvider { | 36 class POLICY_EXPORT AppliedGPOListProvider { |
| 36 public: | 37 public: |
| 37 virtual ~AppliedGPOListProvider() {} | 38 virtual ~AppliedGPOListProvider() {} |
| 38 virtual DWORD GetAppliedGPOList(DWORD flags, | 39 virtual DWORD GetAppliedGPOList(DWORD flags, |
| 39 LPCTSTR machine_name, | 40 LPCTSTR machine_name, |
| 40 PSID sid_user, | 41 PSID sid_user, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 67 | 68 |
| 68 // AsyncPolicyLoader implementation. | 69 // AsyncPolicyLoader implementation. |
| 69 void InitOnBackgroundThread() override; | 70 void InitOnBackgroundThread() override; |
| 70 std::unique_ptr<PolicyBundle> Load() override; | 71 std::unique_ptr<PolicyBundle> Load() override; |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 // Reads Chrome Policy from a PReg file at the given path and stores the | 74 // Reads Chrome Policy from a PReg file at the given path and stores the |
| 74 // result in |policy|. | 75 // result in |policy|. |
| 75 bool ReadPRegFile(const base::FilePath& preg_file, | 76 bool ReadPRegFile(const base::FilePath& preg_file, |
| 76 RegistryDict* policy, | 77 RegistryDict* policy, |
| 77 PolicyLoadStatusSample* status); | 78 PolicyLoadStatusSampler* status); |
| 78 | 79 |
| 79 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If | 80 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If |
| 80 // successful, stores the result in |policy| and returns true. Returns false | 81 // successful, stores the result in |policy| and returns true. Returns false |
| 81 // on failure reading the policy, indicating that policy loading should fall | 82 // on failure reading the policy, indicating that policy loading should fall |
| 82 // back to reading the registry. | 83 // back to reading the registry. |
| 83 bool LoadGPOPolicy(PolicyScope scope, | 84 bool LoadGPOPolicy(PolicyScope scope, |
| 84 PGROUP_POLICY_OBJECT policy_object_list, | 85 PGROUP_POLICY_OBJECT policy_object_list, |
| 85 RegistryDict* policy, | 86 RegistryDict* policy, |
| 86 PolicyLoadStatusSample* status); | 87 PolicyLoadStatusSampler* status); |
| 87 | 88 |
| 88 // Queries Windows for applied group policy and writes the result to |policy|. | 89 // Queries Windows for applied group policy and writes the result to |policy|. |
| 89 // This is the preferred way to obtain GPO data, there are reports of abuse | 90 // This is the preferred way to obtain GPO data, there are reports of abuse |
| 90 // of the registry GPO keys by 3rd-party software. | 91 // of the registry GPO keys by 3rd-party software. |
| 91 bool ReadPolicyFromGPO(PolicyScope scope, | 92 bool ReadPolicyFromGPO(PolicyScope scope, |
| 92 RegistryDict* policy, | 93 RegistryDict* policy, |
| 93 PolicyLoadStatusSample* status); | 94 PolicyLoadStatusSampler* status); |
| 94 | 95 |
| 95 // Parses Chrome policy from |gpo_dict| for the given |scope| and |level| and | 96 // Parses Chrome policy from |gpo_dict| for the given |scope| and |level| and |
| 96 // merges it into |chrome_policy_map|. | 97 // merges it into |chrome_policy_map|. |
| 97 void LoadChromePolicy(const RegistryDict* gpo_dict, | 98 void LoadChromePolicy(const RegistryDict* gpo_dict, |
| 98 PolicyLevel level, | 99 PolicyLevel level, |
| 99 PolicyScope scope, | 100 PolicyScope scope, |
| 100 PolicyMap* chrome_policy_map); | 101 PolicyMap* chrome_policy_map); |
| 101 | 102 |
| 102 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. | 103 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. |
| 103 void Load3rdPartyPolicy(const RegistryDict* gpo_dict, | 104 void Load3rdPartyPolicy(const RegistryDict* gpo_dict, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 120 base::win::ObjectWatcher machine_policy_watcher_; | 121 base::win::ObjectWatcher machine_policy_watcher_; |
| 121 bool user_policy_watcher_failed_; | 122 bool user_policy_watcher_failed_; |
| 122 bool machine_policy_watcher_failed_; | 123 bool machine_policy_watcher_failed_; |
| 123 | 124 |
| 124 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); | 125 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); |
| 125 }; | 126 }; |
| 126 | 127 |
| 127 } // namespace policy | 128 } // namespace policy |
| 128 | 129 |
| 129 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ | 130 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ |
| OLD | NEW |