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

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: rebase on #468985 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 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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "components/content_settings/core/common/content_settings.h" 12 #include "components/content_settings/core/common/content_settings.h"
13 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h" 13 #include "components/subresource_filter/content/browser/subresource_filter_clien t.h"
14 14
15 class GURL; 15 class GURL;
16 class SubresourceFilterContentSettingsManager;
16 17
17 namespace content { 18 namespace content {
18 class NavigationHandle; 19 class NavigationHandle;
19 class WebContents; 20 class WebContents;
20 } // namespace content 21 } // namespace content
21 22
22 // This enum backs a histogram. Make sure new elements are only added to the 23 // This enum backs a histogram. Make sure new elements are only added to the
23 // end. Keep histograms.xml up to date with any changes. 24 // end. Keep histograms.xml up to date with any changes.
24 enum SubresourceFilterAction { 25 enum SubresourceFilterAction {
25 // Main frame navigation to a different document. 26 // Main frame navigation to a different document.
26 kActionNavigationStarted = 0, 27 kActionNavigationStarted = 0,
27 28
28 // Standard UI shown. On Desktop this is in the omnibox, 29 // Standard UI shown. On Desktop this is in the omnibox,
29 // On Android, it is an infobar. 30 // On Android, it is an infobar.
30 kActionUIShown, 31 kActionUIShown,
31 32
32 // On Desktop, this is a bubble. On Android it is an 33 // On Desktop, this is a bubble. On Android it is an
33 // expanded infobar. 34 // expanded infobar.
34 kActionDetailsShown, 35 kActionDetailsShown,
35 36
36 // TODO(csharrison): Log this once the link is in place. 37 // TODO(csharrison): Log this once the link is in place.
37 kActionClickedLearnMore, 38 kActionClickedLearnMore,
38 39
39 // Content settings: 40 // Content settings:
40 // 41 //
41 // Content setting updated automatically via the standard UI. 42 // Content setting updated automatically via the standard UI.
42 kActionContentSettingsBlockedFromUI, 43 kActionContentSettingsBlockedFromUI,
43 44
44 // Content settings which target specific origins (e.g. no wildcards). 45 // Content settings which target specific origins (e.g. no wildcards). These
46 // updates do not include updates from the main UI.
45 kActionContentSettingsAllowed, 47 kActionContentSettingsAllowed,
46 kActionContentSettingsBlocked, 48 kActionContentSettingsBlocked,
47 49
48 // Global settings. 50 // Global settings.
49 kActionContentSettingsAllowedGlobal, 51 kActionContentSettingsAllowedGlobal,
50 kActionContentSettingsBlockedGlobal, 52 kActionContentSettingsBlockedGlobal,
51 53
52 // A wildcard update. The current content settings API makes this a bit 54 // A wildcard update. The current content settings API makes this a bit
53 // difficult to see whether it is Block or Allow. This should not be a huge 55 // difficult to see whether it is Block or Allow. This should not be a huge
54 // problem because this can only be changed from the settings UI, which is 56 // problem because this can only be changed from the settings UI, which is
55 // relatively rare. 57 // relatively rare.
56 // TODO(crbug.com/706061): Fix this once content settings API becomes more 58 // TODO(crbug.com/706061): Fix this once content settings API becomes more
57 // flexible. 59 // flexible.
58 kActionContentSettingsWildcardUpdate, 60 kActionContentSettingsWildcardUpdate,
59 61
62 // The UI was suppressed due to "smart" logic which tries not to spam the UI
63 // on navigations on the same origin within a certain time.
64 kActionUISuppressed,
65
66 // The feature was blocked via content setting manually while smart UI was
67 // suppressing the UI. Potentially indicates that the smart UI is too
68 // aggressive if this happens frequently. This is a reported alongside
69 // kActionContentSettingsBlocked if the UI is currently in suppressed mode.
70 kActionContentSettingsBlockedWhileUISuppressed,
71
60 kActionLastEntry 72 kActionLastEntry
61 }; 73 };
62 74
63 // Chrome implementation of SubresourceFilterClient. 75 // Chrome implementation of SubresourceFilterClient.
64 class ChromeSubresourceFilterClient 76 class ChromeSubresourceFilterClient
65 : public subresource_filter::SubresourceFilterClient { 77 : public subresource_filter::SubresourceFilterClient {
66 public: 78 public:
67 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); 79 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents);
68 ~ChromeSubresourceFilterClient() override; 80 ~ChromeSubresourceFilterClient() override;
69 81
70 // SubresourceFilterClient: 82 // SubresourceFilterClient:
71 void ToggleNotificationVisibility(bool visibility) override; 83 void ToggleNotificationVisibility(bool visibility) override;
72 bool ShouldSuppressActivation( 84 bool ShouldSuppressActivation(
73 content::NavigationHandle* navigation_handle) override; 85 content::NavigationHandle* navigation_handle) override;
74 void WhitelistByContentSettings(const GURL& url) override; 86 void WhitelistByContentSettings(const GURL& url) override;
75 void WhitelistInCurrentWebContents(const GURL& url) override; 87 void WhitelistInCurrentWebContents(const GURL& url) override;
76 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() 88 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer()
77 override; 89 override;
78 90
79 bool did_show_ui_for_navigation() const { 91 bool did_show_ui_for_navigation() const {
80 return did_show_ui_for_navigation_; 92 return did_show_ui_for_navigation_;
81 } 93 }
82 94
83 static void LogAction(SubresourceFilterAction action); 95 static void LogAction(SubresourceFilterAction action);
84 96
85 private: 97 private:
86 ContentSetting GetContentSettingForUrl(const GURL& url);
87 std::set<std::string> whitelisted_hosts_; 98 std::set<std::string> whitelisted_hosts_;
99
100 // Owned by the profile.
101 SubresourceFilterContentSettingsManager* settings_manager_;
102
88 content::WebContents* web_contents_; 103 content::WebContents* web_contents_;
89 bool did_show_ui_for_navigation_; 104 bool did_show_ui_for_navigation_;
90 105
91 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); 106 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient);
92 }; 107 };
93 108
94 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ 109 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698