| Index: chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h
|
| diff --git a/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h b/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h
|
| index c1552ec04894639287ef005709ac67c760cbf51a..35ee278ac0dc25689d91baa81fcd0d05e095f6b5 100644
|
| --- a/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h
|
| +++ b/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h
|
| @@ -5,24 +5,60 @@
|
| #ifndef CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MANAGER_H_
|
| #define CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MANAGER_H_
|
|
|
| +#include <memory>
|
| +#include <set>
|
| #include <string>
|
| +#include <utility>
|
|
|
| #include "base/macros.h"
|
| +#include "base/scoped_observer.h"
|
| +#include "base/time/clock.h"
|
| +#include "base/time/time.h"
|
| #include "components/content_settings/core/browser/content_settings_observer.h"
|
| +#include "components/content_settings/core/common/content_settings.h"
|
| #include "components/content_settings/core/common/content_settings_types.h"
|
| +#include "components/history/core/browser/history_service_observer.h"
|
|
|
| class ContentSettingsPattern;
|
| +class GURL;
|
| class HostContentSettingsMap;
|
| class Profile;
|
|
|
| -// This class observes subresource filter content settings changes for metrics
|
| -// collection.
|
| +namespace base {
|
| +class DictionaryValue;
|
| +} // namespace base
|
| +
|
| +namespace history {
|
| +class HistoryService;
|
| +} // namespace history
|
| +
|
| +// This class contains helpers to get/set content and website settings related
|
| +// to subresource filtering. It also observes content setting changes for
|
| +// metrics collection.
|
| class SubresourceFilterContentSettingsManager
|
| - : public content_settings::Observer {
|
| + : public content_settings::Observer,
|
| + public history::HistoryServiceObserver {
|
| public:
|
| explicit SubresourceFilterContentSettingsManager(Profile* profile);
|
| ~SubresourceFilterContentSettingsManager() override;
|
|
|
| + ContentSetting GetSitePermission(const GURL& url) const;
|
| + void SetSitePermission(const GURL& url, ContentSetting setting, bool from_ui);
|
| +
|
| + // Specific logic for more intelligent UI.
|
| + void OnDidShowUI(const GURL& url);
|
| + bool ShouldShowUIForSite(const GURL& url) const;
|
| + bool should_use_smart_ui() const { return should_use_smart_ui_; }
|
| +
|
| + void set_clock_for_testing(std::unique_ptr<base::Clock> tick_clock) {
|
| + clock_ = std::move(tick_clock);
|
| + }
|
| +
|
| + // Time before showing the UI again on a domain.
|
| + // TODO(csharrison): Consider setting this via a finch param.
|
| + static constexpr base::TimeDelta kDelayBeforeShowingInfobarAgain =
|
| + base::TimeDelta::FromMinutes(30);
|
| +
|
| private:
|
| // content_settings::Observer:
|
| void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
|
| @@ -30,8 +66,32 @@ class SubresourceFilterContentSettingsManager
|
| ContentSettingsType content_type,
|
| std::string resource_identifier) override;
|
|
|
| + // history::HistoryServiceObserver:
|
| + void OnURLsDeleted(history::HistoryService* history_service,
|
| + bool all_history,
|
| + bool expired,
|
| + const history::URLRows& deleted_rows,
|
| + const std::set<GURL>& favicon_urls) override;
|
| +
|
| + std::unique_ptr<base::DictionaryValue> GetSiteMetadata(const GURL& url) const;
|
| + void SetSiteMetadata(const GURL& url,
|
| + std::unique_ptr<base::DictionaryValue> dict);
|
| +
|
| + ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
|
| + history_observer_;
|
| +
|
| HostContentSettingsMap* settings_map_;
|
|
|
| + // A clock is injected into this class so tests can set arbitrary timestamps
|
| + // in website settings.
|
| + std::unique_ptr<base::Clock> clock_;
|
| +
|
| + // Used internally so the class ignores changes to the settings that are not
|
| + // user initiated through the settings UI.
|
| + bool ignore_settings_changes_ = false;
|
| +
|
| + const bool should_use_smart_ui_ = false;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager);
|
| };
|
|
|
|
|