#include "chrome/browser/enterprise/connectors/connectors_manager.h"
#include <memory>
#include "base/check.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_features.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "url/gurl.h"
#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS)
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_sdk_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#endif
namespace enterprise_connectors {
namespace {
#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS)
static constexpr enterprise_connectors::AnalysisConnector
kLocalAnalysisConnectors[] = …;
#endif
constexpr char kReportingConnectorUrlFlag[] = …;
}
ConnectorsManager::ConnectorsManager(PrefService* pref_service,
const ServiceProviderConfig* config,
bool observe_prefs)
: … { … }
#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS)
ConnectorsManager::~ConnectorsManager() { … }
#else
ConnectorsManager::~ConnectorsManager() = default;
#endif
bool ConnectorsManager::IsAnalysisConnectorEnabled(
AnalysisConnector connector) const { … }
#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS)
bool ConnectorsManager::IsConnectorEnabledForLocalAgent(
AnalysisConnector connector) const { … }
#endif
std::optional<AnalysisSettings> ConnectorsManager::GetAnalysisSettings(
const GURL& url,
AnalysisConnector connector) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::optional<AnalysisSettings> ConnectorsManager::GetAnalysisSettings(
content::BrowserContext* context,
const storage::FileSystemURL& source_url,
const storage::FileSystemURL& destination_url,
AnalysisConnector connector) {
if (!IsAnalysisConnectorEnabled(connector)) {
return std::nullopt;
}
if (analysis_connector_settings_.count(connector) == 0)
CacheAnalysisConnectorPolicy(connector);
if (analysis_connector_settings_.count(connector) == 0)
return std::nullopt;
return analysis_connector_settings_[connector][0].GetAnalysisSettings(
context, source_url, destination_url, GetDataRegion());
}
#endif
#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS)
void ConnectorsManager::OnBrowserAdded(Browser* browser) { … }
void ConnectorsManager::OnBrowserRemoved(Browser* browser) { … }
void ConnectorsManager::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) { … }
#endif
void ConnectorsManager::CacheAnalysisConnectorPolicy(
AnalysisConnector connector) const { … }
#if BUILDFLAG(ENTERPRISE_LOCAL_CONTENT_ANALYSIS)
void ConnectorsManager::MaybeCloseLocalContentAnalysisAgentConnection() { … }
#endif
void ConnectorsManager::SetTelemetryObserverCallback(
base::RepeatingCallback<void()> callback) { … }
void ConnectorsManager::OnPrefChanged(AnalysisConnector connector) { … }
bool ConnectorsManager::DelayUntilVerdict(AnalysisConnector connector) { … }
std::optional<std::u16string> ConnectorsManager::GetCustomMessage(
AnalysisConnector connector,
const std::string& tag) { … }
std::optional<GURL> ConnectorsManager::GetLearnMoreUrl(
AnalysisConnector connector,
const std::string& tag) { … }
bool ConnectorsManager::GetBypassJustificationRequired(
AnalysisConnector connector,
const std::string& tag) { … }
std::vector<std::string> ConnectorsManager::GetAnalysisServiceProviderNames(
AnalysisConnector connector) { … }
std::vector<const AnalysisConfig*> ConnectorsManager::GetAnalysisServiceConfigs(
AnalysisConnector connector) { … }
DataRegion ConnectorsManager::GetDataRegion() const { … }
void ConnectorsManager::StartObservingPrefs(PrefService* pref_service) { … }
void ConnectorsManager::StartObservingPref(AnalysisConnector connector) { … }
std::optional<GURL> ConnectorsManager::GetReportingConnectorUrlOverride() { … }
const ConnectorsManager::AnalysisConnectorsSettings&
ConnectorsManager::GetAnalysisConnectorsSettingsForTesting() const { … }
const base::RepeatingCallback<void()>
ConnectorsManager::GetTelemetryObserverCallbackForTesting() const { … }
}