Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_provider.cc

Issue 608283003: Remove retail mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 44 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
45 kAccountsPrefDeviceLocalAccountAutoLoginId, 45 kAccountsPrefDeviceLocalAccountAutoLoginId,
46 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, 46 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline,
47 kAccountsPrefEphemeralUsersEnabled, 47 kAccountsPrefEphemeralUsersEnabled,
48 kAccountsPrefShowUserNamesOnSignIn, 48 kAccountsPrefShowUserNamesOnSignIn,
49 kAccountsPrefSupervisedUsersEnabled, 49 kAccountsPrefSupervisedUsersEnabled,
50 kAccountsPrefTransferSAMLCookies, 50 kAccountsPrefTransferSAMLCookies,
51 kAccountsPrefUsers, 51 kAccountsPrefUsers,
52 kAllowRedeemChromeOsRegistrationOffers, 52 kAllowRedeemChromeOsRegistrationOffers,
53 kAllowedConnectionTypesForUpdate, 53 kAllowedConnectionTypesForUpdate,
54 kAppPack, 54 kAppPack,
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
55 kAttestationForContentProtectionEnabled, 55 kAttestationForContentProtectionEnabled,
56 kDeviceAttestationEnabled, 56 kDeviceAttestationEnabled,
57 kDeviceOwner, 57 kDeviceOwner,
58 kIdleLogoutTimeout, 58 kIdleLogoutTimeout,
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
59 kIdleLogoutWarningDuration, 59 kIdleLogoutWarningDuration,
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
60 kPolicyMissingMitigationMode, 60 kPolicyMissingMitigationMode,
61 kReleaseChannel, 61 kReleaseChannel,
62 kReleaseChannelDelegated, 62 kReleaseChannelDelegated,
63 kReportDeviceActivityTimes, 63 kReportDeviceActivityTimes,
64 kReportDeviceBootMode, 64 kReportDeviceBootMode,
65 kReportDeviceLocation, 65 kReportDeviceLocation,
66 kReportDeviceNetworkInterfaces, 66 kReportDeviceNetworkInterfaces,
67 kReportDeviceUsers, 67 kReportDeviceUsers,
68 kReportDeviceVersionInfo, 68 kReportDeviceVersionInfo,
69 kScreenSaverExtensionId, 69 kScreenSaverExtensionId,
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
70 kScreenSaverTimeout, 70 kScreenSaverTimeout,
bartfab (slow) 2014/10/15 09:52:20 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
71 kServiceAccountIdentity, 71 kServiceAccountIdentity,
72 kSignedDataRoamingEnabled, 72 kSignedDataRoamingEnabled,
73 kStartUpFlags, 73 kStartUpFlags,
74 kStartUpUrls,
75 kStatsReportingPref, 74 kStatsReportingPref,
76 kSystemTimezonePolicy, 75 kSystemTimezonePolicy,
77 kSystemUse24HourClock, 76 kSystemUse24HourClock,
78 kUpdateDisabled, 77 kUpdateDisabled,
79 kVariationsRestrictParameter, 78 kVariationsRestrictParameter,
80 }; 79 };
81 80
82 bool HasOldMetricsFile() { 81 bool HasOldMetricsFile() {
83 // TODO(pastarmovj): Remove this once migration is not needed anymore. 82 // TODO(pastarmovj): Remove this once migration is not needed anymore.
84 // If the value is not set we should try to migrate legacy consent file. 83 // If the value is not set we should try to migrate legacy consent file.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 new_values_cache->SetValue(kStartUpFlags, list); 224 new_values_cache->SetValue(kStartUpFlags, list);
226 } 225 }
227 226
228 if (policy.has_saml_settings()) { 227 if (policy.has_saml_settings()) {
229 new_values_cache->SetBoolean( 228 new_values_cache->SetBoolean(
230 kAccountsPrefTransferSAMLCookies, 229 kAccountsPrefTransferSAMLCookies,
231 policy.saml_settings().transfer_saml_cookies()); 230 policy.saml_settings().transfer_saml_cookies());
232 } 231 }
233 } 232 }
234 233
235 void DecodeKioskPolicies(
236 const em::ChromeDeviceSettingsProto& policy,
237 PrefValueMap* new_values_cache) {
238 if (policy.has_forced_logout_timeouts()) {
239 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) {
240 new_values_cache->SetInteger(
241 kIdleLogoutTimeout,
242 policy.forced_logout_timeouts().idle_logout_timeout());
243 }
244
245 if (policy.forced_logout_timeouts().has_idle_logout_warning_duration()) {
246 new_values_cache->SetInteger(
247 kIdleLogoutWarningDuration,
248 policy.forced_logout_timeouts().idle_logout_warning_duration());
249 }
250 }
251
252 if (policy.has_login_screen_saver()) {
253 if (policy.login_screen_saver().has_screen_saver_timeout()) {
254 new_values_cache->SetInteger(
255 kScreenSaverTimeout,
256 policy.login_screen_saver().screen_saver_timeout());
257 }
258
259 if (policy.login_screen_saver().has_screen_saver_extension_id()) {
260 new_values_cache->SetString(
261 kScreenSaverExtensionId,
262 policy.login_screen_saver().screen_saver_extension_id());
263 }
264 }
265
266 if (policy.has_app_pack()) {
267 typedef RepeatedPtrField<em::AppPackEntryProto> proto_type;
268 base::ListValue* list = new base::ListValue;
269 const proto_type& app_pack = policy.app_pack().app_pack();
270 for (proto_type::const_iterator it = app_pack.begin();
271 it != app_pack.end(); ++it) {
272 base::DictionaryValue* entry = new base::DictionaryValue;
273 if (it->has_extension_id()) {
274 entry->SetStringWithoutPathExpansion(kAppPackKeyExtensionId,
275 it->extension_id());
276 }
277 if (it->has_update_url()) {
278 entry->SetStringWithoutPathExpansion(kAppPackKeyUpdateUrl,
279 it->update_url());
280 }
281 list->Append(entry);
282 }
283 new_values_cache->SetValue(kAppPack, list);
284 }
285
286 if (policy.has_start_up_urls()) {
287 base::ListValue* list = new base::ListValue();
288 const em::StartUpUrlsProto& urls_proto = policy.start_up_urls();
289 const RepeatedPtrField<std::string>& urls = urls_proto.start_up_urls();
290 for (RepeatedPtrField<std::string>::const_iterator it = urls.begin();
291 it != urls.end(); ++it) {
292 list->Append(new base::StringValue(*it));
293 }
294 new_values_cache->SetValue(kStartUpUrls, list);
295 }
296 }
297
298 void DecodeNetworkPolicies( 234 void DecodeNetworkPolicies(
299 const em::ChromeDeviceSettingsProto& policy, 235 const em::ChromeDeviceSettingsProto& policy,
300 PrefValueMap* new_values_cache) { 236 PrefValueMap* new_values_cache) {
301 // kSignedDataRoamingEnabled has a default value of false. 237 // kSignedDataRoamingEnabled has a default value of false.
302 new_values_cache->SetBoolean( 238 new_values_cache->SetBoolean(
303 kSignedDataRoamingEnabled, 239 kSignedDataRoamingEnabled,
304 policy.has_data_roaming_enabled() && 240 policy.has_data_roaming_enabled() &&
305 policy.data_roaming_enabled().has_data_roaming_enabled() && 241 policy.data_roaming_enabled().has_data_roaming_enabled() &&
306 policy.data_roaming_enabled().data_roaming_enabled()); 242 policy.data_roaming_enabled().data_roaming_enabled());
307 } 243 }
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 bool setting_enabled; 671 bool setting_enabled;
736 if (value->GetAsBoolean(&setting_enabled)) { 672 if (value->GetAsBoolean(&setting_enabled)) {
737 attestation_settings->set_content_protection_enabled(setting_enabled); 673 attestation_settings->set_content_protection_enabled(setting_enabled);
738 } else { 674 } else {
739 NOTREACHED(); 675 NOTREACHED();
740 } 676 }
741 } else { 677 } else {
742 // The remaining settings don't support Set(), since they are not 678 // The remaining settings don't support Set(), since they are not
743 // intended to be customizable by the user: 679 // intended to be customizable by the user:
744 // kAccountsPrefTransferSAMLCookies 680 // kAccountsPrefTransferSAMLCookies
745 // kAppPack 681 // kAppPack
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
746 // kDeviceAttestationEnabled 682 // kDeviceAttestationEnabled
747 // kDeviceOwner 683 // kDeviceOwner
748 // kIdleLogoutTimeout 684 // kIdleLogoutTimeout
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
749 // kIdleLogoutWarningDuration 685 // kIdleLogoutWarningDuration
bartfab (slow) 2014/10/15 09:52:20 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
750 // kReleaseChannelDelegated 686 // kReleaseChannelDelegated
751 // kReportDeviceActivityTimes 687 // kReportDeviceActivityTimes
752 // kReportDeviceBootMode 688 // kReportDeviceBootMode
753 // kReportDeviceLocation 689 // kReportDeviceLocation
754 // kReportDeviceVersionInfo 690 // kReportDeviceVersionInfo
755 // kReportDeviceNetworkInterfaces 691 // kReportDeviceNetworkInterfaces
756 // kReportDeviceUsers 692 // kReportDeviceUsers
757 // kScreenSaverExtensionId 693 // kScreenSaverExtensionId
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
758 // kScreenSaverTimeout 694 // kScreenSaverTimeout
bartfab (slow) 2014/10/15 09:52:21 Nit: No longer used.
rkc 2014/11/20 21:06:34 Done.
759 // kServiceAccountIdentity 695 // kServiceAccountIdentity
760 // kStartUpUrls 696 // kStartUpUrls
761 // kSystemTimezonePolicy 697 // kSystemTimezonePolicy
762 // kVariationsRestrictParameter 698 // kVariationsRestrictParameter
763 699
764 LOG(FATAL) << "Device setting " << prop << " is read-only."; 700 LOG(FATAL) << "Device setting " << prop << " is read-only.";
765 } 701 }
766 702
767 em::PolicyData data; 703 em::PolicyData data;
768 data.set_username(device_settings_service_->GetUsername()); 704 data.set_username(device_settings_service_->GetUsername());
(...skipping 23 matching lines...) Expand all
792 728
793 if (policy_data.has_username() && !policy_data.has_request_token()) 729 if (policy_data.has_username() && !policy_data.has_request_token())
794 new_values_cache.SetString(kDeviceOwner, policy_data.username()); 730 new_values_cache.SetString(kDeviceOwner, policy_data.username());
795 731
796 if (policy_data.has_service_account_identity()) { 732 if (policy_data.has_service_account_identity()) {
797 new_values_cache.SetString(kServiceAccountIdentity, 733 new_values_cache.SetString(kServiceAccountIdentity,
798 policy_data.service_account_identity()); 734 policy_data.service_account_identity());
799 } 735 }
800 736
801 DecodeLoginPolicies(settings, &new_values_cache); 737 DecodeLoginPolicies(settings, &new_values_cache);
802 DecodeKioskPolicies(settings, &new_values_cache);
803 DecodeNetworkPolicies(settings, &new_values_cache); 738 DecodeNetworkPolicies(settings, &new_values_cache);
804 DecodeAutoUpdatePolicies(settings, &new_values_cache); 739 DecodeAutoUpdatePolicies(settings, &new_values_cache);
805 DecodeReportingPolicies(settings, &new_values_cache); 740 DecodeReportingPolicies(settings, &new_values_cache);
806 DecodeGenericPolicies(settings, &new_values_cache); 741 DecodeGenericPolicies(settings, &new_values_cache);
807 742
808 // Collect all notifications but send them only after we have swapped the 743 // Collect all notifications but send them only after we have swapped the
809 // cache so that if somebody actually reads the cache will be already valid. 744 // cache so that if somebody actually reads the cache will be already valid.
810 std::vector<std::string> notifications; 745 std::vector<std::string> notifications;
811 // Go through the new values and verify in the old ones. 746 // Go through the new values and verify in the old ones.
812 PrefValueMap::iterator iter = new_values_cache.begin(); 747 PrefValueMap::iterator iter = new_values_cache.begin();
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 void DeviceSettingsProvider::AttemptMigration() { 939 void DeviceSettingsProvider::AttemptMigration() {
1005 if (device_settings_service_->HasPrivateOwnerKey()) { 940 if (device_settings_service_->HasPrivateOwnerKey()) {
1006 PrefValueMap::const_iterator i; 941 PrefValueMap::const_iterator i;
1007 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) 942 for (i = migration_values_.begin(); i != migration_values_.end(); ++i)
1008 DoSet(i->first, *i->second); 943 DoSet(i->first, *i->second);
1009 migration_values_.Clear(); 944 migration_values_.Clear();
1010 } 945 }
1011 } 946 }
1012 947
1013 } // namespace chromeos 948 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698