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

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector.cc

Issue 2192683003: Revert of Reland: Geolocation: move from content/browser to device/ (patchset #2 id:20001 of https:… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2810
Patch Set: Created 4 years, 4 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 #include "chrome/browser/chromeos/policy/device_status_collector.h" 5 #include "chrome/browser/chromeos/policy/device_status_collector.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 session_status_subscription_ = cros_settings_->AddSettingsObserver( 313 session_status_subscription_ = cros_settings_->AddSettingsObserver(
314 chromeos::kReportDeviceSessionStatus, callback); 314 chromeos::kReportDeviceSessionStatus, callback);
315 os_update_status_subscription_ = cros_settings_->AddSettingsObserver( 315 os_update_status_subscription_ = cros_settings_->AddSettingsObserver(
316 chromeos::kReportOsUpdateStatus, callback); 316 chromeos::kReportOsUpdateStatus, callback);
317 running_kiosk_app_subscription_ = cros_settings_->AddSettingsObserver( 317 running_kiosk_app_subscription_ = cros_settings_->AddSettingsObserver(
318 chromeos::kReportRunningKioskApp, callback); 318 chromeos::kReportRunningKioskApp, callback);
319 319
320 // The last known location is persisted in local state. This makes location 320 // The last known location is persisted in local state. This makes location
321 // information available immediately upon startup and avoids the need to 321 // information available immediately upon startup and avoids the need to
322 // reacquire the location on every user session change or browser crash. 322 // reacquire the location on every user session change or browser crash.
323 device::Geoposition position; 323 content::Geoposition position;
324 std::string timestamp_str; 324 std::string timestamp_str;
325 int64_t timestamp; 325 int64_t timestamp;
326 const base::DictionaryValue* location = 326 const base::DictionaryValue* location =
327 local_state_->GetDictionary(prefs::kDeviceLocation); 327 local_state_->GetDictionary(prefs::kDeviceLocation);
328 if (location->GetDouble(kLatitude, &position.latitude) && 328 if (location->GetDouble(kLatitude, &position.latitude) &&
329 location->GetDouble(kLongitude, &position.longitude) && 329 location->GetDouble(kLongitude, &position.longitude) &&
330 location->GetDouble(kAltitude, &position.altitude) && 330 location->GetDouble(kAltitude, &position.altitude) &&
331 location->GetDouble(kAccuracy, &position.accuracy) && 331 location->GetDouble(kAccuracy, &position.accuracy) &&
332 location->GetDouble(kAltitudeAccuracy, &position.altitude_accuracy) && 332 location->GetDouble(kAltitudeAccuracy, &position.altitude_accuracy) &&
333 location->GetDouble(kHeading, &position.heading) && 333 location->GetDouble(kHeading, &position.heading) &&
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // not launched yet. 423 // not launched yet.
424 if (!cros_settings_->GetBoolean( 424 if (!cros_settings_->GetBoolean(
425 chromeos::kReportDeviceLocation, &report_location_)) { 425 chromeos::kReportDeviceLocation, &report_location_)) {
426 report_location_ = false; 426 report_location_ = false;
427 } 427 }
428 428
429 if (report_location_) { 429 if (report_location_) {
430 ScheduleGeolocationUpdateRequest(); 430 ScheduleGeolocationUpdateRequest();
431 } else { 431 } else {
432 geolocation_update_timer_.Stop(); 432 geolocation_update_timer_.Stop();
433 position_ = device::Geoposition(); 433 position_ = content::Geoposition();
434 local_state_->ClearPref(prefs::kDeviceLocation); 434 local_state_->ClearPref(prefs::kDeviceLocation);
435 } 435 }
436 436
437 if (!report_hardware_status_) { 437 if (!report_hardware_status_) {
438 ClearCachedHardwareStatus(); 438 ClearCachedHardwareStatus();
439 } else if (!already_reporting_hardware_status) { 439 } else if (!already_reporting_hardware_status) {
440 // Turning on hardware status reporting - fetch an initial sample 440 // Turning on hardware status reporting - fetch an initial sample
441 // immediately instead of waiting for the sampling timer to fire. 441 // immediately instead of waiting for the sampling timer to fire.
442 SampleHardwareStatus(); 442 SampleHardwareStatus();
443 } 443 }
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 FROM_HERE, 1115 FROM_HERE,
1116 interval - elapsed, 1116 interval - elapsed,
1117 this, 1117 this,
1118 &DeviceStatusCollector::ScheduleGeolocationUpdateRequest); 1118 &DeviceStatusCollector::ScheduleGeolocationUpdateRequest);
1119 return; 1119 return;
1120 } 1120 }
1121 } 1121 }
1122 1122
1123 geolocation_update_in_progress_ = true; 1123 geolocation_update_in_progress_ = true;
1124 if (location_update_requester_.is_null()) { 1124 if (location_update_requester_.is_null()) {
1125 geolocation_subscription_ = 1125 geolocation_subscription_ = content::GeolocationProvider::GetInstance()->
1126 device::GeolocationProvider::GetInstance()->AddLocationUpdateCallback( 1126 AddLocationUpdateCallback(
1127 base::Bind(&DeviceStatusCollector::ReceiveGeolocationUpdate, 1127 base::Bind(&DeviceStatusCollector::ReceiveGeolocationUpdate,
1128 weak_factory_.GetWeakPtr()), 1128 weak_factory_.GetWeakPtr()),
1129 true); 1129 true);
1130 } else { 1130 } else {
1131 location_update_requester_.Run(base::Bind( 1131 location_update_requester_.Run(base::Bind(
1132 &DeviceStatusCollector::ReceiveGeolocationUpdate, 1132 &DeviceStatusCollector::ReceiveGeolocationUpdate,
1133 weak_factory_.GetWeakPtr())); 1133 weak_factory_.GetWeakPtr()));
1134 } 1134 }
1135 } 1135 }
1136 1136
1137 void DeviceStatusCollector::ReceiveGeolocationUpdate( 1137 void DeviceStatusCollector::ReceiveGeolocationUpdate(
1138 const device::Geoposition& position) { 1138 const content::Geoposition& position) {
1139 geolocation_update_in_progress_ = false; 1139 geolocation_update_in_progress_ = false;
1140 1140
1141 // Ignore update if device location reporting has since been disabled. 1141 // Ignore update if device location reporting has since been disabled.
1142 if (!report_location_) 1142 if (!report_location_)
1143 return; 1143 return;
1144 1144
1145 if (position.Validate()) { 1145 if (position.Validate()) {
1146 position_ = position; 1146 position_ = position;
1147 base::DictionaryValue location; 1147 base::DictionaryValue location;
1148 location.SetDouble(kLatitude, position.latitude); 1148 location.SetDouble(kLatitude, position.latitude);
(...skipping 11 matching lines...) Expand all
1160 ScheduleGeolocationUpdateRequest(); 1160 ScheduleGeolocationUpdateRequest();
1161 } 1161 }
1162 1162
1163 void DeviceStatusCollector::ReceiveVolumeInfo( 1163 void DeviceStatusCollector::ReceiveVolumeInfo(
1164 const std::vector<em::VolumeInfo>& info) { 1164 const std::vector<em::VolumeInfo>& info) {
1165 if (report_hardware_status_) 1165 if (report_hardware_status_)
1166 volume_info_ = info; 1166 volume_info_ = info;
1167 } 1167 }
1168 1168
1169 } // namespace policy 1169 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698