Chromium Code Reviews| 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 530e4362e146403031a945e98caa2ca443281ede..075feef9cb4645d27945e48a6e6394a248a20dca 100644 |
| --- a/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h |
| +++ b/chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h |
| @@ -5,19 +5,27 @@ |
| #ifndef CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MANAGER_H_ |
| #define CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MANAGER_H_ |
| +#include <memory> |
|
engedy
2017/04/12 14:02:51
#include <utility> for std::move
Charlie Harrison
2017/04/12 17:53:45
Done.
|
| #include <string> |
| #include "base/macros.h" |
| +#include "base/time/clock.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/keyed_service/core/keyed_service.h" |
| class ContentSettingsPattern; |
| +class GURL; |
| class HostContentSettingsMap; |
| class Profile; |
| +namespace base { |
| +class DictionaryValue; |
| +} // namespace base |
| + |
| // This class observes subresource filter content settings changes for metrics |
| -// collection. |
| +// collection. It is also contains helpers to get/set content settings. |
|
engedy
2017/04/12 14:02:51
nit: Swap the order. I'd argue that it is now the
Charlie Harrison
2017/04/12 17:53:45
Done.
|
| class SubresourceFilterContentSettingsManager |
| : public KeyedService, |
| public content_settings::Observer { |
| @@ -25,6 +33,25 @@ class SubresourceFilterContentSettingsManager |
| explicit SubresourceFilterContentSettingsManager(Profile* profile); |
| ~SubresourceFilterContentSettingsManager() override; |
| + ContentSetting GetContentSetting(const GURL& url) const; |
| + void SetContentSetting(const GURL& url, |
| + ContentSetting setting, |
| + bool log_metrics); |
| + void ClearContentSetting(const GURL& url); |
| + |
| + // 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 const base::TimeDelta kUIShowThresholdTime; |
|
engedy
2017/04/12 14:02:51
#include "base/time.h"
Charlie Harrison
2017/04/12 17:53:45
Done.
|
| + |
| private: |
| // KeyedService: |
| void Shutdown() override; |
| @@ -35,8 +62,23 @@ class SubresourceFilterContentSettingsManager |
| ContentSettingsType content_type, |
| std::string resource_identifier) override; |
| + std::unique_ptr<base::DictionaryValue> GetWebsiteSetting( |
| + const GURL& url) const; |
| + void SetWebsiteSetting(const GURL& url, |
| + std::unique_ptr<base::DictionaryValue> dict); |
| + |
| 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. |
| + bool ignore_settings_changes_ = false; |
| + |
| + const bool should_use_smart_ui_ = false; |
| + |
| DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager); |
| }; |