Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6269)

Unified Diff: chrome/browser/policy/device_status_collector.h

Issue 10103029: Add device location reporting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nits addressed. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.cc ('k') | chrome/browser/policy/device_status_collector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/device_status_collector.h
diff --git a/chrome/browser/policy/device_status_collector.h b/chrome/browser/policy/device_status_collector.h
index 4afffcb09a12ae3b33f9fd7ac157e2aa46c3ca29..254a3186b76ecfff903c84d8838cf2019f893bc6 100644
--- a/chrome/browser/policy/device_status_collector.h
+++ b/chrome/browser/policy/device_status_collector.h
@@ -6,11 +6,19 @@
#define CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_
#pragma once
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
#include "base/time.h"
#include "base/timer.h"
+#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/chromeos/version_loader.h"
#include "chrome/browser/idle.h"
+#include "content/public/browser/geolocation.h"
#include "content/public/browser/notification_observer.h"
+#include "content/public/common/geoposition.h"
namespace chromeos {
class CrosSettings;
@@ -19,6 +27,11 @@ class StatisticsProvider;
}
}
+namespace content {
+class NotificationDetails;
+class NotificationSource;
+}
+
namespace enterprise_management {
class DeviceStatusReportRequest;
}
@@ -30,8 +43,14 @@ namespace policy {
// Collects and summarizes the status of an enterprised-managed ChromeOS device.
class DeviceStatusCollector : public content::NotificationObserver {
public:
+ // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper
+ // way to mock geolocation exists.
+ typedef void(*LocationUpdateRequester)(
+ const content::GeolocationUpdateCallback& callback);
+
DeviceStatusCollector(PrefService* local_state,
- chromeos::system::StatisticsProvider* provider);
+ chromeos::system::StatisticsProvider* provider,
+ LocationUpdateRequester location_update_requester);
virtual ~DeviceStatusCollector();
void GetStatus(enterprise_management::DeviceStatusReportRequest* request);
@@ -39,7 +58,7 @@ class DeviceStatusCollector : public content::NotificationObserver {
static void RegisterPrefs(PrefService* local_state);
// How often, in seconds, to poll to see if the user is idle.
- static const unsigned int kPollIntervalSeconds = 30;
+ static const unsigned int kIdlePollIntervalSeconds = 30;
protected:
// Check whether the user has been idle for a certain period of time.
@@ -80,6 +99,8 @@ class DeviceStatusCollector : public content::NotificationObserver {
enterprise_management::DeviceStatusReportRequest* request);
void GetBootMode(
enterprise_management::DeviceStatusReportRequest* request);
+ void GetLocation(
+ enterprise_management::DeviceStatusReportRequest* request);
// Update the cached values of the reporting settings.
void UpdateReportingSettings();
@@ -90,6 +111,11 @@ class DeviceStatusCollector : public content::NotificationObserver {
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ void ScheduleGeolocationUpdateRequest();
+
+ // content::GeolocationUpdateCallback implementation.
+ void ReceiveGeolocationUpdate(const content::Geoposition&);
+
// How often to poll to see if the user is idle.
int poll_interval_seconds_;
@@ -98,7 +124,11 @@ class DeviceStatusCollector : public content::NotificationObserver {
// The last time an idle state check was performed.
base::Time last_idle_check_;
- base::RepeatingTimer<DeviceStatusCollector> timer_;
+ // Whether a geolocation update is currently in progress.
+ bool geolocation_update_in_progress_;
+
+ base::RepeatingTimer<DeviceStatusCollector> idle_poll_timer_;
+ base::OneShotTimer<DeviceStatusCollector> geolocation_update_timer_;
chromeos::VersionLoader version_loader_;
CancelableRequestConsumer consumer_;
@@ -106,14 +136,23 @@ class DeviceStatusCollector : public content::NotificationObserver {
std::string os_version_;
std::string firmware_version_;
+ content::Geoposition position_;
+
chromeos::system::StatisticsProvider* statistics_provider_;
chromeos::CrosSettings* cros_settings_;
+ base::WeakPtrFactory<DeviceStatusCollector> weak_factory_;
+
+ // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper
+ // way to mock geolocation exists.
+ LocationUpdateRequester location_update_requester_;
+
// Cached values of the reporting settings from the device policy.
bool report_version_info_;
bool report_activity_times_;
bool report_boot_mode_;
+ bool report_location_;
DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector);
};
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.cc ('k') | chrome/browser/policy/device_status_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698