#include "chrome/browser/enterprise/connectors/common.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_downloads_delegate.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_features.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/enterprise/util/affiliation.h"
#include "chrome/browser/policy/dm_token_utils.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "components/user_manager/user.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/policy/core/common/policy_loader_lacros.h"
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
#include "chrome/browser/enterprise/signin/enterprise_signin_prefs.h"
#include "components/prefs/pref_service.h"
#endif
#if BUILDFLAG(ENTERPRISE_CONTENT_ANALYSIS)
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.h"
BinaryUploadService;
#endif
namespace enterprise_connectors {
namespace {
#if BUILDFLAG(ENTERPRISE_CONTENT_ANALYSIS)
bool ContentAnalysisActionAllowsDataUse(TriggeredRule::Action action) { … }
bool ShouldAllowDeepScanOnLargeOrEncryptedFiles(
BinaryUploadService::Result result,
bool block_large_files,
bool block_password_protected_files) { … }
#endif
}
#if BUILDFLAG(ENTERPRISE_CONTENT_ANALYSIS)
bool ResultShouldAllowDataUse(const AnalysisSettings& settings,
BinaryUploadService::Result upload_result) { … }
RequestHandlerResult CalculateRequestHandlerResult(
const AnalysisSettings& settings,
BinaryUploadService::Result upload_result,
const ContentAnalysisResponse& response) { … }
safe_browsing::EventResult CalculateEventResult(
const AnalysisSettings& settings,
bool allowed_by_scan_result,
bool should_warn) { … }
#endif
const char SavePackageScanningData::kKey[] = …;
SavePackageScanningData::SavePackageScanningData(
content::SavePackageAllowedCallback callback)
: … { … }
SavePackageScanningData::~SavePackageScanningData() = default;
void RunSavePackageScanningCallback(download::DownloadItem* item,
bool allowed) { … }
bool IncludeDeviceInfo(Profile* profile, bool per_profile) { … }
bool ShouldPromptReviewForDownload(
Profile* profile,
const download::DownloadItem* download_item) { … }
std::string GetProfileEmail(Profile* profile) { … }
std::string GetProfileEmail(signin::IdentityManager* identity_manager) { … }
#if BUILDFLAG(ENTERPRISE_CONTENT_ANALYSIS)
void ShowDownloadReviewDialog(const std::u16string& filename,
Profile* profile,
download::DownloadItem* download_item,
content::WebContents* web_contents,
base::OnceClosure keep_closure,
base::OnceClosure discard_closure) { … }
bool IsResumableUpload(const BinaryUploadService::Request& request) { … }
bool CloudMultipartResultIsFailure(BinaryUploadService::Result result) { … }
bool CloudResumableResultIsFailure(BinaryUploadService::Result result,
bool block_large_files,
bool block_password_protected_files) { … }
bool LocalResultIsFailure(BinaryUploadService::Result result) { … }
bool ResultIsFailClosed(BinaryUploadService::Result result) { … }
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
Profile* GetMainProfileLacros() {
ProfileManager* profile_manager = g_browser_process->profile_manager();
if (!profile_manager)
return nullptr;
auto profiles = g_browser_process->profile_manager()->GetLoadedProfiles();
const auto main_it = base::ranges::find_if(profiles, &Profile::IsMainProfile);
if (main_it == profiles.end())
return nullptr;
return *main_it;
}
#endif
}