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/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 using google::protobuf::RepeatedField; | 30 using google::protobuf::RepeatedField; |
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 // List of settings handled by the DeviceSettingsProvider. | 39 // List of settings handled by the DeviceSettingsProvider. |
40 const char* kKnownSettings[] = { | 40 const char* const kKnownSettings[] = { |
41 kAccountsPrefAllowGuest, | 41 kAccountsPrefAllowGuest, |
42 kAccountsPrefAllowNewUser, | 42 kAccountsPrefAllowNewUser, |
43 kAccountsPrefDeviceLocalAccounts, | 43 kAccountsPrefDeviceLocalAccounts, |
44 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, | 44 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, |
45 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 45 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
46 kAccountsPrefDeviceLocalAccountAutoLoginId, | 46 kAccountsPrefDeviceLocalAccountAutoLoginId, |
47 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, | 47 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, |
48 kAccountsPrefEphemeralUsersEnabled, | 48 kAccountsPrefEphemeralUsersEnabled, |
49 kAccountsPrefShowUserNamesOnSignIn, | 49 kAccountsPrefShowUserNamesOnSignIn, |
50 kAccountsPrefSupervisedUsersEnabled, | 50 kAccountsPrefSupervisedUsersEnabled, |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 } | 455 } |
456 | 456 |
457 DeviceSettingsProvider::~DeviceSettingsProvider() { | 457 DeviceSettingsProvider::~DeviceSettingsProvider() { |
458 if (device_settings_service_->GetOwnerSettingsService()) | 458 if (device_settings_service_->GetOwnerSettingsService()) |
459 device_settings_service_->GetOwnerSettingsService()->RemoveObserver(this); | 459 device_settings_service_->GetOwnerSettingsService()->RemoveObserver(this); |
460 device_settings_service_->RemoveObserver(this); | 460 device_settings_service_->RemoveObserver(this); |
461 } | 461 } |
462 | 462 |
463 // static | 463 // static |
464 bool DeviceSettingsProvider::IsDeviceSetting(const std::string& name) { | 464 bool DeviceSettingsProvider::IsDeviceSetting(const std::string& name) { |
465 const char** end = kKnownSettings + arraysize(kKnownSettings); | 465 const char* const* end = kKnownSettings + arraysize(kKnownSettings); |
466 return std::find(kKnownSettings, end, name) != end; | 466 return std::find(kKnownSettings, end, name) != end; |
467 } | 467 } |
468 | 468 |
469 void DeviceSettingsProvider::DoSet(const std::string& path, | 469 void DeviceSettingsProvider::DoSet(const std::string& path, |
470 const base::Value& in_value) { | 470 const base::Value& in_value) { |
471 // Make sure that either the current user is the device owner or the | 471 // Make sure that either the current user is the device owner or the |
472 // device doesn't have an owner yet. | 472 // device doesn't have an owner yet. |
473 if (!(device_settings_service_->HasPrivateOwnerKey() || | 473 if (!(device_settings_service_->HasPrivateOwnerKey() || |
474 ownership_status_ == DeviceSettingsService::OWNERSHIP_NONE)) { | 474 ownership_status_ == DeviceSettingsService::OWNERSHIP_NONE)) { |
475 LOG(WARNING) << "Changing settings from non-owner, setting=" << path; | 475 LOG(WARNING) << "Changing settings from non-owner, setting=" << path; |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 void DeviceSettingsProvider::AttemptMigration() { | 796 void DeviceSettingsProvider::AttemptMigration() { |
797 if (device_settings_service_->HasPrivateOwnerKey()) { | 797 if (device_settings_service_->HasPrivateOwnerKey()) { |
798 PrefValueMap::const_iterator i; | 798 PrefValueMap::const_iterator i; |
799 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 799 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
800 DoSet(i->first, *i->second); | 800 DoSet(i->first, *i->second); |
801 migration_values_.Clear(); | 801 migration_values_.Clear(); |
802 } | 802 } |
803 } | 803 } |
804 | 804 |
805 } // namespace chromeos | 805 } // namespace chromeos |
OLD | NEW |