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 // Most of this code is copied from various classes in | 5 // Most of this code is copied from various classes in |
6 // src/chrome/browser/policy. In particular, look at | 6 // src/chrome/browser/policy. In particular, look at |
7 // | 7 // |
8 // configuration_policy_provider_delegate_win.{h,cc} | 8 // configuration_policy_provider_delegate_win.{h,cc} |
9 // configuration_policy_loader_win.{h,cc} | 9 // configuration_policy_loader_win.{h,cc} |
10 // | 10 // |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 machine_policy_changed_event_.handle(), this)) { | 105 machine_policy_changed_event_.handle(), this)) { |
106 LOG(WARNING) << "Failed to start watch for machine policy change event"; | 106 LOG(WARNING) << "Failed to start watch for machine policy change event"; |
107 machine_policy_watcher_failed_ = true; | 107 machine_policy_watcher_failed_ = true; |
108 } | 108 } |
109 | 109 |
110 if (user_policy_watcher_failed_ || machine_policy_watcher_failed_) { | 110 if (user_policy_watcher_failed_ || machine_policy_watcher_failed_) { |
111 ScheduleFallbackReloadTask(); | 111 ScheduleFallbackReloadTask(); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 bool GetRegistryPolicyString(const string16& value_name, | |
alexeypa (please no reviews)
2012/07/30 21:27:06
Mixture of string16 and std::string looks strange.
simonmorris
2012/07/30 22:08:17
Done.
| |
116 std::string* result) const { | |
117 std::wstring value; | |
118 RegKey policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ); | |
119 if (policy_key.ReadValue(value_name.c_str(), &value) == ERROR_SUCCESS) { | |
alexeypa (please no reviews)
2012/07/30 21:27:06
It should be UTF16ToWide(value_name).c_str(). I th
simonmorris
2012/07/30 22:08:17
Done.
| |
120 *result = WideToUTF8(value); | |
121 return true; | |
122 } | |
123 | |
124 if (policy_key.Open(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ) == | |
125 ERROR_SUCCESS) { | |
126 if (policy_key.ReadValue(value_name.c_str(), &value) == ERROR_SUCCESS) { | |
127 *result = WideToUTF8(value); | |
128 return true; | |
129 } | |
130 } | |
131 return false; | |
132 } | |
133 | |
115 bool GetRegistryPolicyInteger(const string16& value_name, | 134 bool GetRegistryPolicyInteger(const string16& value_name, |
116 uint32* result) const { | 135 uint32* result) const { |
117 DWORD value = 0; | 136 DWORD value = 0; |
118 RegKey policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ); | 137 RegKey policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ); |
119 if (policy_key.ReadValueDW(value_name.c_str(), &value) == ERROR_SUCCESS) { | 138 if (policy_key.ReadValueDW(value_name.c_str(), &value) == ERROR_SUCCESS) { |
120 *result = value; | 139 *result = value; |
121 return true; | 140 return true; |
122 } | 141 } |
123 | 142 |
124 if (policy_key.Open(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ) == | 143 if (policy_key.Open(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ) == |
(...skipping 19 matching lines...) Expand all Loading... | |
144 base::DictionaryValue* policy = new base::DictionaryValue(); | 163 base::DictionaryValue* policy = new base::DictionaryValue(); |
145 | 164 |
146 for (int i = 0; i < kBooleanPolicyNamesNum; ++i) { | 165 for (int i = 0; i < kBooleanPolicyNamesNum; ++i) { |
147 const char* policy_name = kBooleanPolicyNames[i]; | 166 const char* policy_name = kBooleanPolicyNames[i]; |
148 bool bool_value; | 167 bool bool_value; |
149 const string16 name(ASCIIToUTF16(policy_name)); | 168 const string16 name(ASCIIToUTF16(policy_name)); |
150 if (GetRegistryPolicyBoolean(name, &bool_value)) { | 169 if (GetRegistryPolicyBoolean(name, &bool_value)) { |
151 policy->SetBoolean(policy_name, bool_value); | 170 policy->SetBoolean(policy_name, bool_value); |
152 } | 171 } |
153 } | 172 } |
154 // TODO(simonmorris): Read policies whose names are in kStringPolicyNames. | 173 for (int i = 0; i < kStringPolicyNamesNum; ++i) { |
155 | 174 const char* policy_name = kStringPolicyNames[i]; |
175 std::string string_value; | |
176 const string16 name(ASCIIToUTF16(policy_name)); | |
177 if (GetRegistryPolicyString(name, &string_value)) { | |
alexeypa (please no reviews)
2012/07/30 21:27:06
nit: Why don't pass ASCIIToUTF16(policy_name) dire
simonmorris
2012/07/30 22:08:17
Done.
| |
178 policy->SetString(policy_name, string_value); | |
179 } | |
180 } | |
156 return policy; | 181 return policy; |
157 } | 182 } |
158 | 183 |
159 // Post a reload notification and update the watch machinery. | 184 // Post a reload notification and update the watch machinery. |
160 void Reload() { | 185 void Reload() { |
161 DCHECK(OnPolicyWatcherThread()); | 186 DCHECK(OnPolicyWatcherThread()); |
162 SetupWatches(); | 187 SetupWatches(); |
163 scoped_ptr<DictionaryValue> new_policy(Load()); | 188 scoped_ptr<DictionaryValue> new_policy(Load()); |
164 UpdatePolicies(new_policy.get()); | 189 UpdatePolicies(new_policy.get()); |
165 } | 190 } |
(...skipping 16 matching lines...) Expand all Loading... | |
182 bool machine_policy_watcher_failed_; | 207 bool machine_policy_watcher_failed_; |
183 }; | 208 }; |
184 | 209 |
185 PolicyWatcher* PolicyWatcher::Create( | 210 PolicyWatcher* PolicyWatcher::Create( |
186 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 211 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
187 return new PolicyWatcherWin(task_runner); | 212 return new PolicyWatcherWin(task_runner); |
188 } | 213 } |
189 | 214 |
190 } // namespace policy_hack | 215 } // namespace policy_hack |
191 } // namespace remoting | 216 } // namespace remoting |
OLD | NEW |