blob: 4f81393533f77922aae93c8ea3cfc270aa55fa58 [file] [log] [blame]
// Copyright 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.
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/web_applications/components/pending_app_manager.h"
#include "components/prefs/pref_change_registrar.h"
#include "url/gurl.h"
class PrefService;
class Profile;
namespace user_prefs {
class PrefRegistrySyncable;
namespace web_app {
// Tracks the policy that affects Web Apps and also tracks which Web Apps are
// currently installed based on this policy. Based on these, it decides which
// apps to install, uninstall, and update, via a PendingAppManager.
class WebAppPolicyManager {
// Constructs a WebAppPolicyManager instance that uses
// |pending_app_manager| to manage apps. |pending_app_manager| should outlive
// this class.
WebAppPolicyManager(Profile* profile, PendingAppManager* pending_app_manager);
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
static bool ShouldEnableForProfile(Profile* profile);
void InitChangeRegistrarAndRefreshPolicyInstalledApps();
void RefreshPolicyInstalledApps();
Profile* profile_;
PrefService* pref_service_;
// Used to install, uninstall, and update apps. Should outlive this class.
PendingAppManager* pending_app_manager_;
PrefChangeRegistrar pref_change_registrar_;
base::WeakPtrFactory<WebAppPolicyManager> weak_ptr_factory_{this};
} // namespace web_app