| 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 CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ | 5 #ifndef CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ |
| 6 #define CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ | 6 #define CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ |
| 7 | 7 |
| 8 #include <userenv.h> | 8 #include <userenv.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "base/win/object_watcher.h" | 17 #include "base/win/object_watcher.h" |
| 18 #include "chrome/browser/policy/async_policy_loader.h" | 18 #include "chrome/browser/policy/async_policy_loader.h" |
| 19 #include "chrome/browser/policy/policy_types.h" | 19 #include "chrome/browser/policy/policy_types.h" |
| 20 #include "components/policy/core/common/policy_schema.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class SequencedTaskRunner; | 23 class SequencedTaskRunner; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace policy { | 26 namespace policy { |
| 26 | 27 |
| 27 class AppliedGPOListProvider; | 28 class AppliedGPOListProvider; |
| 28 class PolicyLoadStatusSample; | 29 class PolicyLoadStatusSample; |
| 29 class PolicyMap; | 30 class PolicyMap; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 59 // Creates a policy loader that uses the Win API to access GPO. | 60 // Creates a policy loader that uses the Win API to access GPO. |
| 60 static scoped_ptr<PolicyLoaderWin> Create( | 61 static scoped_ptr<PolicyLoaderWin> Create( |
| 61 scoped_refptr<base::SequencedTaskRunner> task_runner, | 62 scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 62 const PolicyDefinitionList* policy_list); | 63 const PolicyDefinitionList* policy_list); |
| 63 | 64 |
| 64 // AsyncPolicyLoader implementation. | 65 // AsyncPolicyLoader implementation. |
| 65 virtual void InitOnBackgroundThread() OVERRIDE; | 66 virtual void InitOnBackgroundThread() OVERRIDE; |
| 66 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; | 67 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 // Builds the Chrome policy schema in |chrome_policy_schema_|. | |
| 70 void BuildChromePolicySchema(); | |
| 71 | |
| 72 // Reads Chrome Policy from a PReg file at the given path and stores the | 70 // Reads Chrome Policy from a PReg file at the given path and stores the |
| 73 // result in |policy|. | 71 // result in |policy|. |
| 74 bool ReadPRegFile(const base::FilePath& preg_file, | 72 bool ReadPRegFile(const base::FilePath& preg_file, |
| 75 RegistryDict* policy, | 73 RegistryDict* policy, |
| 76 PolicyLoadStatusSample *status); | 74 PolicyLoadStatusSample *status); |
| 77 | 75 |
| 78 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If | 76 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If |
| 79 // successful, stores the result in |policy| and returns true. Returns false | 77 // successful, stores the result in |policy| and returns true. Returns false |
| 80 // on failure reading the policy, indicating that policy loading should fall | 78 // on failure reading the policy, indicating that policy loading should fall |
| 81 // back to reading the registry. | 79 // back to reading the registry. |
| 82 bool LoadGPOPolicy(PolicyScope scope, | 80 bool LoadGPOPolicy(PolicyScope scope, |
| 83 PGROUP_POLICY_OBJECT policy_object_list, | 81 PGROUP_POLICY_OBJECT policy_object_list, |
| 84 RegistryDict* policy, | 82 RegistryDict* policy, |
| 85 PolicyLoadStatusSample *status); | 83 PolicyLoadStatusSample *status); |
| 86 | 84 |
| 87 // Queries Windows for applied group policy and writes the result to |policy|. | 85 // Queries Windows for applied group policy and writes the result to |policy|. |
| 88 // This is the preferred way to obtain GPO data, there are reports of abuse | 86 // This is the preferred way to obtain GPO data, there are reports of abuse |
| 89 // of the registry GPO keys by 3rd-party software. | 87 // of the registry GPO keys by 3rd-party software. |
| 90 bool ReadPolicyFromGPO(PolicyScope scope, | 88 bool ReadPolicyFromGPO(PolicyScope scope, |
| 91 RegistryDict* policy, | 89 RegistryDict* policy, |
| 92 PolicyLoadStatusSample *status); | 90 PolicyLoadStatusSample *status); |
| 93 | 91 |
| 94 // Parses Chrome policy from |gpo_dict| for the given |scope| and |level| and | 92 // Parses Chrome policy from |gpo_dict| for the given |scope| and |level| and |
| 95 // merges it into |chrome_policy_map|. | 93 // merges it into |chrome_policy_map|. |
| 96 void LoadChromePolicy(const RegistryDict* gpo_dict, | 94 void LoadChromePolicy(const RegistryDict* gpo_dict, |
| 97 PolicyLevel level, | 95 PolicyLevel level, |
| 98 PolicyScope scope, | 96 PolicyScope scope, |
| 99 PolicyMap* chrome_policy_map); | 97 PolicyMap* chrome_policy_map); |
| 100 | 98 |
| 99 // Loads 3rd-party policy schema. |
| 100 const PolicySchema* Load3rdPartyPolicySchema( |
| 101 PolicyDomain domain, |
| 102 const std::string& component_key, |
| 103 RegistryDict* component_dict); |
| 104 |
| 101 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. | 105 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. |
| 102 void Load3rdPartyPolicy(const RegistryDict* gpo_dict, | 106 void Load3rdPartyPolicy(const RegistryDict* gpo_dict, |
| 103 PolicyScope scope, | 107 PolicyScope scope, |
| 104 PolicyBundle* bundle); | 108 PolicyBundle* bundle); |
| 105 | 109 |
| 106 // Installs the watchers for the Group Policy update events. | 110 // Installs the watchers for the Group Policy update events. |
| 107 void SetupWatches(); | 111 void SetupWatches(); |
| 108 | 112 |
| 109 // ObjectWatcher::Delegate overrides: | 113 // ObjectWatcher::Delegate overrides: |
| 110 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | 114 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; |
| 111 | 115 |
| 112 bool is_initialized_; | 116 bool is_initialized_; |
| 113 const PolicyDefinitionList* policy_list_; | 117 const PolicyDefinitionList* policy_list_; |
| 114 const string16 chrome_policy_key_; | 118 const string16 chrome_policy_key_; |
| 115 class AppliedGPOListProvider* gpo_provider_; | 119 class AppliedGPOListProvider* gpo_provider_; |
| 116 base::DictionaryValue chrome_policy_schema_; | |
| 117 | 120 |
| 118 base::WaitableEvent user_policy_changed_event_; | 121 base::WaitableEvent user_policy_changed_event_; |
| 119 base::WaitableEvent machine_policy_changed_event_; | 122 base::WaitableEvent machine_policy_changed_event_; |
| 120 base::win::ObjectWatcher user_policy_watcher_; | 123 base::win::ObjectWatcher user_policy_watcher_; |
| 121 base::win::ObjectWatcher machine_policy_watcher_; | 124 base::win::ObjectWatcher machine_policy_watcher_; |
| 122 bool user_policy_watcher_failed_; | 125 bool user_policy_watcher_failed_; |
| 123 bool machine_policy_watcher_failed_; | 126 bool machine_policy_watcher_failed_; |
| 124 | 127 |
| 125 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); | 128 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); |
| 126 }; | 129 }; |
| 127 | 130 |
| 128 } // namespace policy | 131 } // namespace policy |
| 129 | 132 |
| 130 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ | 133 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ |
| OLD | NEW |