| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 !policy.has_show_user_names() || | 155 !policy.has_show_user_names() || |
| 156 !policy.show_user_names().has_show_user_names() || | 156 !policy.show_user_names().has_show_user_names() || |
| 157 policy.show_user_names().show_user_names()); | 157 policy.show_user_names().show_user_names()); |
| 158 | 158 |
| 159 new_values_cache->SetBoolean( | 159 new_values_cache->SetBoolean( |
| 160 kAccountsPrefEphemeralUsersEnabled, | 160 kAccountsPrefEphemeralUsersEnabled, |
| 161 policy.has_ephemeral_users_enabled() && | 161 policy.has_ephemeral_users_enabled() && |
| 162 policy.ephemeral_users_enabled().has_ephemeral_users_enabled() && | 162 policy.ephemeral_users_enabled().has_ephemeral_users_enabled() && |
| 163 policy.ephemeral_users_enabled().ephemeral_users_enabled()); | 163 policy.ephemeral_users_enabled().ephemeral_users_enabled()); |
| 164 | 164 |
| 165 scoped_ptr<base::ListValue> list(new base::ListValue()); | 165 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 166 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); | 166 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); |
| 167 const RepeatedPtrField<std::string>& whitelist = | 167 const RepeatedPtrField<std::string>& whitelist = |
| 168 whitelist_proto.user_whitelist(); | 168 whitelist_proto.user_whitelist(); |
| 169 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | 169 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
| 170 it != whitelist.end(); ++it) { | 170 it != whitelist.end(); ++it) { |
| 171 list->Append(new base::StringValue(*it)); | 171 list->Append(new base::StringValue(*it)); |
| 172 } | 172 } |
| 173 new_values_cache->SetValue(kAccountsPrefUsers, std::move(list)); | 173 new_values_cache->SetValue(kAccountsPrefUsers, std::move(list)); |
| 174 | 174 |
| 175 scoped_ptr<base::ListValue> account_list(new base::ListValue()); | 175 std::unique_ptr<base::ListValue> account_list(new base::ListValue()); |
| 176 const em::DeviceLocalAccountsProto device_local_accounts_proto = | 176 const em::DeviceLocalAccountsProto device_local_accounts_proto = |
| 177 policy.device_local_accounts(); | 177 policy.device_local_accounts(); |
| 178 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = | 178 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
| 179 device_local_accounts_proto.account(); | 179 device_local_accounts_proto.account(); |
| 180 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; | 180 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; |
| 181 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { | 181 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { |
| 182 scoped_ptr<base::DictionaryValue> entry_dict(new base::DictionaryValue()); | 182 std::unique_ptr<base::DictionaryValue> entry_dict( |
| 183 new base::DictionaryValue()); |
| 183 if (entry->has_type()) { | 184 if (entry->has_type()) { |
| 184 if (entry->has_account_id()) { | 185 if (entry->has_account_id()) { |
| 185 entry_dict->SetStringWithoutPathExpansion( | 186 entry_dict->SetStringWithoutPathExpansion( |
| 186 kAccountsPrefDeviceLocalAccountsKeyId, entry->account_id()); | 187 kAccountsPrefDeviceLocalAccountsKeyId, entry->account_id()); |
| 187 } | 188 } |
| 188 entry_dict->SetIntegerWithoutPathExpansion( | 189 entry_dict->SetIntegerWithoutPathExpansion( |
| 189 kAccountsPrefDeviceLocalAccountsKeyType, entry->type()); | 190 kAccountsPrefDeviceLocalAccountsKeyType, entry->type()); |
| 190 if (entry->kiosk_app().has_app_id()) { | 191 if (entry->kiosk_app().has_app_id()) { |
| 191 entry_dict->SetStringWithoutPathExpansion( | 192 entry_dict->SetStringWithoutPathExpansion( |
| 192 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, | 193 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 226 } |
| 226 | 227 |
| 227 new_values_cache->SetBoolean( | 228 new_values_cache->SetBoolean( |
| 228 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, | 229 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, |
| 229 policy.device_local_accounts().enable_auto_login_bailout()); | 230 policy.device_local_accounts().enable_auto_login_bailout()); |
| 230 new_values_cache->SetBoolean( | 231 new_values_cache->SetBoolean( |
| 231 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, | 232 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, |
| 232 policy.device_local_accounts().prompt_for_network_when_offline()); | 233 policy.device_local_accounts().prompt_for_network_when_offline()); |
| 233 | 234 |
| 234 if (policy.has_start_up_flags()) { | 235 if (policy.has_start_up_flags()) { |
| 235 scoped_ptr<base::ListValue> list(new base::ListValue()); | 236 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 236 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); | 237 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); |
| 237 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); | 238 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); |
| 238 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); | 239 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); |
| 239 it != flags.end(); ++it) { | 240 it != flags.end(); ++it) { |
| 240 list->Append(new base::StringValue(*it)); | 241 list->Append(new base::StringValue(*it)); |
| 241 } | 242 } |
| 242 new_values_cache->SetValue(kStartUpFlags, std::move(list)); | 243 new_values_cache->SetValue(kStartUpFlags, std::move(list)); |
| 243 } | 244 } |
| 244 | 245 |
| 245 if (policy.has_saml_settings()) { | 246 if (policy.has_saml_settings()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 PrefValueMap* new_values_cache) { | 288 PrefValueMap* new_values_cache) { |
| 288 if (policy.has_auto_update_settings()) { | 289 if (policy.has_auto_update_settings()) { |
| 289 const em::AutoUpdateSettingsProto& au_settings_proto = | 290 const em::AutoUpdateSettingsProto& au_settings_proto = |
| 290 policy.auto_update_settings(); | 291 policy.auto_update_settings(); |
| 291 if (au_settings_proto.has_update_disabled()) { | 292 if (au_settings_proto.has_update_disabled()) { |
| 292 new_values_cache->SetBoolean(kUpdateDisabled, | 293 new_values_cache->SetBoolean(kUpdateDisabled, |
| 293 au_settings_proto.update_disabled()); | 294 au_settings_proto.update_disabled()); |
| 294 } | 295 } |
| 295 const RepeatedField<int>& allowed_connection_types = | 296 const RepeatedField<int>& allowed_connection_types = |
| 296 au_settings_proto.allowed_connection_types(); | 297 au_settings_proto.allowed_connection_types(); |
| 297 scoped_ptr<base::ListValue> list(new base::ListValue()); | 298 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 298 for (RepeatedField<int>::const_iterator i(allowed_connection_types.begin()); | 299 for (RepeatedField<int>::const_iterator i(allowed_connection_types.begin()); |
| 299 i != allowed_connection_types.end(); ++i) { | 300 i != allowed_connection_types.end(); ++i) { |
| 300 list->Append(new base::FundamentalValue(*i)); | 301 list->Append(new base::FundamentalValue(*i)); |
| 301 } | 302 } |
| 302 new_values_cache->SetValue(kAllowedConnectionTypesForUpdate, | 303 new_values_cache->SetValue(kAllowedConnectionTypesForUpdate, |
| 303 std::move(list)); | 304 std::move(list)); |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 | 307 |
| 307 void DecodeReportingPolicies( | 308 void DecodeReportingPolicies( |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 trusted_status_ = TEMPORARILY_UNTRUSTED; | 597 trusted_status_ = TEMPORARILY_UNTRUSTED; |
| 597 // Apply the locally-accumulated device settings on top of the initial | 598 // Apply the locally-accumulated device settings on top of the initial |
| 598 // settings from the service and write back the result. | 599 // settings from the service and write back the result. |
| 599 if (device_settings_service_->device_settings()) { | 600 if (device_settings_service_->device_settings()) { |
| 600 em::ChromeDeviceSettingsProto new_settings( | 601 em::ChromeDeviceSettingsProto new_settings( |
| 601 *device_settings_service_->device_settings()); | 602 *device_settings_service_->device_settings()); |
| 602 new_settings.MergeFrom(device_settings_); | 603 new_settings.MergeFrom(device_settings_); |
| 603 device_settings_.Swap(&new_settings); | 604 device_settings_.Swap(&new_settings); |
| 604 } | 605 } |
| 605 | 606 |
| 606 scoped_ptr<em::PolicyData> policy(new em::PolicyData()); | 607 std::unique_ptr<em::PolicyData> policy(new em::PolicyData()); |
| 607 policy->set_username(device_settings_service_->GetUsername()); | 608 policy->set_username(device_settings_service_->GetUsername()); |
| 608 CHECK(device_settings_.SerializeToString(policy->mutable_policy_value())); | 609 CHECK(device_settings_.SerializeToString(policy->mutable_policy_value())); |
| 609 if (!device_settings_service_->GetOwnerSettingsService() | 610 if (!device_settings_service_->GetOwnerSettingsService() |
| 610 ->CommitTentativeDeviceSettings(std::move(policy))) { | 611 ->CommitTentativeDeviceSettings(std::move(policy))) { |
| 611 LOG(ERROR) << "Can't store policy"; | 612 LOG(ERROR) << "Can't store policy"; |
| 612 } | 613 } |
| 613 } | 614 } |
| 614 | 615 |
| 615 ownership_status_ = new_ownership_status; | 616 ownership_status_ = new_ownership_status; |
| 616 } | 617 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 // Notify the observers we are done. | 813 // Notify the observers we are done. |
| 813 std::vector<base::Closure> callbacks; | 814 std::vector<base::Closure> callbacks; |
| 814 callbacks.swap(callbacks_); | 815 callbacks.swap(callbacks_); |
| 815 for (size_t i = 0; i < callbacks.size(); ++i) | 816 for (size_t i = 0; i < callbacks.size(); ++i) |
| 816 callbacks[i].Run(); | 817 callbacks[i].Run(); |
| 817 | 818 |
| 818 return settings_loaded; | 819 return settings_loaded; |
| 819 } | 820 } |
| 820 | 821 |
| 821 } // namespace chromeos | 822 } // namespace chromeos |
| OLD | NEW |