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