| 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 17 #include "chrome/browser/chromeos/version_loader.h" | 19 #include "chrome/browser/chromeos/version_loader.h" |
| 18 #include "chrome/browser/idle.h" | 20 #include "chrome/browser/idle.h" |
| 19 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 21 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
| 20 #include "chrome/common/cancelable_task_tracker.h" | 22 #include "chrome/common/cancelable_task_tracker.h" |
| 21 #include "content/public/browser/geolocation_provider.h" | 23 #include "content/public/browser/geolocation_provider.h" |
| 22 #include "content/public/browser/notification_observer.h" | |
| 23 #include "content/public/common/geoposition.h" | 24 #include "content/public/common/geoposition.h" |
| 24 | 25 |
| 25 namespace chromeos { | 26 namespace chromeos { |
| 26 class CrosSettings; | 27 class CrosSettings; |
| 27 namespace system { | 28 namespace system { |
| 28 class StatisticsProvider; | 29 class StatisticsProvider; |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 class NotificationDetails; | 34 class NotificationDetails; |
| 34 class NotificationSource; | 35 class NotificationSource; |
| 35 } | 36 } |
| 36 | 37 |
| 37 namespace enterprise_management { | 38 namespace enterprise_management { |
| 38 class DeviceStatusReportRequest; | 39 class DeviceStatusReportRequest; |
| 39 } | 40 } |
| 40 | 41 |
| 41 class PrefRegistrySimple; | 42 class PrefRegistrySimple; |
| 42 class PrefService; | 43 class PrefService; |
| 43 | 44 |
| 44 namespace policy { | 45 namespace policy { |
| 45 | 46 |
| 46 // Collects and summarizes the status of an enterprised-managed ChromeOS device. | 47 // Collects and summarizes the status of an enterprised-managed ChromeOS device. |
| 47 class DeviceStatusCollector : public CloudPolicyClient::StatusProvider, | 48 class DeviceStatusCollector : public CloudPolicyClient::StatusProvider { |
| 48 public content::NotificationObserver { | |
| 49 public: | 49 public: |
| 50 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper | 50 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper |
| 51 // way to mock geolocation exists. | 51 // way to mock geolocation exists. |
| 52 typedef base::Callback<void( | 52 typedef base::Callback<void( |
| 53 const content::GeolocationProvider::LocationUpdateCallback& callback)> | 53 const content::GeolocationProvider::LocationUpdateCallback& callback)> |
| 54 LocationUpdateRequester; | 54 LocationUpdateRequester; |
| 55 | 55 |
| 56 DeviceStatusCollector( | 56 DeviceStatusCollector( |
| 57 PrefService* local_state, | 57 PrefService* local_state, |
| 58 chromeos::system::StatisticsProvider* provider, | 58 chromeos::system::StatisticsProvider* provider, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 // The number of days in the past to store device activity. | 86 // The number of days in the past to store device activity. |
| 87 // This is kept in case device status uploads fail for a number of days. | 87 // This is kept in case device status uploads fail for a number of days. |
| 88 unsigned int max_stored_past_activity_days_; | 88 unsigned int max_stored_past_activity_days_; |
| 89 | 89 |
| 90 // The number of days in the future to store device activity. | 90 // The number of days in the future to store device activity. |
| 91 // When changing the system time and/or timezones, it's possible to record | 91 // When changing the system time and/or timezones, it's possible to record |
| 92 // activity time that is slightly in the future. | 92 // activity time that is slightly in the future. |
| 93 unsigned int max_stored_future_activity_days_; | 93 unsigned int max_stored_future_activity_days_; |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 // A helper class to manage receiving geolocation notifications on the IO | 96 // A helper class to manage receiving geolocation callbacks on the IO |
| 97 // thread. | 97 // thread. |
| 98 class Context : public base::RefCountedThreadSafe<Context> { | 98 class Context : public base::RefCountedThreadSafe<Context> { |
| 99 public: | 99 public: |
| 100 Context(); | 100 Context(); |
| 101 | 101 |
| 102 void GetLocationUpdate( | 102 void GetLocationUpdate( |
| 103 const content::GeolocationProvider::LocationUpdateCallback& callback); | 103 const content::GeolocationProvider::LocationUpdateCallback& callback); |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 friend class base::RefCountedThreadSafe<Context>; | 106 friend class base::RefCountedThreadSafe<Context>; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 void GetBootMode( | 144 void GetBootMode( |
| 145 enterprise_management::DeviceStatusReportRequest* request); | 145 enterprise_management::DeviceStatusReportRequest* request); |
| 146 void GetLocation( | 146 void GetLocation( |
| 147 enterprise_management::DeviceStatusReportRequest* request); | 147 enterprise_management::DeviceStatusReportRequest* request); |
| 148 void GetNetworkInterfaces( | 148 void GetNetworkInterfaces( |
| 149 enterprise_management::DeviceStatusReportRequest* request); | 149 enterprise_management::DeviceStatusReportRequest* request); |
| 150 | 150 |
| 151 // Update the cached values of the reporting settings. | 151 // Update the cached values of the reporting settings. |
| 152 void UpdateReportingSettings(); | 152 void UpdateReportingSettings(); |
| 153 | 153 |
| 154 // content::NotificationObserver interface. | |
| 155 virtual void Observe( | |
| 156 int type, | |
| 157 const content::NotificationSource& source, | |
| 158 const content::NotificationDetails& details) OVERRIDE; | |
| 159 | |
| 160 void ScheduleGeolocationUpdateRequest(); | 154 void ScheduleGeolocationUpdateRequest(); |
| 161 | 155 |
| 162 // content::GeolocationUpdateCallback implementation. | 156 // content::GeolocationUpdateCallback implementation. |
| 163 void ReceiveGeolocationUpdate(const content::Geoposition&); | 157 void ReceiveGeolocationUpdate(const content::Geoposition&); |
| 164 | 158 |
| 165 // How often to poll to see if the user is idle. | 159 // How often to poll to see if the user is idle. |
| 166 int poll_interval_seconds_; | 160 int poll_interval_seconds_; |
| 167 | 161 |
| 168 PrefService* local_state_; | 162 PrefService* local_state_; |
| 169 | 163 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 197 |
| 204 // Cached values of the reporting settings from the device policy. | 198 // Cached values of the reporting settings from the device policy. |
| 205 bool report_version_info_; | 199 bool report_version_info_; |
| 206 bool report_activity_times_; | 200 bool report_activity_times_; |
| 207 bool report_boot_mode_; | 201 bool report_boot_mode_; |
| 208 bool report_location_; | 202 bool report_location_; |
| 209 bool report_network_interfaces_; | 203 bool report_network_interfaces_; |
| 210 | 204 |
| 211 scoped_refptr<Context> context_; | 205 scoped_refptr<Context> context_; |
| 212 | 206 |
| 207 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 208 version_info_subscription_; |
| 209 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 210 activity_times_subscription_; |
| 211 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 212 boot_mode_subscription_; |
| 213 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 214 location_subscription_; |
| 215 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |
| 216 network_interfaces_subscription_; |
| 217 |
| 213 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); | 218 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); |
| 214 }; | 219 }; |
| 215 | 220 |
| 216 } // namespace policy | 221 } // namespace policy |
| 217 | 222 |
| 218 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ | 223 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_STATUS_COLLECTOR_H_ |
| OLD | NEW |