chromium/chrome/browser/web_applications/isolated_web_apps/test/isolated_web_app_builder.cc

// Copyright 2024 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/isolated_web_apps/test/isolated_web_app_builder.h"

#include <map>
#include <memory>
#include <string>
#include <string_view>

#include "base/base_paths.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_file.h"
#include "base/functional/overloaded.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_future.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/web_applications/isolated_web_apps/install_isolated_web_app_command.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_install_source.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h"
#include "chrome/browser/web_applications/test/fake_web_app_provider.h"
#include "chrome/browser/web_applications/test/fake_web_contents_manager.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_id.h"
#include "components/web_package/test_support/signed_web_bundles/web_bundle_signer.h"
#include "components/web_package/web_bundle_builder.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/embedded_test_server/request_handler_util.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/common/permissions_policy/origin_with_possible_wildcards.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy_declaration.h"
#include "third_party/blink/public/common/permissions_policy/policy_helper_public.h"
#include "third_party/blink/public/mojom/manifest/manifest.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkStream.h"
#include "third_party/skia/include/encode/SkPngEncoder.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace web_app {
namespace {

constexpr char kInstallPagePath[] =;
constexpr char kManifestPath[] =;

InstallResult;

FakeWebAppProvider* GetFakeWebAppProvider(Profile* profile) {}

void FakeInstallPageState(Profile* profile,
                          const IsolatedWebAppUrlInfo& url_info,
                          blink::mojom::ManifestPtr blink_manifest) {}

base::expected<IsolatedWebAppUrlInfo, std::string> Install(
    Profile* profile,
    const web_package::SignedWebBundleId& web_bundle_id,
    const IsolatedWebAppInstallSource& install_source) {}

web_package::SignedWebBundleId CreateSignedWebBundleIdFromKeyPair(
    const web_package::test::KeyPair& key_pair) {}

}  // namespace

BundledIsolatedWebApp::BundledIsolatedWebApp(
    const web_package::SignedWebBundleId& web_bundle_id,
    const std::vector<uint8_t> serialized_bundle,
    const base::FilePath path,
    ManifestBuilder manifest_builder)
    :{}

BundledIsolatedWebApp::~BundledIsolatedWebApp() = default;

void BundledIsolatedWebApp::TrustSigningKey() {}

std::string BundledIsolatedWebApp::GetBundleData() const {}

IsolatedWebAppUrlInfo BundledIsolatedWebApp::InstallChecked(Profile* profile) {}

base::expected<IsolatedWebAppUrlInfo, std::string>
BundledIsolatedWebApp::Install(Profile* profile) {}

void BundledIsolatedWebApp::FakeInstallPageState(Profile* profile) {}

// static
std::unique_ptr<ScopedBundledIsolatedWebApp>
ScopedBundledIsolatedWebApp::Create(
    const web_package::SignedWebBundleId& web_bundle_id,
    const std::vector<uint8_t> serialized_bundle,
    ManifestBuilder manifest_builder) {}

ScopedBundledIsolatedWebApp::ScopedBundledIsolatedWebApp(
    const web_package::SignedWebBundleId& web_bundle_id,
    const std::vector<uint8_t> serialized_bundle,
    base::ScopedTempFile bundle_file,
    ManifestBuilder manifest_builder)
    :{}

ScopedBundledIsolatedWebApp::~ScopedBundledIsolatedWebApp() {}

ScopedProxyIsolatedWebApp::ScopedProxyIsolatedWebApp(
    std::unique_ptr<net::EmbeddedTestServer> proxy_server,
    std::optional<ManifestBuilder> manifest_builder)
    :{}

ScopedProxyIsolatedWebApp::~ScopedProxyIsolatedWebApp() = default;

IsolatedWebAppUrlInfo ScopedProxyIsolatedWebApp::InstallChecked(
    Profile* profile) {}

base::expected<IsolatedWebAppUrlInfo, std::string>
ScopedProxyIsolatedWebApp::Install(Profile* profile) {}

base::expected<IsolatedWebAppUrlInfo, std::string>
ScopedProxyIsolatedWebApp::Install(
    Profile* profile,
    const web_package::SignedWebBundleId& web_bundle_id) {}

ManifestBuilder::PermissionsPolicy::PermissionsPolicy(
    bool wildcard,
    bool self,
    std::vector<url::Origin> origins)
    :{}

ManifestBuilder::PermissionsPolicy::PermissionsPolicy(
    const ManifestBuilder::PermissionsPolicy&) = default;
ManifestBuilder::PermissionsPolicy::~PermissionsPolicy() = default;

ManifestBuilder::ManifestBuilder()
    :{}

ManifestBuilder::ManifestBuilder(const ManifestBuilder&) = default;
ManifestBuilder::~ManifestBuilder() = default;

ManifestBuilder& ManifestBuilder::SetName(std::string_view name) {}

ManifestBuilder& ManifestBuilder::SetVersion(std::string_view version) {}

ManifestBuilder& ManifestBuilder::SetStartUrl(std::string_view start_url) {}

ManifestBuilder& ManifestBuilder::AddIcon(std::string_view resource_path,
                                          gfx::Size size,
                                          std::string_view content_type) {}

ManifestBuilder& ManifestBuilder::AddPermissionsPolicyWildcard(
    blink::mojom::PermissionsPolicyFeature feature) {}

ManifestBuilder& ManifestBuilder::AddPermissionsPolicy(
    blink::mojom::PermissionsPolicyFeature feature,
    bool self,
    std::vector<url::Origin> origins) {}

ManifestBuilder& ManifestBuilder::AddProtocolHandler(std::string_view protocol,
                                                     std::string_view url) {}

ManifestBuilder& ManifestBuilder::AddFileHandler(
    std::string_view action,
    const FileHandlerAccept& accept) {}

const std::string& ManifestBuilder::start_url() const {}

const std::vector<ManifestBuilder::IconMetadata>& ManifestBuilder::icons()
    const {}

base::Version ManifestBuilder::version() const {}

std::string ManifestBuilder::ToJson() const {}

blink::mojom::ManifestPtr ManifestBuilder::ToBlinkManifest(
    const url::Origin& app_origin) const {}

IsolatedWebAppBuilder::Resource::Resource(
    net::HttpStatusCode status,
    const IsolatedWebAppBuilder::Headers& headers,
    const IsolatedWebAppBuilder::ResourceBody& body)
    :{}

IsolatedWebAppBuilder::Resource::Resource(
    const IsolatedWebAppBuilder::Resource&) = default;
IsolatedWebAppBuilder::Resource::~Resource() = default;

scoped_refptr<net::HttpResponseHeaders>
IsolatedWebAppBuilder::Resource::headers(std::string_view resource_path) const {}

std::string IsolatedWebAppBuilder::Resource::body() const {}

IsolatedWebAppBuilder::IsolatedWebAppBuilder(
    const ManifestBuilder& manifest_builder)
    :{}

IsolatedWebAppBuilder::IsolatedWebAppBuilder(const IsolatedWebAppBuilder&) =
    default;
IsolatedWebAppBuilder::~IsolatedWebAppBuilder() = default;

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddResource(
    std::string_view resource_path,
    std::string_view content,
    std::string_view content_type) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddResource(
    std::string_view resource_path,
    std::string_view content,
    const Headers& headers,
    net::HttpStatusCode status) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddHtml(
    std::string_view resource_path,
    std::string_view content) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddJs(
    std::string_view resource_path,
    std::string_view content) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddIconAsPng(
    std::string_view resource_path,
    const SkBitmap& image) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddImageAsPng(
    std::string_view resource_path,
    const SkBitmap& image) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddFileFromDisk(
    std::string_view resource_path,
    const base::FilePath& file_path,
    const Headers& headers) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddFolderFromDisk(
    std::string_view resource_path,
    const base::FilePath& folder_path) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::AddFolderFromDisk(
    std::string_view resource_path,
    const std::string& chrome_test_data_relative_path) {}

IsolatedWebAppBuilder& IsolatedWebAppBuilder::RemoveResource(
    std::string_view resource_path) {}

std::unique_ptr<ScopedProxyIsolatedWebApp>
IsolatedWebAppBuilder::BuildAndStartProxyServer() {}

std::unique_ptr<ScopedBundledIsolatedWebApp>
IsolatedWebAppBuilder::BuildBundle() {}

std::unique_ptr<ScopedBundledIsolatedWebApp> IsolatedWebAppBuilder::BuildBundle(
    const web_package::test::KeyPair& key_pair) {}

std::unique_ptr<ScopedBundledIsolatedWebApp> IsolatedWebAppBuilder::BuildBundle(
    const web_package::SignedWebBundleId& web_bundle_id,
    const web_package::test::KeyPairs& key_pairs) {}

std::unique_ptr<BundledIsolatedWebApp> IsolatedWebAppBuilder::BuildBundle(
    const base::FilePath& bundle_path) {}

std::unique_ptr<BundledIsolatedWebApp> IsolatedWebAppBuilder::BuildBundle(
    const base::FilePath& bundle_path,
    const web_package::test::KeyPair& key_pair) {}

std::unique_ptr<BundledIsolatedWebApp> IsolatedWebAppBuilder::BuildBundle(
    const base::FilePath& bundle_path,
    const web_package::SignedWebBundleId& web_bundle_id,
    const web_package::test::KeyPairs& key_pairs) {}

std::vector<uint8_t> IsolatedWebAppBuilder ::BuildInMemoryBundle(
    const web_package::SignedWebBundleId& web_bundle_id,
    const web_package::test::KeyPairs& key_pairs) {}

void IsolatedWebAppBuilder::Validate() {}

// static
std::unique_ptr<net::test_server::HttpResponse>
IsolatedWebAppBuilder::HandleRequest(
    const ManifestBuilder& manifest_builder,
    const std::map<std::string, Resource>& resources,
    const net::test_server::HttpRequest& request) {}

}  // namespace web_app