-// Copyright 2018 The Chromium Authors. All rights reserved.
+// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/policy/policy_recommendation_restorer.h"
-#include "ash/session/session_controller.h"
+#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
+#include "base/check.h"
+#include "base/containers/contains.h"
+#include "base/functional/bind.h"
+#include "base/notreached.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "ui/base/user_activity/user_activity_detector.h"
namespace {
// The amount of idle time after which recommended values are restored.
-constexpr base::TimeDelta kRestoreDelayInMinutes =
- base::TimeDelta::FromMinutes(1);
+constexpr base::TimeDelta kRestoreDelayInMinutes = base::Minutes(1);
} // namespace
PrefService* prefs =
Shell::Get()->session_controller()->GetSigninScreenPrefService();
DCHECK(prefs);
- DCHECK(!base::ContainsKey(pref_names_, pref_name));
+ DCHECK(!base::Contains(pref_names_, pref_name));
if (!pref_change_registrar_) {
pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
restore_timer_.Reset();
}
+void PolicyRecommendationRestorer::DisableForTesting() {
+ disabled_for_testing_ = true;
+}
+
void PolicyRecommendationRestorer::Restore(bool allow_delay,
const std::string& pref_name) {
const PrefService::Preference* pref =
if (allow_delay)
StartTimer();
- else
+ else if (!disabled_for_testing_)
pref_change_registrar_->prefs()->ClearPref(pref->name());
}
// case of a recommended value changing, a single timer is a close
// approximation of the behavior that would be obtained by resetting the timer
// for the affected pref only.
- restore_timer_.Start(
- FROM_HERE, kRestoreDelayInMinutes,
- base::BindRepeating(&PolicyRecommendationRestorer::RestoreAll,
- base::Unretained(this)));
+ restore_timer_.Start(FROM_HERE, kRestoreDelayInMinutes,
+ base::BindOnce(&PolicyRecommendationRestorer::RestoreAll,
+ base::Unretained(this)));
}
void PolicyRecommendationRestorer::StopTimer() {