chromium/chrome/browser/web_applications/manifest_update_utils.h

// Copyright 2022 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_MANIFEST_UPDATE_UTILS_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_MANIFEST_UPDATE_UTILS_H_

#include <iosfwd>
#include <string>

#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/browser/web_applications/web_app_icon_generator.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "chrome/browser/web_applications/web_app_install_utils.h"
#include "components/webapps/common/web_app_id.h"

namespace web_app {

class WebApp;
class WebAppRegistrar;

constexpr SquareSizePx kIdentitySizes[] =;

// This enum is recorded by UMA, the numeric values must not change.
enum class ManifestUpdateResult {};

std::ostream& operator<<(std::ostream& os, ManifestUpdateResult result);

// Not actually used in production logic. This is just for async code
// organisation and debugging output.
enum class ManifestUpdateCheckStage {};

std::ostream& operator<<(std::ostream& os, ManifestUpdateCheckStage stage);

enum class ManifestUpdateCheckResult {};

std::ostream& operator<<(std::ostream& os, ManifestUpdateCheckResult result);

ManifestUpdateResult FinalResultFromManifestUpdateCheckResult(
    ManifestUpdateCheckResult check_result);

void RecordIconDownloadMetrics(IconsDownloadedResult result,
                               DownloadedIconsHttpResults icons_http_results);

bool CanWebAppSilentlyUpdateIdentity(const WebApp& web_app);
bool CanShowIdentityUpdateConfirmationDialog(const WebAppRegistrar& registrar,
                                             const WebApp& web_app);

struct AppIconIdentityChange {};

enum class IdentityUpdateDecision {};

// Represents what's different between two sets of manifest data split up by
// whether the parts are important to app identity. Also captures whether
// identity changes are allowed/pending/reverted.
struct ManifestDataChanges {};

// `existing_app_icon_bitmaps` and `existing_shortcuts_menu_icon_bitmaps` are
// optional and will not be checked if not provided.
ManifestDataChanges GetManifestDataChanges(
    const WebApp& existing_web_app,
    const IconBitmaps* existing_app_icon_bitmaps,
    const ShortcutsMenuIconBitmaps* existing_shortcuts_menu_icon_bitmaps,
    const WebAppInstallInfo& new_install_info);

std::optional<AppIconIdentityChange> CompareIdentityIconBitmaps(
    const IconBitmaps& existing_app_icon_bitmaps,
    const IconBitmaps& new_app_icon_bitmaps);

void RecordIdentityConfirmationMetrics(
    const ManifestDataChanges& manifest_data_changes,
    const WebApp& web_app);

}  // namespace web_app

#endif  // CHROME_BROWSER_WEB_APPLICATIONS_MANIFEST_UPDATE_UTILS_H_