| 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/policy/proto/device_management_backend.pb.h" | 9 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 10 #include "chrome/browser/policy/proto/device_management_constants.h" | 10 #include "chrome/browser/policy/proto/device_management_constants.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 kChromeDevicePolicyType, | 76 kChromeDevicePolicyType, |
| 77 machine_model, | 77 machine_model, |
| 78 machine_id); | 78 machine_id); |
| 79 } | 79 } |
| 80 | 80 |
| 81 CloudPolicyDataStore::CloudPolicyDataStore( | 81 CloudPolicyDataStore::CloudPolicyDataStore( |
| 82 const em::DeviceRegisterRequest_Type policy_register_type, | 82 const em::DeviceRegisterRequest_Type policy_register_type, |
| 83 const std::string& policy_type, | 83 const std::string& policy_type, |
| 84 const std::string& machine_model, | 84 const std::string& machine_model, |
| 85 const std::string& machine_id) | 85 const std::string& machine_id) |
| 86 : user_affiliation_(USER_AFFILIATION_NONE), | 86 : policy_register_type_(policy_register_type), |
| 87 policy_register_type_(policy_register_type), | |
| 88 policy_type_(policy_type), | 87 policy_type_(policy_type), |
| 89 machine_model_(machine_model), | 88 machine_model_(machine_model), |
| 90 machine_id_(machine_id), | 89 machine_id_(machine_id), |
| 91 token_cache_loaded_(false) {} | 90 token_cache_loaded_(false) {} |
| 92 | 91 |
| 93 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, | 92 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, |
| 94 bool from_cache) { | 93 bool from_cache) { |
| 95 DCHECK(token_cache_loaded_ != from_cache); | 94 DCHECK(token_cache_loaded_ != from_cache); |
| 96 if (!token_cache_loaded_) { | 95 if (!token_cache_loaded_) { |
| 97 // The cache should be the first to set the token. (It may be "") | 96 // The cache should be the first to set the token. (It may be "") |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 141 } |
| 143 | 142 |
| 144 const std::string& CloudPolicyDataStore::device_id() const { | 143 const std::string& CloudPolicyDataStore::device_id() const { |
| 145 return device_id_; | 144 return device_id_; |
| 146 } | 145 } |
| 147 | 146 |
| 148 void CloudPolicyDataStore::set_user_name(const std::string& user_name) { | 147 void CloudPolicyDataStore::set_user_name(const std::string& user_name) { |
| 149 user_name_ = user_name; | 148 user_name_ = user_name; |
| 150 } | 149 } |
| 151 | 150 |
| 152 void CloudPolicyDataStore::set_user_affiliation( | |
| 153 UserAffiliation user_affiliation) { | |
| 154 user_affiliation_ = user_affiliation; | |
| 155 } | |
| 156 | |
| 157 const std::string& CloudPolicyDataStore::device_token() const { | 151 const std::string& CloudPolicyDataStore::device_token() const { |
| 158 return device_token_; | 152 return device_token_; |
| 159 } | 153 } |
| 160 | 154 |
| 161 const std::string& CloudPolicyDataStore::gaia_token() const { | 155 const std::string& CloudPolicyDataStore::gaia_token() const { |
| 162 return gaia_token_; | 156 return gaia_token_; |
| 163 } | 157 } |
| 164 | 158 |
| 165 const std::string& CloudPolicyDataStore::oauth_token() const { | 159 const std::string& CloudPolicyDataStore::oauth_token() const { |
| 166 return oauth_token_; | 160 return oauth_token_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 188 } | 182 } |
| 189 | 183 |
| 190 bool CloudPolicyDataStore::token_cache_loaded() const { | 184 bool CloudPolicyDataStore::token_cache_loaded() const { |
| 191 return token_cache_loaded_; | 185 return token_cache_loaded_; |
| 192 } | 186 } |
| 193 | 187 |
| 194 const std::string& CloudPolicyDataStore::user_name() const { | 188 const std::string& CloudPolicyDataStore::user_name() const { |
| 195 return user_name_; | 189 return user_name_; |
| 196 } | 190 } |
| 197 | 191 |
| 198 const CloudPolicyDataStore::UserAffiliation | |
| 199 CloudPolicyDataStore::user_affiliation() const { | |
| 200 return user_affiliation_; | |
| 201 } | |
| 202 | |
| 203 void CloudPolicyDataStore::AddObserver( | 192 void CloudPolicyDataStore::AddObserver( |
| 204 CloudPolicyDataStore::Observer* observer) { | 193 CloudPolicyDataStore::Observer* observer) { |
| 205 observer_list_.AddObserver(observer); | 194 observer_list_.AddObserver(observer); |
| 206 } | 195 } |
| 207 | 196 |
| 208 void CloudPolicyDataStore::RemoveObserver( | 197 void CloudPolicyDataStore::RemoveObserver( |
| 209 CloudPolicyDataStore::Observer* observer) { | 198 CloudPolicyDataStore::Observer* observer) { |
| 210 observer_list_.RemoveObserver(observer); | 199 observer_list_.RemoveObserver(observer); |
| 211 } | 200 } |
| 212 | 201 |
| 213 void CloudPolicyDataStore::NotifyCredentialsChanged() { | 202 void CloudPolicyDataStore::NotifyCredentialsChanged() { |
| 214 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); | 203 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); |
| 215 } | 204 } |
| 216 | 205 |
| 217 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { | 206 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { |
| 218 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); | 207 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); |
| 219 } | 208 } |
| 220 | 209 |
| 221 } // namespace policy | 210 } // namespace policy |
| OLD | NEW |