1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
// Copyright 2025 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/enterprise/signals/profile_signals_collector.h"
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/identifiers/profile_id_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/device_signals/core/browser/browser_utils.h"
#include "components/device_signals/core/browser/signals_types.h"
#include "components/device_signals/core/browser/user_permission_service.h"
#include "components/device_signals/core/common/platform_utils.h"
#include "components/enterprise/browser/identifiers/profile_id_service.h"
#include "components/enterprise/buildflags/buildflags.h"
#include "components/policy/content/policy_blocklist_service.h"
#include "components/policy/core/common/cloud/cloud_policy_manager.h"
#include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h"
#if BUILDFLAG(ENTERPRISE_CLOUD_CONTENT_ANALYSIS)
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#endif
namespace device_signals {
namespace {
bool GetBuiltInDnsClientEnabled(PrefService* local_state) {
DCHECK(local_state);
return local_state->GetBoolean(prefs::kBuiltInDnsClientEnabled);
}
} // namespace
ProfileSignalsCollector::ProfileSignalsCollector(Profile* profile)
: BaseSignalsCollector({
{SignalName::kBrowserContextSignals,
base::BindRepeating(&ProfileSignalsCollector::GetProfileSignals,
base::Unretained(this))},
}),
policy_blocklist_service_(
PolicyBlocklistFactory::GetForBrowserContext(profile)),
profile_prefs_(profile->GetPrefs()),
policy_manager_(profile->GetCloudPolicyManager()),
connectors_service_(
enterprise_connectors::ConnectorsServiceFactory::GetForBrowserContext(
profile)),
profile_id_service_(
enterprise::ProfileIdServiceFactory::GetForProfile(profile)) {
#if BUILDFLAG(ENTERPRISE_CLOUD_CONTENT_ANALYSIS)
CHECK(connectors_service_);
#endif // BUILDFLAG(ENTERPRISE_CLOUD_CONTENT_ANALYSIS)
CHECK(policy_blocklist_service_);
CHECK(profile_id_service_);
}
ProfileSignalsCollector::~ProfileSignalsCollector() = default;
void ProfileSignalsCollector::GetProfileSignals(
UserPermission permission,
const SignalsAggregationRequest& request,
SignalsAggregationResponse& response,
base::OnceClosure done_closure) {
ProfileSignalsResponse signal_response;
signal_response.built_in_dns_client_enabled =
GetBuiltInDnsClientEnabled(g_browser_process->local_state());
signal_response.chrome_remote_desktop_app_blocked =
device_signals::GetChromeRemoteDesktopAppBlocked(
policy_blocklist_service_);
signal_response.password_protection_warning_trigger =
device_signals::GetPasswordProtectionWarningTrigger(profile_prefs_);
signal_response.profile_enrollment_domain =
device_signals::TryGetEnrollmentDomain(policy_manager_);
signal_response.safe_browsing_protection_level =
device_signals::GetSafeBrowsingProtectionLevel(profile_prefs_);
signal_response.site_isolation_enabled =
device_signals::GetSiteIsolationEnabled();
signal_response.profile_id = profile_id_service_->GetProfileId();
#if BUILDFLAG(ENTERPRISE_CLOUD_CONTENT_ANALYSIS)
signal_response.realtime_url_check_mode =
connectors_service_->GetAppliedRealTimeUrlCheck();
signal_response.file_downloaded_providers =
connectors_service_->GetAnalysisServiceProviderNames(
enterprise_connectors::FILE_DOWNLOADED);
signal_response.file_attached_providers =
connectors_service_->GetAnalysisServiceProviderNames(
enterprise_connectors::FILE_ATTACHED);
signal_response.bulk_data_entry_providers =
connectors_service_->GetAnalysisServiceProviderNames(
enterprise_connectors::BULK_DATA_ENTRY);
signal_response.print_providers =
connectors_service_->GetAnalysisServiceProviderNames(
enterprise_connectors::PRINT);
signal_response.security_event_providers =
connectors_service_->GetReportingServiceProviderNames();
#endif // BUILDFLAG(ENTERPRISE_CLOUD_CONTENT_ANALYSIS)
response.profile_signals_response = std::move(signal_response);
// All signals are fetched synchronously for now, so we can run the closure
// immediately. Once async signals are added, `done_closure` should be moved
// to be run in the callback.
std::move(done_closure).Run();
}
} // namespace device_signals
|