chromium/components/content_settings/core/browser/host_content_settings_map.h

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Maps hostnames to custom content settings.  Written on the UI thread and read
// on any thread.  One instance per profile.

#ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_
#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_

#include <map>
#include <memory>
#include <string>
#include <vector>

#include "base/check_is_test.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_checker.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/browser/user_modifiable_provider.h"

#include "components/content_settings/core/common/content_settings_constraints.h"
#include "components/content_settings/core/common/content_settings_metadata.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/keyed_service/core/refcounted_keyed_service.h"
#include "components/prefs/pref_change_registrar.h"

// In the context of active expiry enforcement, content settings are considered
// expired if their expiration time is before 'Now() + `kEagerExpiryBuffer` at
// the time of check. This value accounts for posted task delays due to
// prioritization. Note that there are no guarantees about CPU contention, so
// this doesn't prevent occasional outlier tasks that are delayed further.
// However, consistency is more important then accuracy in this context.
// Expirations are not user visible, and are not guarantees given to or chosen
// by the user. If we do not delete but also don't provide, we get into an
// inconsistent state which among other issues is also a security concern: the
// expired content setting is no longer provided and thus isn't listed in page
// info even though the site might still have active access to it. At this
// point, the only way the user can block access to the permission is to
// reload, navigate away or close the tab/browser. These are not reasonable user
// journeys. Additionally, if CPU contention leads to significant delays in the
// run loop, other browser process tasks such as checking content settings
// are very likely similarly delayed.
static constexpr base::TimeDelta kEagerExpiryBuffer =;

class GURL;
class PrefService;

namespace base {
class Value;
class Clock;
}  // namespace base

namespace content_settings {
class ObservableProvider;
class ProviderInterface;
class PrefProvider;
class TestUtils;
class WebsiteSettingsInfo;
}  // namespace content_settings

namespace user_prefs {
class PrefRegistrySyncable;
}

class HostContentSettingsMap : public content_settings::Observer,
                               public RefcountedKeyedService {};

#endif  // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_