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 18 matching lines...) Expand all Loading... |
29 #include "chrome/installer/util/google_update_settings.h" | 29 #include "chrome/installer/util/google_update_settings.h" |
30 | 30 |
31 using google::protobuf::RepeatedPtrField; | 31 using google::protobuf::RepeatedPtrField; |
32 | 32 |
33 namespace em = enterprise_management; | 33 namespace em = enterprise_management; |
34 | 34 |
35 namespace chromeos { | 35 namespace chromeos { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
| 39 // Legacy policy file location. Used to detect migration from pre v12 ChromeOS. |
| 40 const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences"; |
| 41 |
39 // List of settings handled by the DeviceSettingsProvider. | 42 // List of settings handled by the DeviceSettingsProvider. |
40 const char* kKnownSettings[] = { | 43 const char* kKnownSettings[] = { |
41 kAccountsPrefAllowGuest, | 44 kAccountsPrefAllowGuest, |
42 kAccountsPrefAllowNewUser, | 45 kAccountsPrefAllowNewUser, |
43 kAccountsPrefEphemeralUsersEnabled, | 46 kAccountsPrefEphemeralUsersEnabled, |
44 kAccountsPrefShowUserNamesOnSignIn, | 47 kAccountsPrefShowUserNamesOnSignIn, |
45 kAccountsPrefUsers, | 48 kAccountsPrefUsers, |
46 kAccountsPrefDeviceLocalAccounts, | 49 kAccountsPrefDeviceLocalAccounts, |
47 kAppPack, | 50 kAppPack, |
48 kDeviceOwner, | 51 kDeviceOwner, |
49 kIdleLogoutTimeout, | 52 kIdleLogoutTimeout, |
50 kIdleLogoutWarningDuration, | 53 kIdleLogoutWarningDuration, |
51 kPolicyMissingMitigationMode, | 54 kPolicyMissingMitigationMode, |
52 kReleaseChannel, | 55 kReleaseChannel, |
53 kReleaseChannelDelegated, | 56 kReleaseChannelDelegated, |
54 kReportDeviceActivityTimes, | 57 kReportDeviceActivityTimes, |
55 kReportDeviceBootMode, | 58 kReportDeviceBootMode, |
56 kReportDeviceLocation, | 59 kReportDeviceLocation, |
57 kReportDeviceVersionInfo, | 60 kReportDeviceVersionInfo, |
58 kScreenSaverExtensionId, | 61 kScreenSaverExtensionId, |
59 kScreenSaverTimeout, | 62 kScreenSaverTimeout, |
60 kSettingProxyEverywhere, | 63 kSettingProxyEverywhere, |
61 kSignedDataRoamingEnabled, | 64 kSignedDataRoamingEnabled, |
62 kStartUpUrls, | 65 kStartUpUrls, |
63 kStatsReportingPref, | 66 kStatsReportingPref, |
64 kSystemTimezonePolicy, | 67 kSystemTimezonePolicy, |
65 }; | 68 }; |
66 | 69 |
67 // Legacy policy file location. Used to detect migration from pre v12 ChromeOS. | 70 } // namespace |
68 const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences"; | 71 |
| 72 const char** DeviceSettingsProvider::kKnownSettingsBegin = kKnownSettings; |
| 73 const char** DeviceSettingsProvider::kKnownSettingsEnd = |
| 74 kKnownSettings + arraysize(kKnownSettings); |
| 75 |
| 76 namespace { |
69 | 77 |
70 bool IsControlledSetting(const std::string& pref_path) { | 78 bool IsControlledSetting(const std::string& pref_path) { |
71 const char** end = kKnownSettings + arraysize(kKnownSettings); | 79 static const char** begin = DeviceSettingsProvider::kKnownSettingsBegin; |
72 return std::find(kKnownSettings, end, pref_path) != end; | 80 static const char** end = DeviceSettingsProvider::kKnownSettingsEnd; |
| 81 return std::find(begin, end, pref_path) != end; |
73 } | 82 } |
74 | 83 |
75 bool HasOldMetricsFile() { | 84 bool HasOldMetricsFile() { |
76 // TODO(pastarmovj): Remove this once migration is not needed anymore. | 85 // 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. | 86 // 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. | 87 // Loading consent file state causes us to do blocking IO on UI thread. |
79 // Temporarily allow it until we fix http://crbug.com/62626 | 88 // Temporarily allow it until we fix http://crbug.com/62626 |
80 base::ThreadRestrictions::ScopedAllowIO allow_io; | 89 base::ThreadRestrictions::ScopedAllowIO allow_io; |
81 return GoogleUpdateSettings::GetCollectStatsConsent(); | 90 return GoogleUpdateSettings::GetCollectStatsConsent(); |
82 } | 91 } |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 void DeviceSettingsProvider::AttemptMigration() { | 781 void DeviceSettingsProvider::AttemptMigration() { |
773 if (device_settings_service_->HasPrivateOwnerKey()) { | 782 if (device_settings_service_->HasPrivateOwnerKey()) { |
774 PrefValueMap::const_iterator i; | 783 PrefValueMap::const_iterator i; |
775 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 784 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
776 DoSet(i->first, *i->second); | 785 DoSet(i->first, *i->second); |
777 migration_values_.Clear(); | 786 migration_values_.Clear(); |
778 } | 787 } |
779 } | 788 } |
780 | 789 |
781 } // namespace chromeos | 790 } // namespace chromeos |
OLD | NEW |