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

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

Issue 2795053002: [subresource_filter] Implement the "Smart" UI on Android (Closed)
Patch Set: fix tests 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ 5 #ifndef CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_
6 #define CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ 6 #define CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/time/clock.h"
9 #include "components/content_settings/core/common/content_settings.h" 12 #include "components/content_settings/core/common/content_settings.h"
10 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h" 13 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h"
11 14
12 class GURL; 15 class GURL;
16 class HostContentSettingsMap;
13 17
14 namespace content { 18 namespace content {
15 class WebContents; 19 class WebContents;
16 } // namespace content 20 } // namespace content
17 21
18 // This enum backs a histogram. Make sure new elements are only added to the 22 // This enum backs a histogram. Make sure new elements are only added to the
19 // end. Keep histograms.xml up to date with any changes. 23 // end. Keep histograms.xml up to date with any changes.
20 enum SubresourceFilterAction { 24 enum SubresourceFilterAction {
21 // Main frame navigation to a different document. 25 // Main frame navigation to a different document.
22 kActionNavigationStarted = 0, 26 kActionNavigationStarted = 0,
(...skipping 22 matching lines...) Expand all
45 kActionContentSettingsBlockedGlobal, 49 kActionContentSettingsBlockedGlobal,
46 50
47 // A wildcard update. The current content settings API makes this a bit 51 // A wildcard update. The current content settings API makes this a bit
48 // difficult to see whether it is Block or Allow. This should not be a huge 52 // difficult to see whether it is Block or Allow. This should not be a huge
49 // problem because this can only be changed from the settings UI, which is 53 // problem because this can only be changed from the settings UI, which is
50 // relatively rare. 54 // relatively rare.
51 // TODO(crbug.com/706061): Fix this once content settings API becomes more 55 // TODO(crbug.com/706061): Fix this once content settings API becomes more
52 // flexible. 56 // flexible.
53 kActionContentSettingsWildcardUpdate, 57 kActionContentSettingsWildcardUpdate,
54 58
59 // The UI was suppressed due to "smart" logic which tries not to spam the UI
60 // on navigations within a certain time period.
61 kActionUISuppressed,
62
55 kActionLastEntry 63 kActionLastEntry
56 }; 64 };
57 65
58 // Chrome implementation of SubresourceFilterClient. 66 // Chrome implementation of SubresourceFilterClient.
59 class ChromeSubresourceFilterClient 67 class ChromeSubresourceFilterClient
60 : public subresource_filter::SubresourceFilterClient { 68 : public subresource_filter::SubresourceFilterClient {
61 public: 69 public:
62 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); 70 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents);
63 ~ChromeSubresourceFilterClient() override; 71 ~ChromeSubresourceFilterClient() override;
64 72
65 // SubresourceFilterClient: 73 // SubresourceFilterClient:
66 void ToggleNotificationVisibility(bool visibility) override; 74 void ToggleNotificationVisibility(const GURL& url, bool visibility) override;
67 bool IsWhitelistedByContentSettings(const GURL& url) override; 75 bool IsWhitelistedByContentSettings(const GURL& url) override;
68 void WhitelistByContentSettings(const GURL& url) override; 76 void WhitelistByContentSettings(const GURL& url) override;
69 77
70 static void LogAction(SubresourceFilterAction action); 78 static void LogAction(SubresourceFilterAction action);
71 79
80 bool UsingSmartUI() const;
81
82 void set_clock_for_testing(std::unique_ptr<base::Clock> tick_clock) {
engedy 2017/04/04 13:36:00 nit: Have you considered supplying this in the cto
Charlie Harrison 2017/04/10 14:58:53 Yeah, but it isn't ideal, because we want to reset
engedy 2017/04/12 14:02:50 Acknowledged.
83 clock_ = std::move(tick_clock);
84 }
85
86 bool shown_for_navigation() const { return shown_for_navigation_; }
87
72 private: 88 private:
73 ContentSetting GetContentSettingForUrl(const GURL& url); 89 // Android specific logic for more intelligent UI.
90 void OnUIShown(const GURL& url);
engedy 2017/04/04 13:36:00 nit: How about OnDidShowUI?
Charlie Harrison 2017/04/10 14:58:53 Done.
91 bool ShouldShowUIForSite(const GURL& url) const;
92
93 HostContentSettingsMap* GetSettingsMap() const;
94
95 // For testing.
engedy 2017/04/04 13:35:59 nit: I find this comment a bit misleading, as this
Charlie Harrison 2017/04/10 14:58:53 Updated the comment.
96 std::unique_ptr<base::Clock> clock_;
97
74 content::WebContents* web_contents_; 98 content::WebContents* web_contents_;
75 bool shown_for_navigation_; 99 bool shown_for_navigation_;
76 100
77 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); 101 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient);
78 }; 102 };
79 103
80 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ 104 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698