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" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 12 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
13 #include "chrome/browser/policy/cloud_policy_controller.h" | 13 #include "chrome/browser/policy/cloud_policy_controller.h" |
14 #include "chrome/browser/policy/cloud_policy_data_store.h" | 14 #include "chrome/browser/policy/cloud_policy_data_store.h" |
15 #include "chrome/browser/policy/device_management_service.h" | 15 #include "chrome/browser/policy/device_management_service.h" |
16 #include "chrome/browser/policy/device_token_fetcher.h" | 16 #include "chrome/browser/policy/device_token_fetcher.h" |
17 #include "chrome/browser/policy/policy_notifier.h" | 17 #include "chrome/browser/policy/policy_notifier.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "content/common/notification_details.h" | 22 #include "content/common/notification_details.h" |
22 #include "content/common/notification_source.h" | 23 #include "content/common/notification_source.h" |
23 #include "content/common/notification_type.h" | |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Default refresh rate. | 27 // Default refresh rate. |
28 const int64 kDefaultPolicyRefreshRateMs = 3 * 60 * 60 * 1000; // 3 hours. | 28 const int64 kDefaultPolicyRefreshRateMs = 3 * 60 * 60 * 1000; // 3 hours. |
29 | 29 |
30 // Refresh rate sanity interval bounds. | 30 // Refresh rate sanity interval bounds. |
31 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes | 31 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes |
32 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day | 32 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day |
33 | 33 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { | 148 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { |
149 if (cloud_policy_controller_.get()) { | 149 if (cloud_policy_controller_.get()) { |
150 // Clamp to sane values. | 150 // Clamp to sane values. |
151 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); | 151 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); |
152 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); | 152 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); |
153 cloud_policy_controller_->SetRefreshRate(refresh_rate); | 153 cloud_policy_controller_->SetRefreshRate(refresh_rate); |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 void CloudPolicySubsystem::Observe(NotificationType type, | 157 void CloudPolicySubsystem::Observe(int type, |
158 const NotificationSource& source, | 158 const NotificationSource& source, |
159 const NotificationDetails& details) { | 159 const NotificationDetails& details) { |
160 if (type == NotificationType::PREF_CHANGED) { | 160 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
161 DCHECK_EQ(*(Details<std::string>(details).ptr()), | 161 DCHECK_EQ(*(Details<std::string>(details).ptr()), |
162 std::string(refresh_pref_name_)); | 162 std::string(refresh_pref_name_)); |
163 PrefService* local_state = g_browser_process->local_state(); | 163 PrefService* local_state = g_browser_process->local_state(); |
164 DCHECK_EQ(Source<PrefService>(source).ptr(), local_state); | 164 DCHECK_EQ(Source<PrefService>(source).ptr(), local_state); |
165 UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); | 165 UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_)); |
166 } else { | 166 } else { |
167 NOTREACHED(); | 167 NOTREACHED(); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
(...skipping 19 matching lines...) Expand all Loading... |
190 cloud_policy_cache_.get(), | 190 cloud_policy_cache_.get(), |
191 device_token_fetcher_.get(), | 191 device_token_fetcher_.get(), |
192 data_store_, | 192 data_store_, |
193 notifier_.get())); | 193 notifier_.get())); |
194 } | 194 } |
195 | 195 |
196 CloudPolicySubsystem::CloudPolicySubsystem() | 196 CloudPolicySubsystem::CloudPolicySubsystem() |
197 : refresh_pref_name_(NULL) {} | 197 : refresh_pref_name_(NULL) {} |
198 | 198 |
199 } // namespace policy | 199 } // namespace policy |
OLD | NEW |