#include "chrome/browser/content_index/content_index_provider_impl.h"
#include <memory>
#include <string_view>
#include "base/barrier_closure.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/engagement/site_engagement_service_factory.h"
#include "chrome/browser/metrics/ukm_background_recorder_service.h"
#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_key.h"
#include "components/offline_items_collection/core/offline_content_aggregator.h"
#include "components/offline_items_collection/core/offline_item.h"
#include "components/offline_items_collection/core/update_delta.h"
#include "components/site_engagement/content/site_engagement_score.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_index_context.h"
#include "content/public/browser/storage_partition.h"
#include "ui/gfx/image/image_skia.h"
#include "url/origin.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/android/service_tab_launcher.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/common/referrer.h"
#else
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#endif
ContentId;
LaunchLocation;
OfflineItem;
OfflineItemFilter;
namespace {
constexpr char kEntryKeySeparator[] = …;
struct EntryKeyComponents { … };
std::string EntryKey(int64_t service_worker_registration_id,
const url::Origin& origin,
const std::string& description_id) { … }
std::string EntryKey(const content::ContentIndexEntry& entry) { … }
EntryKeyComponents GetEntryKeyComponents(const std::string& key) { … }
OfflineItemFilter CategoryToFilter(blink::mojom::ContentCategory category) { … }
}
const char ContentIndexProviderImpl::kProviderNamespace[] = …;
ContentIndexProviderImpl::ContentIndexProviderImpl(Profile* profile)
: … { … }
ContentIndexProviderImpl::~ContentIndexProviderImpl() { … }
void ContentIndexProviderImpl::Shutdown() { … }
std::vector<gfx::Size> ContentIndexProviderImpl::GetIconSizes(
blink::mojom::ContentCategory category) { … }
void ContentIndexProviderImpl::OnContentAdded(
content::ContentIndexEntry entry) { … }
void ContentIndexProviderImpl::OnContentDeleted(
int64_t service_worker_registration_id,
const url::Origin& origin,
const std::string& description_id) { … }
void ContentIndexProviderImpl::OpenItem(
const offline_items_collection::OpenParams& open_params,
const ContentId& id) { … }
void ContentIndexProviderImpl::DidGetEntryToOpen(
std::optional<content::ContentIndexEntry> entry) { … }
void ContentIndexProviderImpl::DidOpenTab(content::ContentIndexEntry entry,
content::WebContents* web_contents) { … }
void ContentIndexProviderImpl::RemoveItem(const ContentId& id) { … }
void ContentIndexProviderImpl::CancelDownload(const ContentId& id) { … }
void ContentIndexProviderImpl::PauseDownload(const ContentId& id) { … }
void ContentIndexProviderImpl::ResumeDownload(const ContentId& id) { … }
void ContentIndexProviderImpl::GetItemById(const ContentId& id,
SingleItemCallback callback) { … }
void ContentIndexProviderImpl::DidGetItem(
SingleItemCallback callback,
std::optional<content::ContentIndexEntry> entry) { … }
void ContentIndexProviderImpl::GetAllItems(MultipleItemCallback callback) { … }
void ContentIndexProviderImpl::DidGetAllEntriesAcrossStorageParitions(
std::unique_ptr<OfflineItemList> item_list,
MultipleItemCallback callback) { … }
void ContentIndexProviderImpl::DidGetAllEntries(
base::OnceClosure done_closure,
OfflineItemList* item_list,
blink::mojom::ContentIndexError error,
std::vector<content::ContentIndexEntry> entries) { … }
void ContentIndexProviderImpl::GetVisualsForItem(const ContentId& id,
GetVisualsOptions options,
VisualsCallback callback) { … }
OfflineItem ContentIndexProviderImpl::EntryToOfflineItem(
const content::ContentIndexEntry& entry) { … }
void ContentIndexProviderImpl::DidGetIcons(const ContentId& id,
VisualsCallback callback,
std::vector<SkBitmap> icons) { … }
void ContentIndexProviderImpl::GetShareInfoForItem(const ContentId& id,
ShareCallback callback) { … }
void ContentIndexProviderImpl::RenameItem(const ContentId& id,
const std::string& name,
RenameCallback callback) { … }