chromium/chrome/browser/web_applications/isolated_web_apps/signed_web_bundle_reader.cc

// Copyright 2022 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/signed_web_bundle_reader.h"

#include <cstddef>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/containers/to_vector.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/types/cxx23_to_underlying.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "chrome/browser/web_applications/isolated_web_apps/error/unusable_swbn_file_error.h"
#include "components/web_package/mojom/web_bundle_parser.mojom.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_integrity_block.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_signature_verifier.h"
#include "mojo/public/cpp/system/data_pipe_producer.h"
#include "mojo/public/cpp/system/file_data_source.h"
#include "net/base/url_util.h"
#include "services/network/public/cpp/resource_request.h"
#include "url/gurl.h"

namespace web_app {
namespace {
// This is blocking operation.
base::expected<uint64_t, base::File::Error> ReadLengthOfFile(base::File file) {}

void OpenFile(const base::FilePath& file_path,
              base::OnceCallback<void(base::File)> open_callback) {}

void CloseFile(base::File file, base::OnceClosure close_callback) {}

void OpenFileDataSource(
    base::File file,
    uint64_t start,
    uint64_t end,
    base::OnceCallback<void(
        std::unique_ptr<mojo::DataPipeProducer::DataSource>)> open_callback) {}

}  // namespace

SignedWebBundleReader::SignedWebBundleReader(
    const base::FilePath& web_bundle_path,
    const std::optional<GURL>& base_url,
    std::unique_ptr<web_package::SignedWebBundleSignatureVerifier>
        signature_verifier)
    :{}

SignedWebBundleReader::~SignedWebBundleReader() {}

// static
std::unique_ptr<SignedWebBundleReader> SignedWebBundleReader::Create(
    const base::FilePath& web_bundle_path,
    const std::optional<GURL>& base_url,
    std::unique_ptr<web_package::SignedWebBundleSignatureVerifier>
        signature_verifier) {}

void SignedWebBundleReader::Close(base::OnceClosure callback) {}

void SignedWebBundleReader::OnFileClosed(base::OnceClosure callback) {}

void SignedWebBundleReader::OnParserClosed(base::OnceClosure callback) {}

void SignedWebBundleReader::ReadIntegrityBlock(
    IntegrityBlockReadResultCallback integrity_block_result_callback) {}

void SignedWebBundleReader::OnFileOpened(
    IntegrityBlockReadResultCallback integrity_block_result_callback,
    base::File file) {}

void SignedWebBundleReader::OnIntegrityBlockParsed(
    IntegrityBlockReadResultCallback integrity_block_result_callback,
    web_package::mojom::BundleIntegrityBlockPtr raw_integrity_block,
    web_package::mojom::BundleIntegrityBlockParseErrorPtr error) {}

void SignedWebBundleReader::ProceedWithAction(
    SignatureVerificationAction action,
    ReadErrorCallback callback) {}

void SignedWebBundleReader::OnFileLengthRead(
    ReadErrorCallback callback,
    base::expected<uint64_t, base::File::Error> file_length) {}

void SignedWebBundleReader::OnSignaturesVerified(
    const base::TimeTicks& verification_start_time,
    uint64_t file_length,
    ReadErrorCallback callback,
    base::expected<void, web_package::SignedWebBundleSignatureVerifier::Error>
        verification_result) {}

void SignedWebBundleReader::ReadMetadata(ReadErrorCallback callback) {}

void SignedWebBundleReader::OnMetadataParsed(
    ReadErrorCallback callback,
    web_package::mojom::BundleMetadataPtr metadata,
    web_package::mojom::BundleMetadataParseErrorPtr error) {}

void SignedWebBundleReader::FulfillWithError(ReadErrorCallback callback,
                                             UnusableSwbnFileError error) {}

const web_package::SignedWebBundleIntegrityBlock&
SignedWebBundleReader::GetIntegrityBlock() const {}

const std::optional<GURL>& SignedWebBundleReader::GetPrimaryURL() const {}

std::vector<GURL> SignedWebBundleReader::GetEntries() const {}

void SignedWebBundleReader::ReadResponse(
    const network::ResourceRequest& resource_request,
    ResponseCallback callback) {}

void SignedWebBundleReader::ReadResponseInternal(
    web_package::mojom::BundleResponseLocationPtr location,
    ResponseCallback callback) {}

void SignedWebBundleReader::OnResponseParsed(
    ResponseCallback callback,
    web_package::mojom::BundleResponsePtr response,
    web_package::mojom::BundleResponseParseErrorPtr error) {}

void SignedWebBundleReader::ReadResponseBody(
    web_package::mojom::BundleResponsePtr response,
    mojo::ScopedDataPipeProducerHandle producer_handle,
    ResponseBodyCallback callback) {}

void SignedWebBundleReader::StartReadingFromDataSource(
    mojo::DataPipeProducer* data_pipe_producer,
    ResponseBodyCallback callback,
    std::unique_ptr<mojo::DataPipeProducer::DataSource> data_source) {}

void SignedWebBundleReader::OnResponseBodyRead(mojo::DataPipeProducer* producer,
                                               ResponseBodyCallback callback,
                                               MojoResult result) {}

void SignedWebBundleReader::ReplyClosedIfNecessary() {}

base::WeakPtr<SignedWebBundleReader> SignedWebBundleReader::AsWeakPtr() {}

// static
SignedWebBundleReader::ReadResponseError
SignedWebBundleReader::ReadResponseError::FromBundleParseError(
    web_package::mojom::BundleResponseParseErrorPtr error) {}

// static
SignedWebBundleReader::ReadResponseError
SignedWebBundleReader::ReadResponseError::ForParserInternalError(
    const std::string& message) {}

// static
SignedWebBundleReader::ReadResponseError
SignedWebBundleReader::ReadResponseError::ForResponseNotFound(
    const std::string& message) {}

// static
SignedWebBundleReader::SignatureVerificationAction
SignedWebBundleReader::SignatureVerificationAction::Abort(
    UnusableSwbnFileError error) {}

// static
SignedWebBundleReader::SignatureVerificationAction SignedWebBundleReader::
    SignatureVerificationAction::ContinueAndVerifySignatures() {}

// static
SignedWebBundleReader::SignatureVerificationAction SignedWebBundleReader::
    SignatureVerificationAction::ContinueAndSkipSignatureVerification() {}

SignedWebBundleReader::SignatureVerificationAction::SignatureVerificationAction(
    Type type,
    std::optional<UnusableSwbnFileError> error)
    :{}

SignedWebBundleReader::SignatureVerificationAction::SignatureVerificationAction(
    const SignatureVerificationAction&) = default;

SignedWebBundleReader::SignatureVerificationAction::
    ~SignatureVerificationAction() = default;

UnsecureReader::UnsecureReader(const base::FilePath& web_bundle_path)
    :{}

UnsecureReader::~UnsecureReader() {}

void UnsecureReader::StartReading() {}

void UnsecureReader::OnFileOpened(base::File file) {}

// static
void UnsecureSignedWebBundleIdReader::GetWebBundleId(
    const base::FilePath& web_bundle_path,
    WebBundleIdCallback result_callback) {}

UnsecureSignedWebBundleIdReader::UnsecureSignedWebBundleIdReader(
    const base::FilePath& web_bundle_path)
    :{}

void UnsecureSignedWebBundleIdReader::DoReading() {}

void UnsecureSignedWebBundleIdReader::ReturnError(UnusableSwbnFileError error) {}

base::WeakPtr<UnsecureReader> UnsecureSignedWebBundleIdReader::GetWeakPtr() {}

void UnsecureSignedWebBundleIdReader::OnIntegrityBlockParsed(
    web_package::mojom::BundleIntegrityBlockPtr raw_integrity_block,
    web_package::mojom::BundleIntegrityBlockParseErrorPtr error) {}

void UnsecureSignedWebBundleIdReader::SetResultCallback(
    WebBundleIdCallback web_bundle_id_result_callback) {}

UnsecureSignedWebBundleIdReader::~UnsecureSignedWebBundleIdReader() = default;

}  // namespace web_app