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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
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_POLICY_DEVICE_STATUS_COLLECTOR_H_ 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_
6 #define CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_ 6 #define CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/weak_ptr.h"
9 #include "base/time.h" 14 #include "base/time.h"
10 #include "base/timer.h" 15 #include "base/timer.h"
16 #include "chrome/browser/cancelable_request.h"
11 #include "chrome/browser/chromeos/version_loader.h" 17 #include "chrome/browser/chromeos/version_loader.h"
12 #include "chrome/browser/idle.h" 18 #include "chrome/browser/idle.h"
19 #include "content/public/browser/geolocation.h"
13 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/common/geoposition.h"
14 22
15 namespace chromeos { 23 namespace chromeos {
16 class CrosSettings; 24 class CrosSettings;
17 namespace system { 25 namespace system {
18 class StatisticsProvider; 26 class StatisticsProvider;
19 } 27 }
20 } 28 }
21 29
30 namespace content {
31 class NotificationDetails;
32 class NotificationSource;
33 }
34
22 namespace enterprise_management { 35 namespace enterprise_management {
23 class DeviceStatusReportRequest; 36 class DeviceStatusReportRequest;
24 } 37 }
25 38
26 class PrefService; 39 class PrefService;
27 40
28 namespace policy { 41 namespace policy {
29 42
30 // Collects and summarizes the status of an enterprised-managed ChromeOS device. 43 // Collects and summarizes the status of an enterprised-managed ChromeOS device.
31 class DeviceStatusCollector : public content::NotificationObserver { 44 class DeviceStatusCollector : public content::NotificationObserver {
32 public: 45 public:
46 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper
47 // way to mock geolocation exists.
48 typedef void(*LocationUpdateRequester)(
49 const content::GeolocationUpdateCallback& callback);
50
33 DeviceStatusCollector(PrefService* local_state, 51 DeviceStatusCollector(PrefService* local_state,
34 chromeos::system::StatisticsProvider* provider); 52 chromeos::system::StatisticsProvider* provider,
53 LocationUpdateRequester location_update_requester);
35 virtual ~DeviceStatusCollector(); 54 virtual ~DeviceStatusCollector();
36 55
37 void GetStatus(enterprise_management::DeviceStatusReportRequest* request); 56 void GetStatus(enterprise_management::DeviceStatusReportRequest* request);
38 57
39 static void RegisterPrefs(PrefService* local_state); 58 static void RegisterPrefs(PrefService* local_state);
40 59
41 // How often, in seconds, to poll to see if the user is idle. 60 // How often, in seconds, to poll to see if the user is idle.
42 static const unsigned int kPollIntervalSeconds = 30; 61 static const unsigned int kIdlePollIntervalSeconds = 30;
43 62
44 protected: 63 protected:
45 // Check whether the user has been idle for a certain period of time. 64 // Check whether the user has been idle for a certain period of time.
46 virtual void CheckIdleState(); 65 virtual void CheckIdleState();
47 66
48 // Used instead of base::Time::Now(), to make testing possible. 67 // Used instead of base::Time::Now(), to make testing possible.
49 virtual base::Time GetCurrentTime(); 68 virtual base::Time GetCurrentTime();
50 69
51 // Callback which receives the results of the idle state check. 70 // Callback which receives the results of the idle state check.
52 void IdleStateCallback(IdleState state); 71 void IdleStateCallback(IdleState state);
(...skipping 20 matching lines...) Expand all
73 void OnOSFirmware(chromeos::VersionLoader::Handle handle, 92 void OnOSFirmware(chromeos::VersionLoader::Handle handle,
74 std::string version); 93 std::string version);
75 94
76 // Helpers for the various portions of the status. 95 // Helpers for the various portions of the status.
77 void GetActivityTimes( 96 void GetActivityTimes(
78 enterprise_management::DeviceStatusReportRequest* request); 97 enterprise_management::DeviceStatusReportRequest* request);
79 void GetVersionInfo( 98 void GetVersionInfo(
80 enterprise_management::DeviceStatusReportRequest* request); 99 enterprise_management::DeviceStatusReportRequest* request);
81 void GetBootMode( 100 void GetBootMode(
82 enterprise_management::DeviceStatusReportRequest* request); 101 enterprise_management::DeviceStatusReportRequest* request);
102 void GetLocation(
103 enterprise_management::DeviceStatusReportRequest* request);
83 104
84 // Update the cached values of the reporting settings. 105 // Update the cached values of the reporting settings.
85 void UpdateReportingSettings(); 106 void UpdateReportingSettings();
86 107
87 // content::NotificationObserver interface. 108 // content::NotificationObserver interface.
88 virtual void Observe( 109 virtual void Observe(
89 int type, 110 int type,
90 const content::NotificationSource& source, 111 const content::NotificationSource& source,
91 const content::NotificationDetails& details) OVERRIDE; 112 const content::NotificationDetails& details) OVERRIDE;
92 113
114 void ScheduleGeolocationUpdateRequest();
115
116 // content::GeolocationUpdateCallback implementation.
117 void ReceiveGeolocationUpdate(const content::Geoposition&);
118
93 // How often to poll to see if the user is idle. 119 // How often to poll to see if the user is idle.
94 int poll_interval_seconds_; 120 int poll_interval_seconds_;
95 121
96 PrefService* local_state_; 122 PrefService* local_state_;
97 123
98 // The last time an idle state check was performed. 124 // The last time an idle state check was performed.
99 base::Time last_idle_check_; 125 base::Time last_idle_check_;
100 126
101 base::RepeatingTimer<DeviceStatusCollector> timer_; 127 // Whether a geolocation update is currently in progress.
128 bool geolocation_update_in_progress_;
129
130 base::RepeatingTimer<DeviceStatusCollector> idle_poll_timer_;
131 base::OneShotTimer<DeviceStatusCollector> geolocation_update_timer_;
102 132
103 chromeos::VersionLoader version_loader_; 133 chromeos::VersionLoader version_loader_;
104 CancelableRequestConsumer consumer_; 134 CancelableRequestConsumer consumer_;
105 135
106 std::string os_version_; 136 std::string os_version_;
107 std::string firmware_version_; 137 std::string firmware_version_;
108 138
139 content::Geoposition position_;
140
109 chromeos::system::StatisticsProvider* statistics_provider_; 141 chromeos::system::StatisticsProvider* statistics_provider_;
110 142
111 chromeos::CrosSettings* cros_settings_; 143 chromeos::CrosSettings* cros_settings_;
112 144
145 base::WeakPtrFactory<DeviceStatusCollector> weak_factory_;
146
147 // TODO(bartfab): Remove this once crbug.com/125931 is addressed and a proper
148 // way to mock geolocation exists.
149 LocationUpdateRequester location_update_requester_;
150
113 // Cached values of the reporting settings from the device policy. 151 // Cached values of the reporting settings from the device policy.
114 bool report_version_info_; 152 bool report_version_info_;
115 bool report_activity_times_; 153 bool report_activity_times_;
116 bool report_boot_mode_; 154 bool report_boot_mode_;
155 bool report_location_;
117 156
118 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector); 157 DISALLOW_COPY_AND_ASSIGN(DeviceStatusCollector);
119 }; 158 };
120 159
121 } // namespace policy 160 } // namespace policy
122 161
123 #endif // CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_ 162 #endif // CHROME_BROWSER_POLICY_DEVICE_STATUS_COLLECTOR_H_
OLDNEW
« 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