Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/subresource_filter/subresource_filter_content_settings_manager.h

Issue 2859783002: [subresource_filter] Make website setting existence imply site activation (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MA NAGER_H_ 5 #ifndef CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MA NAGER_H_
6 #define CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MA NAGER_H_ 6 #define CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS_MA NAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 30 matching lines...) Expand all
41 public: 41 public:
42 explicit SubresourceFilterContentSettingsManager(Profile* profile); 42 explicit SubresourceFilterContentSettingsManager(Profile* profile);
43 ~SubresourceFilterContentSettingsManager() override; 43 ~SubresourceFilterContentSettingsManager() override;
44 44
45 ContentSetting GetSitePermission(const GURL& url) const; 45 ContentSetting GetSitePermission(const GURL& url) const;
46 46
47 // Only called via direct user action on via the subresource filter UI. Sets 47 // Only called via direct user action on via the subresource filter UI. Sets
48 // the content setting to turn off the subresource filter. 48 // the content setting to turn off the subresource filter.
49 void WhitelistSite(const GURL& url); 49 void WhitelistSite(const GURL& url);
50 50
51 // Public for testing.
52 std::unique_ptr<base::DictionaryValue> GetSiteMetadata(const GURL& url) const;
53
51 // Specific logic for more intelligent UI. 54 // Specific logic for more intelligent UI.
52 void OnDidShowUI(const GURL& url); 55 void OnDidShowUI(const GURL& url);
53 bool ShouldShowUIForSite(const GURL& url) const; 56 bool ShouldShowUIForSite(const GURL& url) const;
54 bool should_use_smart_ui() const { return should_use_smart_ui_; } 57 bool should_use_smart_ui() const { return should_use_smart_ui_; }
55 58
59 void ClearSiteMetadata(const GURL& url);
60
56 void set_clock_for_testing(std::unique_ptr<base::Clock> tick_clock) { 61 void set_clock_for_testing(std::unique_ptr<base::Clock> tick_clock) {
57 clock_ = std::move(tick_clock); 62 clock_ = std::move(tick_clock);
58 } 63 }
59 64
60 // Time before showing the UI again on a domain. 65 // Time before showing the UI again on a domain.
61 // TODO(csharrison): Consider setting this via a finch param. 66 // TODO(csharrison): Consider setting this via a finch param.
62 static constexpr base::TimeDelta kDelayBeforeShowingInfobarAgain = 67 static constexpr base::TimeDelta kDelayBeforeShowingInfobarAgain =
63 base::TimeDelta::FromMinutes(30); 68 base::TimeDelta::FromMinutes(30);
64 69
65 private: 70 private:
66 // content_settings::Observer: 71 // content_settings::Observer:
67 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 72 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
68 const ContentSettingsPattern& secondary_pattern, 73 const ContentSettingsPattern& secondary_pattern,
69 ContentSettingsType content_type, 74 ContentSettingsType content_type,
70 std::string resource_identifier) override; 75 std::string resource_identifier) override;
71 76
72 // history::HistoryServiceObserver: 77 // history::HistoryServiceObserver:
73 void OnURLsDeleted(history::HistoryService* history_service, 78 void OnURLsDeleted(history::HistoryService* history_service,
74 bool all_history, 79 bool all_history,
75 bool expired, 80 bool expired,
76 const history::URLRows& deleted_rows, 81 const history::URLRows& deleted_rows,
77 const std::set<GURL>& favicon_urls) override; 82 const std::set<GURL>& favicon_urls) override;
78 83
79 std::unique_ptr<base::DictionaryValue> GetSiteMetadata(const GURL& url) const;
80 void SetSiteMetadata(const GURL& url, 84 void SetSiteMetadata(const GURL& url,
81 std::unique_ptr<base::DictionaryValue> dict); 85 std::unique_ptr<base::DictionaryValue> dict);
82 86
83 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> 87 ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
84 history_observer_; 88 history_observer_;
85 89
86 HostContentSettingsMap* settings_map_; 90 HostContentSettingsMap* settings_map_;
87 91
88 // A clock is injected into this class so tests can set arbitrary timestamps 92 // A clock is injected into this class so tests can set arbitrary timestamps
89 // in website settings. 93 // in website settings.
90 std::unique_ptr<base::Clock> clock_; 94 std::unique_ptr<base::Clock> clock_;
91 95
92 // Used internally so the class ignores changes to the settings that are not 96 // Used internally so the class ignores changes to the settings that are not
93 // user initiated through the settings UI. 97 // user initiated through the settings UI.
94 bool ignore_settings_changes_ = false; 98 bool ignore_settings_changes_ = false;
95 99
96 const bool should_use_smart_ui_ = false; 100 const bool should_use_smart_ui_ = false;
97 101
98 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager); 102 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager);
99 }; 103 };
100 104
101 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS _MANAGER_H_ 105 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS _MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698