#ifndef ASH_SYSTEM_MODEL_UPDATE_MODEL_H_
#define ASH_SYSTEM_MODEL_UPDATE_MODEL_H_
#include "ash/public/cpp/update_types.h"
#include "base/observer_list.h"
namespace ash {
class UpdateObserver {
public:
virtual ~UpdateObserver() {}
virtual void OnUpdateAvailable() = 0;
};
class UpdateModel {
public:
UpdateModel();
UpdateModel(const UpdateModel&) = delete;
UpdateModel& operator=(const UpdateModel&) = delete;
~UpdateModel();
void AddObserver(UpdateObserver* observer);
void RemoveObserver(UpdateObserver* observer);
void SetUpdateAvailable(UpdateSeverity severity,
bool factory_reset_required,
bool rollback);
void SetRelaunchNotificationState(
const RelaunchNotificationState& relaunch_notification_state);
void SetUpdateOverCellularAvailable(bool available);
void SetUpdateDeferred(DeferredUpdateState state);
void SetShowEolNotice(bool show);
void SetShowExtendedUpdatesNotice(bool show);
UpdateSeverity GetSeverity() const;
void ResetUpdateAvailable();
bool update_required() const { return update_required_; }
bool factory_reset_required() const { return factory_reset_required_; }
bool rollback() const { return rollback_; }
const RelaunchNotificationState& relaunch_notification_state() const {
return relaunch_notification_state_;
}
bool update_over_cellular_available() const {
return update_over_cellular_available_;
}
DeferredUpdateState update_deferred() const { return update_deferred_; }
bool show_eol_notice() const { return show_eol_notice_; }
bool show_extended_updates_notice() const {
return show_extended_updates_notice_;
}
private:
void NotifyUpdateAvailable();
bool update_required_ = false;
UpdateSeverity severity_ = UpdateSeverity::kNone;
bool factory_reset_required_ = false;
bool rollback_ = false;
RelaunchNotificationState relaunch_notification_state_;
bool update_over_cellular_available_ = false;
DeferredUpdateState update_deferred_ = DeferredUpdateState::kNone;
bool show_eol_notice_ = false;
bool show_extended_updates_notice_ = false;
base::ObserverList<UpdateObserver>::Unchecked observers_;
};
}
#endif