#ifndef CHROME_BROWSER_ASH_APP_MODE_KIOSK_APP_MANAGER_BASE_H_
#define CHROME_BROWSER_ASH_APP_MODE_KIOSK_APP_MANAGER_BASE_H_
#include <string>
#include <vector>
#include "base/callback_list.h"
#include "base/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/path_service.h"
#include "chrome/browser/ash/app_mode/kiosk_app_data_delegate.h"
#include "chrome/browser/ash/app_mode/kiosk_app_types.h"
#include "chrome/common/chrome_paths.h"
#include "chromeos/ash/components/settings/cros_settings.h"
#include "components/account_id/account_id.h"
#include "ui/gfx/image/image_skia.h"
#include "url/gurl.h"
class PrefService;
namespace base {
class FilePath;
}
namespace ash {
class KioskAppDataBase;
class KioskAppManagerObserver;
class KioskCryptohomeRemover;
class KioskAppManagerBase : public KioskAppDataDelegate {
public:
struct App {
explicit App(const KioskAppDataBase&);
App();
App(const App&);
~App();
std::string app_id;
AccountId account_id;
std::string name;
gfx::ImageSkia icon;
GURL url;
std::string required_platform_version;
bool is_loading = false;
bool was_auto_launched_with_zero_delay = false;
};
using AppList = std::vector<App>;
KioskAppManagerBase(PrefService* local_state,
KioskCryptohomeRemover* cryptohome_remover);
KioskAppManagerBase(const KioskAppManagerBase&) = delete;
KioskAppManagerBase& operator=(const KioskAppManagerBase&) = delete;
~KioskAppManagerBase() override;
virtual AppList GetApps() const = 0;
void AddObserver(KioskAppManagerObserver* observer);
void RemoveObserver(KioskAppManagerObserver* observer);
base::FilePath GetKioskAppIconCacheDir() override;
void OnKioskAppDataChanged(const std::string& app_id) override;
void OnKioskAppDataLoadFailure(const std::string& app_id) override;
void OnExternalCacheDamaged(const std::string& app_id) override;
bool GetDisableBailoutShortcut() const;
bool current_app_was_auto_launched_with_zero_delay() const {
return auto_launched_with_zero_delay_;
}
void set_current_app_was_auto_launched_with_zero_delay_for_testing(
bool value) {
auto_launched_with_zero_delay_ = value;
}
protected:
void NotifyKioskAppsChanged() const;
void NotifySessionInitialized() const;
void NotifyAppRemoved(const std::string& app_id) const;
virtual void UpdateAppsFromPolicy() = 0;
void ClearRemovedApps(
const std::vector<const KioskAppDataBase*>& old_apps) const;
const raw_ref<PrefService> local_state_;
const raw_ref<KioskCryptohomeRemover> cryptohome_remover_;
bool auto_launched_with_zero_delay_ = false;
base::CallbackListSubscription local_accounts_subscription_;
base::CallbackListSubscription local_account_auto_login_id_subscription_;
base::ObserverList<KioskAppManagerObserver, true> observers_;
private:
base::WeakPtrFactory<KioskAppManagerBase> weak_ptr_factory_{this};
};
}
#endif