| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/policy/cloud_policy_subsystem.h" | 5 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 CloudPolicySubsystem::GetRecommendedPolicyProvider() { | 138 CloudPolicySubsystem::GetRecommendedPolicyProvider() { |
| 139 if (cloud_policy_cache_.get()) | 139 if (cloud_policy_cache_.get()) |
| 140 return cloud_policy_cache_->GetRecommendedPolicyProvider(); | 140 return cloud_policy_cache_->GetRecommendedPolicyProvider(); |
| 141 | 141 |
| 142 return NULL; | 142 return NULL; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // static | 145 // static |
| 146 void CloudPolicySubsystem::RegisterPrefs(PrefService* pref_service) { | 146 void CloudPolicySubsystem::RegisterPrefs(PrefService* pref_service) { |
| 147 pref_service->RegisterIntegerPref(prefs::kPolicyRefreshRate, | 147 pref_service->RegisterIntegerPref(prefs::kPolicyRefreshRate, |
| 148 kDefaultPolicyRefreshRateMs); | 148 kDefaultPolicyRefreshRateMs, |
| 149 PrefService::UNSYNCABLE_PREF); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void CloudPolicySubsystem::UpdatePolicyRefreshRate() { | 152 void CloudPolicySubsystem::UpdatePolicyRefreshRate() { |
| 152 if (cloud_policy_controller_.get()) { | 153 if (cloud_policy_controller_.get()) { |
| 153 // Clamp to sane values. | 154 // Clamp to sane values. |
| 154 int64 refresh_rate = policy_refresh_rate_.GetValue(); | 155 int64 refresh_rate = policy_refresh_rate_.GetValue(); |
| 155 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); | 156 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); |
| 156 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); | 157 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); |
| 157 cloud_policy_controller_->SetRefreshRate(refresh_rate); | 158 cloud_policy_controller_->SetRefreshRate(refresh_rate); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 | 161 |
| 161 void CloudPolicySubsystem::Observe(NotificationType type, | 162 void CloudPolicySubsystem::Observe(NotificationType type, |
| 162 const NotificationSource& source, | 163 const NotificationSource& source, |
| 163 const NotificationDetails& details) { | 164 const NotificationDetails& details) { |
| 164 if (type == NotificationType::PREF_CHANGED && | 165 if (type == NotificationType::PREF_CHANGED && |
| 165 policy_refresh_rate_.GetPrefName() == | 166 policy_refresh_rate_.GetPrefName() == |
| 166 *(Details<std::string>(details).ptr()) && | 167 *(Details<std::string>(details).ptr()) && |
| 167 prefs_ == Source<PrefService>(source).ptr()) { | 168 prefs_ == Source<PrefService>(source).ptr()) { |
| 168 UpdatePolicyRefreshRate(); | 169 UpdatePolicyRefreshRate(); |
| 169 } else { | 170 } else { |
| 170 NOTREACHED(); | 171 NOTREACHED(); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 } // namespace policy | 175 } // namespace policy |
| OLD | NEW |