chromium/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_manager.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_WEB_APPLICATIONS_ISOLATED_WEB_APPS_ISOLATED_WEB_APP_UPDATE_MANAGER_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_ISOLATED_WEB_APPS_ISOLATED_WEB_APP_UPDATE_MANAGER_H_

#include <memory>
#include <optional>

#include "base/callback_list.h"
#include "base/cancelable_callback.h"
#include "base/containers/circular_deque.h"
#include "base/containers/flat_map.h"
#include "base/files/file_error_or.h"
#include "base/files/file_path.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "base/types/pass_key.h"
#include "base/values.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_apply_update_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_storage_location.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_apply_task.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_apply_waiter.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_discovery_task.h"
#include "chrome/browser/web_applications/isolated_web_apps/key_distribution/iwa_key_distribution_info_provider.h"
#include "chrome/browser/web_applications/web_app_install_manager_observer.h"
#include "components/webapps/common/web_app_id.h"

class GURL;
class Profile;

namespace web_package {
class SignedWebBundleId;
}

namespace web_app {

class IsolatedWebAppUrlInfo;
class IsolatedWebAppURLLoaderFactory;
class WebAppProvider;

namespace {
constexpr base::TimeDelta kDefaultUpdateDiscoveryFrequency =;
}

// This enum lists the error types that can occur during the update of an
// isolated web apps.
//
// These values are persisted to logs and the values match the entries of
// `enum IsolatedWebAppUpdateError` in
// `tools/metrics/histograms/metadata/webapps/enums.xml`.
// Entries should not be renumbered and numeric values should never be reused.
enum class IsolatedWebAppUpdateError {};

// The `IsolatedWebAppUpdateManager` is responsible for discovery, download, and
// installation of Isolated Web App updates. Currently, it is only updating
// policy-installed IWAs on ChromeOS.
//
// TODO(crbug.com/40274186): Implement updates for unmanaged IWAs once we have
// designed that process.
//
// TODO(crbug.com/40274187): Consider only executing update discovery tasks when
// the user is not on a metered/paid internet connection.
class IsolatedWebAppUpdateManager
    : public WebAppInstallManagerObserver,
      public IwaKeyDistributionInfoProvider::Observer {};

}  // namespace web_app

#endif  // CHROME_BROWSER_WEB_APPLICATIONS_ISOLATED_WEB_APPS_ISOLATED_WEB_APP_UPDATE_MANAGER_H_