#include "chrome/browser/ui/hats/trust_safety_sentiment_service.h"
#include <map>
#include <vector>
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/ui/hats/hats_service.h"
#include "chrome/browser/ui/hats/hats_service_factory.h"
#include "chrome/browser/ui/hats/survey_config.h"
#include "chrome/browser/ui/safety_hub/card_data_helper.h"
#include "chrome/browser/ui/safety_hub/menu_notification_service_factory.h"
#include "chrome/browser/ui/safety_hub/safety_hub_constants.h"
#include "chrome/browser/ui/webui/settings/site_settings_helper.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/browser/website_settings_registry.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
#include "components/privacy_sandbox/tracking_protection_prefs.h"
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/unified_consent/pref_names.h"
#include "components/version_info/channel.h"
namespace {
base::TimeDelta GetMinTimeToPrompt() { … }
base::TimeDelta GetMaxTimeToPrompt() { … }
base::TimeDelta GetMinSessionTime() { … }
int GetRequiredNtpCount() { … }
int GetMaxRequiredNtpCount() { … }
bool HasNonDefaultPrivacySetting(Profile* profile) { … }
std::map<std::string, bool> GetPrivacySettingsProductSpecificData(
Profile* profile,
bool ran_safety_check) { … }
bool IsOtherSBInterstitialCategory(safe_browsing::SBThreatType threat_type) { … }
std::map<std::string, bool> BuildProductSpecificDataForPasswordProtection(
Profile* profile,
PasswordProtectionUIType ui_type,
PasswordProtectionUIAction action) { … }
}
TrustSafetySentimentService::TrustSafetySentimentService(Profile* profile)
: … { … }
TrustSafetySentimentService::~TrustSafetySentimentService() { … }
void TrustSafetySentimentService::OpenedNewTabPage() { … }
void TrustSafetySentimentService::InteractedWithPrivacySettings(
content::WebContents* web_contents) { … }
void TrustSafetySentimentService::RanSafetyCheck() { … }
void TrustSafetySentimentService::PageInfoOpened() { … }
void TrustSafetySentimentService::InteractedWithPageInfo() { … }
void TrustSafetySentimentService::PageInfoClosed() { … }
void TrustSafetySentimentService::SavedPassword() { … }
void TrustSafetySentimentService::OpenedPasswordManager(
content::WebContents* web_contents) { … }
void TrustSafetySentimentService::SavedCard() { … }
void TrustSafetySentimentService::RanPasswordCheck() { … }
void TrustSafetySentimentService::ClearedBrowsingData(
browsing_data::BrowsingDataType datatype) { … }
void TrustSafetySentimentService::FinishedPrivacyGuide() { … }
void TrustSafetySentimentService::InteractedWithPrivacySandbox4(
FeatureArea feature_area) { … }
void TrustSafetySentimentService::InteractedWithSafeBrowsingInterstitial(
bool did_proceed,
safe_browsing::SBThreatType threat_type) { … }
void TrustSafetySentimentService::InteractedWithDownloadWarningUI(
DownloadItemWarningData::WarningSurface surface,
DownloadItemWarningData::WarningAction action) { … }
void TrustSafetySentimentService::ProtectResetOrCheckPasswordClicked(
PasswordProtectionUIType ui_type) { … }
void TrustSafetySentimentService::PhishedPasswordUpdateNotClicked(
PasswordProtectionUIType ui_type,
PasswordProtectionUIAction action) { … }
void TrustSafetySentimentService::PhishedPasswordUpdateFinished() { … }
void TrustSafetySentimentService::OnOffTheRecordProfileCreated(
Profile* off_the_record) { … }
void TrustSafetySentimentService::OnProfileWillBeDestroyed(Profile* profile) { … }
void TrustSafetySentimentService::OnSessionEnded(base::TimeDelta session_length,
base::TimeTicks session_end) { … }
TrustSafetySentimentService::PendingTrigger::PendingTrigger(
const std::map<std::string, bool>& product_specific_data,
int remaining_ntps_to_open)
: … { … }
TrustSafetySentimentService::PendingTrigger::PendingTrigger(
int remaining_ntps_to_open)
: … { … }
TrustSafetySentimentService::PendingTrigger::PendingTrigger() = default;
TrustSafetySentimentService::PendingTrigger::~PendingTrigger() = default;
TrustSafetySentimentService::PendingTrigger::PendingTrigger(
const PendingTrigger& other) = default;
TrustSafetySentimentService::SettingsWatcher::SettingsWatcher(
content::WebContents* web_contents,
base::TimeDelta required_open_time,
base::OnceCallback<void()> success_callback,
base::OnceCallback<void()> complete_callback)
: … { … }
TrustSafetySentimentService::SettingsWatcher::~SettingsWatcher() = default;
void TrustSafetySentimentService::SettingsWatcher::WebContentsDestroyed() { … }
void TrustSafetySentimentService::SettingsWatcher::TimerComplete() { … }
TrustSafetySentimentService::PageInfoState::PageInfoState()
: … { … }
TrustSafetySentimentService::PhishedPasswordChangeState::
PhishedPasswordChangeState()
: … { … }
void TrustSafetySentimentService::SettingsWatcherComplete() { … }
void TrustSafetySentimentService::TriggerOccurred(
FeatureArea feature_area,
const std::map<std::string, bool>& product_specific_data) { … }
void TrustSafetySentimentService::PerformedIneligibleAction() { … }
bool TrustSafetySentimentService::ShouldBlockSurvey(
const PendingTrigger& trigger) { … }
void TrustSafetySentimentService::MaybeTriggerPasswordProtectionSurvey(
PasswordProtectionUIType ui_type,
PasswordProtectionUIAction action) { … }
void TrustSafetySentimentService::TriggerSafetyHubSurvey(
TrustSafetySentimentService::FeatureArea feature_area,
std::map<std::string, bool> product_specific_data) { … }
bool TrustSafetySentimentService::VersionCheck(FeatureArea feature_area) { … }
std::string TrustSafetySentimentService::GetHatsTriggerForFeatureArea(
FeatureArea feature_area) { … }
bool TrustSafetySentimentService::ProbabilityCheck(FeatureArea feature_area) { … }