#include "components/content_settings/core/browser/content_settings_pref_provider.h"
#include <stddef.h>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/content_settings/core/browser/content_settings_info.h"
#include "components/content_settings/core/browser/content_settings_pref.h"
#include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/browser/content_settings_rule.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/browser/website_settings_registry.h"
#include "components/content_settings/core/common/content_settings_metadata.h"
#include "components/content_settings/core/common/content_settings_partition_key.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry.h"
#include "components/prefs/pref_service.h"
#include "services/preferences/public/cpp/dictionary_value_update.h"
#include "services/preferences/public/cpp/scoped_pref_update.h"
#include "services/tracing/public/cpp/perfetto/macros.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_content_settings_event_info.pbzero.h"
namespace content_settings {
namespace {
#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)
const char kObsoleteInstalledWebAppMetadataExceptionsPref[] = …;
const char kObsoletePpapiBrokerExceptionsPref[] = …;
#endif
const char
kObsoleteGetDisplayMediaSetAutoSelectAllScreensAllowedForUrlsExceptionsPref
[] = …;
constexpr char kObsoleteFederatedIdentityActiveSesssionExceptionsPref[] = …;
}
void PrefProvider::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
PrefProvider::PrefProvider(PrefService* prefs,
bool off_the_record,
bool store_last_modified,
bool restore_session)
: … { … }
PrefProvider::~PrefProvider() { … }
std::unique_ptr<RuleIterator> PrefProvider::GetRuleIterator(
ContentSettingsType content_type,
bool off_the_record,
const PartitionKey& partition_key) const { … }
std::unique_ptr<Rule> PrefProvider::GetRule(
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
bool off_the_record,
const PartitionKey& partition_key) const { … }
bool PrefProvider::SetWebsiteSetting(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
base::Value&& in_value,
const ContentSettingConstraints& constraints,
const PartitionKey& partition_key) { … }
bool PrefProvider::SetLastVisitTime(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const base::Time time,
const PartitionKey& partition_key) { … }
bool PrefProvider::UpdateSetting(ContentSettingsType content_type,
base::FunctionRef<bool(const Rule&)> is_match,
base::FunctionRef<bool(Rule&)> perform_update,
const PartitionKey& partition_key) { … }
bool PrefProvider::UpdateLastUsedTime(const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
const base::Time time,
const PartitionKey& partition_key) { … }
bool PrefProvider::ResetLastVisitTime(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const PartitionKey& partition_key) { … }
bool PrefProvider::UpdateLastVisitTime(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const PartitionKey& partition_key) { … }
std::optional<base::TimeDelta> PrefProvider::RenewContentSetting(
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
std::optional<ContentSetting> setting_to_match,
const PartitionKey& partition_key) { … }
void PrefProvider::ClearAllContentSettingsRules(
ContentSettingsType content_type,
const PartitionKey& partition_key) { … }
void PrefProvider::ShutdownOnUIThread() { … }
ContentSettingsPref* PrefProvider::GetPref(ContentSettingsType type) const { … }
void PrefProvider::Notify(const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const PartitionKey* partition_key) { … }
void PrefProvider::DiscardOrMigrateObsoletePreferences() { … }
void PrefProvider::SetClockForTesting(base::Clock* clock) { … }
}