chromium/components/content_relationship_verification/digital_asset_links_handler.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/content_relationship_verification/digital_asset_links_handler.h"

#include <vector>

#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "content/public/browser/web_contents.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
#include "url/origin.h"

namespace {

// In some cases we get a network change while fetching the digital asset
// links file. See https://crbug.com/987329.
const int kNumNetworkRetries =;

// Location on a website where the asset links file can be found, see
// https://developers.google.com/digital-asset-links/v1/getting-started.
const char kAssetLinksAbsolutePath[] =;

void RecordNumFingerprints(size_t num_fingerprints) {}

GURL GetUrlForAssetLinks(const url::Origin& origin) {}

// An example, well formed asset links file for reference:
//  [{
//    "relation": ["delegate_permission/common.handle_all_urls"],
//    "target": {
//      "namespace": "android_app",
//      "package_name": "com.peter.trustedpetersactivity",
//      "sha256_cert_fingerprints": [
//        "FA:2A:03: ... :9D"
//      ]
//    }
//  }, {
//    "relation": ["delegate_permission/common.handle_all_urls"],
//    "target": {
//      "namespace": "android_app",
//      "package_name": "com.example.firstapp",
//      "sha256_cert_fingerprints": [
//        "64:2F:D4: ... :C1"
//      ]
//    }
//  }]

bool StatementHasMatchingRelationship(const base::Value::Dict& statement,
                                      const std::string& target_relation) {}

bool StatementHasMatchingTargetValue(
    const base::Value::Dict& statement,
    const std::string& target_key,
    const std::set<std::string>& target_value) {}

bool StatementHasMatchingFingerprint(
    const base::Value::Dict& statement,
    const std::vector<std::string>& target_fingerprints) {}

// Shows a warning message in the DevTools console.
void AddMessageToConsole(content::WebContents* web_contents,
                         const std::string& message) {}

}  // namespace

namespace content_relationship_verification {

const char kDigitalAssetLinksCheckResponseKeyLinked[] =;

DigitalAssetLinksHandler::DigitalAssetLinksHandler(
    scoped_refptr<network::SharedURLLoaderFactory> factory,
    content::WebContents* web_contents)
    :{}

DigitalAssetLinksHandler::~DigitalAssetLinksHandler() = default;

void DigitalAssetLinksHandler::OnURLLoadComplete(
    std::string relationship,
    std::optional<std::vector<std::string>> fingerprints,
    std::map<std::string, std::set<std::string>> target_values,
    std::unique_ptr<std::string> response_body) {}

void DigitalAssetLinksHandler::OnJSONParseResult(
    std::string relationship,
    std::optional<std::vector<std::string>> fingerprints,
    std::map<std::string, std::set<std::string>> target_values,
    data_decoder::DataDecoder::ValueOrError result) {}

bool DigitalAssetLinksHandler::CheckDigitalAssetLinkRelationshipForAndroidApp(
    const url::Origin& web_domain,
    const std::string& relationship,
    std::vector<std::string> fingerprints,
    const std::string& package,
    RelationshipCheckResultCallback callback) {}

bool DigitalAssetLinksHandler::CheckDigitalAssetLinkRelationshipForWebApk(
    const url::Origin& web_domain,
    const std::string& manifest_url,
    RelationshipCheckResultCallback callback) {}

bool DigitalAssetLinksHandler::CheckDigitalAssetLinkRelationship(
    const url::Origin& web_domain,
    const std::string& relationship,
    std::optional<std::vector<std::string>> fingerprints,
    const std::map<std::string, std::set<std::string>>& target_values,
    RelationshipCheckResultCallback callback) {}

}  // namespace content_relationship_verification