#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service.h"
#include "base/command_line.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/connectors/common.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/cloud_binary_upload_service_factory.h"
#include "components/enterprise/common/strings.h"
#include "components/enterprise/connectors/core/analysis_settings.h"
#include "net/base/url_util.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
#include "chrome/browser/enterprise/connectors/analysis/local_binary_upload_service_factory.h"
#endif
namespace safe_browsing {
namespace {
constexpr char kCloudBinaryUploadServiceUrlFlag[] = …;
std::optional<GURL> GetUrlOverride() { … }
}
std::string BinaryUploadService::ResultToString(Result result) { … }
BinaryUploadService::Request::Data::Data() = default;
BinaryUploadService::Request::Data::Data(const Data& other) { … }
BinaryUploadService::Request::Data::Data(Data&&) = default;
BinaryUploadService::Request::Data&
BinaryUploadService::Request::Data::operator=(
const BinaryUploadService::Request::Data& other) { … }
BinaryUploadService::Request::Data&
BinaryUploadService::Request::Data::operator=(
BinaryUploadService::Request::Data&& other) = default;
BinaryUploadService::Request::Data::~Data() = default;
BinaryUploadService::Request::Request(
ContentAnalysisCallback callback,
enterprise_connectors::CloudOrLocalAnalysisSettings settings)
: … { … }
BinaryUploadService::Request::Request(
ContentAnalysisCallback content_analysis_callback,
enterprise_connectors::CloudOrLocalAnalysisSettings settings,
Request::RequestStartCallback start_callback)
: … { … }
BinaryUploadService::Request::~Request() = default;
void BinaryUploadService::Request::set_id(Id id) { … }
BinaryUploadService::Request::Id BinaryUploadService::Request::id() const { … }
void BinaryUploadService::Request::set_per_profile_request(
bool per_profile_request) { … }
bool BinaryUploadService::Request::per_profile_request() const { … }
void BinaryUploadService::Request::set_fcm_token(const std::string& token) { … }
void BinaryUploadService::Request::set_device_token(const std::string& token) { … }
void BinaryUploadService::Request::set_filename(const std::string& filename) { … }
void BinaryUploadService::Request::set_digest(const std::string& digest) { … }
void BinaryUploadService::Request::clear_dlp_scan_request() { … }
void BinaryUploadService::Request::set_analysis_connector(
enterprise_connectors::AnalysisConnector connector) { … }
void BinaryUploadService::Request::set_url(const std::string& url) { … }
void BinaryUploadService::Request::set_source(const std::string& source) { … }
void BinaryUploadService::Request::set_destination(
const std::string& destination) { … }
void BinaryUploadService::Request::set_csd(ClientDownloadRequest csd) { … }
void BinaryUploadService::Request::add_tag(const std::string& tag) { … }
void BinaryUploadService::Request::set_email(const std::string& email) { … }
void BinaryUploadService::Request::set_client_metadata(
enterprise_connectors::ClientMetadata metadata) { … }
void BinaryUploadService::Request::set_content_type(const std::string& type) { … }
void BinaryUploadService::Request::set_tab_title(const std::string& tab_title) { … }
void BinaryUploadService::Request::set_user_action_id(
const std::string& user_action_id) { … }
void BinaryUploadService::Request::set_user_action_requests_count(
uint64_t user_action_requests_count) { … }
void BinaryUploadService::Request::set_tab_url(const GURL& tab_url) { … }
void BinaryUploadService::Request::set_printer_name(
const std::string& printer_name) { … }
void BinaryUploadService::Request::set_printer_type(
enterprise_connectors::ContentMetaData::PrintMetadata::PrinterType
printer_type) { … }
void BinaryUploadService::Request::set_password(const std::string& password) { … }
void BinaryUploadService::Request::set_reason(
enterprise_connectors::ContentAnalysisRequest::Reason reason) { … }
void BinaryUploadService::Request::set_require_metadata_verdict(
bool require_metadata_verdict) { … }
void BinaryUploadService::Request::set_blocking(bool blocking) { … }
std::string BinaryUploadService::Request::SetRandomRequestToken() { … }
enterprise_connectors::AnalysisConnector
BinaryUploadService::Request::analysis_connector() { … }
const std::string& BinaryUploadService::Request::device_token() const { … }
const std::string& BinaryUploadService::Request::request_token() const { … }
const std::string& BinaryUploadService::Request::fcm_notification_token()
const { … }
const std::string& BinaryUploadService::Request::filename() const { … }
const std::string& BinaryUploadService::Request::digest() const { … }
const std::string& BinaryUploadService::Request::content_type() const { … }
const std::string& BinaryUploadService::Request::user_action_id() const { … }
const std::string& BinaryUploadService::Request::tab_title() const { … }
const std::string& BinaryUploadService::Request::printer_name() const { … }
uint64_t BinaryUploadService::Request::user_action_requests_count() const { … }
GURL BinaryUploadService::Request::tab_url() const { … }
base::optional_ref<const std::string> BinaryUploadService::Request::password()
const { … }
enterprise_connectors::ContentAnalysisRequest::Reason
BinaryUploadService::Request::reason() const { … }
bool BinaryUploadService::Request::blocking() const { … }
void BinaryUploadService::Request::StartRequest() { … }
void BinaryUploadService::Request::FinishRequest(
Result result,
enterprise_connectors::ContentAnalysisResponse response) { … }
void BinaryUploadService::Request::SerializeToString(
std::string* destination) const { … }
GURL BinaryUploadService::Request::GetUrlWithParams() const { … }
bool BinaryUploadService::Request::IsAuthRequest() const { … }
const std::string& BinaryUploadService::Request::access_token() const { … }
void BinaryUploadService::Request::set_access_token(
const std::string& access_token) { … }
BinaryUploadService::Ack::Ack(
enterprise_connectors::CloudOrLocalAnalysisSettings settings)
: … { … }
BinaryUploadService::Ack::~Ack() = default;
void BinaryUploadService::Ack::set_request_token(const std::string& token) { … }
void BinaryUploadService::Ack::set_status(
enterprise_connectors::ContentAnalysisAcknowledgement::Status status) { … }
void BinaryUploadService::Ack::set_final_action(
enterprise_connectors::ContentAnalysisAcknowledgement::FinalAction
final_action) { … }
BinaryUploadService::CancelRequests::CancelRequests(
enterprise_connectors::CloudOrLocalAnalysisSettings settings)
: … { … }
BinaryUploadService::CancelRequests::~CancelRequests() = default;
void BinaryUploadService::CancelRequests::set_user_action_id(
const std::string& user_action_id) { … }
BinaryUploadService* BinaryUploadService::GetForProfile(
Profile* profile,
const enterprise_connectors::AnalysisSettings& settings) { … }
}