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 14 matching lines...) Expand all Loading... |
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_(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 known_machine_id_(false), |
35 token_cache_loaded_(false) {} | 36 token_cache_loaded_(false) {} |
36 | 37 |
37 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, | 38 void CloudPolicyDataStore::SetDeviceToken(const std::string& device_token, |
38 bool from_cache) { | 39 bool from_cache) { |
39 DCHECK(token_cache_loaded_ != from_cache); | 40 DCHECK(token_cache_loaded_ != from_cache); |
40 if (!token_cache_loaded_) { | 41 if (!token_cache_loaded_) { |
41 // 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 "") |
42 DCHECK(from_cache); | 43 DCHECK(from_cache); |
43 token_cache_loaded_ = true; | 44 token_cache_loaded_ = true; |
44 } else { | 45 } else { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 100 |
100 void CloudPolicyDataStore::set_user_name(const std::string& user_name) { | 101 void CloudPolicyDataStore::set_user_name(const std::string& user_name) { |
101 user_name_ = user_name; | 102 user_name_ = user_name; |
102 } | 103 } |
103 | 104 |
104 void CloudPolicyDataStore::set_user_affiliation( | 105 void CloudPolicyDataStore::set_user_affiliation( |
105 UserAffiliation user_affiliation) { | 106 UserAffiliation user_affiliation) { |
106 user_affiliation_ = user_affiliation; | 107 user_affiliation_ = user_affiliation; |
107 } | 108 } |
108 | 109 |
| 110 void CloudPolicyDataStore::set_known_machine_id(bool known_machine_id) { |
| 111 known_machine_id_ = known_machine_id; |
| 112 } |
| 113 |
109 const std::string& CloudPolicyDataStore::device_token() const { | 114 const std::string& CloudPolicyDataStore::device_token() const { |
110 return device_token_; | 115 return device_token_; |
111 } | 116 } |
112 | 117 |
113 const std::string& CloudPolicyDataStore::gaia_token() const { | 118 const std::string& CloudPolicyDataStore::gaia_token() const { |
114 return gaia_token_; | 119 return gaia_token_; |
115 } | 120 } |
116 | 121 |
117 const std::string& CloudPolicyDataStore::oauth_token() const { | 122 const std::string& CloudPolicyDataStore::oauth_token() const { |
118 return oauth_token_; | 123 return oauth_token_; |
(...skipping 25 matching lines...) Expand all Loading... |
144 } | 149 } |
145 | 150 |
146 const std::string& CloudPolicyDataStore::user_name() const { | 151 const std::string& CloudPolicyDataStore::user_name() const { |
147 return user_name_; | 152 return user_name_; |
148 } | 153 } |
149 | 154 |
150 UserAffiliation CloudPolicyDataStore::user_affiliation() const { | 155 UserAffiliation CloudPolicyDataStore::user_affiliation() const { |
151 return user_affiliation_; | 156 return user_affiliation_; |
152 } | 157 } |
153 | 158 |
| 159 bool CloudPolicyDataStore::known_machine_id() const { |
| 160 return known_machine_id_; |
| 161 } |
| 162 |
154 #if defined(OS_CHROMEOS) | 163 #if defined(OS_CHROMEOS) |
155 DeviceStatusCollector* | 164 DeviceStatusCollector* |
156 CloudPolicyDataStore::device_status_collector() { | 165 CloudPolicyDataStore::device_status_collector() { |
157 return device_status_collector_.get(); | 166 return device_status_collector_.get(); |
158 } | 167 } |
159 | 168 |
160 void CloudPolicyDataStore::set_device_status_collector( | 169 void CloudPolicyDataStore::set_device_status_collector( |
161 DeviceStatusCollector* collector) { | 170 DeviceStatusCollector* collector) { |
162 device_status_collector_.reset(collector); | 171 device_status_collector_.reset(collector); |
163 } | 172 } |
(...skipping 11 matching lines...) Expand all Loading... |
175 | 184 |
176 void CloudPolicyDataStore::NotifyCredentialsChanged() { | 185 void CloudPolicyDataStore::NotifyCredentialsChanged() { |
177 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); | 186 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); |
178 } | 187 } |
179 | 188 |
180 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { | 189 void CloudPolicyDataStore::NotifyDeviceTokenChanged() { |
181 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); | 190 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); |
182 } | 191 } |
183 | 192 |
184 } // namespace policy | 193 } // namespace policy |
OLD | NEW |