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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 kReportDeviceLocation, | 60 kReportDeviceLocation, |
61 kReportDeviceVersionInfo, | 61 kReportDeviceVersionInfo, |
62 kScreenSaverExtensionId, | 62 kScreenSaverExtensionId, |
63 kScreenSaverTimeout, | 63 kScreenSaverTimeout, |
64 kSettingProxyEverywhere, | 64 kSettingProxyEverywhere, |
65 kSignedDataRoamingEnabled, | 65 kSignedDataRoamingEnabled, |
66 kStartUpUrls, | 66 kStartUpUrls, |
67 kStatsReportingPref, | 67 kStatsReportingPref, |
68 kSystemTimezonePolicy, | 68 kSystemTimezonePolicy, |
69 kStartUpFlags, | 69 kStartUpFlags, |
| 70 kVariationsRestrictParameter, |
70 }; | 71 }; |
71 | 72 |
72 // Legacy policy file location. Used to detect migration from pre v12 ChromeOS. | 73 // Legacy policy file location. Used to detect migration from pre v12 ChromeOS. |
73 const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences"; | 74 const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences"; |
74 | 75 |
75 bool HasOldMetricsFile() { | 76 bool HasOldMetricsFile() { |
76 // TODO(pastarmovj): Remove this once migration is not needed anymore. | 77 // TODO(pastarmovj): Remove this once migration is not needed anymore. |
77 // If the value is not set we should try to migrate legacy consent file. | 78 // If the value is not set we should try to migrate legacy consent file. |
78 // Loading consent file state causes us to do blocking IO on UI thread. | 79 // Loading consent file state causes us to do blocking IO on UI thread. |
79 // Temporarily allow it until we fix http://crbug.com/62626 | 80 // Temporarily allow it until we fix http://crbug.com/62626 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // kIdleLogoutWarningDuration | 346 // kIdleLogoutWarningDuration |
346 // kReleaseChannelDelegated | 347 // kReleaseChannelDelegated |
347 // kReportDeviceVersionInfo | 348 // kReportDeviceVersionInfo |
348 // kReportDeviceActivityTimes | 349 // kReportDeviceActivityTimes |
349 // kReportDeviceBootMode | 350 // kReportDeviceBootMode |
350 // kReportDeviceLocation | 351 // kReportDeviceLocation |
351 // kScreenSaverExtensionId | 352 // kScreenSaverExtensionId |
352 // kScreenSaverTimeout | 353 // kScreenSaverTimeout |
353 // kStartUpUrls | 354 // kStartUpUrls |
354 // kSystemTimezonePolicy | 355 // kSystemTimezonePolicy |
| 356 // kVariationsRestrictParameter |
355 | 357 |
356 LOG(FATAL) << "Device setting " << prop << " is read-only."; | 358 LOG(FATAL) << "Device setting " << prop << " is read-only."; |
357 } | 359 } |
358 | 360 |
359 em::PolicyData data; | 361 em::PolicyData data; |
360 data.set_username(device_settings_service_->GetUsername()); | 362 data.set_username(device_settings_service_->GetUsername()); |
361 CHECK(device_settings_.SerializeToString(data.mutable_policy_value())); | 363 CHECK(device_settings_.SerializeToString(data.mutable_policy_value())); |
362 | 364 |
363 // Set the cache to the updated value. | 365 // Set the cache to the updated value. |
364 UpdateValuesCache(data, device_settings_, trusted_status_); | 366 UpdateValuesCache(data, device_settings_, trusted_status_); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 613 |
612 if (policy.has_allow_redeem_offers()) { | 614 if (policy.has_allow_redeem_offers()) { |
613 new_values_cache->SetBoolean( | 615 new_values_cache->SetBoolean( |
614 kAllowRedeemChromeOsRegistrationOffers, | 616 kAllowRedeemChromeOsRegistrationOffers, |
615 policy.allow_redeem_offers().allow_redeem_offers()); | 617 policy.allow_redeem_offers().allow_redeem_offers()); |
616 } else { | 618 } else { |
617 new_values_cache->SetBoolean( | 619 new_values_cache->SetBoolean( |
618 kAllowRedeemChromeOsRegistrationOffers, | 620 kAllowRedeemChromeOsRegistrationOffers, |
619 !g_browser_process->browser_policy_connector()->IsEnterpriseManaged()); | 621 !g_browser_process->browser_policy_connector()->IsEnterpriseManaged()); |
620 } | 622 } |
| 623 |
| 624 if (policy.has_variations_parameter()) { |
| 625 new_values_cache->SetString( |
| 626 kVariationsRestrictParameter, |
| 627 policy.variations_parameter().parameter()); |
| 628 } |
621 } | 629 } |
622 | 630 |
623 void DeviceSettingsProvider::UpdateValuesCache( | 631 void DeviceSettingsProvider::UpdateValuesCache( |
624 const em::PolicyData& policy_data, | 632 const em::PolicyData& policy_data, |
625 const em::ChromeDeviceSettingsProto& settings, | 633 const em::ChromeDeviceSettingsProto& settings, |
626 TrustedStatus trusted_status) { | 634 TrustedStatus trusted_status) { |
627 PrefValueMap new_values_cache; | 635 PrefValueMap new_values_cache; |
628 | 636 |
629 if (policy_data.has_username() && !policy_data.has_request_token()) | 637 if (policy_data.has_username() && !policy_data.has_request_token()) |
630 new_values_cache.SetString(kDeviceOwner, policy_data.username()); | 638 new_values_cache.SetString(kDeviceOwner, policy_data.username()); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 void DeviceSettingsProvider::AttemptMigration() { | 864 void DeviceSettingsProvider::AttemptMigration() { |
857 if (device_settings_service_->HasPrivateOwnerKey()) { | 865 if (device_settings_service_->HasPrivateOwnerKey()) { |
858 PrefValueMap::const_iterator i; | 866 PrefValueMap::const_iterator i; |
859 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 867 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
860 DoSet(i->first, *i->second); | 868 DoSet(i->first, *i->second); |
861 migration_values_.Clear(); | 869 migration_values_.Clear(); |
862 } | 870 } |
863 } | 871 } |
864 | 872 |
865 } // namespace chromeos | 873 } // namespace chromeos |
OLD | NEW |