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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 kAttestationForContentProtectionEnabled, | 56 kAttestationForContentProtectionEnabled, |
57 kDeviceAttestationEnabled, | 57 kDeviceAttestationEnabled, |
58 kDeviceDisabled, | |
59 kDeviceDisabledMessage, | |
58 kDeviceOwner, | 60 kDeviceOwner, |
61 kExtensionCacheSize, | |
59 kHeartbeatEnabled, | 62 kHeartbeatEnabled, |
60 kHeartbeatFrequency, | 63 kHeartbeatFrequency, |
61 kPolicyMissingMitigationMode, | 64 kPolicyMissingMitigationMode, |
65 kRebootOnShutdown, | |
62 kReleaseChannel, | 66 kReleaseChannel, |
63 kReleaseChannelDelegated, | 67 kReleaseChannelDelegated, |
64 kReportDeviceActivityTimes, | 68 kReportDeviceActivityTimes, |
65 kReportDeviceBootMode, | 69 kReportDeviceBootMode, |
66 kReportDeviceHardwareStatus, | 70 kReportDeviceHardwareStatus, |
67 kReportDeviceLocation, | 71 kReportDeviceLocation, |
68 kReportDeviceNetworkInterfaces, | 72 kReportDeviceNetworkInterfaces, |
69 kReportDeviceSessionStatus, | 73 kReportDeviceSessionStatus, |
70 kReportDeviceUsers, | 74 kReportDeviceUsers, |
71 kReportDeviceVersionInfo, | 75 kReportDeviceVersionInfo, |
72 kReportUploadFrequency, | 76 kReportUploadFrequency, |
73 kServiceAccountIdentity, | 77 kServiceAccountIdentity, |
74 kSignedDataRoamingEnabled, | 78 kSignedDataRoamingEnabled, |
75 kStartUpFlags, | 79 kStartUpFlags, |
76 kStatsReportingPref, | 80 kStatsReportingPref, |
77 kSystemTimezonePolicy, | 81 kSystemTimezonePolicy, |
78 kSystemUse24HourClock, | 82 kSystemUse24HourClock, |
79 kUpdateDisabled, | 83 kUpdateDisabled, |
80 kVariationsRestrictParameter, | 84 kVariationsRestrictParameter, |
81 kDeviceDisabled, | |
82 kDeviceDisabledMessage, | |
83 kRebootOnShutdown, | |
84 kExtensionCacheSize, | |
85 }; | 85 }; |
86 | 86 |
87 bool HasOldMetricsFile() { | 87 bool HasOldMetricsFile() { |
88 // TODO(pastarmovj): Remove this once migration is not needed anymore. | 88 // TODO(pastarmovj): Remove this once migration is not needed anymore. |
89 // 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. |
90 // 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. |
91 // Temporarily allow it until we fix http://crbug.com/62626 | 91 // Temporarily allow it until we fix http://crbug.com/62626 |
92 base::ThreadRestrictions::ScopedAllowIO allow_io; | 92 base::ThreadRestrictions::ScopedAllowIO allow_io; |
93 return GoogleUpdateSettings::GetCollectStatsConsent(); | 93 return GoogleUpdateSettings::GetCollectStatsConsent(); |
94 } | 94 } |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 | 444 |
445 } // namespace | 445 } // namespace |
446 | 446 |
447 DeviceSettingsProvider::DeviceSettingsProvider( | 447 DeviceSettingsProvider::DeviceSettingsProvider( |
448 const NotifyObserversCallback& notify_cb, | 448 const NotifyObserversCallback& notify_cb, |
449 DeviceSettingsService* device_settings_service) | 449 DeviceSettingsService* device_settings_service) |
450 : CrosSettingsProvider(notify_cb), | 450 : CrosSettingsProvider(notify_cb), |
451 device_settings_service_(device_settings_service), | 451 device_settings_service_(device_settings_service), |
452 trusted_status_(TEMPORARILY_UNTRUSTED), | 452 trusted_status_(TEMPORARILY_UNTRUSTED), |
453 ownership_status_(device_settings_service_->GetOwnershipStatus()), | 453 ownership_status_(device_settings_service_->GetOwnershipStatus()), |
454 trusted_for_test_(false), | |
454 store_callback_factory_(this) { | 455 store_callback_factory_(this) { |
455 device_settings_service_->AddObserver(this); | 456 device_settings_service_->AddObserver(this); |
456 if (!UpdateFromService()) { | 457 if (!UpdateFromService()) { |
457 // Make sure we have at least the cache data immediately. | 458 // Make sure we have at least the cache data immediately. |
458 RetrieveCachedData(); | 459 RetrieveCachedData(); |
459 } | 460 } |
460 } | 461 } |
461 | 462 |
462 DeviceSettingsProvider::~DeviceSettingsProvider() { | 463 DeviceSettingsProvider::~DeviceSettingsProvider() { |
463 if (device_settings_service_->GetOwnerSettingsService()) | 464 if (device_settings_service_->GetOwnerSettingsService()) |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 return value; | 712 return value; |
712 } else { | 713 } else { |
713 NOTREACHED() << "Trying to get non cros setting."; | 714 NOTREACHED() << "Trying to get non cros setting."; |
714 } | 715 } |
715 | 716 |
716 return NULL; | 717 return NULL; |
717 } | 718 } |
718 | 719 |
719 DeviceSettingsProvider::TrustedStatus | 720 DeviceSettingsProvider::TrustedStatus |
720 DeviceSettingsProvider::PrepareTrustedValues(const base::Closure& cb) { | 721 DeviceSettingsProvider::PrepareTrustedValues(const base::Closure& cb) { |
722 if (trusted_for_test_) | |
Mattias Nissler (ping if slow)
2015/03/27 12:42:06
Uh, why is this needed?
Ivan Podogov
2015/03/27 12:51:14
Because the first time the owner settings observer
Mattias Nissler (ping if slow)
2015/03/27 12:58:52
There are a number of tests that prepare device se
Ivan Podogov
2015/03/27 13:10:50
Off the top of my head those would be HeartbeatSch
Mattias Nissler (ping if slow)
2015/03/27 13:45:58
I think it's fine to actually retain StubSettingsP
| |
723 return TRUSTED; | |
721 TrustedStatus status = RequestTrustedEntity(); | 724 TrustedStatus status = RequestTrustedEntity(); |
722 if (status == TEMPORARILY_UNTRUSTED && !cb.is_null()) | 725 if (status == TEMPORARILY_UNTRUSTED && !cb.is_null()) |
723 callbacks_.push_back(cb); | 726 callbacks_.push_back(cb); |
724 return status; | 727 return status; |
725 } | 728 } |
726 | 729 |
727 bool DeviceSettingsProvider::HandlesSetting(const std::string& path) const { | 730 bool DeviceSettingsProvider::HandlesSetting(const std::string& path) const { |
728 return IsDeviceSetting(path); | 731 return IsDeviceSetting(path); |
729 } | 732 } |
730 | 733 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 void DeviceSettingsProvider::AttemptMigration() { | 807 void DeviceSettingsProvider::AttemptMigration() { |
805 if (device_settings_service_->HasPrivateOwnerKey()) { | 808 if (device_settings_service_->HasPrivateOwnerKey()) { |
806 PrefValueMap::const_iterator i; | 809 PrefValueMap::const_iterator i; |
807 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 810 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
808 DoSet(i->first, *i->second); | 811 DoSet(i->first, *i->second); |
809 migration_values_.Clear(); | 812 migration_values_.Clear(); |
810 } | 813 } |
811 } | 814 } |
812 | 815 |
813 } // namespace chromeos | 816 } // namespace chromeos |
OLD | NEW |