Index: remoting/host/policy_hack/policy_watcher.cc |
diff --git a/remoting/host/policy_hack/policy_watcher.cc b/remoting/host/policy_hack/policy_watcher.cc |
index 565119844283900db006bec40ff119d62ca575fc..33e5d7bc02c0d7d898474d4b2107c0ffcb3ab1e8 100644 |
--- a/remoting/host/policy_hack/policy_watcher.cc |
+++ b/remoting/host/policy_hack/policy_watcher.cc |
@@ -41,6 +41,24 @@ bool GetBooleanOrDefault(const base::DictionaryValue* dict, const char* key, |
return default_if_value_not_boolean; |
} |
+// Gets a string from a dictionary, or returns a default value if the string |
+// couldn't be read. |
+std::string GetStringOrDefault(const base::DictionaryValue* dict, |
+ const char* key, |
+ const std::string& default_if_value_missing, |
+ const std::string& default_if_value_not_string) { |
+ if (!dict->HasKey(key)) { |
+ return default_if_value_missing; |
+ } |
+ const base::Value* value; |
+ if (dict->Get(key, &value) && value->IsType(base::Value::TYPE_STRING)) { |
+ std::string string_value; |
+ CHECK(value->GetAsString(&string_value)); |
+ return string_value; |
+ } |
+ return default_if_value_not_string; |
+} |
+ |
// Copies a boolean from one dictionary to another, using a default value |
// if the boolean couldn't be read from the first dictionary. |
void CopyBooleanOrDefault(base::DictionaryValue* to, |
@@ -52,6 +70,17 @@ void CopyBooleanOrDefault(base::DictionaryValue* to, |
default_if_value_not_boolean))); |
} |
+// Copies a string from one dictionary to another, using a default value |
+// if the string couldn't be read from the first dictionary. |
+void CopyStringOrDefault(base::DictionaryValue* to, |
+ const base::DictionaryValue* from, const char* key, |
+ const std::string& default_if_value_missing, |
+ const std::string& default_if_value_not_string) { |
+ to->Set(key, base::Value::CreateStringValue( |
+ GetStringOrDefault(from, key, default_if_value_missing, |
+ default_if_value_not_string))); |
+} |
+ |
// Copies all policy values from one dictionary to another, using default values |
// when necessary. |
scoped_ptr<base::DictionaryValue> AddDefaultValuesWhenNecessary( |
@@ -59,6 +88,8 @@ scoped_ptr<base::DictionaryValue> AddDefaultValuesWhenNecessary( |
scoped_ptr<base::DictionaryValue> to(new base::DictionaryValue()); |
CopyBooleanOrDefault(to.get(), from, |
PolicyWatcher::kNatPolicyName, true, false); |
+ CopyStringOrDefault(to.get(), from, |
+ PolicyWatcher::kHostDomainPolicyName, "", ""); |
return to.Pass(); |
} |
@@ -67,12 +98,21 @@ scoped_ptr<base::DictionaryValue> AddDefaultValuesWhenNecessary( |
const char PolicyWatcher::kNatPolicyName[] = |
"RemoteAccessHostFirewallTraversal"; |
+const char PolicyWatcher::kHostDomainPolicyName[] = |
+ "RemoteAccessHostDomain"; |
+ |
const char* const PolicyWatcher::kBooleanPolicyNames[] = |
{ PolicyWatcher::kNatPolicyName }; |
const int PolicyWatcher::kBooleanPolicyNamesNum = |
arraysize(kBooleanPolicyNames); |
+const char* const PolicyWatcher::kStringPolicyNames[] = |
+ { PolicyWatcher::kHostDomainPolicyName }; |
+ |
+const int PolicyWatcher::kStringPolicyNamesNum = |
+ arraysize(kStringPolicyNames); |
+ |
PolicyWatcher::PolicyWatcher( |
scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
: task_runner_(task_runner), |