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/chromeos/settings/device_settings_provider.h" | 5 #include "chrome/browser/chromeos/settings/device_settings_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 NotifyObservers(path); | 512 NotifyObservers(path); |
513 return; | 513 return; |
514 } | 514 } |
515 } else { | 515 } else { |
516 // Temporary store new setting in | 516 // Temporary store new setting in |
517 // |device_settings_|. |device_settings_| will be stored on a disk | 517 // |device_settings_|. |device_settings_| will be stored on a disk |
518 // as soon as an ownership of device the will be taken. | 518 // as soon as an ownership of device the will be taken. |
519 OwnerSettingsServiceChromeOS::UpdateDeviceSettings( | 519 OwnerSettingsServiceChromeOS::UpdateDeviceSettings( |
520 path, in_value, device_settings_); | 520 path, in_value, device_settings_); |
521 em::PolicyData data; | 521 em::PolicyData data; |
522 data.set_username(device_settings_service_->GetUsername()); | 522 data.set_username(device_settings_service_->GetUserID().GetUserEmail()); |
523 CHECK(device_settings_.SerializeToString(data.mutable_policy_value())); | 523 CHECK(device_settings_.SerializeToString(data.mutable_policy_value())); |
524 | 524 |
525 // Set the cache to the updated value. | 525 // Set the cache to the updated value. |
526 UpdateValuesCache(data, device_settings_, TEMPORARILY_UNTRUSTED); | 526 UpdateValuesCache(data, device_settings_, TEMPORARILY_UNTRUSTED); |
527 | 527 |
528 if (!device_settings_cache::Store(data, g_browser_process->local_state())) { | 528 if (!device_settings_cache::Store(data, g_browser_process->local_state())) { |
529 LOG(ERROR) << "Couldn't store to the temp storage."; | 529 LOG(ERROR) << "Couldn't store to the temp storage."; |
530 NotifyObservers(path); | 530 NotifyObservers(path); |
531 return; | 531 return; |
532 } | 532 } |
(...skipping 26 matching lines...) Expand all Loading... |
559 // Apply the locally-accumulated device settings on top of the initial | 559 // Apply the locally-accumulated device settings on top of the initial |
560 // settings from the service and write back the result. | 560 // settings from the service and write back the result. |
561 if (device_settings_service_->device_settings()) { | 561 if (device_settings_service_->device_settings()) { |
562 em::ChromeDeviceSettingsProto new_settings( | 562 em::ChromeDeviceSettingsProto new_settings( |
563 *device_settings_service_->device_settings()); | 563 *device_settings_service_->device_settings()); |
564 new_settings.MergeFrom(device_settings_); | 564 new_settings.MergeFrom(device_settings_); |
565 device_settings_.Swap(&new_settings); | 565 device_settings_.Swap(&new_settings); |
566 } | 566 } |
567 | 567 |
568 scoped_ptr<em::PolicyData> policy(new em::PolicyData()); | 568 scoped_ptr<em::PolicyData> policy(new em::PolicyData()); |
569 policy->set_username(device_settings_service_->GetUsername()); | 569 policy->set_username(device_settings_service_->GetUserID().GetUserEmail()); |
570 CHECK(device_settings_.SerializeToString(policy->mutable_policy_value())); | 570 CHECK(device_settings_.SerializeToString(policy->mutable_policy_value())); |
571 if (!device_settings_service_->GetOwnerSettingsService() | 571 if (!device_settings_service_->GetOwnerSettingsService() |
572 ->CommitTentativeDeviceSettings(policy.Pass())) { | 572 ->CommitTentativeDeviceSettings(policy.Pass())) { |
573 LOG(ERROR) << "Can't store policy"; | 573 LOG(ERROR) << "Can't store policy"; |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 // The owner key might have become available, allowing migration to happen. | 577 // The owner key might have become available, allowing migration to happen. |
578 AttemptMigration(); | 578 AttemptMigration(); |
579 | 579 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 void DeviceSettingsProvider::AttemptMigration() { | 819 void DeviceSettingsProvider::AttemptMigration() { |
820 if (device_settings_service_->HasPrivateOwnerKey()) { | 820 if (device_settings_service_->HasPrivateOwnerKey()) { |
821 PrefValueMap::const_iterator i; | 821 PrefValueMap::const_iterator i; |
822 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 822 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
823 DoSet(i->first, *i->second); | 823 DoSet(i->first, *i->second); |
824 migration_values_.Clear(); | 824 migration_values_.Clear(); |
825 } | 825 } |
826 } | 826 } |
827 | 827 |
828 } // namespace chromeos | 828 } // namespace chromeos |
OLD | NEW |