OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/ownership/owner_settings_service_chromeos.h" | 5 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 policy_data.set_username(user_id_); | 217 policy_data.set_username(user_id_); |
218 CHECK(device_settings_.SerializeToString(policy_data.mutable_policy_value())); | 218 CHECK(device_settings_.SerializeToString(policy_data.mutable_policy_value())); |
219 FOR_EACH_OBSERVER(OwnerSettingsService::Observer, | 219 FOR_EACH_OBSERVER(OwnerSettingsService::Observer, |
220 observers_, | 220 observers_, |
221 OnTentativeChangesInPolicy(policy_data)); | 221 OnTentativeChangesInPolicy(policy_data)); |
222 has_pending_changes_ = true; | 222 has_pending_changes_ = true; |
223 StoreDeviceSettings(); | 223 StoreDeviceSettings(); |
224 return true; | 224 return true; |
225 } | 225 } |
226 | 226 |
| 227 bool OwnerSettingsServiceChromeOS::CommitTentativeDeviceSettings( |
| 228 scoped_ptr<enterprise_management::PolicyData> policy) { |
| 229 if (!IsOwner() && !IsOwnerInTests(user_id_)) |
| 230 return false; |
| 231 if (policy->username() != user_id_) { |
| 232 LOG(ERROR) << "Username mismatch: " << policy->username() << " vs. " |
| 233 << user_id_; |
| 234 return false; |
| 235 } |
| 236 CHECK(device_settings_.ParseFromString(policy->policy_value())); |
| 237 FOR_EACH_OBSERVER(OwnerSettingsService::Observer, |
| 238 observers_, |
| 239 OnTentativeChangesInPolicy(*policy)); |
| 240 has_pending_changes_ = true; |
| 241 StoreDeviceSettings(); |
| 242 return true; |
| 243 } |
| 244 |
227 void OwnerSettingsServiceChromeOS::Observe( | 245 void OwnerSettingsServiceChromeOS::Observe( |
228 int type, | 246 int type, |
229 const content::NotificationSource& source, | 247 const content::NotificationSource& source, |
230 const content::NotificationDetails& details) { | 248 const content::NotificationDetails& details) { |
231 DCHECK(thread_checker_.CalledOnValidThread()); | 249 DCHECK(thread_checker_.CalledOnValidThread()); |
232 if (type != chrome::NOTIFICATION_PROFILE_CREATED) { | 250 if (type != chrome::NOTIFICATION_PROFILE_CREATED) { |
233 NOTREACHED(); | 251 NOTREACHED(); |
234 return; | 252 return; |
235 } | 253 } |
236 | 254 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 return false; | 618 return false; |
601 } | 619 } |
602 enterprise_management::ChromeDeviceSettingsProto settings = | 620 enterprise_management::ChromeDeviceSettingsProto settings = |
603 *device_settings_service_->device_settings(); | 621 *device_settings_service_->device_settings(); |
604 settings.MergeFrom(device_settings_); | 622 settings.MergeFrom(device_settings_); |
605 device_settings_.Swap(&settings); | 623 device_settings_.Swap(&settings); |
606 return true; | 624 return true; |
607 } | 625 } |
608 | 626 |
609 } // namespace chromeos | 627 } // namespace chromeos |
OLD | NEW |