#include "components/content_settings/core/browser/content_settings_pref.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/json/values_util.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/content_settings/core/browser/content_settings_info.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/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_constraints.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_utils.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "services/preferences/public/cpp/dictionary_value_update.h"
#include "services/preferences/public/cpp/scoped_pref_update.h"
#include "url/gurl.h"
namespace {
const char kExpirationKey[] = …;
const char kLastUsedKey[] = …;
const char kLastVisitKey[] = …;
const char kSessionModelKey[] = …;
const char kSettingKey[] = …;
const char kLastModifiedKey[] = …;
const char kLifetimeKey[] = …;
const char kDecidedByRelatedWebsiteSets[] = …;
const base::TimeDelta kLastUsedPermissionExpiration = …;
bool IsValueAllowedForType(const base::Value& value, ContentSettingsType type) { … }
base::Time GetTimeFromDictKey(const base::Value::Dict& dict,
const std::string& key) { … }
base::TimeDelta GetTimeDeltaFromDictKey(const base::Value::Dict& dict,
const std::string& key) { … }
base::Time GetLastModified(const base::Value::Dict& dictionary) { … }
base::Time GetExpiration(const base::Value::Dict& dictionary) { … }
base::Time GetLastUsed(const base::Value::Dict& dictionary) { … }
base::Time GetLastVisit(const base::Value::Dict& dictionary) { … }
base::TimeDelta GetLifetime(const base::Value::Dict& dictionary) { … }
bool GetDecidedByRelatedWebsiteSets(const base::Value::Dict& dictionary) { … }
content_settings::mojom::SessionModel GetSessionModel(
const base::Value::Dict& dictionary) { … }
}
namespace content_settings {
ContentSettingsPref::ContentSettingsPref(
ContentSettingsType content_type,
PrefService* prefs,
PrefChangeRegistrar* registrar,
const std::string& pref_name,
const std::string& partitioned_pref_name,
bool off_the_record,
bool restore_session,
NotifyObserversCallback notify_callback)
: … { … }
ContentSettingsPref::~ContentSettingsPref() = default;
std::unique_ptr<RuleIterator> ContentSettingsPref::GetRuleIterator(
bool off_the_record,
const PartitionKey& partition_key) const { … }
std::unique_ptr<Rule> ContentSettingsPref::GetRule(
const GURL& primary_url,
const GURL& secondary_url,
bool off_the_record,
const PartitionKey& partition_key) const { … }
void ContentSettingsPref::SetWebsiteSetting(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
base::Value value,
const RuleMetaData& metadata,
const PartitionKey& partition_key) { … }
void ContentSettingsPref::ClearAllContentSettingsRules(
const PartitionKey& partition_key) { … }
void ContentSettingsPref::OnShutdown() { … }
size_t ContentSettingsPref::GetNumExceptions() { … }
bool ContentSettingsPref::TryLockForTesting() const { … }
void ContentSettingsPref::ReadContentSettingsFromPref() { … }
void ContentSettingsPref::ReadContentSettingsFromPrefForPartition(
const PartitionKey& partition_key,
const base::Value::Dict& partition,
prefs::DictionaryValueUpdate* mutable_partition) { … }
bool ContentSettingsPref::ShouldRemoveSetting(
base::Time expiration,
content_settings::mojom::SessionModel session_model) { … }
void ContentSettingsPref::OnPrefChanged() { … }
void ContentSettingsPref::UpdatePref(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
base::Value value,
const RuleMetaData& metadata,
const PartitionKey& partition_key) { … }
void ContentSettingsPref::AssertLockNotHeld() const { … }
void ContentSettingsPref::SetClockForTesting(base::Clock* clock) { … }
}