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 <memory.h> | 7 #include <memory.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 | 735 |
736 UpdateValuesCache(policy_data, device_settings_, trusted_status_); | 736 UpdateValuesCache(policy_data, device_settings_, trusted_status_); |
737 } | 737 } |
738 | 738 |
739 void DeviceSettingsProvider::UpdateValuesCache( | 739 void DeviceSettingsProvider::UpdateValuesCache( |
740 const em::PolicyData& policy_data, | 740 const em::PolicyData& policy_data, |
741 const em::ChromeDeviceSettingsProto& settings, | 741 const em::ChromeDeviceSettingsProto& settings, |
742 TrustedStatus trusted_status) { | 742 TrustedStatus trusted_status) { |
743 PrefValueMap new_values_cache; | 743 PrefValueMap new_values_cache; |
744 | 744 |
| 745 // Determine whether device is managed. See PolicyData::management_mode docs |
| 746 // for details. |
| 747 bool managed = false; |
| 748 if (policy_data.has_management_mode()) { |
| 749 managed = |
| 750 (policy_data.management_mode() == em::PolicyData::ENTERPRISE_MANAGED); |
| 751 } else { |
| 752 managed = policy_data.has_request_token(); |
| 753 } |
| 754 |
745 // If the device is not managed, we set the device owner value. | 755 // If the device is not managed, we set the device owner value. |
746 if (policy_data.has_username() && !policy_data.has_request_token()) | 756 if (policy_data.has_username() && !managed) |
747 new_values_cache.SetString(kDeviceOwner, policy_data.username()); | 757 new_values_cache.SetString(kDeviceOwner, policy_data.username()); |
748 | 758 |
749 if (policy_data.has_service_account_identity()) { | 759 if (policy_data.has_service_account_identity()) { |
750 new_values_cache.SetString(kServiceAccountIdentity, | 760 new_values_cache.SetString(kServiceAccountIdentity, |
751 policy_data.service_account_identity()); | 761 policy_data.service_account_identity()); |
752 } | 762 } |
753 | 763 |
754 DecodeLoginPolicies(settings, &new_values_cache); | 764 DecodeLoginPolicies(settings, &new_values_cache); |
755 DecodeNetworkPolicies(settings, &new_values_cache); | 765 DecodeNetworkPolicies(settings, &new_values_cache); |
756 DecodeAutoUpdatePolicies(settings, &new_values_cache); | 766 DecodeAutoUpdatePolicies(settings, &new_values_cache); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 // Notify the observers we are done. | 910 // Notify the observers we are done. |
901 std::vector<base::Closure> callbacks; | 911 std::vector<base::Closure> callbacks; |
902 callbacks.swap(callbacks_); | 912 callbacks.swap(callbacks_); |
903 for (size_t i = 0; i < callbacks.size(); ++i) | 913 for (size_t i = 0; i < callbacks.size(); ++i) |
904 callbacks[i].Run(); | 914 callbacks[i].Run(); |
905 | 915 |
906 return settings_loaded; | 916 return settings_loaded; |
907 } | 917 } |
908 | 918 |
909 } // namespace chromeos | 919 } // namespace chromeos |
OLD | NEW |