#include "content/browser/installedapp/installed_app_provider_impl.h"
#include "base/check_is_test.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/functional/concurrent_callbacks.h"
#include "base/ranges/algorithm.h"
#include "base/task/task_traits.h"
#include "build/build_config.h"
#include "content/browser/browser_thread_impl.h"
#if !BUILDFLAG(IS_ANDROID)
#include "content/browser/installedapp/fetch_related_web_apps_task.h"
#endif
#include "content/common/features.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "third_party/blink/public/mojom/installedapp/related_application.mojom.h"
#if BUILDFLAG(IS_WIN)
#include "content/browser/installedapp/fetch_related_win_apps_task.h"
#include "content/browser/installedapp/native_win_app_fetcher.h"
#include "content/browser/installedapp/native_win_app_fetcher_impl.h"
#endif
namespace content {
namespace {
constexpr int kMaxNumberOfMatchedApps = …;
#if BUILDFLAG(IS_WIN)
std::unique_ptr<NativeWinAppFetcher> CreateNativeWinAppFetcher() {
return std::make_unique<NativeWinAppFetcherImpl>();
}
#endif
}
InstalledAppProviderImpl::InstalledAppProviderImpl(
RenderFrameHost& render_frame_host,
mojo::PendingReceiver<blink::mojom::InstalledAppProvider> pending_receiver)
: … { … }
InstalledAppProviderImpl::~InstalledAppProviderImpl() = default;
void InstalledAppProviderImpl::FilterInstalledApps(
std::vector<blink::mojom::RelatedApplicationPtr> related_apps,
const GURL& manifest_url,
FilterInstalledAppsCallback callback) { … }
void InstalledAppProviderImpl::StartTask(
std::unique_ptr<FetchRelatedAppsTask> task,
std::vector<blink::mojom::RelatedApplicationPtr>& related_apps,
FetchRelatedAppsTaskCallback callback) { … }
void InstalledAppProviderImpl::EraseTask(FetchRelatedAppsTask* task) { … }
void InstalledAppProviderImpl::AggregateTaskResults(
FilterInstalledAppsCallback callback,
std::vector<FetchRelatedAppsTaskResult> task_result_list) { … }
#if BUILDFLAG(IS_WIN)
void InstalledAppProviderImpl::SetNativeWinAppFetcherFactoryForTesting(
base::RepeatingCallback<std::unique_ptr<NativeWinAppFetcher>()> factory) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK_IS_TEST();
native_win_app_fetcher_factory_ = std::move(factory);
}
#endif
void InstalledAppProviderImpl::Create(
RenderFrameHost& host,
mojo::PendingReceiver<blink::mojom::InstalledAppProvider> receiver) { … }
InstalledAppProviderImpl* InstalledAppProviderImpl::CreateForTesting(
RenderFrameHost& render_frame_host,
mojo::PendingReceiver<blink::mojom::InstalledAppProvider> receiver) { … }
}