OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef REMOTING_HOST_POLICY_WATCHER_H_ | 5 #ifndef REMOTING_HOST_POLICY_WATCHER_H_ |
6 #define REMOTING_HOST_POLICY_WATCHER_H_ | 6 #define REMOTING_HOST_POLICY_WATCHER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // policy from files / registry / preferences (although (2) is just an | 73 // policy from files / registry / preferences (although (2) is just an |
74 // implementation detail and should likely be ignored outside of | 74 // implementation detail and should likely be ignored outside of |
75 // PolicyWatcher). | 75 // PolicyWatcher). |
76 static scoped_ptr<PolicyWatcher> Create( | 76 static scoped_ptr<PolicyWatcher> Create( |
77 policy::PolicyService* policy_service, | 77 policy::PolicyService* policy_service, |
78 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); | 78 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); |
79 | 79 |
80 private: | 80 private: |
81 friend class PolicyWatcherTest; | 81 friend class PolicyWatcherTest; |
82 | 82 |
83 // Takes the policy dictionary from the OS specific store and extracts the | |
84 // relevant policies. | |
85 void UpdatePolicies(const base::DictionaryValue* new_policy); | |
86 | |
87 // Gets Chromoting schema stored inside |owned_schema_registry_|. | 83 // Gets Chromoting schema stored inside |owned_schema_registry_|. |
88 const policy::Schema* GetPolicySchema() const; | 84 const policy::Schema* GetPolicySchema() const; |
89 | 85 |
| 86 // Simplifying wrapper around Schema::Normalize. |
| 87 // - Returns false if |dict| is invalid (i.e. contains mistyped policy |
| 88 // values). |
| 89 // - Returns true if |dict| was valid or got normalized. |
| 90 bool NormalizePolicies(base::DictionaryValue* dict); |
| 91 |
| 92 // Stores |new_policies| into |old_policies_|. Returns dictionary with items |
| 93 // from |new_policies| that are different from the old |old_policies_|. |
| 94 scoped_ptr<base::DictionaryValue> StoreNewAndReturnChangedPolicies( |
| 95 scoped_ptr<base::DictionaryValue> new_policies); |
| 96 |
90 // Signals policy error to the registered |PolicyErrorCallback|. | 97 // Signals policy error to the registered |PolicyErrorCallback|. |
91 void SignalPolicyError(); | 98 void SignalPolicyError(); |
92 | 99 |
93 // |policy_service_task_runner| is the task runner where it is safe | 100 // |policy_service_task_runner| is the task runner where it is safe |
94 // to call |policy_service_| methods and where we expect to get callbacks | 101 // to call |policy_service_| methods and where we expect to get callbacks |
95 // from |policy_service_|. | 102 // from |policy_service_|. |
96 PolicyWatcher( | 103 PolicyWatcher( |
97 policy::PolicyService* policy_service, | 104 policy::PolicyService* policy_service, |
98 scoped_ptr<policy::PolicyService> owned_policy_service, | 105 scoped_ptr<policy::PolicyService> owned_policy_service, |
99 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider, | 106 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider, |
(...skipping 28 matching lines...) Expand all Loading... |
128 scoped_ptr<policy::SchemaRegistry> owned_schema_registry_; | 135 scoped_ptr<policy::SchemaRegistry> owned_schema_registry_; |
129 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider_; | 136 scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider_; |
130 scoped_ptr<policy::PolicyService> owned_policy_service_; | 137 scoped_ptr<policy::PolicyService> owned_policy_service_; |
131 | 138 |
132 DISALLOW_COPY_AND_ASSIGN(PolicyWatcher); | 139 DISALLOW_COPY_AND_ASSIGN(PolicyWatcher); |
133 }; | 140 }; |
134 | 141 |
135 } // namespace remoting | 142 } // namespace remoting |
136 | 143 |
137 #endif // REMOTING_HOST_POLICY_WATCHER_H_ | 144 #endif // REMOTING_HOST_POLICY_WATCHER_H_ |
OLD | NEW |