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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 kReportDeviceActivityTimes, | 54 kReportDeviceActivityTimes, |
55 kReportDeviceBootMode, | 55 kReportDeviceBootMode, |
56 kReportDeviceLocation, | 56 kReportDeviceLocation, |
57 kReportDeviceVersionInfo, | 57 kReportDeviceVersionInfo, |
58 kScreenSaverExtensionId, | 58 kScreenSaverExtensionId, |
59 kScreenSaverTimeout, | 59 kScreenSaverTimeout, |
60 kSettingProxyEverywhere, | 60 kSettingProxyEverywhere, |
61 kSignedDataRoamingEnabled, | 61 kSignedDataRoamingEnabled, |
62 kStartUpUrls, | 62 kStartUpUrls, |
63 kStatsReportingPref, | 63 kStatsReportingPref, |
64 kSystemTimezonePolicy, | |
65 }; | 64 }; |
66 | 65 |
67 // Upper bound for number of retries to fetch a signed setting. | 66 // Upper bound for number of retries to fetch a signed setting. |
68 static const int kNumRetriesLimit = 9; | 67 static const int kNumRetriesLimit = 9; |
69 | 68 |
70 // Legacy policy file location. Used to detect migration from pre v12 ChromeOS. | 69 // Legacy policy file location. Used to detect migration from pre v12 ChromeOS. |
71 const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences"; | 70 const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences"; |
72 | 71 |
73 bool IsControlledSetting(const std::string& pref_path) { | 72 bool IsControlledSetting(const std::string& pref_path) { |
74 const char** end = kKnownSettings + arraysize(kKnownSettings); | 73 const char** end = kKnownSettings + arraysize(kKnownSettings); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // kIdleLogoutTimeout | 291 // kIdleLogoutTimeout |
293 // kIdleLogoutWarningDuration | 292 // kIdleLogoutWarningDuration |
294 // kReleaseChannelDelegated | 293 // kReleaseChannelDelegated |
295 // kReportDeviceVersionInfo | 294 // kReportDeviceVersionInfo |
296 // kReportDeviceActivityTimes | 295 // kReportDeviceActivityTimes |
297 // kReportDeviceBootMode | 296 // kReportDeviceBootMode |
298 // kReportDeviceLocation | 297 // kReportDeviceLocation |
299 // kScreenSaverExtensionId | 298 // kScreenSaverExtensionId |
300 // kScreenSaverTimeout | 299 // kScreenSaverTimeout |
301 // kStartUpUrls | 300 // kStartUpUrls |
302 // kSystemTimezonePolicy | |
303 | 301 |
304 NOTREACHED(); | 302 NOTREACHED(); |
305 } | 303 } |
306 data.set_policy_value(pol.SerializeAsString()); | 304 data.set_policy_value(pol.SerializeAsString()); |
307 // Set the cache to the updated value. | 305 // Set the cache to the updated value. |
308 policy_ = data; | 306 policy_ = data; |
309 UpdateValuesCache(); | 307 UpdateValuesCache(); |
310 | 308 |
311 if (!signed_settings_cache::Store(data, g_browser_process->local_state())) | 309 if (!signed_settings_cache::Store(data, g_browser_process->local_state())) |
312 LOG(ERROR) << "Couldn't store to the temp storage."; | 310 LOG(ERROR) << "Couldn't store to the temp storage."; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } else { | 519 } else { |
522 new_values_cache->SetString(kReleaseChannel, | 520 new_values_cache->SetString(kReleaseChannel, |
523 policy.release_channel().release_channel()); | 521 policy.release_channel().release_channel()); |
524 } | 522 } |
525 | 523 |
526 new_values_cache->SetBoolean( | 524 new_values_cache->SetBoolean( |
527 kReleaseChannelDelegated, | 525 kReleaseChannelDelegated, |
528 policy.has_release_channel() && | 526 policy.has_release_channel() && |
529 policy.release_channel().has_release_channel_delegated() && | 527 policy.release_channel().has_release_channel_delegated() && |
530 policy.release_channel().release_channel_delegated()); | 528 policy.release_channel().release_channel_delegated()); |
531 | |
532 if (policy.has_system_timezone()) { | |
533 if (policy.system_timezone().has_timezone()) { | |
534 new_values_cache->SetString( | |
535 kSystemTimezonePolicy, | |
536 policy.system_timezone().timezone()); | |
537 } | |
538 } | |
539 } | 529 } |
540 | 530 |
541 void DeviceSettingsProvider::UpdateValuesCache() { | 531 void DeviceSettingsProvider::UpdateValuesCache() { |
542 const em::PolicyData data = policy(); | 532 const em::PolicyData data = policy(); |
543 PrefValueMap new_values_cache; | 533 PrefValueMap new_values_cache; |
544 | 534 |
545 if (data.has_username() && !data.has_request_token()) | 535 if (data.has_username() && !data.has_request_token()) |
546 new_values_cache.SetString(kDeviceOwner, data.username()); | 536 new_values_cache.SetString(kDeviceOwner, data.username()); |
547 | 537 |
548 em::ChromeDeviceSettingsProto pol; | 538 em::ChromeDeviceSettingsProto pol; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 } | 739 } |
750 } | 740 } |
751 // Notify the observers we are done. | 741 // Notify the observers we are done. |
752 std::vector<base::Closure> callbacks; | 742 std::vector<base::Closure> callbacks; |
753 callbacks.swap(callbacks_); | 743 callbacks.swap(callbacks_); |
754 for (size_t i = 0; i < callbacks.size(); ++i) | 744 for (size_t i = 0; i < callbacks.size(); ++i) |
755 callbacks[i].Run(); | 745 callbacks[i].Run(); |
756 } | 746 } |
757 | 747 |
758 } // namespace chromeos | 748 } // namespace chromeos |
OLD | NEW |