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

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: raymes review 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>
8 #include <string> 9 #include <string>
10 #include <utility>
9 11
10 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/time/clock.h"
14 #include "base/time/time.h"
11 #include "components/content_settings/core/browser/content_settings_observer.h" 15 #include "components/content_settings/core/browser/content_settings_observer.h"
16 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/content_settings/core/common/content_settings_types.h" 17 #include "components/content_settings/core/common/content_settings_types.h"
13 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
14 19
15 class ContentSettingsPattern; 20 class ContentSettingsPattern;
21 class GURL;
16 class HostContentSettingsMap; 22 class HostContentSettingsMap;
17 class Profile; 23 class Profile;
18 24
19 // This class observes subresource filter content settings changes for metrics 25 namespace base {
20 // collection. 26 class DictionaryValue;
27 } // namespace base
28
29 // This class contains helpers to get/set content and website settings related
30 // to subresource filtering. It also observes content setting changes for
31 // metrics collection.
21 class SubresourceFilterContentSettingsManager 32 class SubresourceFilterContentSettingsManager
22 : public KeyedService, 33 : public KeyedService,
23 public content_settings::Observer { 34 public content_settings::Observer {
msramek 2017/04/13 16:08:27 Also HistoryServiceObserver and please delete the
Charlie Harrison 2017/04/13 17:54:01 Done + some tests.
24 public: 35 public:
25 explicit SubresourceFilterContentSettingsManager(Profile* profile); 36 explicit SubresourceFilterContentSettingsManager(Profile* profile);
26 ~SubresourceFilterContentSettingsManager() override; 37 ~SubresourceFilterContentSettingsManager() override;
27 38
39 ContentSetting GetContentSetting(const GURL& url) const;
40 void SetContentSetting(const GURL& url, ContentSetting setting, bool from_ui);
41 void ClearContentSetting(const GURL& url);
42
43 // Specific logic for more intelligent UI.
44 void OnDidShowUI(const GURL& url);
45 bool ShouldShowUIForSite(const GURL& url) const;
46 bool should_use_smart_ui() const { return should_use_smart_ui_; }
47
48 void set_clock_for_testing(std::unique_ptr<base::Clock> tick_clock) {
49 clock_ = std::move(tick_clock);
50 }
51
52 // Time before showing the UI again on a domain.
53 // TODO(csharrison): Consider setting this via a finch param.
54 static const base::TimeDelta kDelayBeforeShowingInfobarAgain;
jkarlin 2017/04/13 12:57:18 static duration variables must be POD
engedy 2017/04/13 13:23:32 The fashionable thing to do nowadays is to make th
jkarlin 2017/04/13 14:02:33 Good point, and https://groups.google.com/a/chromi
55
28 private: 56 private:
29 // KeyedService: 57 // KeyedService:
30 void Shutdown() override; 58 void Shutdown() override;
31 59
32 // content_settings::Observer: 60 // content_settings::Observer:
33 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 61 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
34 const ContentSettingsPattern& secondary_pattern, 62 const ContentSettingsPattern& secondary_pattern,
35 ContentSettingsType content_type, 63 ContentSettingsType content_type,
36 std::string resource_identifier) override; 64 std::string resource_identifier) override;
37 65
66 std::unique_ptr<base::DictionaryValue> GetWebsiteSetting(
67 const GURL& url) const;
68 void SetWebsiteSetting(const GURL& url,
69 std::unique_ptr<base::DictionaryValue> dict);
70
38 HostContentSettingsMap* settings_map_; 71 HostContentSettingsMap* settings_map_;
39 72
73 // A clock is injected into this class so tests can set arbitrary timestamps
74 // in website settings.
75 std::unique_ptr<base::Clock> clock_;
76
77 // Used internally so the class ignores changes to the settings that are not
78 // user initiated through the settings UI.
79 bool ignore_settings_changes_ = false;
80
81 const bool should_use_smart_ui_ = false;
82
40 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager); 83 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterContentSettingsManager);
41 }; 84 };
42 85
43 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS _MANAGER_H_ 86 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_SUBRESOURCE_FILTER_CONTENT_SETTINGS _MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698