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/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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { | 152 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { |
153 if (cloud_policy_controller_.get()) { | 153 if (cloud_policy_controller_.get()) { |
154 // Clamp to sane values. | 154 // Clamp to sane values. |
155 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); | 155 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); |
156 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); | 156 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); |
157 cloud_policy_controller_->SetRefreshRate(refresh_rate); | 157 cloud_policy_controller_->SetRefreshRate(refresh_rate); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void CloudPolicySubsystem::Observe( | 161 void CloudPolicySubsystem::OnPreferenceChanged(PrefServiceBase* service, |
162 int type, | 162 const std::string& pref_name) { |
163 const content::NotificationSource& source, | 163 DCHECK_EQ(pref_name, refresh_pref_name_); |
164 const content::NotificationDetails& details) { | 164 PrefService* local_state = g_browser_process->local_state(); |
165 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 165 DCHECK_EQ(service, local_state); |
166 DCHECK_EQ(*(content::Details<std::string>(details).ptr()), | 166 UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); |
167 std::string(refresh_pref_name_)); | |
168 PrefService* local_state = g_browser_process->local_state(); | |
169 DCHECK_EQ(content::Source<PrefService>(source).ptr(), local_state); | |
170 UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); | |
171 } else { | |
172 NOTREACHED(); | |
173 } | |
174 } | 167 } |
175 | 168 |
176 void CloudPolicySubsystem::ScheduleServiceInitialization( | 169 void CloudPolicySubsystem::ScheduleServiceInitialization( |
177 int64 delay_milliseconds) { | 170 int64 delay_milliseconds) { |
178 if (device_management_service_.get()) | 171 if (device_management_service_.get()) |
179 device_management_service_->ScheduleInitialization(delay_milliseconds); | 172 device_management_service_->ScheduleInitialization(delay_milliseconds); |
180 } | 173 } |
181 | 174 |
182 | 175 |
183 void CloudPolicySubsystem::CreateDeviceTokenFetcher() { | 176 void CloudPolicySubsystem::CreateDeviceTokenFetcher() { |
(...skipping 17 matching lines...) Expand all Loading... |
201 CloudPolicyCacheBase* CloudPolicySubsystem::GetCloudPolicyCacheBase() const { | 194 CloudPolicyCacheBase* CloudPolicySubsystem::GetCloudPolicyCacheBase() const { |
202 return cloud_policy_cache_.get(); | 195 return cloud_policy_cache_.get(); |
203 } | 196 } |
204 | 197 |
205 CloudPolicySubsystem::CloudPolicySubsystem() | 198 CloudPolicySubsystem::CloudPolicySubsystem() |
206 : refresh_pref_name_(NULL), | 199 : refresh_pref_name_(NULL), |
207 data_store_(NULL) { | 200 data_store_(NULL) { |
208 } | 201 } |
209 | 202 |
210 } // namespace policy | 203 } // namespace policy |
OLD | NEW |