OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/policy_hack/policy_watcher.h" | 8 #include "remoting/host/policy_hack/policy_watcher.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 const int kFallbackReloadDelayMinutes = 15; | 25 const int kFallbackReloadDelayMinutes = 15; |
26 | 26 |
27 // Gets a boolean from a dictionary, or returns a default value if the boolean | 27 // Gets a boolean from a dictionary, or returns a default value if the boolean |
28 // couldn't be read. | 28 // couldn't be read. |
29 bool GetBooleanOrDefault(const base::DictionaryValue* dict, const char* key, | 29 bool GetBooleanOrDefault(const base::DictionaryValue* dict, const char* key, |
30 bool default_if_value_missing, | 30 bool default_if_value_missing, |
31 bool default_if_value_not_boolean) { | 31 bool default_if_value_not_boolean) { |
32 if (!dict->HasKey(key)) { | 32 if (!dict->HasKey(key)) { |
33 return default_if_value_missing; | 33 return default_if_value_missing; |
34 } | 34 } |
35 base::Value* value; | 35 const base::Value* value; |
36 if (dict->Get(key, &value) && value->IsType(base::Value::TYPE_BOOLEAN)) { | 36 if (dict->Get(key, &value) && value->IsType(base::Value::TYPE_BOOLEAN)) { |
37 bool bool_value; | 37 bool bool_value; |
38 CHECK(value->GetAsBoolean(&bool_value)); | 38 CHECK(value->GetAsBoolean(&bool_value)); |
39 return bool_value; | 39 return bool_value; |
40 } | 40 } |
41 return default_if_value_not_boolean; | 41 return default_if_value_not_boolean; |
42 } | 42 } |
43 | 43 |
44 // Copies a boolean from one dictionary to another, using a default value | 44 // Copies a boolean from one dictionary to another, using a default value |
45 // if the boolean couldn't be read from the first dictionary. | 45 // if the boolean couldn't be read from the first dictionary. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 old_policies_.swap(new_policies); | 154 old_policies_.swap(new_policies); |
155 | 155 |
156 // Notify our client of the changed policies. | 156 // Notify our client of the changed policies. |
157 if (!changed_policies->empty()) { | 157 if (!changed_policies->empty()) { |
158 policy_callback_.Run(changed_policies.Pass()); | 158 policy_callback_.Run(changed_policies.Pass()); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 } // namespace policy_hack | 162 } // namespace policy_hack |
163 } // namespace remoting | 163 } // namespace remoting |
OLD | NEW |