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 #include "chrome/browser/policy/policy_service.h" | 5 #include "chrome/browser/policy/policy_service.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 | 8 |
9 namespace policy { | 9 namespace policy { |
10 | 10 |
11 PolicyNamespace::PolicyNamespace() {} | |
12 | |
13 PolicyNamespace::PolicyNamespace(PolicyDomain domain, | |
14 const std::string& component_id) | |
15 : domain(domain), | |
16 component_id(component_id) {} | |
17 | |
18 PolicyNamespace::PolicyNamespace(const PolicyNamespace& other) | |
19 : domain(other.domain), | |
20 component_id(other.component_id) {} | |
21 | |
22 PolicyNamespace::~PolicyNamespace() {} | |
23 | |
24 PolicyNamespace& PolicyNamespace::operator=(const PolicyNamespace& other) { | |
25 domain = other.domain; | |
26 component_id = other.component_id; | |
27 return *this; | |
28 } | |
29 | |
30 bool PolicyNamespace::operator<(const PolicyNamespace& other) const { | |
31 return domain < other.domain || | |
32 (domain == other.domain && component_id < other.component_id); | |
33 } | |
34 | |
35 bool PolicyNamespace::operator==(const PolicyNamespace& other) const { | |
36 return domain == other.domain && component_id == other.component_id; | |
37 } | |
38 | |
39 bool PolicyNamespace::operator!=(const PolicyNamespace& other) const { | |
40 return !(*this == other); | |
41 } | |
42 | |
43 PolicyChangeRegistrar::PolicyChangeRegistrar(PolicyService* policy_service, | 11 PolicyChangeRegistrar::PolicyChangeRegistrar(PolicyService* policy_service, |
44 const PolicyNamespace& ns) | 12 const PolicyNamespace& ns) |
45 : policy_service_(policy_service), | 13 : policy_service_(policy_service), |
46 ns_(ns) {} | 14 ns_(ns) {} |
47 | 15 |
48 PolicyChangeRegistrar::~PolicyChangeRegistrar() { | 16 PolicyChangeRegistrar::~PolicyChangeRegistrar() { |
49 if (!callback_map_.empty()) | 17 if (!callback_map_.empty()) |
50 policy_service_->RemoveObserver(ns_.domain, this); | 18 policy_service_->RemoveObserver(ns_.domain, this); |
51 } | 19 } |
52 | 20 |
(...skipping 12 matching lines...) Expand all Loading... |
65 for (CallbackMap::iterator it = callback_map_.begin(); | 33 for (CallbackMap::iterator it = callback_map_.begin(); |
66 it != callback_map_.end(); ++it) { | 34 it != callback_map_.end(); ++it) { |
67 const Value* prev = previous.GetValue(it->first); | 35 const Value* prev = previous.GetValue(it->first); |
68 const Value* cur = current.GetValue(it->first); | 36 const Value* cur = current.GetValue(it->first); |
69 if (!base::Value::Equals(prev, cur)) | 37 if (!base::Value::Equals(prev, cur)) |
70 it->second.Run(prev, cur); | 38 it->second.Run(prev, cur); |
71 } | 39 } |
72 } | 40 } |
73 | 41 |
74 } // namespace policy | 42 } // namespace policy |
OLD | NEW |