| 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 <windows.h> | 8 #include <windows.h> |
| 9 #include <userenv.h> | 9 #include <userenv.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/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/values.h" | |
| 18 #include "base/win/object_watcher.h" | 17 #include "base/win/object_watcher.h" |
| 19 #include "components/policy/core/common/async_policy_loader.h" | 18 #include "components/policy/core/common/async_policy_loader.h" |
| 20 #include "components/policy/core/common/policy_types.h" | 19 #include "components/policy/core/common/policy_types.h" |
| 21 | 20 |
| 22 namespace base { | 21 namespace base { |
| 23 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace policy { | 25 namespace policy { |
| 27 | 26 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 58 // 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. |
| 59 static scoped_ptr<PolicyLoaderWin> Create( | 58 static scoped_ptr<PolicyLoaderWin> Create( |
| 60 scoped_refptr<base::SequencedTaskRunner> task_runner, | 59 scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 61 const string16& chrome_policy_key); | 60 const string16& chrome_policy_key); |
| 62 | 61 |
| 63 // AsyncPolicyLoader implementation. | 62 // AsyncPolicyLoader implementation. |
| 64 virtual void InitOnBackgroundThread() OVERRIDE; | 63 virtual void InitOnBackgroundThread() OVERRIDE; |
| 65 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; | 64 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 // Builds the Chrome policy schema in |chrome_policy_schema_|. | |
| 69 void BuildChromePolicySchema(); | |
| 70 | |
| 71 // Reads Chrome Policy from a PReg file at the given path and stores the | 67 // Reads Chrome Policy from a PReg file at the given path and stores the |
| 72 // result in |policy|. | 68 // result in |policy|. |
| 73 bool ReadPRegFile(const base::FilePath& preg_file, | 69 bool ReadPRegFile(const base::FilePath& preg_file, |
| 74 RegistryDict* policy, | 70 RegistryDict* policy, |
| 75 PolicyLoadStatusSample *status); | 71 PolicyLoadStatusSample *status); |
| 76 | 72 |
| 77 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If | 73 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If |
| 78 // successful, stores the result in |policy| and returns true. Returns false | 74 // successful, stores the result in |policy| and returns true. Returns false |
| 79 // on failure reading the policy, indicating that policy loading should fall | 75 // on failure reading the policy, indicating that policy loading should fall |
| 80 // back to reading the registry. | 76 // back to reading the registry. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 104 | 100 |
| 105 // Installs the watchers for the Group Policy update events. | 101 // Installs the watchers for the Group Policy update events. |
| 106 void SetupWatches(); | 102 void SetupWatches(); |
| 107 | 103 |
| 108 // ObjectWatcher::Delegate overrides: | 104 // ObjectWatcher::Delegate overrides: |
| 109 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | 105 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; |
| 110 | 106 |
| 111 bool is_initialized_; | 107 bool is_initialized_; |
| 112 const string16 chrome_policy_key_; | 108 const string16 chrome_policy_key_; |
| 113 class AppliedGPOListProvider* gpo_provider_; | 109 class AppliedGPOListProvider* gpo_provider_; |
| 114 base::DictionaryValue chrome_policy_schema_; | |
| 115 | 110 |
| 116 base::WaitableEvent user_policy_changed_event_; | 111 base::WaitableEvent user_policy_changed_event_; |
| 117 base::WaitableEvent machine_policy_changed_event_; | 112 base::WaitableEvent machine_policy_changed_event_; |
| 118 base::win::ObjectWatcher user_policy_watcher_; | 113 base::win::ObjectWatcher user_policy_watcher_; |
| 119 base::win::ObjectWatcher machine_policy_watcher_; | 114 base::win::ObjectWatcher machine_policy_watcher_; |
| 120 bool user_policy_watcher_failed_; | 115 bool user_policy_watcher_failed_; |
| 121 bool machine_policy_watcher_failed_; | 116 bool machine_policy_watcher_failed_; |
| 122 | 117 |
| 123 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); | 118 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); |
| 124 }; | 119 }; |
| 125 | 120 |
| 126 } // namespace policy | 121 } // namespace policy |
| 127 | 122 |
| 128 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ | 123 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ |
| OLD | NEW |