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

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

Issue 776093004: Add device policy to disallow shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 21 matching lines...) Expand all
32 using google::protobuf::RepeatedPtrField; 32 using google::protobuf::RepeatedPtrField;
33 33
34 namespace em = enterprise_management; 34 namespace em = enterprise_management;
35 35
36 namespace chromeos { 36 namespace chromeos {
37 37
38 namespace { 38 namespace {
39 39
40 // List of settings handled by the DeviceSettingsProvider. 40 // List of settings handled by the DeviceSettingsProvider.
41 const char* const kKnownSettings[] = { 41 const char* const kKnownSettings[] = {
42 kAccountsPrefAllowGuest, 42 kAccountsPrefAllowGuest,
43 kAccountsPrefAllowNewUser, 43 kAccountsPrefAllowNewUser,
44 kAccountsPrefDeviceLocalAccounts, 44 kAccountsPrefDeviceLocalAccounts,
45 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, 45 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled,
46 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 46 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
47 kAccountsPrefDeviceLocalAccountAutoLoginId, 47 kAccountsPrefDeviceLocalAccountAutoLoginId,
48 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, 48 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline,
49 kAccountsPrefEphemeralUsersEnabled, 49 kAccountsPrefEphemeralUsersEnabled,
50 kAccountsPrefShowUserNamesOnSignIn, 50 kAccountsPrefShowUserNamesOnSignIn,
51 kAccountsPrefSupervisedUsersEnabled, 51 kAccountsPrefSupervisedUsersEnabled,
52 kAccountsPrefTransferSAMLCookies, 52 kAccountsPrefTransferSAMLCookies,
53 kAccountsPrefUsers, 53 kAccountsPrefUsers,
54 kAllowRedeemChromeOsRegistrationOffers, 54 kAllowRedeemChromeOsRegistrationOffers,
55 kAllowedConnectionTypesForUpdate, 55 kAllowedConnectionTypesForUpdate,
56 kAppPack, 56 kAppPack,
57 kAttestationForContentProtectionEnabled, 57 kAttestationForContentProtectionEnabled,
58 kDeviceAttestationEnabled, 58 kDeviceAttestationEnabled,
59 kDeviceOwner, 59 kDeviceOwner,
60 kIdleLogoutTimeout, 60 kIdleLogoutTimeout,
61 kIdleLogoutWarningDuration, 61 kIdleLogoutWarningDuration,
62 kPolicyMissingMitigationMode, 62 kPolicyMissingMitigationMode,
63 kReleaseChannel, 63 kReleaseChannel,
64 kReleaseChannelDelegated, 64 kReleaseChannelDelegated,
65 kReportDeviceActivityTimes, 65 kReportDeviceActivityTimes,
66 kReportDeviceBootMode, 66 kReportDeviceBootMode,
67 kReportDeviceLocation, 67 kReportDeviceLocation,
68 kReportDeviceNetworkInterfaces, 68 kReportDeviceNetworkInterfaces,
69 kReportDeviceUsers, 69 kReportDeviceUsers,
70 kReportDeviceVersionInfo, 70 kReportDeviceVersionInfo,
71 kScreenSaverExtensionId, 71 kScreenSaverExtensionId,
72 kScreenSaverTimeout, 72 kScreenSaverTimeout,
73 kServiceAccountIdentity, 73 kServiceAccountIdentity,
74 kSignedDataRoamingEnabled, 74 kSignedDataRoamingEnabled,
75 kStartUpFlags, 75 kStartUpFlags,
76 kStartUpUrls, 76 kStartUpUrls,
77 kStatsReportingPref, 77 kStatsReportingPref,
78 kSystemTimezonePolicy, 78 kSystemTimezonePolicy,
79 kSystemUse24HourClock, 79 kSystemUse24HourClock,
80 kUpdateDisabled, 80 kUpdateDisabled,
81 kVariationsRestrictParameter, 81 kVariationsRestrictParameter,
82 kDeviceDisabled, 82 kDeviceDisabled,
83 kDeviceDisabledMessage, 83 kDeviceDisabledMessage,
84 kRebootOnShutdown,
84 }; 85 };
85 86
86 bool HasOldMetricsFile() { 87 bool HasOldMetricsFile() {
87 // TODO(pastarmovj): Remove this once migration is not needed anymore. 88 // TODO(pastarmovj): Remove this once migration is not needed anymore.
88 // If the value is not set we should try to migrate legacy consent file. 89 // If the value is not set we should try to migrate legacy consent file.
89 // Loading consent file state causes us to do blocking IO on UI thread. 90 // Loading consent file state causes us to do blocking IO on UI thread.
90 // Temporarily allow it until we fix http://crbug.com/62626 91 // Temporarily allow it until we fix http://crbug.com/62626
91 base::ThreadRestrictions::ScopedAllowIO allow_io; 92 base::ThreadRestrictions::ScopedAllowIO allow_io;
92 return GoogleUpdateSettings::GetCollectStatsConsent(); 93 return GoogleUpdateSettings::GetCollectStatsConsent();
93 } 94 }
(...skipping 19 matching lines...) Expand all
113 !policy.has_user_whitelist()); 114 !policy.has_user_whitelist());
114 } 115 }
115 } else { 116 } else {
116 // No configured allow-new-users value, enforce whitelist if non-empty. 117 // No configured allow-new-users value, enforce whitelist if non-empty.
117 new_values_cache->SetBoolean( 118 new_values_cache->SetBoolean(
118 kAccountsPrefAllowNewUser, 119 kAccountsPrefAllowNewUser,
119 policy.user_whitelist().user_whitelist_size() == 0); 120 policy.user_whitelist().user_whitelist_size() == 0);
120 } 121 }
121 122
122 new_values_cache->SetBoolean( 123 new_values_cache->SetBoolean(
124 kRebootOnShutdown,
125 policy.has_reboot_on_shutdown() &&
126 policy.reboot_on_shutdown().has_reboot_on_shutdown() &&
127 policy.reboot_on_shutdown().reboot_on_shutdown());
128
129 new_values_cache->SetBoolean(
123 kAccountsPrefAllowGuest, 130 kAccountsPrefAllowGuest,
124 !policy.has_guest_mode_enabled() || 131 !policy.has_guest_mode_enabled() ||
125 !policy.guest_mode_enabled().has_guest_mode_enabled() || 132 !policy.guest_mode_enabled().has_guest_mode_enabled() ||
126 policy.guest_mode_enabled().guest_mode_enabled()); 133 policy.guest_mode_enabled().guest_mode_enabled());
127 134
128 policy::BrowserPolicyConnectorChromeOS* connector = 135 policy::BrowserPolicyConnectorChromeOS* connector =
129 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 136 g_browser_process->platform_part()->browser_policy_connector_chromeos();
130 bool supervised_users_enabled = false; 137 bool supervised_users_enabled = false;
131 if (connector->IsEnterpriseManaged()) { 138 if (connector->IsEnterpriseManaged()) {
132 supervised_users_enabled = 139 supervised_users_enabled =
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 void DeviceSettingsProvider::AttemptMigration() { 825 void DeviceSettingsProvider::AttemptMigration() {
819 if (device_settings_service_->HasPrivateOwnerKey()) { 826 if (device_settings_service_->HasPrivateOwnerKey()) {
820 PrefValueMap::const_iterator i; 827 PrefValueMap::const_iterator i;
821 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) 828 for (i = migration_values_.begin(); i != migration_values_.end(); ++i)
822 DoSet(i->first, *i->second); 829 DoSet(i->first, *i->second);
823 migration_values_.Clear(); 830 migration_values_.Clear();
824 } 831 }
825 } 832 }
826 833
827 } // namespace chromeos 834 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698