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/device_status_collector.h" | 5 #include "chrome/browser/policy/device_status_collector.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
17 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
18 #include "chrome/browser/chromeos/system/statistics_provider.h" | 18 #include "chrome/browser/chromeos/system/statistics_provider.h" |
19 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 19 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 20 #include "chrome/browser/prefs/pref_registry_simple.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 22 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
22 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/chrome_version_info.h" | 24 #include "chrome/common/chrome_version_info.h" |
24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
25 #include "content/public/browser/notification_details.h" | 26 #include "content/public/browser/notification_details.h" |
26 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
27 | 28 |
28 using base::Time; | 29 using base::Time; |
29 using base::TimeDelta; | 30 using base::TimeDelta; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 DeviceStatusCollector::~DeviceStatusCollector() { | 146 DeviceStatusCollector::~DeviceStatusCollector() { |
146 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceVersionInfo, | 147 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceVersionInfo, |
147 this); | 148 this); |
148 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceActivityTimes, | 149 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceActivityTimes, |
149 this); | 150 this); |
150 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceBootMode, this); | 151 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceBootMode, this); |
151 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceLocation, this); | 152 cros_settings_->RemoveSettingsObserver(chromeos::kReportDeviceLocation, this); |
152 } | 153 } |
153 | 154 |
154 // static | 155 // static |
155 void DeviceStatusCollector::RegisterPrefs(PrefServiceSimple* local_state) { | 156 void DeviceStatusCollector::RegisterPrefs(PrefRegistrySimple* registry) { |
156 local_state->RegisterDictionaryPref(prefs::kDeviceActivityTimes, | 157 registry->RegisterDictionaryPref(prefs::kDeviceActivityTimes, |
157 new base::DictionaryValue); | 158 new base::DictionaryValue); |
158 local_state->RegisterDictionaryPref(prefs::kDeviceLocation, | 159 registry->RegisterDictionaryPref(prefs::kDeviceLocation, |
159 new base::DictionaryValue); | 160 new base::DictionaryValue); |
160 } | 161 } |
161 | 162 |
162 void DeviceStatusCollector::CheckIdleState() { | 163 void DeviceStatusCollector::CheckIdleState() { |
163 CalculateIdleState(kIdleStateThresholdSeconds, | 164 CalculateIdleState(kIdleStateThresholdSeconds, |
164 base::Bind(&DeviceStatusCollector::IdleStateCallback, | 165 base::Bind(&DeviceStatusCollector::IdleStateCallback, |
165 base::Unretained(this))); | 166 base::Unretained(this))); |
166 } | 167 } |
167 | 168 |
168 void DeviceStatusCollector::UpdateReportingSettings() { | 169 void DeviceStatusCollector::UpdateReportingSettings() { |
169 // Attempt to fetch the current value of the reporting settings. | 170 // Attempt to fetch the current value of the reporting settings. |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 location.SetDouble(kSpeed, position.speed); | 461 location.SetDouble(kSpeed, position.speed); |
461 location.SetString(kTimestamp, | 462 location.SetString(kTimestamp, |
462 base::Int64ToString(position.timestamp.ToInternalValue())); | 463 base::Int64ToString(position.timestamp.ToInternalValue())); |
463 local_state_->Set(prefs::kDeviceLocation, location); | 464 local_state_->Set(prefs::kDeviceLocation, location); |
464 } | 465 } |
465 | 466 |
466 ScheduleGeolocationUpdateRequest(); | 467 ScheduleGeolocationUpdateRequest(); |
467 } | 468 } |
468 | 469 |
469 } // namespace policy | 470 } // namespace policy |
OLD | NEW |