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

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

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

Powered by Google App Engine
This is Rietveld 408576698