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

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

Issue 2795053002: [subresource_filter] Implement the "Smart" UI on Android (Closed)
Patch Set: rebase Created 3 years, 8 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>
9 #include <set>
8 #include <string> 10 #include <string>
11 #include <utility>
9 12
10 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/scoped_observer.h"
15 #include "base/time/clock.h"
16 #include "base/time/time.h"
11 #include "components/content_settings/core/browser/content_settings_observer.h" 17 #include "components/content_settings/core/browser/content_settings_observer.h"
18 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/content_settings/core/common/content_settings_types.h" 19 #include "components/content_settings/core/common/content_settings_types.h"
20 #include "components/history/core/browser/history_service_observer.h"
13 21
14 class ContentSettingsPattern; 22 class ContentSettingsPattern;
23 class GURL;
15 class HostContentSettingsMap; 24 class HostContentSettingsMap;
16 class Profile; 25 class Profile;
17 26
18 // This class observes subresource filter content settings changes for metrics 27 namespace base {
19 // collection. 28 class DictionaryValue;
29 } // namespace base
30
31 namespace history {
32 class HistoryService;
33 } // namespace history
34
35 // This class contains helpers to get/set content and website settings related
36 // to subresource filtering. It also observes content setting changes for
37 // metrics collection.
20 class SubresourceFilterContentSettingsManager 38 class SubresourceFilterContentSettingsManager
21 : public content_settings::Observer { 39 : public content_settings::Observer,
40 public history::HistoryServiceObserver {
22 public: 41 public:
23 explicit SubresourceFilterContentSettingsManager(Profile* profile); 42 explicit SubresourceFilterContentSettingsManager(Profile* profile);
24 ~SubresourceFilterContentSettingsManager() override; 43 ~SubresourceFilterContentSettingsManager() override;
25 44
45 ContentSetting GetSitePermission(const GURL& url) const;
46 void SetSitePermission(const GURL& url, ContentSetting setting, bool from_ui);
47
48 // Specific logic for more intelligent UI.
49 void OnDidShowUI(const GURL& url);
50 bool ShouldShowUIForSite(const GURL& url) const;
51 bool should_use_smart_ui() const { return should_use_smart_ui_; }
52
53 void set_clock_for_testing(std::unique_ptr<base::Clock> tick_clock) {
54 clock_ = std::move(tick_clock);
55 }
56
57 // Time before showing the UI again on a domain.
58 // TODO(csharrison): Consider setting this via a finch param.
59 static constexpr base::TimeDelta kDelayBeforeShowingInfobarAgain =
60 base::TimeDelta::FromMinutes(30);
61
26 private: 62 private:
27 // content_settings::Observer: 63 // content_settings::Observer:
28 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 64 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
29 const ContentSettingsPattern& secondary_pattern, 65 const ContentSettingsPattern& secondary_pattern,
30 ContentSettingsType content_type, 66 ContentSettingsType content_type,
31 std::string resource_identifier) override; 67 std::string resource_identifier) override;
32 68
69 // history::HistoryServiceObserver:
70 void OnURLsDeleted(history::HistoryService* history_service,
71 bool all_history,
72 bool expired,
73 const history::URLRows& deleted_rows,
74 const std::set<GURL>& favicon_urls) override;
75
76 std::unique_ptr<base::DictionaryValue> GetSiteMetadata(const GURL& url) const;
77 void SetSiteMetadata(const GURL& url,
78 std::unique_ptr<base::DictionaryValue> dict);
79
80 ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
81 history_observer_;
82
33 HostContentSettingsMap* settings_map_; 83 HostContentSettingsMap* settings_map_;
34 84
85 // A clock is injected into this class so tests can set arbitrary timestamps
86 // in website settings.
87 std::unique_ptr<base::Clock> clock_;
88
89 // Used internally so the class ignores changes to the settings that are not
90 // user initiated through the settings UI.
91 bool ignore_settings_changes_ = false;
92
93 const bool should_use_smart_ui_ = false;
94
35 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager); 95 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager);
36 }; 96 };
37 97
38 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS _MANAGER_H_ 98 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS _MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698