| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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: | 5 // Most of this code is copied from: |
| 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} | 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} |
| 7 | 7 |
| 8 #include "remoting/host/plugin/policy_hack/nat_policy.h" | 8 #include "remoting/host/plugin/policy_hack/nat_policy.h" |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 if (!new_policy->HasKey(kNatPolicyName)) { | 88 if (!new_policy->HasKey(kNatPolicyName)) { |
| 89 // If unspecified, the default value of this policy is true. | 89 // If unspecified, the default value of this policy is true. |
| 90 // | 90 // |
| 91 // TODO(ajwong): Currently defaults to false until we have policy | 91 // TODO(ajwong): Currently defaults to false until we have policy |
| 92 // implemented and verified in all 3 platforms. | 92 // implemented and verified in all 3 platforms. |
| 93 new_nat_enabled_state = false; | 93 new_nat_enabled_state = false; |
| 94 } else { | 94 } else { |
| 95 // Otherwise, try to parse the value and only change from false if we get | 95 // Otherwise, try to parse the value and only change from false if we get |
| 96 // a successful read. | 96 // a successful read. |
| 97 base::Value* value; | 97 base::Value* value; |
| 98 if (new_policy->Get(kNatPolicyName, &value) && | 98 if (new_policy->Get(kNatPolicyName, &value) && value->IsBoolean()) |
| 99 value->IsType(base::Value::TYPE_BOOLEAN)) { | |
| 100 CHECK(value->GetAsBoolean(&new_nat_enabled_state)); | 99 CHECK(value->GetAsBoolean(&new_nat_enabled_state)); |
| 101 } | |
| 102 } | 100 } |
| 103 | 101 |
| 104 if (!first_state_published_ || | 102 if (!first_state_published_ || |
| 105 (new_nat_enabled_state != current_nat_enabled_state_)) { | 103 (new_nat_enabled_state != current_nat_enabled_state_)) { |
| 106 first_state_published_ = true; | 104 first_state_published_ = true; |
| 107 current_nat_enabled_state_ = new_nat_enabled_state; | 105 current_nat_enabled_state_ = new_nat_enabled_state; |
| 108 nat_enabled_cb_.Run(current_nat_enabled_state_); | 106 nat_enabled_cb_.Run(current_nat_enabled_state_); |
| 109 } | 107 } |
| 110 } | 108 } |
| 111 | 109 |
| 112 } // namespace policy_hack | 110 } // namespace policy_hack |
| 113 } // namespace remoting | 111 } // namespace remoting |
| OLD | NEW |