chromium/chrome/browser/extensions/chrome_app_sorting.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/extensions/chrome_app_sorting.h"

#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include "base/feature_list.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/extension_constants.h"
#include "components/app_constants/constants.h"
#include "components/webapps/common/web_app_id.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/manifest_handlers/app_display_info.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/extensions/default_app_order.h"
#endif

namespace extensions {

namespace {

template <typename Multimap, typename Key, typename Value>
bool DoesMultimapContainKeyAndValue(const Multimap& map,
                                    const Key& key,
                                    const Value& value) {}

// The number of apps per page. This isn't a hard limit, but new apps installed
// from the webstore will overflow onto a new page if this limit is reached.
const size_t kNaturalAppPageSize =;

// A preference determining the order of which the apps appear on the NTP.
const char kPrefAppLaunchIndexDeprecated[] =;
const char kPrefAppLaunchOrdinal[] =;

// A preference determining the page on which an app appears in the NTP.
const char kPrefPageIndexDeprecated[] =;
const char kPrefPageOrdinal[] =;

}  // namespace

////////////////////////////////////////////////////////////////////////////////
// ChromeAppSorting::AppOrdinals

ChromeAppSorting::AppOrdinals::AppOrdinals() = default;

ChromeAppSorting::AppOrdinals::AppOrdinals(const AppOrdinals& other) = default;

ChromeAppSorting::AppOrdinals::~AppOrdinals() = default;

////////////////////////////////////////////////////////////////////////////////
// ChromeAppSorting

ChromeAppSorting::ChromeAppSorting(content::BrowserContext* browser_context)
    :{}

ChromeAppSorting::~ChromeAppSorting() {}

void ChromeAppSorting::CreateOrdinalsIfNecessary(size_t minimum_size) {}

void ChromeAppSorting::MigrateAppIndex(const ExtensionIdList& extension_ids) {}

void ChromeAppSorting::InitializePageOrdinalMapFromWebApps() {}

void ChromeAppSorting::FixNTPOrdinalCollisions() {}

void ChromeAppSorting::EnsureValidOrdinals(
    const ExtensionId& extension_id,
    const syncer::StringOrdinal& suggested_page) {}

bool ChromeAppSorting::GetDefaultOrdinals(
    const ExtensionId& extension_id,
    syncer::StringOrdinal* page_ordinal,
    syncer::StringOrdinal* app_launch_ordinal) {}

void ChromeAppSorting::OnExtensionMoved(
    const ExtensionId& moved_extension_id,
    const ExtensionId& predecessor_extension_id,
    const ExtensionId& successor_extension_id) {}

syncer::StringOrdinal ChromeAppSorting::GetAppLaunchOrdinal(
    const ExtensionId& extension_id) const {}

void ChromeAppSorting::SetAppLaunchOrdinal(
    const ExtensionId& extension_id,
    const syncer::StringOrdinal& new_app_launch_ordinal) {}

syncer::StringOrdinal ChromeAppSorting::CreateFirstAppLaunchOrdinal(
    const syncer::StringOrdinal& page_ordinal) const {}

syncer::StringOrdinal ChromeAppSorting::CreateNextAppLaunchOrdinal(
    const syncer::StringOrdinal& page_ordinal) const {}

syncer::StringOrdinal ChromeAppSorting::CreateFirstAppPageOrdinal() const {}

syncer::StringOrdinal ChromeAppSorting::GetNaturalAppPageOrdinal() const {}

syncer::StringOrdinal ChromeAppSorting::GetPageOrdinal(
    const ExtensionId& extension_id) const {}

void ChromeAppSorting::SetPageOrdinal(
    const ExtensionId& extension_id,
    const syncer::StringOrdinal& new_page_ordinal) {}

void ChromeAppSorting::ClearOrdinals(const ExtensionId& extension_id) {}

int ChromeAppSorting::PageStringOrdinalAsInteger(
    const syncer::StringOrdinal& page_ordinal) const {}

syncer::StringOrdinal ChromeAppSorting::PageIntegerAsStringOrdinal(
    size_t page_index) {}

void ChromeAppSorting::SetExtensionVisible(const ExtensionId& extension_id,
                                           bool visible) {}

void ChromeAppSorting::OnWebAppInstalled(const webapps::AppId& app_id) {}

void ChromeAppSorting::OnWebAppInstallManagerDestroyed() {}

void ChromeAppSorting::OnWebAppsWillBeUpdatedFromSync(
    const std::vector<const web_app::WebApp*>& updated_apps_state) {}

void ChromeAppSorting::OnAppRegistrarDestroyed() {}

syncer::StringOrdinal ChromeAppSorting::GetMinOrMaxAppLaunchOrdinalsOnPage(
    const syncer::StringOrdinal& target_page_ordinal,
    AppLaunchOrdinalReturn return_type) const {}

void ChromeAppSorting::InitializePageOrdinalMap(
    const ExtensionIdList& extension_ids) {}

void ChromeAppSorting::AddOrdinalMapping(
    const ExtensionId& extension_id,
    const syncer::StringOrdinal& page_ordinal,
    const syncer::StringOrdinal& app_launch_ordinal) {}

void ChromeAppSorting::RemoveOrdinalMapping(
    const ExtensionId& extension_id,
    const syncer::StringOrdinal& page_ordinal,
    const syncer::StringOrdinal& app_launch_ordinal) {}

void ChromeAppSorting::SyncIfNeeded(const ExtensionId& extension_id) {}

void ChromeAppSorting::CreateDefaultOrdinals() {}

syncer::StringOrdinal ChromeAppSorting::ResolveCollision(
    const syncer::StringOrdinal& page_ordinal,
    const syncer::StringOrdinal& app_launch_ordinal) const {}

size_t ChromeAppSorting::CountItemsVisibleOnNtp(
    const AppLaunchOrdinalMap& m) const {}

void ChromeAppSorting::OnExtensionLoaded(
    content::BrowserContext* browser_context,
    const Extension* extension) {}

}  // namespace extensions