OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CONFIGURATION_POLICY_PROVIDER_WIN_H_ | 5 #ifndef CHROME_BROWSER_CONFIGURATION_POLICY_PROVIDER_WIN_H_ |
6 #define CHROME_BROWSER_CONFIGURATION_POLICY_PROVIDER_WIN_H_ | 6 #define CHROME_BROWSER_CONFIGURATION_POLICY_PROVIDER_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/object_watcher.h" |
| 10 #include "base/scoped_ptr.h" |
| 11 #include "base/waitable_event.h" |
9 #include "chrome/browser/configuration_policy_store.h" | 12 #include "chrome/browser/configuration_policy_store.h" |
10 #include "chrome/browser/configuration_policy_provider.h" | 13 #include "chrome/browser/configuration_policy_provider.h" |
11 | 14 |
12 // An implementation of |ConfigurationPolicyProvider| using the | 15 // An implementation of |ConfigurationPolicyProvider| using the |
13 // mechanism provided by Windows Groups Policy. Policy decisions are | 16 // mechanism provided by Windows Groups Policy. Policy decisions are |
14 // stored as values in a special section of the Windows Registry. | 17 // stored as values in a special section of the Windows Registry. |
15 // On a managed machine in a domain, this portion of the registry is | 18 // On a managed machine in a domain, this portion of the registry is |
16 // periodically updated by the Windows Group Policy machinery to contain | 19 // periodically updated by the Windows Group Policy machinery to contain |
17 // the latest version of the policy set by administrators. | 20 // the latest version of the policy set by administrators. |
18 class ConfigurationPolicyProviderWin : public ConfigurationPolicyProvider { | 21 class ConfigurationPolicyProviderWin : public ConfigurationPolicyProvider { |
19 public: | 22 public: |
| 23 // Keeps watch on Windows Group Policy notification event to trigger |
| 24 // a policy reload when Group Policy changes. |
| 25 class GroupPolicyChangeWatcher : public base::ObjectWatcher::Delegate { |
| 26 public: |
| 27 explicit GroupPolicyChangeWatcher(ConfigurationPolicyProvider* provider); |
| 28 virtual ~GroupPolicyChangeWatcher() {} |
| 29 |
| 30 virtual void OnObjectSignaled(HANDLE object); |
| 31 |
| 32 private: |
| 33 ConfigurationPolicyProvider* provider_; |
| 34 base::WaitableEvent user_policy_changed_event_; |
| 35 base::WaitableEvent machine_policy_changed_event_; |
| 36 base::ObjectWatcher user_policy_watcher_; |
| 37 base::ObjectWatcher machine_policy_watcher_; |
| 38 }; |
| 39 |
20 ConfigurationPolicyProviderWin(); | 40 ConfigurationPolicyProviderWin(); |
21 virtual ~ConfigurationPolicyProviderWin() { } | 41 virtual ~ConfigurationPolicyProviderWin() { } |
22 | 42 |
23 // ConfigurationPolicyProvider method overrides: | 43 // ConfigurationPolicyProvider method overrides: |
24 virtual bool Provide(ConfigurationPolicyStore* store); | 44 virtual bool Provide(ConfigurationPolicyStore* store); |
25 | 45 |
26 protected: | 46 protected: |
27 // The sub key path for Chromium's Group Policy information in the | 47 // The sub key path for Chromium's Group Policy information in the |
28 // Windows registry. | 48 // Windows registry. |
29 static const wchar_t kPolicyRegistrySubKey[]; | 49 static const wchar_t kPolicyRegistrySubKey[]; |
30 | 50 |
31 private: | 51 private: |
| 52 scoped_ptr<GroupPolicyChangeWatcher> watcher_; |
| 53 |
32 // Methods to perfrom type-specific policy lookups in the registry. | 54 // Methods to perfrom type-specific policy lookups in the registry. |
33 // HKLM is checked first, then HKCU. | 55 // HKLM is checked first, then HKCU. |
34 bool GetRegistryPolicyString(const wchar_t* value_name, string16* result); | 56 bool GetRegistryPolicyString(const wchar_t* value_name, string16* result); |
35 bool GetRegistryPolicyBoolean(const wchar_t* value_name, bool* result); | 57 bool GetRegistryPolicyBoolean(const wchar_t* value_name, bool* result); |
36 bool GetRegistryPolicyInteger(const wchar_t* value_name, uint32* result); | 58 bool GetRegistryPolicyInteger(const wchar_t* value_name, uint32* result); |
37 }; | 59 }; |
38 | 60 |
39 #endif // CHROME_BROWSER_CONFIGURATION_POLICY_PROVIDER_WIN_H_ | 61 #endif // CHROME_BROWSER_CONFIGURATION_POLICY_PROVIDER_WIN_H_ |
40 | 62 |
OLD | NEW |