blob: e2f8f221bee13137258d18521b20f3d06b6dc9ad [file] [log] [blame]
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_SETTINGS_STATS_REPORTING_CONTROLLER_H_
#define CHROME_BROWSER_ASH_SETTINGS_STATS_REPORTING_CONTROLLER_H_
#include "chrome/browser/ash/settings/owner_pending_setting_controller.h"
#include "base/memory/weak_ptr.h"
class PrefRegistrySimple;
class PrefService;
namespace ash {
// Class to control setting of cros.metrics.reportingEnabled device preference
// before ownership is taken.
class StatsReportingController : public OwnerPendingSettingController {
public:
// Manage singleton instance.
static void Initialize(PrefService* local_state);
static bool IsInitialized();
static void Shutdown();
static StatsReportingController* Get();
StatsReportingController(const StatsReportingController&) = delete;
StatsReportingController& operator=(const StatsReportingController&) = delete;
static void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
void SetEnabled(Profile* profile, bool enabled);
bool IsEnabled() const;
private:
explicit StatsReportingController(PrefService* local_state);
~StatsReportingController() override;
base::WeakPtr<StatsReportingController> as_weak_ptr() {
return weak_factory_.GetWeakPtr();
}
base::CallbackListSubscription neutrino_logging_subscription_;
base::WeakPtrFactory<StatsReportingController> weak_factory_{this};
};
} // namespace ash
// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is
// done.
namespace chromeos {
using ::ash::StatsReportingController;
} // namespace chromeos
#endif // CHROME_BROWSER_ASH_SETTINGS_STATS_REPORTING_CONTROLLER_H_