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 #include "chrome/browser/policy/cloud_policy_data_store.h" | 5 #include "chrome/browser/policy/cloud_policy_data_store.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/browser/browser_process.h" | |
9 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 10 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
10 #include "chrome/browser/policy/proto/device_management_constants.h" | 11 #include "chrome/browser/policy/proto/device_management_constants.h" |
11 | 12 |
12 namespace policy { | 13 namespace policy { |
13 | 14 |
14 CloudPolicyDataStore::~CloudPolicyDataStore() {} | 15 CloudPolicyDataStore::~CloudPolicyDataStore() {} |
15 | 16 |
16 // static | 17 // static |
17 CloudPolicyDataStore* CloudPolicyDataStore::CreateForUserPolicies() { | 18 CloudPolicyDataStore* CloudPolicyDataStore::CreateForUserPolicies() { |
18 return new CloudPolicyDataStore(em::DeviceRegisterRequest::USER, | 19 return new CloudPolicyDataStore(em::DeviceRegisterRequest::USER, |
19 kChromeUserPolicyType); | 20 kChromeUserPolicyType); |
20 } | 21 } |
21 | 22 |
22 // static | 23 // static |
23 CloudPolicyDataStore* CloudPolicyDataStore::CreateForDevicePolicies() { | 24 CloudPolicyDataStore* CloudPolicyDataStore::CreateForDevicePolicies() { |
24 return new CloudPolicyDataStore(em::DeviceRegisterRequest::DEVICE, | 25 return new CloudPolicyDataStore(em::DeviceRegisterRequest::DEVICE, |
25 kChromeDevicePolicyType); | 26 kChromeDevicePolicyType); |
26 } | 27 } |
27 | 28 |
28 CloudPolicyDataStore::CloudPolicyDataStore( | 29 CloudPolicyDataStore::CloudPolicyDataStore( |
29 const em::DeviceRegisterRequest_Type policy_register_type, | 30 const em::DeviceRegisterRequest_Type policy_register_type, |
30 const std::string& policy_type) | 31 const std::string& policy_type) |
31 : user_affiliation_(USER_AFFILIATION_NONE), | 32 : user_affiliation_(USER_AFFILIATION_NONE), |
32 policy_register_type_(policy_register_type), | 33 policy_register_type_(policy_register_type), |
33 policy_type_(policy_type), | 34 policy_type_(policy_type), |
34 token_cache_loaded_(false) {} | 35 token_cache_loaded_(false), |
36 device_status_reporter_(g_browser_process->local_state()) {} | |
Mattias Nissler (ping if slow)
2011/11/25 14:15:19
Please pass in the reference to local state so eas
Patrick Dubroy
2011/11/29 18:01:46
Decided to leave this as-is.
| |
35 | 37 |
36 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, | 38 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, |
37 bool from_cache) { | 39 bool from_cache) { |
38 DCHECK(token_cache_loaded_ != from_cache); | 40 DCHECK(token_cache_loaded_ != from_cache); |
39 if (!token_cache_loaded_) { | 41 if (!token_cache_loaded_) { |
40 // The cache should be the first to set the token. (It may be "") | 42 // The cache should be the first to set the token. (It may be "") |
41 DCHECK(from_cache); | 43 DCHECK(from_cache); |
42 token_cache_loaded_ = true; | 44 token_cache_loaded_ = true; |
43 } else { | 45 } else { |
44 // The cache should never set the token later. | 46 // The cache should never set the token later. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 146 |
145 const std::string& CloudPolicyDataStore::user_name() const { | 147 const std::string& CloudPolicyDataStore::user_name() const { |
146 return user_name_; | 148 return user_name_; |
147 } | 149 } |
148 | 150 |
149 CloudPolicyDataStore::UserAffiliation | 151 CloudPolicyDataStore::UserAffiliation |
150 CloudPolicyDataStore::user_affiliation() const { | 152 CloudPolicyDataStore::user_affiliation() const { |
151 return user_affiliation_; | 153 return user_affiliation_; |
152 } | 154 } |
153 | 155 |
156 DeviceStatusReporter* | |
157 CloudPolicyDataStore::device_status_reporter() { | |
158 return &device_status_reporter_; | |
159 } | |
160 | |
154 void CloudPolicyDataStore::AddObserver( | 161 void CloudPolicyDataStore::AddObserver( |
155 CloudPolicyDataStore::Observer* observer) { | 162 CloudPolicyDataStore::Observer* observer) { |
156 observer_list_.AddObserver(observer); | 163 observer_list_.AddObserver(observer); |
157 } | 164 } |
158 | 165 |
159 void CloudPolicyDataStore::RemoveObserver( | 166 void CloudPolicyDataStore::RemoveObserver( |
160 CloudPolicyDataStore::Observer* observer) { | 167 CloudPolicyDataStore::Observer* observer) { |
161 observer_list_.RemoveObserver(observer); | 168 observer_list_.RemoveObserver(observer); |
162 } | 169 } |
163 | 170 |
164 void CloudPolicyDataStore::NotifyCredentialsChanged() { | 171 void CloudPolicyDataStore::NotifyCredentialsChanged() { |
165 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); | 172 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); |
166 } | 173 } |
167 | 174 |
168 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { | 175 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { |
169 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); | 176 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); |
170 } | 177 } |
171 | 178 |
172 } // namespace policy | 179 } // namespace policy |
OLD | NEW |