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

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

Issue 2396103002: Create policy ReportArcStatus (Closed)
Patch Set: Rebase Created 4 years, 2 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 chromeos::kReportDeviceUsers, callback); 465 chromeos::kReportDeviceUsers, callback);
466 hardware_status_subscription_ = cros_settings_->AddSettingsObserver( 466 hardware_status_subscription_ = cros_settings_->AddSettingsObserver(
467 chromeos::kReportDeviceHardwareStatus, callback); 467 chromeos::kReportDeviceHardwareStatus, callback);
468 session_status_subscription_ = cros_settings_->AddSettingsObserver( 468 session_status_subscription_ = cros_settings_->AddSettingsObserver(
469 chromeos::kReportDeviceSessionStatus, callback); 469 chromeos::kReportDeviceSessionStatus, callback);
470 os_update_status_subscription_ = cros_settings_->AddSettingsObserver( 470 os_update_status_subscription_ = cros_settings_->AddSettingsObserver(
471 chromeos::kReportOsUpdateStatus, callback); 471 chromeos::kReportOsUpdateStatus, callback);
472 running_kiosk_app_subscription_ = cros_settings_->AddSettingsObserver( 472 running_kiosk_app_subscription_ = cros_settings_->AddSettingsObserver(
473 chromeos::kReportRunningKioskApp, callback); 473 chromeos::kReportRunningKioskApp, callback);
474 474
475 report_arc_status_pref_.Init(prefs::kReportArcStatus, local_state_, callback);
476
475 // Fetch the current values of the policies. 477 // Fetch the current values of the policies.
476 UpdateReportingSettings(); 478 UpdateReportingSettings();
477 479
478 // Get the the OS and firmware version info. 480 // Get the the OS and firmware version info.
479 base::PostTaskAndReplyWithResult( 481 base::PostTaskAndReplyWithResult(
480 content::BrowserThread::GetBlockingPool(), 482 content::BrowserThread::GetBlockingPool(),
481 FROM_HERE, 483 FROM_HERE,
482 base::Bind(&chromeos::version_loader::GetVersion, 484 base::Bind(&chromeos::version_loader::GetVersion,
483 chromeos::version_loader::VERSION_FULL), 485 chromeos::version_loader::VERSION_FULL),
484 base::Bind(&DeviceStatusCollector::OnOSVersion, 486 base::Bind(&DeviceStatusCollector::OnOSVersion,
485 weak_factory_.GetWeakPtr())); 487 weak_factory_.GetWeakPtr()));
486 base::PostTaskAndReplyWithResult( 488 base::PostTaskAndReplyWithResult(
487 content::BrowserThread::GetBlockingPool(), 489 content::BrowserThread::GetBlockingPool(),
488 FROM_HERE, 490 FROM_HERE,
489 base::Bind(&chromeos::version_loader::GetFirmware), 491 base::Bind(&chromeos::version_loader::GetFirmware),
490 base::Bind(&DeviceStatusCollector::OnOSFirmware, 492 base::Bind(&DeviceStatusCollector::OnOSFirmware,
491 weak_factory_.GetWeakPtr())); 493 weak_factory_.GetWeakPtr()));
492 } 494 }
493 495
494 DeviceStatusCollector::~DeviceStatusCollector() { 496 DeviceStatusCollector::~DeviceStatusCollector() {
495 } 497 }
496 498
497 // static 499 // static
498 void DeviceStatusCollector::RegisterPrefs(PrefRegistrySimple* registry) { 500 void DeviceStatusCollector::RegisterPrefs(PrefRegistrySimple* registry) {
499 registry->RegisterDictionaryPref(prefs::kDeviceActivityTimes, 501 registry->RegisterDictionaryPref(prefs::kDeviceActivityTimes,
500 new base::DictionaryValue); 502 new base::DictionaryValue);
503 registry->RegisterBooleanPref(prefs::kReportArcStatus, true);
501 } 504 }
502 505
503 void DeviceStatusCollector::CheckIdleState() { 506 void DeviceStatusCollector::CheckIdleState() {
504 CalculateIdleState(kIdleStateThresholdSeconds, 507 CalculateIdleState(kIdleStateThresholdSeconds,
505 base::Bind(&DeviceStatusCollector::IdleStateCallback, 508 base::Bind(&DeviceStatusCollector::IdleStateCallback,
506 base::Unretained(this))); 509 base::Unretained(this)));
507 } 510 }
508 511
509 void DeviceStatusCollector::UpdateReportingSettings() { 512 void DeviceStatusCollector::UpdateReportingSettings() {
510 // Attempt to fetch the current value of the reporting settings. 513 // Attempt to fetch the current value of the reporting settings.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 if (!cros_settings_->GetBoolean( 547 if (!cros_settings_->GetBoolean(
545 chromeos::kReportDeviceHardwareStatus, &report_hardware_status_)) { 548 chromeos::kReportDeviceHardwareStatus, &report_hardware_status_)) {
546 report_hardware_status_ = true; 549 report_hardware_status_ = true;
547 } 550 }
548 551
549 if (!cros_settings_->GetBoolean(chromeos::kReportDeviceSessionStatus, 552 if (!cros_settings_->GetBoolean(chromeos::kReportDeviceSessionStatus,
550 &report_kiosk_session_status_)) { 553 &report_kiosk_session_status_)) {
551 report_kiosk_session_status_ = true; 554 report_kiosk_session_status_ = true;
552 } 555 }
553 556
554 // TODO(phweiss): Create policy to control this, and turn it on by default. 557 report_android_status_ = local_state_->GetBoolean(prefs::kReportArcStatus);
555 report_android_status_ = false;
556 558
557 if (!report_hardware_status_) { 559 if (!report_hardware_status_) {
558 ClearCachedResourceUsage(); 560 ClearCachedResourceUsage();
559 } else if (!already_reporting_hardware_status) { 561 } else if (!already_reporting_hardware_status) {
560 // Turning on hardware status reporting - fetch an initial sample 562 // Turning on hardware status reporting - fetch an initial sample
561 // immediately instead of waiting for the sampling timer to fire. 563 // immediately instead of waiting for the sampling timer to fire.
562 SampleResourceUsage(); 564 SampleResourceUsage();
563 } 565 }
564 566
565 // Os update status and running kiosk app reporting are disabled by default. 567 // Os update status and running kiosk app reporting are disabled by default.
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 1187
1186 void DeviceStatusCollector::OnOSVersion(const std::string& version) { 1188 void DeviceStatusCollector::OnOSVersion(const std::string& version) {
1187 os_version_ = version; 1189 os_version_ = version;
1188 } 1190 }
1189 1191
1190 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { 1192 void DeviceStatusCollector::OnOSFirmware(const std::string& version) {
1191 firmware_version_ = version; 1193 firmware_version_ = version;
1192 } 1194 }
1193 1195
1194 } // namespace policy 1196 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698