Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: remoting/host/policy_hack/policy_watcher_win.cc

Issue 10832071: [Chromoting] Let the Windows host policy watcher read string-valued policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve use of wide strings. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/policy_hack/policy_watcher_win.cc
diff --git a/remoting/host/policy_hack/policy_watcher_win.cc b/remoting/host/policy_hack/policy_watcher_win.cc
index 9f3b5e4eeb3c583519576840a86ec4394799e297..5628219eeb7ab30e1e5afb2a2371890702ed1740 100644
--- a/remoting/host/policy_hack/policy_watcher_win.cc
+++ b/remoting/host/policy_hack/policy_watcher_win.cc
@@ -112,18 +112,43 @@ class PolicyWatcherWin :
}
}
- bool GetRegistryPolicyInteger(const string16& value_name,
+ bool GetRegistryPolicyString(const std::string& value_name,
+ std::string* result) const {
+ string16 value_name_wide = UTF8ToWide(value_name);
alexeypa (please no reviews) 2012/07/30 22:15:45 string16 -> std::wstring because you are convertin
simonmorris 2012/07/30 23:17:13 Done.
+ std::wstring value;
+ RegKey policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ);
+ if (policy_key.ReadValue(value_name_wide.c_str(), &value) ==
+ ERROR_SUCCESS) {
+ *result = WideToUTF8(value);
+ return true;
+ }
+
+ if (policy_key.Open(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ) ==
+ ERROR_SUCCESS) {
+ if (policy_key.ReadValue(value_name_wide.c_str(), &value) ==
+ ERROR_SUCCESS) {
+ *result = WideToUTF8(value);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetRegistryPolicyInteger(const std::string& value_name,
uint32* result) const {
+ string16 value_name_wide = UTF8ToWide(value_name);
DWORD value = 0;
RegKey policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ);
- if (policy_key.ReadValueDW(value_name.c_str(), &value) == ERROR_SUCCESS) {
+ if (policy_key.ReadValueDW(value_name_wide.c_str(), &value) ==
+ ERROR_SUCCESS) {
*result = value;
return true;
}
if (policy_key.Open(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ) ==
ERROR_SUCCESS) {
- if (policy_key.ReadValueDW(value_name.c_str(), &value) == ERROR_SUCCESS) {
+ if (policy_key.ReadValueDW(value_name_wide.c_str(), &value) ==
+ ERROR_SUCCESS) {
*result = value;
return true;
}
@@ -131,7 +156,7 @@ class PolicyWatcherWin :
return false;
}
- bool GetRegistryPolicyBoolean(const string16& value_name,
+ bool GetRegistryPolicyBoolean(const std::string& value_name,
bool* result) const {
uint32 local_result = 0;
bool ret = GetRegistryPolicyInteger(value_name, &local_result);
@@ -146,13 +171,17 @@ class PolicyWatcherWin :
for (int i = 0; i < kBooleanPolicyNamesNum; ++i) {
const char* policy_name = kBooleanPolicyNames[i];
bool bool_value;
- const string16 name(ASCIIToUTF16(policy_name));
- if (GetRegistryPolicyBoolean(name, &bool_value)) {
+ if (GetRegistryPolicyBoolean(policy_name, &bool_value)) {
policy->SetBoolean(policy_name, bool_value);
}
}
- // TODO(simonmorris): Read policies whose names are in kStringPolicyNames.
-
+ for (int i = 0; i < kStringPolicyNamesNum; ++i) {
+ const char* policy_name = kStringPolicyNames[i];
+ std::string string_value;
+ if (GetRegistryPolicyString(policy_name, &string_value)) {
+ policy->SetString(policy_name, string_value);
+ }
+ }
return policy;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698