blob: a146c980b1d418c2361a45a7f8c9abe6cf50e637 [file] [log] [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/app_mode/kiosk_troubleshooting_controller.h"
#include "base/functional/callback_forward.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
namespace chromeos {
KioskTroubleshootingController::KioskTroubleshootingController(
PrefService* pref_service,
base::OnceClosure shutdown_app_session_callback)
: pref_service_(pref_service),
shutdown_app_session_callback_(std::move(shutdown_app_session_callback)) {
pref_change_registrar_.Init(pref_service);
pref_change_registrar_.Add(
prefs::kKioskTroubleshootingToolsEnabled,
base::BindRepeating(&KioskTroubleshootingController::PolicyChanged,
base::Unretained(this)));
}
KioskTroubleshootingController::~KioskTroubleshootingController() = default;
bool KioskTroubleshootingController::AreKioskTroubleshootingToolsEnabled()
const {
return pref_service_->GetBoolean(prefs::kKioskTroubleshootingToolsEnabled);
}
void KioskTroubleshootingController::PolicyChanged() {
// If the policy value is changed from enabled to disabled, exit the kiosk
// session.
if (!AreKioskTroubleshootingToolsEnabled()) {
std::move(shutdown_app_session_callback_).Run();
}
// Policy is enabled now, no action needed.
}
} // namespace chromeos