chromium/chrome/browser/safe_browsing/cloud_content_scanning/cloud_binary_upload_service.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/safe_browsing/cloud_content_scanning/cloud_binary_upload_service.h"

#include "base/base64.h"
#include "base/command_line.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/enterprise/connectors/common.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/enterprise/util/affiliation.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/multipart_uploader.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/resumable_uploader.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chromeos/components/mgs/managed_guest_session_utils.h"
#include "components/policy/core/common/management/management_service.h"
#include "components/safe_browsing/content/browser/web_ui/safe_browsing_ui.h"
#include "components/safe_browsing/core/common/features.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/http/http_status_code.h"

namespace safe_browsing {
namespace {

// The command line flag to control the max amount of concurrent active
// requests.
// TODO(crbug.com/40174400): Tweak this number to an "optimal" value.
constexpr char kMaxParallelActiveRequests[] =;
constexpr int kDefaultMaxParallelActiveRequests =;

constexpr base::TimeDelta kAuthTimeout =;
constexpr base::TimeDelta kScanningTimeout =;

const char kSbEnterpriseUploadUrl[] =;

const char kSbConsumerUploadUrl[] =;

net::NetworkTrafficAnnotationTag GetTrafficAnnotationTag(bool is_app) {}

bool CanUseAccessToken(const BinaryUploadService::Request& request,
                       Profile* profile) {}

bool IgnoreErrorResultForResumableUpload(BinaryUploadService::Request* request,
                                         BinaryUploadService::Result result) {}

}  // namespace

// static
size_t CloudBinaryUploadService::GetParallelActiveRequestsMax() {}

CloudBinaryUploadService::CloudBinaryUploadService(Profile* profile)
    :{}

CloudBinaryUploadService::CloudBinaryUploadService(
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    Profile* profile,
    std::unique_ptr<BinaryFCMService> binary_fcm_service)
    :{}

CloudBinaryUploadService::~CloudBinaryUploadService() = default;

void CloudBinaryUploadService::MaybeUploadForDeepScanning(
    std::unique_ptr<CloudBinaryUploadService::Request> request) {}

void CloudBinaryUploadService::MaybeAcknowledge(std::unique_ptr<Ack> ack) {}

void CloudBinaryUploadService::MaybeCancelRequests(
    std::unique_ptr<CancelRequests> cancel) {}

base::WeakPtr<BinaryUploadService> CloudBinaryUploadService::AsWeakPtr() {}

void CloudBinaryUploadService::MaybeUploadForDeepScanningCallback(
    std::unique_ptr<CloudBinaryUploadService::Request> request,
    bool authorized) {}

void CloudBinaryUploadService::QueueForDeepScanning(
    std::unique_ptr<CloudBinaryUploadService::Request> request) {}

void CloudBinaryUploadService::UploadForDeepScanning(
    std::unique_ptr<Request> request) {}

void CloudBinaryUploadService::MaybeConnectToFCM(Request::Id request_id) {}

void CloudBinaryUploadService::OnGetInstanceID(Request::Id request_id,
                                               const std::string& instance_id) {}

void CloudBinaryUploadService::MaybeGetAccessToken(Request::Id request_id) {}

void CloudBinaryUploadService::OnGetAccessToken(
    Request::Id request_id,
    const std::string& access_token) {}

void CloudBinaryUploadService::OnGetRequestData(Request::Id request_id,
                                                Result result,
                                                Request::Data data) {}

void CloudBinaryUploadService::OnUploadComplete(
    Request::Id request_id,
    bool success,
    int http_status,
    const std::string& response_data) {}

void CloudBinaryUploadService::OnGetResponse(
    Request::Id request_id,
    enterprise_connectors::ContentAnalysisResponse response) {}

void CloudBinaryUploadService::MaybeFinishRequest(Request::Id request_id) {}

void CloudBinaryUploadService::FinishIfActive(
    Request::Id request_id,
    Result result,
    enterprise_connectors::ContentAnalysisResponse response) {}

void CloudBinaryUploadService::FinishRequest(
    Request* request,
    Result result,
    enterprise_connectors::ContentAnalysisResponse response) {}

void CloudBinaryUploadService::FinishRequestCleanup(
    Request* request,
    const std::string& instance_id) {}

void CloudBinaryUploadService::InstanceIDUnregisteredCallback(
    const std::string& dm_token,
    enterprise_connectors::AnalysisConnector connector,
    bool) {}

void CloudBinaryUploadService::RecordRequestMetrics(Request::Id request_id,
                                                    Result result) {}

void CloudBinaryUploadService::RecordRequestMetrics(
    Request::Id request_id,
    Result result,
    const enterprise_connectors::ContentAnalysisResponse& response) {}

bool CloudBinaryUploadService::ResponseIsComplete(Request::Id request_id) {}

BinaryUploadService::Request* CloudBinaryUploadService::GetRequest(
    Request::Id request_id) {}

class ValidateDataUploadRequest : public CloudBinaryUploadService::Request {};

inline void ValidateDataUploadRequest::GetRequestData(DataCallback callback) {}

bool ValidateDataUploadRequest::IsAuthRequest() const {}

void CloudBinaryUploadService::IsAuthorized(
    const GURL& url,
    bool per_profile_request,
    AuthorizationCallback callback,
    const std::string& dm_token,
    enterprise_connectors::AnalysisConnector connector) {}

void CloudBinaryUploadService::ValidateDataUploadRequestConnectorCallback(
    const std::string& dm_token,
    enterprise_connectors::AnalysisConnector connector,
    CloudBinaryUploadService::Result result,
    enterprise_connectors::ContentAnalysisResponse response) {}

void CloudBinaryUploadService::RunAuthorizationCallbacks(
    const std::string& dm_token,
    enterprise_connectors::AnalysisConnector connector) {}

void CloudBinaryUploadService::ResetAuthorizationData(const GURL& url) {}

void CloudBinaryUploadService::Shutdown() {}

void CloudBinaryUploadService::SetAuthForTesting(const std::string& dm_token,
                                                 bool authorized) {}

void CloudBinaryUploadService::SetTokenFetcherForTesting(
    std::unique_ptr<SafeBrowsingTokenFetcher> token_fetcher) {}

// static
GURL CloudBinaryUploadService::GetUploadUrl(bool is_consumer_scan_eligible) {}

void CloudBinaryUploadService::PopRequestQueue() {}

}  // namespace safe_browsing