// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MANAGER_H_ #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MANAGER_H_ #include <memory> #include <optional> #include <utility> #include "base/memory/raw_ptr.h" #include "base/time/clock.h" #include "base/time/time.h" #include "base/values.h" #include "components/content_settings/core/common/content_settings.h" class GURL; class HostContentSettingsMap; namespace subresource_filter { // This class contains helpers to get/set content and website settings related // to subresource filtering. // // Site metadata is stored in two formats as a base::Value::Dict: // - V1 (or legacy) metadata, which uses the presence of metadata to indicate // activation due to safe browsing and may store additional data for // the time since UI was shown, see OnDidShowUI. The absence of metadata // indicates no activation. // TODO(justinmiron): All V1 metadata will be updated to V2 when it is // processed, but we should ideally migrate it all at some point to remove // this case. // // - V2 metadata, which explicitly stores the activation status in a key // within the metadata dict. This metadata, by default, expires after 1 // week. However, when metadata is set by an ads intervention, and we // and ads interventions are not blocking ads (no activation), the // expiration time is explicitly set to match the metadata expiry key in the // metadata dict. Additional data may be persisted but will be deleted // if there is no activation and the metadata expiry key is not set. // // Data stored in the metadata for a url: // - kInfobarLastShownTimeKey (V1/V2): The last time the info bar was shown for // the smart UI. // - kActivatedKey (V2): The current activation status of the url. // - kNonRenewingExpiryTime (V2): The time that this url's // metadata will expire at and be cleared from the website settings. // Note, if this is set, there is no code path that should be able to extend // the expiry time. This is a "non-renewable" expiry. // TODO(crbug.com/40710549): This ensures that even safe browsing // activation is not persisted for the full expiration if it comes after an // ads intervention. This is non-ideal and this behavior should be removed // when metrics collection is finished, in M88. // // TODO(crbug.com/41309958): Once observing changes to content settings is // robust enough for metrics collection, should collect metrics here too, using // a content_settings::Observer. Generally speaking, we want a system where we // can easily log metrics if the content setting has changed meaningfully from // it's previous value. class SubresourceFilterContentSettingsManager { … }; } // namespace subresource_filter #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MANAGER_H_