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

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

Issue 79113002: kiosk: Network connectivity test during launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, add policy and only show network error screen once Created 7 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 | Annotate | Revision Log
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 namespace { 44 namespace {
45 45
46 // List of settings handled by the DeviceSettingsProvider. 46 // List of settings handled by the DeviceSettingsProvider.
47 const char* kKnownSettings[] = { 47 const char* kKnownSettings[] = {
48 kAccountsPrefAllowGuest, 48 kAccountsPrefAllowGuest,
49 kAccountsPrefAllowNewUser, 49 kAccountsPrefAllowNewUser,
50 kAccountsPrefDeviceLocalAccounts, 50 kAccountsPrefDeviceLocalAccounts,
51 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, 51 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled,
52 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 52 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
53 kAccountsPrefDeviceLocalAccountAutoLoginId, 53 kAccountsPrefDeviceLocalAccountAutoLoginId,
54 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline,
54 kAccountsPrefEphemeralUsersEnabled, 55 kAccountsPrefEphemeralUsersEnabled,
55 kAccountsPrefShowUserNamesOnSignIn, 56 kAccountsPrefShowUserNamesOnSignIn,
56 kAccountsPrefSupervisedUsersEnabled, 57 kAccountsPrefSupervisedUsersEnabled,
57 kAccountsPrefUsers, 58 kAccountsPrefUsers,
58 kAllowRedeemChromeOsRegistrationOffers, 59 kAllowRedeemChromeOsRegistrationOffers,
59 kAllowedConnectionTypesForUpdate, 60 kAllowedConnectionTypesForUpdate,
60 kAppPack, 61 kAppPack,
61 kAttestationForContentProtectionEnabled, 62 kAttestationForContentProtectionEnabled,
62 kDeviceAttestationEnabled, 63 kDeviceAttestationEnabled,
63 kDeviceOwner, 64 kDeviceOwner,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 else 301 else
301 NOTREACHED(); 302 NOTREACHED();
302 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled) { 303 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled) {
303 em::DeviceLocalAccountsProto* device_local_accounts = 304 em::DeviceLocalAccountsProto* device_local_accounts =
304 device_settings_.mutable_device_local_accounts(); 305 device_settings_.mutable_device_local_accounts();
305 bool enabled; 306 bool enabled;
306 if (value->GetAsBoolean(&enabled)) 307 if (value->GetAsBoolean(&enabled))
307 device_local_accounts->set_enable_auto_login_bailout(enabled); 308 device_local_accounts->set_enable_auto_login_bailout(enabled);
308 else 309 else
309 NOTREACHED(); 310 NOTREACHED();
311 } else if (prop ==
312 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline) {
313 em::DeviceLocalAccountsProto* device_local_accounts =
314 device_settings_.mutable_device_local_accounts();
315 bool should_prompt;
316 if (value->GetAsBoolean(&should_prompt))
317 device_local_accounts->set_prompt_for_network_when_offline(should_prompt);
318 else
319 NOTREACHED();
310 } else if (prop == kSignedDataRoamingEnabled) { 320 } else if (prop == kSignedDataRoamingEnabled) {
311 em::DataRoamingEnabledProto* roam = 321 em::DataRoamingEnabledProto* roam =
312 device_settings_.mutable_data_roaming_enabled(); 322 device_settings_.mutable_data_roaming_enabled();
313 bool roaming_value = false; 323 bool roaming_value = false;
314 if (value->GetAsBoolean(&roaming_value)) 324 if (value->GetAsBoolean(&roaming_value))
315 roam->set_data_roaming_enabled(roaming_value); 325 roam->set_data_roaming_enabled(roaming_value);
316 else 326 else
317 NOTREACHED(); 327 NOTREACHED();
318 ApplyRoamingSetting(roaming_value); 328 ApplyRoamingSetting(roaming_value);
319 } else if (prop == kReleaseChannel) { 329 } else if (prop == kReleaseChannel) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (policy.device_local_accounts().has_auto_login_delay()) { 557 if (policy.device_local_accounts().has_auto_login_delay()) {
548 new_values_cache->SetInteger( 558 new_values_cache->SetInteger(
549 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 559 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
550 policy.device_local_accounts().auto_login_delay()); 560 policy.device_local_accounts().auto_login_delay());
551 } 561 }
552 } 562 }
553 563
554 new_values_cache->SetBoolean( 564 new_values_cache->SetBoolean(
555 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, 565 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled,
556 policy.device_local_accounts().enable_auto_login_bailout()); 566 policy.device_local_accounts().enable_auto_login_bailout());
567 new_values_cache->SetBoolean(
568 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline,
569 policy.device_local_accounts().prompt_for_network_when_offline());
557 570
558 if (policy.has_start_up_flags()) { 571 if (policy.has_start_up_flags()) {
559 base::ListValue* list = new base::ListValue(); 572 base::ListValue* list = new base::ListValue();
560 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); 573 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags();
561 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); 574 const RepeatedPtrField<std::string>& flags = flags_proto.flags();
562 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); 575 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin();
563 it != flags.end(); ++it) { 576 it != flags.end(); ++it) {
564 list->Append(new base::StringValue(*it)); 577 list->Append(new base::StringValue(*it));
565 } 578 }
566 new_values_cache->SetValue(kStartUpFlags, list); 579 new_values_cache->SetValue(kStartUpFlags, list);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 void DeviceSettingsProvider::ApplyMetricsSetting(bool use_file, 822 void DeviceSettingsProvider::ApplyMetricsSetting(bool use_file,
810 bool new_value) { 823 bool new_value) {
811 // TODO(pastarmovj): Remove this once migration is not needed anymore. 824 // TODO(pastarmovj): Remove this once migration is not needed anymore.
812 // If the value is not set we should try to migrate legacy consent file. 825 // If the value is not set we should try to migrate legacy consent file.
813 if (use_file) { 826 if (use_file) {
814 new_value = HasOldMetricsFile(); 827 new_value = HasOldMetricsFile();
815 // Make sure the values will get eventually written to the policy file. 828 // Make sure the values will get eventually written to the policy file.
816 migration_values_.SetValue(kStatsReportingPref, 829 migration_values_.SetValue(kStatsReportingPref,
817 base::Value::CreateBooleanValue(new_value)); 830 base::Value::CreateBooleanValue(new_value));
818 AttemptMigration(); 831 AttemptMigration();
819 LOG(INFO) << "No metrics policy set will revert to checking " 832 VLOG(1) << "No metrics policy set will revert to checking "
820 << "consent file which is " 833 << "consent file which is "
821 << (new_value ? "on." : "off."); 834 << (new_value ? "on." : "off.");
822 UMA_HISTOGRAM_COUNTS("DeviceSettings.MetricsMigrated", 1); 835 UMA_HISTOGRAM_COUNTS("DeviceSettings.MetricsMigrated", 1);
823 } 836 }
824 VLOG(1) << "Metrics policy is being set to : " << new_value 837 VLOG(1) << "Metrics policy is being set to : " << new_value
825 << "(use file : " << use_file << ")"; 838 << "(use file : " << use_file << ")";
826 // TODO(pastarmovj): Remove this once we don't need to regenerate the 839 // TODO(pastarmovj): Remove this once we don't need to regenerate the
827 // consent file for the GUID anymore. 840 // consent file for the GUID anymore.
828 OptionsUtil::ResolveMetricsReportingEnabled(new_value); 841 OptionsUtil::ResolveMetricsReportingEnabled(new_value);
829 } 842 }
830 843
831 void DeviceSettingsProvider::ApplyRoamingSetting(bool new_value) { 844 void DeviceSettingsProvider::ApplyRoamingSetting(bool new_value) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 void DeviceSettingsProvider::AttemptMigration() { 1044 void DeviceSettingsProvider::AttemptMigration() {
1032 if (device_settings_service_->HasPrivateOwnerKey()) { 1045 if (device_settings_service_->HasPrivateOwnerKey()) {
1033 PrefValueMap::const_iterator i; 1046 PrefValueMap::const_iterator i;
1034 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) 1047 for (i = migration_values_.begin(); i != migration_values_.end(); ++i)
1035 DoSet(i->first, *i->second); 1048 DoSet(i->first, *i->second);
1036 migration_values_.Clear(); 1049 migration_values_.Clear();
1037 } 1050 }
1038 } 1051 }
1039 1052
1040 } // namespace chromeos 1053 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698