Updated DeviceStatusReportRequest to contain new monitoring data.
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / device_status_collector.cc
blobd4759b92d09f051e05983fa09263b8bf3c8d1d3a
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/policy/device_status_collector.h"
7 #include <limits>
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/location.h"
12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/pref_service.h"
16 #include "base/prefs/scoped_user_pref_update.h"
17 #include "base/strings/string_number_conversions.h"
18 #include "base/values.h"
19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
21 #include "chrome/browser/chromeos/settings/cros_settings.h"
22 #include "chrome/common/chrome_version_info.h"
23 #include "chrome/common/pref_names.h"
24 #include "chromeos/network/device_state.h"
25 #include "chromeos/network/network_handler.h"
26 #include "chromeos/network/network_state.h"
27 #include "chromeos/network/network_state_handler.h"
28 #include "chromeos/settings/cros_settings_names.h"
29 #include "chromeos/system/statistics_provider.h"
30 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
31 #include "components/user_manager/user_manager.h"
32 #include "components/user_manager/user_type.h"
33 #include "content/public/browser/browser_thread.h"
34 #include "policy/proto/device_management_backend.pb.h"
35 #include "third_party/cros_system_api/dbus/service_constants.h"
37 using base::Time;
38 using base::TimeDelta;
40 namespace em = enterprise_management;
42 namespace {
43 // How many seconds of inactivity triggers the idle state.
44 const int kIdleStateThresholdSeconds = 300;
46 // How many days in the past to store active periods for.
47 const unsigned int kMaxStoredPastActivityDays = 30;
49 // How many days in the future to store active periods for.
50 const unsigned int kMaxStoredFutureActivityDays = 2;
52 // How often, in seconds, to update the device location.
53 const unsigned int kGeolocationPollIntervalSeconds = 30 * 60;
55 const int64 kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000;
57 // Keys for the geolocation status dictionary in local state.
58 const char kLatitude[] = "latitude";
59 const char kLongitude[] = "longitude";
60 const char kAltitude[] = "altitude";
61 const char kAccuracy[] = "accuracy";
62 const char kAltitudeAccuracy[] = "altitude_accuracy";
63 const char kHeading[] = "heading";
64 const char kSpeed[] = "speed";
65 const char kTimestamp[] = "timestamp";
67 // Determine the day key (milliseconds since epoch for corresponding day in UTC)
68 // for a given |timestamp|.
69 int64 TimestampToDayKey(Time timestamp) {
70 Time::Exploded exploded;
71 timestamp.LocalMidnight().LocalExplode(&exploded);
72 return (Time::FromUTCExploded(exploded) - Time::UnixEpoch()).InMilliseconds();
75 } // namespace
77 namespace policy {
79 DeviceStatusCollector::DeviceStatusCollector(
80 PrefService* local_state,
81 chromeos::system::StatisticsProvider* provider,
82 LocationUpdateRequester* location_update_requester)
83 : max_stored_past_activity_days_(kMaxStoredPastActivityDays),
84 max_stored_future_activity_days_(kMaxStoredFutureActivityDays),
85 local_state_(local_state),
86 last_idle_check_(Time()),
87 last_reported_day_(0),
88 duration_for_last_reported_day_(0),
89 geolocation_update_in_progress_(false),
90 statistics_provider_(provider),
91 report_version_info_(false),
92 report_activity_times_(false),
93 report_boot_mode_(false),
94 report_location_(false),
95 report_network_interfaces_(false),
96 report_users_(false),
97 report_hardware_status_(false),
98 weak_factory_(this) {
99 if (location_update_requester)
100 location_update_requester_ = *location_update_requester;
101 idle_poll_timer_.Start(FROM_HERE,
102 TimeDelta::FromSeconds(kIdlePollIntervalSeconds),
103 this, &DeviceStatusCollector::CheckIdleState);
105 cros_settings_ = chromeos::CrosSettings::Get();
107 // Watch for changes to the individual policies that control what the status
108 // reports contain.
109 base::Closure callback =
110 base::Bind(&DeviceStatusCollector::UpdateReportingSettings,
111 base::Unretained(this));
112 version_info_subscription_ = cros_settings_->AddSettingsObserver(
113 chromeos::kReportDeviceVersionInfo, callback);
114 activity_times_subscription_ = cros_settings_->AddSettingsObserver(
115 chromeos::kReportDeviceActivityTimes, callback);
116 boot_mode_subscription_ = cros_settings_->AddSettingsObserver(
117 chromeos::kReportDeviceBootMode, callback);
118 location_subscription_ = cros_settings_->AddSettingsObserver(
119 chromeos::kReportDeviceLocation, callback);
120 network_interfaces_subscription_ = cros_settings_->AddSettingsObserver(
121 chromeos::kReportDeviceNetworkInterfaces, callback);
122 users_subscription_ = cros_settings_->AddSettingsObserver(
123 chromeos::kReportDeviceUsers, callback);
124 hardware_status_subscription_ = cros_settings_->AddSettingsObserver(
125 chromeos::kReportDeviceHardwareStatus, callback);
127 // The last known location is persisted in local state. This makes location
128 // information available immediately upon startup and avoids the need to
129 // reacquire the location on every user session change or browser crash.
130 content::Geoposition position;
131 std::string timestamp_str;
132 int64 timestamp;
133 const base::DictionaryValue* location =
134 local_state_->GetDictionary(prefs::kDeviceLocation);
135 if (location->GetDouble(kLatitude, &position.latitude) &&
136 location->GetDouble(kLongitude, &position.longitude) &&
137 location->GetDouble(kAltitude, &position.altitude) &&
138 location->GetDouble(kAccuracy, &position.accuracy) &&
139 location->GetDouble(kAltitudeAccuracy, &position.altitude_accuracy) &&
140 location->GetDouble(kHeading, &position.heading) &&
141 location->GetDouble(kSpeed, &position.speed) &&
142 location->GetString(kTimestamp, &timestamp_str) &&
143 base::StringToInt64(timestamp_str, &timestamp)) {
144 position.timestamp = Time::FromInternalValue(timestamp);
145 position_ = position;
148 // Fetch the current values of the policies.
149 UpdateReportingSettings();
151 // Get the the OS and firmware version info.
152 base::PostTaskAndReplyWithResult(
153 content::BrowserThread::GetBlockingPool(),
154 FROM_HERE,
155 base::Bind(&chromeos::version_loader::GetVersion,
156 chromeos::version_loader::VERSION_FULL),
157 base::Bind(&DeviceStatusCollector::OnOSVersion,
158 weak_factory_.GetWeakPtr()));
159 base::PostTaskAndReplyWithResult(
160 content::BrowserThread::GetBlockingPool(),
161 FROM_HERE,
162 base::Bind(&chromeos::version_loader::GetFirmware),
163 base::Bind(&DeviceStatusCollector::OnOSFirmware,
164 weak_factory_.GetWeakPtr()));
167 DeviceStatusCollector::~DeviceStatusCollector() {
170 // static
171 void DeviceStatusCollector::RegisterPrefs(PrefRegistrySimple* registry) {
172 registry->RegisterDictionaryPref(prefs::kDeviceActivityTimes,
173 new base::DictionaryValue);
174 registry->RegisterDictionaryPref(prefs::kDeviceLocation,
175 new base::DictionaryValue);
178 void DeviceStatusCollector::CheckIdleState() {
179 CalculateIdleState(kIdleStateThresholdSeconds,
180 base::Bind(&DeviceStatusCollector::IdleStateCallback,
181 base::Unretained(this)));
184 void DeviceStatusCollector::UpdateReportingSettings() {
185 // Attempt to fetch the current value of the reporting settings.
186 // If trusted values are not available, register this function to be called
187 // back when they are available.
188 if (chromeos::CrosSettingsProvider::TRUSTED !=
189 cros_settings_->PrepareTrustedValues(
190 base::Bind(&DeviceStatusCollector::UpdateReportingSettings,
191 weak_factory_.GetWeakPtr()))) {
192 return;
195 // All reporting settings default to 'enabled'.
196 if (!cros_settings_->GetBoolean(
197 chromeos::kReportDeviceVersionInfo, &report_version_info_)) {
198 report_version_info_ = true;
200 if (!cros_settings_->GetBoolean(
201 chromeos::kReportDeviceActivityTimes, &report_activity_times_)) {
202 report_activity_times_ = true;
204 if (!cros_settings_->GetBoolean(
205 chromeos::kReportDeviceBootMode, &report_boot_mode_)) {
206 report_boot_mode_ = true;
208 if (!cros_settings_->GetBoolean(
209 chromeos::kReportDeviceNetworkInterfaces, &report_network_interfaces_)) {
210 report_network_interfaces_ = true;
212 if (!cros_settings_->GetBoolean(
213 chromeos::kReportDeviceUsers, &report_users_)) {
214 report_users_ = true;
216 if (!cros_settings_->GetBoolean(
217 chromeos::kReportDeviceHardwareStatus, &report_hardware_status_)) {
218 report_hardware_status_ = true;
221 // Device location reporting is disabled by default because it is
222 // not launched yet.
223 if (!cros_settings_->GetBoolean(
224 chromeos::kReportDeviceLocation, &report_location_)) {
225 report_location_ = false;
228 if (report_location_) {
229 ScheduleGeolocationUpdateRequest();
230 } else {
231 geolocation_update_timer_.Stop();
232 position_ = content::Geoposition();
233 local_state_->ClearPref(prefs::kDeviceLocation);
237 Time DeviceStatusCollector::GetCurrentTime() {
238 return Time::Now();
241 // Remove all out-of-range activity times from the local store.
242 void DeviceStatusCollector::PruneStoredActivityPeriods(Time base_time) {
243 Time min_time =
244 base_time - TimeDelta::FromDays(max_stored_past_activity_days_);
245 Time max_time =
246 base_time + TimeDelta::FromDays(max_stored_future_activity_days_);
247 TrimStoredActivityPeriods(TimestampToDayKey(min_time), 0,
248 TimestampToDayKey(max_time));
251 void DeviceStatusCollector::TrimStoredActivityPeriods(int64 min_day_key,
252 int min_day_trim_duration,
253 int64 max_day_key) {
254 const base::DictionaryValue* activity_times =
255 local_state_->GetDictionary(prefs::kDeviceActivityTimes);
257 scoped_ptr<base::DictionaryValue> copy(activity_times->DeepCopy());
258 for (base::DictionaryValue::Iterator it(*activity_times); !it.IsAtEnd();
259 it.Advance()) {
260 int64 timestamp;
261 if (base::StringToInt64(it.key(), &timestamp)) {
262 // Remove data that is too old, or too far in the future.
263 if (timestamp >= min_day_key && timestamp < max_day_key) {
264 if (timestamp == min_day_key) {
265 int new_activity_duration = 0;
266 if (it.value().GetAsInteger(&new_activity_duration)) {
267 new_activity_duration =
268 std::max(new_activity_duration - min_day_trim_duration, 0);
270 copy->SetInteger(it.key(), new_activity_duration);
272 continue;
275 // The entry is out of range or couldn't be parsed. Remove it.
276 copy->Remove(it.key(), NULL);
278 local_state_->Set(prefs::kDeviceActivityTimes, *copy);
281 void DeviceStatusCollector::AddActivePeriod(Time start, Time end) {
282 DCHECK(start < end);
284 // Maintain the list of active periods in a local_state pref.
285 DictionaryPrefUpdate update(local_state_, prefs::kDeviceActivityTimes);
286 base::DictionaryValue* activity_times = update.Get();
288 // Assign the period to day buckets in local time.
289 Time midnight = start.LocalMidnight();
290 while (midnight < end) {
291 midnight += TimeDelta::FromDays(1);
292 int64 activity = (std::min(end, midnight) - start).InMilliseconds();
293 std::string day_key = base::Int64ToString(TimestampToDayKey(start));
294 int previous_activity = 0;
295 activity_times->GetInteger(day_key, &previous_activity);
296 activity_times->SetInteger(day_key, previous_activity + activity);
297 start = midnight;
301 void DeviceStatusCollector::IdleStateCallback(IdleState state) {
302 // Do nothing if device activity reporting is disabled.
303 if (!report_activity_times_)
304 return;
306 Time now = GetCurrentTime();
308 if (state == IDLE_STATE_ACTIVE) {
309 // If it's been too long since the last report, or if the activity is
310 // negative (which can happen when the clock changes), assume a single
311 // interval of activity.
312 int active_seconds = (now - last_idle_check_).InSeconds();
313 if (active_seconds < 0 ||
314 active_seconds >= static_cast<int>((2 * kIdlePollIntervalSeconds))) {
315 AddActivePeriod(now - TimeDelta::FromSeconds(kIdlePollIntervalSeconds),
316 now);
317 } else {
318 AddActivePeriod(last_idle_check_, now);
321 PruneStoredActivityPeriods(now);
323 last_idle_check_ = now;
326 void DeviceStatusCollector::GetActivityTimes(
327 em::DeviceStatusReportRequest* request) {
328 DictionaryPrefUpdate update(local_state_, prefs::kDeviceActivityTimes);
329 base::DictionaryValue* activity_times = update.Get();
331 for (base::DictionaryValue::Iterator it(*activity_times); !it.IsAtEnd();
332 it.Advance()) {
333 int64 start_timestamp;
334 int activity_milliseconds;
335 if (base::StringToInt64(it.key(), &start_timestamp) &&
336 it.value().GetAsInteger(&activity_milliseconds)) {
337 // This is correct even when there are leap seconds, because when a leap
338 // second occurs, two consecutive seconds have the same timestamp.
339 int64 end_timestamp = start_timestamp + kMillisecondsPerDay;
341 em::ActiveTimePeriod* active_period = request->add_active_period();
342 em::TimePeriod* period = active_period->mutable_time_period();
343 period->set_start_timestamp(start_timestamp);
344 period->set_end_timestamp(end_timestamp);
345 active_period->set_active_duration(activity_milliseconds);
346 if (start_timestamp >= last_reported_day_) {
347 last_reported_day_ = start_timestamp;
348 duration_for_last_reported_day_ = activity_milliseconds;
350 } else {
351 NOTREACHED();
356 void DeviceStatusCollector::GetVersionInfo(
357 em::DeviceStatusReportRequest* request) {
358 chrome::VersionInfo version_info;
359 request->set_browser_version(version_info.Version());
360 request->set_os_version(os_version_);
361 request->set_firmware_version(firmware_version_);
364 void DeviceStatusCollector::GetBootMode(
365 em::DeviceStatusReportRequest* request) {
366 std::string dev_switch_mode;
367 if (statistics_provider_->GetMachineStatistic(
368 chromeos::system::kDevSwitchBootMode, &dev_switch_mode)) {
369 if (dev_switch_mode == "1")
370 request->set_boot_mode("Dev");
371 else if (dev_switch_mode == "0")
372 request->set_boot_mode("Verified");
376 void DeviceStatusCollector::GetLocation(
377 em::DeviceStatusReportRequest* request) {
378 em::DeviceLocation* location = request->mutable_device_location();
379 if (!position_.Validate()) {
380 location->set_error_code(
381 em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE);
382 location->set_error_message(position_.error_message);
383 } else {
384 location->set_latitude(position_.latitude);
385 location->set_longitude(position_.longitude);
386 location->set_accuracy(position_.accuracy);
387 location->set_timestamp(
388 (position_.timestamp - Time::UnixEpoch()).InMilliseconds());
389 // Lowest point on land is at approximately -400 meters.
390 if (position_.altitude > -10000.)
391 location->set_altitude(position_.altitude);
392 if (position_.altitude_accuracy >= 0.)
393 location->set_altitude_accuracy(position_.altitude_accuracy);
394 if (position_.heading >= 0. && position_.heading <= 360)
395 location->set_heading(position_.heading);
396 if (position_.speed >= 0.)
397 location->set_speed(position_.speed);
398 location->set_error_code(em::DeviceLocation::ERROR_CODE_NONE);
402 void DeviceStatusCollector::GetNetworkInterfaces(
403 em::DeviceStatusReportRequest* request) {
404 // Maps shill device type strings to proto enum constants.
405 static const struct {
406 const char* type_string;
407 em::NetworkInterface::NetworkDeviceType type_constant;
408 } kDeviceTypeMap[] = {
409 { shill::kTypeEthernet, em::NetworkInterface::TYPE_ETHERNET, },
410 { shill::kTypeWifi, em::NetworkInterface::TYPE_WIFI, },
411 { shill::kTypeWimax, em::NetworkInterface::TYPE_WIMAX, },
412 { shill::kTypeBluetooth, em::NetworkInterface::TYPE_BLUETOOTH, },
413 { shill::kTypeCellular, em::NetworkInterface::TYPE_CELLULAR, },
416 // Maps shill device connection status to proto enum constants.
417 static const struct {
418 const char* state_string;
419 em::NetworkState::ConnectionState state_constant;
420 } kConnectionStateMap[] = {
421 { shill::kStateIdle, em::NetworkState::IDLE },
422 { shill::kStateCarrier, em::NetworkState::CARRIER },
423 { shill::kStateAssociation, em::NetworkState::ASSOCIATION },
424 { shill::kStateConfiguration, em::NetworkState::CONFIGURATION },
425 { shill::kStateReady, em::NetworkState::READY },
426 { shill::kStatePortal, em::NetworkState::PORTAL },
427 { shill::kStateOffline, em::NetworkState::OFFLINE },
428 { shill::kStateOnline, em::NetworkState::ONLINE },
429 { shill::kStateDisconnect, em::NetworkState::DISCONNECT },
430 { shill::kStateFailure, em::NetworkState::FAILURE },
431 { shill::kStateActivationFailure,
432 em::NetworkState::ACTIVATION_FAILURE },
435 chromeos::NetworkStateHandler::DeviceStateList device_list;
436 chromeos::NetworkStateHandler* network_state_handler =
437 chromeos::NetworkHandler::Get()->network_state_handler();
438 network_state_handler->GetDeviceList(&device_list);
440 chromeos::NetworkStateHandler::DeviceStateList::const_iterator device;
441 for (device = device_list.begin(); device != device_list.end(); ++device) {
442 // Determine the type enum constant for |device|.
443 size_t type_idx = 0;
444 for (; type_idx < arraysize(kDeviceTypeMap); ++type_idx) {
445 if ((*device)->type() == kDeviceTypeMap[type_idx].type_string)
446 break;
449 // If the type isn't in |kDeviceTypeMap|, the interface is not relevant for
450 // reporting. This filters out VPN devices.
451 if (type_idx >= arraysize(kDeviceTypeMap))
452 continue;
454 em::NetworkInterface* interface = request->add_network_interface();
455 interface->set_type(kDeviceTypeMap[type_idx].type_constant);
456 if (!(*device)->mac_address().empty())
457 interface->set_mac_address((*device)->mac_address());
458 if (!(*device)->meid().empty())
459 interface->set_meid((*device)->meid());
460 if (!(*device)->imei().empty())
461 interface->set_imei((*device)->imei());
462 if (!(*device)->path().empty())
463 interface->set_device_path((*device)->path());
466 // Walk the various networks and store their state in the status report.
467 chromeos::NetworkStateHandler::NetworkStateList state_list;
468 network_state_handler->GetNetworkListByType(
469 chromeos::NetworkTypePattern::Default(),
470 true, // configured_only
471 false, // visible_only,
472 0, // no limit to number of results
473 &state_list);
475 for (const chromeos::NetworkState* state: state_list) {
476 // Determine the connection state and signal strength for |state|.
477 em::NetworkState::ConnectionState connection_state_enum =
478 em::NetworkState::UNKNOWN;
479 const std::string connection_state_string(state->connection_state());
480 for (size_t i = 0; i < arraysize(kConnectionStateMap); ++i) {
481 if (connection_state_string == kConnectionStateMap[i].state_string) {
482 connection_state_enum = kConnectionStateMap[i].state_constant;
483 break;
487 // Copy fields from NetworkState into the status report.
488 em::NetworkState* proto_state = request->add_network_state();
489 proto_state->set_connection_state(connection_state_enum);
490 proto_state->set_signal_strength(state->signal_strength());
491 if (!state->device_path().empty())
492 proto_state->set_device_path(state->device_path());
496 void DeviceStatusCollector::GetUsers(em::DeviceStatusReportRequest* request) {
497 policy::BrowserPolicyConnectorChromeOS* connector =
498 g_browser_process->platform_part()->browser_policy_connector_chromeos();
499 const user_manager::UserList& users =
500 user_manager::UserManager::Get()->GetUsers();
501 user_manager::UserList::const_iterator user;
502 for (user = users.begin(); user != users.end(); ++user) {
503 // Only users with gaia accounts (regular) are reported.
504 if (!(*user)->HasGaiaAccount())
505 continue;
507 em::DeviceUser* device_user = request->add_user();
508 const std::string& email = (*user)->email();
509 if (connector->GetUserAffiliation(email) == USER_AFFILIATION_MANAGED) {
510 device_user->set_type(em::DeviceUser::USER_TYPE_MANAGED);
511 device_user->set_email(email);
512 } else {
513 device_user->set_type(em::DeviceUser::USER_TYPE_UNMANAGED);
514 // Do not report the email address of unmanaged users.
519 void DeviceStatusCollector::GetHardwareStatus(
520 em::DeviceStatusReportRequest* status) {
521 // TODO(atwilson): Fill in hardware status fields.
524 bool DeviceStatusCollector::GetDeviceStatus(
525 em::DeviceStatusReportRequest* status) {
526 if (report_activity_times_)
527 GetActivityTimes(status);
529 if (report_version_info_)
530 GetVersionInfo(status);
532 if (report_boot_mode_)
533 GetBootMode(status);
535 if (report_location_)
536 GetLocation(status);
538 if (report_network_interfaces_)
539 GetNetworkInterfaces(status);
541 if (report_users_) {
542 GetUsers(status);
545 if (report_hardware_status_)
546 GetHardwareStatus(status);
548 return true;
551 bool DeviceStatusCollector::GetSessionStatus(
552 em::SessionStatusReportRequest* status) {
553 return false;
556 void DeviceStatusCollector::OnSubmittedSuccessfully() {
557 TrimStoredActivityPeriods(last_reported_day_, duration_for_last_reported_day_,
558 std::numeric_limits<int64>::max());
561 void DeviceStatusCollector::OnOSVersion(const std::string& version) {
562 os_version_ = version;
565 void DeviceStatusCollector::OnOSFirmware(const std::string& version) {
566 firmware_version_ = version;
569 void DeviceStatusCollector::ScheduleGeolocationUpdateRequest() {
570 if (geolocation_update_timer_.IsRunning() || geolocation_update_in_progress_)
571 return;
573 if (position_.Validate()) {
574 TimeDelta elapsed = GetCurrentTime() - position_.timestamp;
575 TimeDelta interval =
576 TimeDelta::FromSeconds(kGeolocationPollIntervalSeconds);
577 if (elapsed <= interval) {
578 geolocation_update_timer_.Start(
579 FROM_HERE,
580 interval - elapsed,
581 this,
582 &DeviceStatusCollector::ScheduleGeolocationUpdateRequest);
583 return;
587 geolocation_update_in_progress_ = true;
588 if (location_update_requester_.is_null()) {
589 geolocation_subscription_ = content::GeolocationProvider::GetInstance()->
590 AddLocationUpdateCallback(
591 base::Bind(&DeviceStatusCollector::ReceiveGeolocationUpdate,
592 weak_factory_.GetWeakPtr()),
593 true);
594 } else {
595 location_update_requester_.Run(base::Bind(
596 &DeviceStatusCollector::ReceiveGeolocationUpdate,
597 weak_factory_.GetWeakPtr()));
601 void DeviceStatusCollector::ReceiveGeolocationUpdate(
602 const content::Geoposition& position) {
603 geolocation_update_in_progress_ = false;
605 // Ignore update if device location reporting has since been disabled.
606 if (!report_location_)
607 return;
609 if (position.Validate()) {
610 position_ = position;
611 base::DictionaryValue location;
612 location.SetDouble(kLatitude, position.latitude);
613 location.SetDouble(kLongitude, position.longitude);
614 location.SetDouble(kAltitude, position.altitude);
615 location.SetDouble(kAccuracy, position.accuracy);
616 location.SetDouble(kAltitudeAccuracy, position.altitude_accuracy);
617 location.SetDouble(kHeading, position.heading);
618 location.SetDouble(kSpeed, position.speed);
619 location.SetString(kTimestamp,
620 base::Int64ToString(position.timestamp.ToInternalValue()));
621 local_state_->Set(prefs::kDeviceLocation, location);
624 ScheduleGeolocationUpdateRequest();
627 } // namespace policy