| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace base { | 21 namespace base { |
| 22 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace policy { | 25 namespace policy { |
| 26 | 26 |
| 27 class AppliedGPOListProvider; | 27 class AppliedGPOListProvider; |
| 28 class PolicyLoadStatusSample; | 28 class PolicyLoadStatusSample; |
| 29 class PolicyMap; | 29 class PolicyMap; |
| 30 class RegistryDict; | 30 class RegistryDict; |
| 31 struct PolicyDefinitionList; | |
| 32 | 31 |
| 33 // Interface for mocking out GPO enumeration in tests. | 32 // Interface for mocking out GPO enumeration in tests. |
| 34 class AppliedGPOListProvider { | 33 class AppliedGPOListProvider { |
| 35 public: | 34 public: |
| 36 virtual ~AppliedGPOListProvider() {} | 35 virtual ~AppliedGPOListProvider() {} |
| 37 virtual DWORD GetAppliedGPOList(DWORD flags, | 36 virtual DWORD GetAppliedGPOList(DWORD flags, |
| 38 LPCTSTR machine_name, | 37 LPCTSTR machine_name, |
| 39 PSID sid_user, | 38 PSID sid_user, |
| 40 GUID* extension_guid, | 39 GUID* extension_guid, |
| 41 PGROUP_POLICY_OBJECT* gpo_list) = 0; | 40 PGROUP_POLICY_OBJECT* gpo_list) = 0; |
| 42 virtual BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) = 0; | 41 virtual BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) = 0; |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 // Loads policies from the Windows registry, and watches for Group Policy | 44 // Loads policies from the Windows registry, and watches for Group Policy |
| 46 // notifications to trigger reloads. | 45 // notifications to trigger reloads. |
| 47 class PolicyLoaderWin : public AsyncPolicyLoader, | 46 class PolicyLoaderWin : public AsyncPolicyLoader, |
| 48 public base::win::ObjectWatcher::Delegate { | 47 public base::win::ObjectWatcher::Delegate { |
| 49 public: | 48 public: |
| 50 // The PReg file name used by GPO. | 49 // The PReg file name used by GPO. |
| 51 static const base::FilePath::CharType kPRegFileName[]; | 50 static const base::FilePath::CharType kPRegFileName[]; |
| 52 | 51 |
| 53 PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner, | 52 PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 54 const PolicyDefinitionList* policy_list, | |
| 55 const string16& chrome_policy_key, | 53 const string16& chrome_policy_key, |
| 56 AppliedGPOListProvider* gpo_provider); | 54 AppliedGPOListProvider* gpo_provider); |
| 57 virtual ~PolicyLoaderWin(); | 55 virtual ~PolicyLoaderWin(); |
| 58 | 56 |
| 59 // Creates a policy loader that uses the Win API to access GPO. | 57 // Creates a policy loader that uses the Win API to access GPO. |
| 60 static scoped_ptr<PolicyLoaderWin> Create( | 58 static scoped_ptr<PolicyLoaderWin> Create( |
| 61 scoped_refptr<base::SequencedTaskRunner> task_runner, | 59 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 62 const PolicyDefinitionList* policy_list); | |
| 63 | 60 |
| 64 // AsyncPolicyLoader implementation. | 61 // AsyncPolicyLoader implementation. |
| 65 virtual void InitOnBackgroundThread() OVERRIDE; | 62 virtual void InitOnBackgroundThread() OVERRIDE; |
| 66 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; | 63 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; |
| 67 | 64 |
| 68 private: | 65 private: |
| 69 // Builds the Chrome policy schema in |chrome_policy_schema_|. | 66 // Builds the Chrome policy schema in |chrome_policy_schema_|. |
| 70 void BuildChromePolicySchema(); | 67 void BuildChromePolicySchema(); |
| 71 | 68 |
| 72 // Reads Chrome Policy from a PReg file at the given path and stores the | 69 // Reads Chrome Policy from a PReg file at the given path and stores the |
| (...skipping 30 matching lines...) Expand all Loading... |
| 103 PolicyScope scope, | 100 PolicyScope scope, |
| 104 PolicyBundle* bundle); | 101 PolicyBundle* bundle); |
| 105 | 102 |
| 106 // Installs the watchers for the Group Policy update events. | 103 // Installs the watchers for the Group Policy update events. |
| 107 void SetupWatches(); | 104 void SetupWatches(); |
| 108 | 105 |
| 109 // ObjectWatcher::Delegate overrides: | 106 // ObjectWatcher::Delegate overrides: |
| 110 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | 107 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; |
| 111 | 108 |
| 112 bool is_initialized_; | 109 bool is_initialized_; |
| 113 const PolicyDefinitionList* policy_list_; | |
| 114 const string16 chrome_policy_key_; | 110 const string16 chrome_policy_key_; |
| 115 class AppliedGPOListProvider* gpo_provider_; | 111 class AppliedGPOListProvider* gpo_provider_; |
| 116 base::DictionaryValue chrome_policy_schema_; | 112 base::DictionaryValue chrome_policy_schema_; |
| 117 | 113 |
| 118 base::WaitableEvent user_policy_changed_event_; | 114 base::WaitableEvent user_policy_changed_event_; |
| 119 base::WaitableEvent machine_policy_changed_event_; | 115 base::WaitableEvent machine_policy_changed_event_; |
| 120 base::win::ObjectWatcher user_policy_watcher_; | 116 base::win::ObjectWatcher user_policy_watcher_; |
| 121 base::win::ObjectWatcher machine_policy_watcher_; | 117 base::win::ObjectWatcher machine_policy_watcher_; |
| 122 bool user_policy_watcher_failed_; | 118 bool user_policy_watcher_failed_; |
| 123 bool machine_policy_watcher_failed_; | 119 bool machine_policy_watcher_failed_; |
| 124 | 120 |
| 125 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); | 121 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); |
| 126 }; | 122 }; |
| 127 | 123 |
| 128 } // namespace policy | 124 } // namespace policy |
| 129 | 125 |
| 130 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ | 126 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ |
| OLD | NEW |