chromium/chrome/browser/web_applications/web_app_sync_bridge.cc

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

#include "chrome/browser/web_applications/web_app_sync_bridge.h"

#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <ostream>
#include <type_traits>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/flat_set.h"
#include "base/containers/flat_tree.h"
#include "base/dcheck_is_on.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/not_fatal_until.h"
#include "base/strings/to_string.h"
#include "base/types/expected.h"
#include "base/types/pass_key.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
#include "chrome/browser/web_applications/user_display_mode.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_chromeos_data.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/browser/web_applications/web_app_database.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_proto_utils.h"
#include "chrome/browser/web_applications/web_app_registry_update.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "chrome/common/channel_info.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/deletion_origin.h"
#include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/model/client_tag_based_data_type_processor.h"
#include "components/sync/model/data_type_local_change_processor.h"
#include "components/sync/model/data_type_store.h"
#include "components/sync/model/metadata_batch.h"
#include "components/sync/model/metadata_change_list.h"
#include "components/sync/model/model_error.h"
#include "components/sync/model/mutable_data_batch.h"
#include "components/sync/model/string_ordinal.h"
#include "components/sync/protocol/entity_data.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/web_app_specifics.pb.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "components/webapps/browser/uninstall_result_code.h"
#include "components/webapps/common/web_app_id.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace web_app {
namespace {
// Returns the manifest id from the sync entity. Does not validate whether the
// manifest_id is valid.
base::expected<webapps::ManifestId, StorageKeyParseResult>
ParseManifestIdFromSyncEntity(const sync_pb::WebAppSpecifics& specifics) {}

base::expected<webapps::ManifestId, ManifestIdParseResult>
ValidateManifestIdFromParsableSyncEntity(
    const sync_pb::WebAppSpecifics& specifics,
    const WebApp* existing_web_app) {}

}  // namespace

BASE_FEATURE();

std::unique_ptr<syncer::EntityData> CreateSyncEntityData(const WebApp& app) {}

void ApplySyncDataToApp(const sync_pb::WebAppSpecifics& sync_proto,
                        WebApp* app) {}

WebAppSyncBridge::WebAppSyncBridge(WebAppRegistrarMutable* registrar)
    :{}

WebAppSyncBridge::WebAppSyncBridge(
    WebAppRegistrarMutable* registrar,
    std::unique_ptr<syncer::DataTypeLocalChangeProcessor> change_processor)
    :{}

WebAppSyncBridge::~WebAppSyncBridge() = default;

void WebAppSyncBridge::SetSubsystems(
    AbstractWebAppDatabaseFactory* database_factory,
    WebAppCommandManager* command_manager,
    WebAppCommandScheduler* command_scheduler,
    WebAppInstallManager* install_manager) {}

[[nodiscard]] ScopedRegistryUpdate WebAppSyncBridge::BeginUpdate(
    CommitCallback callback) {}

void WebAppSyncBridge::Init(base::OnceClosure initialized_callback) {}

void WebAppSyncBridge::SetAppUserDisplayModeForTesting(
    const webapps::AppId& app_id,
    mojom::UserDisplayMode user_display_mode) {}

void WebAppSyncBridge::SetAppWindowControlsOverlayEnabled(
    const webapps::AppId& app_id,
    bool enabled) {}

void WebAppSyncBridge::SetAppIsDisabled(AppLock& lock,
                                        const webapps::AppId& app_id,
                                        bool is_disabled) {}

void WebAppSyncBridge::UpdateAppsDisableMode() {}

void WebAppSyncBridge::SetAppLastBadgingTime(const webapps::AppId& app_id,
                                             const base::Time& time) {}

void WebAppSyncBridge::SetAppLastLaunchTime(const webapps::AppId& app_id,
                                            const base::Time& time) {}

void WebAppSyncBridge::SetAppFirstInstallTime(const webapps::AppId& app_id,
                                              const base::Time& time) {}

void WebAppSyncBridge::SetAppManifestUpdateTime(const webapps::AppId& app_id,
                                                const base::Time& time) {}

void WebAppSyncBridge::SetUserPageOrdinal(const webapps::AppId& app_id,
                                          syncer::StringOrdinal page_ordinal) {}

void WebAppSyncBridge::SetUserLaunchOrdinal(
    const webapps::AppId& app_id,
    syncer::StringOrdinal launch_ordinal) {}

#if BUILDFLAG(IS_MAC)
void WebAppSyncBridge::SetAlwaysShowToolbarInFullscreen(
    const webapps::AppId& app_id,
    bool show) {
  if (!registrar_->IsInstalled(app_id)) {
    return;
  }
  {
    ScopedRegistryUpdate update = BeginUpdate();
    update->UpdateApp(app_id)->SetAlwaysShowToolbarInFullscreen(show);
  }
  registrar_->NotifyAlwaysShowToolbarInFullscreenChanged(app_id, show);
}
#endif

void WebAppSyncBridge::SetAppFileHandlerApprovalState(
    const webapps::AppId& app_id,
    ApiApprovalState state) {}

void WebAppSyncBridge::CommitUpdate(
    CommitCallback callback,
    std::unique_ptr<WebAppRegistryUpdate> update) {}

void WebAppSyncBridge::CheckRegistryUpdateData(
    const RegistryUpdateData& update_data) const {}

void WebAppSyncBridge::UpdateRegistrar(
    std::unique_ptr<RegistryUpdateData> update_data) {}

void WebAppSyncBridge::UpdateSync(
    const RegistryUpdateData& update_data,
    syncer::MetadataChangeList* metadata_change_list) {}

void WebAppSyncBridge::OnDatabaseOpened(
    base::OnceClosure initialized_callback,
    Registry registry,
    std::unique_ptr<syncer::MetadataBatch> metadata_batch) {}

void WebAppSyncBridge::EnsureAppsHaveUserDisplayModeForCurrentPlatform() {}

void WebAppSyncBridge::EnsurePartiallyInstalledAppsHaveCorrectStatus() {}

void WebAppSyncBridge::OnDataWritten(CommitCallback callback, bool success) {}

void WebAppSyncBridge::OnWebAppUninstallComplete(
    const webapps::AppId& app,
    webapps::UninstallResultCode code) {}

void WebAppSyncBridge::ReportErrorToChangeProcessor(
    const syncer::ModelError& error) {}

void WebAppSyncBridge::MergeLocalAppsToSync(
    const syncer::EntityChangeList& entity_data,
    syncer::MetadataChangeList* metadata_change_list) {}

ManifestIdParseResult WebAppSyncBridge::PrepareLocalUpdateFromSyncChange(
    const syncer::EntityChange& change,
    RegistryUpdateData* update_local_data,
    std::vector<webapps::AppId>& apps_display_mode_changed) {}

void WebAppSyncBridge::ApplyIncrementalSyncChangesToRegistrar(
    std::unique_ptr<RegistryUpdateData> update_local_data,
    const std::vector<webapps::AppId>& apps_display_mode_changed) {}

std::unique_ptr<syncer::MetadataChangeList>
WebAppSyncBridge::CreateMetadataChangeList() {}

std::optional<syncer::ModelError> WebAppSyncBridge::MergeFullSyncData(
    std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
    syncer::EntityChangeList entity_data) {}

std::optional<syncer::ModelError> WebAppSyncBridge::ApplyIncrementalSyncChanges(
    std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
    syncer::EntityChangeList entity_changes) {}

std::unique_ptr<syncer::DataBatch> WebAppSyncBridge::GetDataForCommit(
    StorageKeyList storage_keys) {}

std::unique_ptr<syncer::DataBatch> WebAppSyncBridge::GetAllDataForDebugging() {}

std::string WebAppSyncBridge::GetClientTag(
    const syncer::EntityData& entity_data) {}

std::string WebAppSyncBridge::GetStorageKey(
    const syncer::EntityData& entity_data) {}

bool WebAppSyncBridge::IsEntityDataValid(
    const syncer::EntityData& entity_data) const {}

void WebAppSyncBridge::SetRetryIncompleteUninstallsCallbackForTesting(
    RetryIncompleteUninstallsCallback callback) {}

void WebAppSyncBridge::SetInstallWebAppsAfterSyncCallbackForTesting(
    InstallWebAppsAfterSyncCallback callback) {}

void WebAppSyncBridge::SetUninstallFromSyncCallbackForTesting(
    UninstallFromSyncCallback callback) {}

void WebAppSyncBridge::SetAppNotLocallyInstalledForTesting(
    const webapps::AppId& app_id) {}

void WebAppSyncBridge::MaybeUninstallAppsPendingUninstall() {}

void WebAppSyncBridge::MaybeInstallAppsFromSyncAndPendingInstallation() {}

void WebAppSyncBridge::InstallWebAppsAfterSync(
    std::vector<WebApp*> web_apps,
    RepeatingInstallCallback callback) {}

}  // namespace web_app