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/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "base/win/object_watcher.h" | 15 #include "base/win/object_watcher.h" |
16 #include "chrome/browser/policy/async_policy_loader.h" | 16 #include "chrome/browser/policy/async_policy_loader.h" |
17 #include "chrome/browser/policy/policy_types.h" | 17 #include "chrome/browser/policy/policy_types.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class FilePath; | 20 class FilePath; |
21 } | 21 } |
22 | 22 |
23 namespace policy { | 23 namespace policy { |
24 | 24 |
25 class AppliedGPOListProvider; | 25 class AppliedGPOListProvider; |
| 26 class PolicyLoadStatusSample; |
26 class PolicyMap; | 27 class PolicyMap; |
27 struct PolicyDefinitionList; | 28 struct PolicyDefinitionList; |
28 | 29 |
29 // Interface for mocking out GPO enumeration in tests. | 30 // Interface for mocking out GPO enumeration in tests. |
30 class AppliedGPOListProvider { | 31 class AppliedGPOListProvider { |
31 public: | 32 public: |
32 virtual ~AppliedGPOListProvider() {} | 33 virtual ~AppliedGPOListProvider() {} |
33 virtual DWORD GetAppliedGPOList(DWORD flags, | 34 virtual DWORD GetAppliedGPOList(DWORD flags, |
34 LPCTSTR machine_name, | 35 LPCTSTR machine_name, |
35 PSID sid_user, | 36 PSID sid_user, |
(...skipping 20 matching lines...) Expand all Loading... |
56 virtual void InitOnFile() OVERRIDE; | 57 virtual void InitOnFile() OVERRIDE; |
57 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; | 58 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; |
58 | 59 |
59 private: | 60 private: |
60 // Builds the Chrome policy schema in |chrome_policy_schema_|. | 61 // Builds the Chrome policy schema in |chrome_policy_schema_|. |
61 void BuildChromePolicySchema(); | 62 void BuildChromePolicySchema(); |
62 | 63 |
63 // Reads Chrome Policy from a PReg file at the given path and stores the | 64 // Reads Chrome Policy from a PReg file at the given path and stores the |
64 // result in |policy|. | 65 // result in |policy|. |
65 bool ReadPRegFile(const base::FilePath& preg_file, | 66 bool ReadPRegFile(const base::FilePath& preg_file, |
66 base::DictionaryValue* policy); | 67 base::DictionaryValue* policy, |
| 68 PolicyLoadStatusSample *status); |
67 | 69 |
68 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If | 70 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If |
69 // successful, stores the result in |policy| and returns true. Returns false | 71 // successful, stores the result in |policy| and returns true. Returns false |
70 // on failure reading the policy, indicating that policy loading should fall | 72 // on failure reading the policy, indicating that policy loading should fall |
71 // back to reading the registry. | 73 // back to reading the registry. |
72 bool LoadGPOPolicy(PolicyScope scope, | 74 bool LoadGPOPolicy(PolicyScope scope, |
73 PGROUP_POLICY_OBJECT policy_object_list, | 75 PGROUP_POLICY_OBJECT policy_object_list, |
74 base::DictionaryValue* policy); | 76 base::DictionaryValue* policy, |
| 77 PolicyLoadStatusSample *status); |
75 | 78 |
76 // Queries Windows for applied group policy and writes the result to |policy|. | 79 // Queries Windows for applied group policy and writes the result to |policy|. |
77 // This is the preferred way to obtain GPO data, there are reports of abuse | 80 // This is the preferred way to obtain GPO data, there are reports of abuse |
78 // of the registry GPO keys by 3rd-party software. | 81 // of the registry GPO keys by 3rd-party software. |
79 bool ReadPolicyFromGPO(PolicyScope scope, base::DictionaryValue* policy); | 82 bool ReadPolicyFromGPO(PolicyScope scope, |
| 83 base::DictionaryValue* policy, |
| 84 PolicyLoadStatusSample *status); |
80 | 85 |
81 // Parses Chrome policy from |gpo_dict| for the given |scope| and |level| and | 86 // Parses Chrome policy from |gpo_dict| for the given |scope| and |level| and |
82 // merges it into |chrome_policy_map|. | 87 // merges it into |chrome_policy_map|. |
83 void LoadChromePolicy(const base::DictionaryValue* gpo_dict, | 88 void LoadChromePolicy(const base::DictionaryValue* gpo_dict, |
84 PolicyLevel level, | 89 PolicyLevel level, |
85 PolicyScope scope, | 90 PolicyScope scope, |
86 PolicyMap* chrome_policy_map); | 91 PolicyMap* chrome_policy_map); |
87 | 92 |
88 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. | 93 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. |
89 void Load3rdPartyPolicy(const base::DictionaryValue* gpo_dict, | 94 void Load3rdPartyPolicy(const base::DictionaryValue* gpo_dict, |
(...skipping 18 matching lines...) Expand all Loading... |
108 base::win::ObjectWatcher machine_policy_watcher_; | 113 base::win::ObjectWatcher machine_policy_watcher_; |
109 bool user_policy_watcher_failed_; | 114 bool user_policy_watcher_failed_; |
110 bool machine_policy_watcher_failed_; | 115 bool machine_policy_watcher_failed_; |
111 | 116 |
112 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); | 117 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); |
113 }; | 118 }; |
114 | 119 |
115 } // namespace policy | 120 } // namespace policy |
116 | 121 |
117 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ | 122 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_WIN_H_ |
OLD | NEW |