chromium/chrome/browser/ui/web_applications/sub_apps_service_impl.cc

// Copyright 2021 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/ui/web_applications/sub_apps_service_impl.h"

#include <string>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/functional/bind.h"
#include "base/functional/concurrent_callbacks.h"
#include "base/i18n/message_formatter.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/notifications/notification_display_service_factory.h"
#include "chrome/browser/notifications/notification_handler.h"
#include "chrome/browser/permissions/permission_decision_auto_blocker_factory.h"
#include "chrome/browser/policy/policy_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/web_applications/sub_apps_install_dialog_controller.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_install_finalizer.h"
#include "chrome/browser/web_applications/web_app_install_params.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/browser/web_applications/web_app_tab_helper.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/permissions/permission_decision_auto_blocker.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 "content/public/browser/isolated_context_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/public/cpp/notification.h"
#include "url/gurl.h"
#include "url/origin.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/notifier_catalogs.h"
#endif

SubAppsService;
SubAppsServiceAddParametersPtr;
SubAppsServiceAddResult;
SubAppsServiceAddResultPtr;
SubAppsServiceListResult;
SubAppsServiceListResultEntry;
SubAppsServiceListResultEntryPtr;
SubAppsServiceRemoveResult;
SubAppsServiceRemoveResultPtr;
SubAppsServiceResultCode;

namespace web_app {

// TODO(crbug.com/40924576): Replace registrar_unsafe with Locks
// TODO (crbug.com/1467862): Move from //c/b/ui/web_applications to
// //c/b/web_applications

namespace {

constexpr char kSubAppsUninstallNotifierId[] =;

// Resolve string `path` with `origin`, and if the resulting GURL isn't same
// origin with `origin` then return an error (for which the caller needs to
// raise a `ReportBadMessageAndDeleteThis`).
base::expected<GURL, std::string> ConvertPathToUrl(const std::string& path,
                                                   const url::Origin& origin) {}

std::string ConvertUrlToPath(const webapps::ManifestId& manifest_id) {}

base::expected<std::vector<SubAppInstallParams>, std::string>
AddOptionsFromMojo(
    const url::Origin& origin,
    const std::vector<SubAppsServiceAddParametersPtr>& sub_apps_to_add_mojo) {}

Profile* GetProfile(content::RenderFrameHost& render_frame_host) {}

WebAppProvider* GetWebAppProvider(content::RenderFrameHost& render_frame_host) {}

const webapps::AppId* GetAppId(content::RenderFrameHost& render_frame_host) {}

blink::mojom::SubAppsServiceResultCode InstallResultCodeToMojo(
    webapps::InstallResultCode install_result_code) {}

void ReturnAllAddsAsFailed(
    const std::vector<SubAppsServiceAddParametersPtr>& sub_apps,
    SubAppsServiceImpl::AddCallback result_callback) {}

bool IsInstalledNonChildApp(content::RenderFrameHost& render_frame_host) {}

// Verify that the calling app has the SubApps permissions policy set and that
// it is an installed IWA that is not a sub app itself. This check is called
// from `CreateIfAllowed` and from each of the APIs entry points to avoid a
// potential race between the parent app calling an API while being uninstalled.
bool CanAccessSubAppsApi(content::RenderFrameHost& render_frame_host) {}

bool ShouldSkipUserConfirmation(content::RenderFrameHost& frame) {}

}  // namespace

SubAppsServiceImpl::SubAppsServiceImpl(
    content::RenderFrameHost& render_frame_host,
    mojo::PendingReceiver<SubAppsService> receiver)
    :{}

SubAppsServiceImpl::~SubAppsServiceImpl() = default;

SubAppsServiceImpl::AddCallInfo::AddCallInfo() = default;
SubAppsServiceImpl::AddCallInfo::~AddCallInfo() = default;

// static
void SubAppsServiceImpl::CreateIfAllowed(
    content::RenderFrameHost* render_frame_host,
    mojo::PendingReceiver<SubAppsService> receiver) {}

void SubAppsServiceImpl::Add(
    std::vector<SubAppsServiceAddParametersPtr> sub_apps_to_add,
    AddCallback result_callback) {}

void SubAppsServiceImpl::CollectInstallData(
    int add_call_id,
    std::vector<SubAppInstallParams> requested_installs,
    webapps::ManifestId parent_manifest_id) {}

void SubAppsServiceImpl::ProcessInstallData(
    int add_call_id,
    std::vector<std::pair<webapps::ManifestId,
                          std::unique_ptr<WebAppInstallInfo>>> install_data) {}

void SubAppsServiceImpl::FinishAddCallOrShowInstallDialog(int add_call_id) {}

void SubAppsServiceImpl::ProcessDialogResponse(int add_call_id,
                                               bool dialog_accepted) {}

void SubAppsServiceImpl::ScheduleSubAppInstalls(int add_call_id) {}

void SubAppsServiceImpl::FinishAddCall(
    int add_call_id,
    std::vector<SubAppInstallResult> install_results) {}

void SubAppsServiceImpl::List(ListCallback result_callback) {}

void SubAppsServiceImpl::Remove(
    const std::vector<std::string>& manifest_id_paths,
    RemoveCallback result_callback) {}

void SubAppsServiceImpl::RemoveSubApp(
    const std::string& manifest_id_path,
    base::OnceCallback<void(SubAppsServiceRemoveResultPtr)> callback,
    const webapps::AppId* calling_app_id) {}

void SubAppsServiceImpl::NotifyUninstall(
    RemoveCallback result_callback,
    std::vector<SubAppsServiceRemoveResultPtr> remove_results) {}

}  // namespace web_app