#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 {
const int kNumNetworkRetries = …;
const char kAssetLinksAbsolutePath[] = …;
void RecordNumFingerprints(size_t num_fingerprints) { … }
GURL GetUrlForAssetLinks(const url::Origin& origin) { … }
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) { … }
void AddMessageToConsole(content::WebContents* web_contents,
const std::string& message) { … }
}
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) { … }
}