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 COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ |
6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <userenv.h> | 9 #include <userenv.h> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 public: | 50 public: |
51 // The PReg file name used by GPO. | 51 // The PReg file name used by GPO. |
52 static const base::FilePath::CharType kPRegFileName[]; | 52 static const base::FilePath::CharType kPRegFileName[]; |
53 | 53 |
54 // Passing |gpo_provider| equal nullptr forces all reads to go through the | 54 // Passing |gpo_provider| equal nullptr forces all reads to go through the |
55 // registry. This is undesirable for Chrome (see crbug.com/259236), but | 55 // registry. This is undesirable for Chrome (see crbug.com/259236), but |
56 // needed for some other use cases (i.e. Chromoting - see crbug.com/460734). | 56 // needed for some other use cases (i.e. Chromoting - see crbug.com/460734). |
57 PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner, | 57 PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner, |
58 const base::string16& chrome_policy_key, | 58 const base::string16& chrome_policy_key, |
59 AppliedGPOListProvider* gpo_provider); | 59 AppliedGPOListProvider* gpo_provider); |
60 virtual ~PolicyLoaderWin(); | 60 ~PolicyLoaderWin() override; |
61 | 61 |
62 // Creates a policy loader that uses the Win API to access GPO. | 62 // Creates a policy loader that uses the Win API to access GPO. |
63 static scoped_ptr<PolicyLoaderWin> Create( | 63 static scoped_ptr<PolicyLoaderWin> Create( |
64 scoped_refptr<base::SequencedTaskRunner> task_runner, | 64 scoped_refptr<base::SequencedTaskRunner> task_runner, |
65 const base::string16& chrome_policy_key); | 65 const base::string16& chrome_policy_key); |
66 | 66 |
67 // AsyncPolicyLoader implementation. | 67 // AsyncPolicyLoader implementation. |
68 virtual void InitOnBackgroundThread() override; | 68 void InitOnBackgroundThread() override; |
69 virtual scoped_ptr<PolicyBundle> Load() override; | 69 scoped_ptr<PolicyBundle> Load() override; |
70 | 70 |
71 private: | 71 private: |
72 // Reads Chrome Policy from a PReg file at the given path and stores the | 72 // Reads Chrome Policy from a PReg file at the given path and stores the |
73 // result in |policy|. | 73 // result in |policy|. |
74 bool ReadPRegFile(const base::FilePath& preg_file, | 74 bool ReadPRegFile(const base::FilePath& preg_file, |
75 RegistryDict* policy, | 75 RegistryDict* policy, |
76 PolicyLoadStatusSample* status); | 76 PolicyLoadStatusSample* status); |
77 | 77 |
78 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If | 78 // 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 | 79 // successful, stores the result in |policy| and returns true. Returns false |
(...skipping 20 matching lines...) Expand all Loading... |
100 | 100 |
101 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. | 101 // Loads 3rd-party policy from |gpo_dict| and merges it into |bundle|. |
102 void Load3rdPartyPolicy(const RegistryDict* gpo_dict, | 102 void Load3rdPartyPolicy(const RegistryDict* gpo_dict, |
103 PolicyScope scope, | 103 PolicyScope scope, |
104 PolicyBundle* bundle); | 104 PolicyBundle* bundle); |
105 | 105 |
106 // Installs the watchers for the Group Policy update events. | 106 // Installs the watchers for the Group Policy update events. |
107 void SetupWatches(); | 107 void SetupWatches(); |
108 | 108 |
109 // ObjectWatcher::Delegate overrides: | 109 // ObjectWatcher::Delegate overrides: |
110 virtual void OnObjectSignaled(HANDLE object) override; | 110 void OnObjectSignaled(HANDLE object) override; |
111 | 111 |
112 bool is_initialized_; | 112 bool is_initialized_; |
113 const base::string16 chrome_policy_key_; | 113 const base::string16 chrome_policy_key_; |
114 class AppliedGPOListProvider* gpo_provider_; | 114 class AppliedGPOListProvider* gpo_provider_; |
115 | 115 |
116 base::WaitableEvent user_policy_changed_event_; | 116 base::WaitableEvent user_policy_changed_event_; |
117 base::WaitableEvent machine_policy_changed_event_; | 117 base::WaitableEvent machine_policy_changed_event_; |
118 base::win::ObjectWatcher user_policy_watcher_; | 118 base::win::ObjectWatcher user_policy_watcher_; |
119 base::win::ObjectWatcher machine_policy_watcher_; | 119 base::win::ObjectWatcher machine_policy_watcher_; |
120 bool user_policy_watcher_failed_; | 120 bool user_policy_watcher_failed_; |
121 bool machine_policy_watcher_failed_; | 121 bool machine_policy_watcher_failed_; |
122 | 122 |
123 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); | 123 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); |
124 }; | 124 }; |
125 | 125 |
126 } // namespace policy | 126 } // namespace policy |
127 | 127 |
128 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ | 128 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ |
OLD | NEW |