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

Unified Diff: remoting/host/policy_hack/nat_policy_mac.mm

Issue 10804040: [Chromoting] Refactor the host policy watcher so that policies can easily be added. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass the policy dictionary as a scoped_ptr. 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
Index: remoting/host/policy_hack/nat_policy_mac.mm
diff --git a/remoting/host/policy_hack/nat_policy_mac.mm b/remoting/host/policy_hack/nat_policy_mac.mm
index d3d26215447009caa985a1ff8523681437b5c130..c2b53eadb93fa7380ca3aa13c81d4a33c3964d45 100644
--- a/remoting/host/policy_hack/nat_policy_mac.mm
+++ b/remoting/host/policy_hack/nat_policy_mac.mm
@@ -20,13 +20,14 @@ namespace policy_hack {
// practice on the Mac that the user must logout/login for policies to be
// applied. This will actually pick up policies every
// |kFallbackReloadDelayMinutes| which is sufficient for right now.
-class NatPolicyMac : public NatPolicy {
+class PolicyWatcherMac : public PolicyWatcher {
public:
- explicit NatPolicyMac(scoped_refptr<base::SingleThreadTaskRunner> task_runner)
- : NatPolicy(task_runner) {
+ explicit PolicyWatcherMac(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner)
+ : PolicyWatcher(task_runner) {
}
- virtual ~NatPolicyMac() {
+ virtual ~PolicyWatcherMac() {
}
protected:
@@ -38,34 +39,37 @@ class NatPolicyMac : public NatPolicy {
}
virtual void Reload() OVERRIDE {
- DCHECK(OnPolicyThread());
+ DCHECK(OnPolicyWatcherThread());
base::DictionaryValue policy;
CFStringRef policy_bundle_id = CFSTR("com.google.Chrome");
if (CFPreferencesAppSynchronize(policy_bundle_id)) {
- base::mac::ScopedCFTypeRef<CFStringRef> policy_key(
- base::SysUTF8ToCFStringRef(kNatPolicyName));
- Boolean valid = false;
- bool allowed = CFPreferencesGetAppBooleanValue(policy_key,
- policy_bundle_id,
- &valid);
- if (valid) {
- policy.SetBoolean(kNatPolicyName, allowed);
+ for (int i = 0; i < kBooleanPolicyNamesNum; ++i) {
+ const char* policy_name = kBooleanPolicyNames[i];
+ base::mac::ScopedCFTypeRef<CFStringRef> policy_key(
+ base::SysUTF8ToCFStringRef(policy_name));
+ Boolean valid = false;
+ bool allowed = CFPreferencesGetAppBooleanValue(policy_key,
+ policy_bundle_id,
+ &valid);
+ if (valid) {
+ policy.SetBoolean(policy_name, allowed);
+ }
}
}
// Set policy. Policy must be set (even if it is empty) so that the
// default policy is picked up the first time reload is called.
- UpdateNatPolicy(&policy);
+ UpdatePolicies(&policy);
// Reschedule task.
ScheduleFallbackReloadTask();
}
};
-NatPolicy* NatPolicy::Create(
+PolicyWatcher* PolicyWatcher::Create(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
- return new NatPolicyMac(task_runner);
+ return new PolicyWatcherMac(task_runner);
}
} // namespace policy_hack

Powered by Google App Engine
This is Rietveld 408576698