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

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

Issue 10816036: [Chromoting] Add a host domain policy to the PolicyWatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix to match r148833. 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 | « remoting/host/policy_hack/policy_watcher.h ('k') | remoting/host/policy_hack/policy_watcher_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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),
« no previous file with comments | « remoting/host/policy_hack/policy_watcher.h ('k') | remoting/host/policy_hack/policy_watcher_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698