| 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/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 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 CloudPolicyDataStore* CloudPolicyDataStore::CreateForDevicePolicies() { | 24 CloudPolicyDataStore* CloudPolicyDataStore::CreateForDevicePolicies() { |
| 25 return new CloudPolicyDataStore(em::DeviceRegisterRequest::DEVICE, | 25 return new CloudPolicyDataStore(em::DeviceRegisterRequest::DEVICE, |
| 26 dm_protocol::kChromeDevicePolicyType); | 26 dm_protocol::kChromeDevicePolicyType); |
| 27 } | 27 } |
| 28 | 28 |
| 29 CloudPolicyDataStore::CloudPolicyDataStore( | 29 CloudPolicyDataStore::CloudPolicyDataStore( |
| 30 const em::DeviceRegisterRequest_Type policy_register_type, | 30 const em::DeviceRegisterRequest_Type policy_register_type, |
| 31 const std::string& policy_type) | 31 const std::string& policy_type) |
| 32 : user_affiliation_(policy::USER_AFFILIATION_NONE), | 32 : user_affiliation_(USER_AFFILIATION_NONE), |
| 33 policy_register_type_(policy_register_type), | 33 policy_register_type_(policy_register_type), |
| 34 policy_type_(policy_type), | 34 policy_type_(policy_type), |
| 35 token_cache_loaded_(false) {} | 35 token_cache_loaded_(false) {} |
| 36 | 36 |
| 37 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, | 37 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, |
| 38 bool from_cache) { | 38 bool from_cache) { |
| 39 DCHECK(token_cache_loaded_ != from_cache); | 39 DCHECK(token_cache_loaded_ != from_cache); |
| 40 if (!token_cache_loaded_) { | 40 if (!token_cache_loaded_) { |
| 41 // The cache should be the first to set the token. (It may be "") | 41 // The cache should be the first to set the token. (It may be "") |
| 42 DCHECK(from_cache); | 42 DCHECK(from_cache); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 const std::string& CloudPolicyDataStore::device_id() const { | 96 const std::string& CloudPolicyDataStore::device_id() const { |
| 97 return device_id_; | 97 return device_id_; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void CloudPolicyDataStore::set_user_name(const std::string& user_name) { | 100 void CloudPolicyDataStore::set_user_name(const std::string& user_name) { |
| 101 user_name_ = user_name; | 101 user_name_ = user_name; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void CloudPolicyDataStore::set_user_affiliation( | 104 void CloudPolicyDataStore::set_user_affiliation( |
| 105 policy::UserAffiliation user_affiliation) { | 105 UserAffiliation user_affiliation) { |
| 106 user_affiliation_ = user_affiliation; | 106 user_affiliation_ = user_affiliation; |
| 107 } | 107 } |
| 108 | 108 |
| 109 const std::string& CloudPolicyDataStore::device_token() const { | 109 const std::string& CloudPolicyDataStore::device_token() const { |
| 110 return device_token_; | 110 return device_token_; |
| 111 } | 111 } |
| 112 | 112 |
| 113 const std::string& CloudPolicyDataStore::gaia_token() const { | 113 const std::string& CloudPolicyDataStore::gaia_token() const { |
| 114 return gaia_token_; | 114 return gaia_token_; |
| 115 } | 115 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool CloudPolicyDataStore::token_cache_loaded() const { | 142 bool CloudPolicyDataStore::token_cache_loaded() const { |
| 143 return token_cache_loaded_; | 143 return token_cache_loaded_; |
| 144 } | 144 } |
| 145 | 145 |
| 146 const std::string& CloudPolicyDataStore::user_name() const { | 146 const std::string& CloudPolicyDataStore::user_name() const { |
| 147 return user_name_; | 147 return user_name_; |
| 148 } | 148 } |
| 149 | 149 |
| 150 policy::UserAffiliation CloudPolicyDataStore::user_affiliation() const { | 150 UserAffiliation CloudPolicyDataStore::user_affiliation() const { |
| 151 return user_affiliation_; | 151 return user_affiliation_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
| 155 DeviceStatusCollector* | 155 DeviceStatusCollector* |
| 156 CloudPolicyDataStore::device_status_collector() { | 156 CloudPolicyDataStore::device_status_collector() { |
| 157 return device_status_collector_.get(); | 157 return device_status_collector_.get(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void CloudPolicyDataStore::set_device_status_collector( | 160 void CloudPolicyDataStore::set_device_status_collector( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 175 | 175 |
| 176 void CloudPolicyDataStore::NotifyCredentialsChanged() { | 176 void CloudPolicyDataStore::NotifyCredentialsChanged() { |
| 177 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); | 177 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { | 180 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { |
| 181 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); | 181 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace policy | 184 } // namespace policy |
| OLD | NEW |