OLD | NEW |
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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/content_settings/core/common/content_settings.h" |
9 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" | 10 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" |
10 | 11 |
| 12 class GURL; |
| 13 |
11 namespace content { | 14 namespace content { |
12 class WebContents; | 15 class WebContents; |
13 } // namespace content | 16 } // namespace content |
14 | 17 |
| 18 // 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. |
| 20 enum SubresourceFilterAction { |
| 21 // Main frame navigation to a different document. |
| 22 kActionNavigationStarted = 0, |
| 23 |
| 24 // Standard UI shown. On Desktop this is in the omnibox, |
| 25 // On Android, it is an infobar. |
| 26 kActionUIShown, |
| 27 |
| 28 // On Desktop, this is a bubble. On Android it is an |
| 29 // expanded infobar. |
| 30 // TODO(csharrison): Start logging these once the new UI is finished. |
| 31 kActionDetailsShown, |
| 32 kActionClickedLearnMore, |
| 33 |
| 34 // Content settings: |
| 35 // |
| 36 // Content setting updated automatically via the standard UI. |
| 37 kActionContentSettingsBlockedFromUI, |
| 38 |
| 39 // Content settings which target specific origins (e.g. no wildcards). |
| 40 kActionContentSettingsAllowed, |
| 41 kActionContentSettingsBlocked, |
| 42 |
| 43 // Global settings. |
| 44 kActionContentSettingsAllowedGlobal, |
| 45 kActionContentSettingsBlockedGlobal, |
| 46 |
| 47 // 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 |
| 49 // problem because this can only be changed from the settings UI, which is |
| 50 // relatively rare. |
| 51 // TODO(crbug.com/706061): Fix this once content settings API becomes more |
| 52 // flexible. |
| 53 kActionContentSettingsWildcardUpdate, |
| 54 |
| 55 kActionLastEntry |
| 56 }; |
| 57 |
15 // Chrome implementation of SubresourceFilterClient. | 58 // Chrome implementation of SubresourceFilterClient. |
16 class ChromeSubresourceFilterClient | 59 class ChromeSubresourceFilterClient |
17 : public subresource_filter::SubresourceFilterClient { | 60 : public subresource_filter::SubresourceFilterClient { |
18 public: | 61 public: |
19 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); | 62 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); |
20 ~ChromeSubresourceFilterClient() override; | 63 ~ChromeSubresourceFilterClient() override; |
21 | 64 |
22 // SubresourceFilterClient: | 65 // SubresourceFilterClient: |
23 void ToggleNotificationVisibility(bool visibility) override; | 66 void ToggleNotificationVisibility(bool visibility) override; |
24 bool IsWhitelistedByContentSettings(const GURL& url) override; | 67 bool IsWhitelistedByContentSettings(const GURL& url) override; |
25 void WhitelistByContentSettings(const GURL& url) override; | 68 void WhitelistByContentSettings(const GURL& url) override; |
26 | 69 |
| 70 static void LogAction(SubresourceFilterAction action); |
| 71 |
27 private: | 72 private: |
| 73 ContentSetting GetContentSettingForUrl(const GURL& url); |
28 content::WebContents* web_contents_; | 74 content::WebContents* web_contents_; |
29 bool shown_for_navigation_; | 75 bool shown_for_navigation_; |
30 | 76 |
31 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); | 77 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); |
32 }; | 78 }; |
33 | 79 |
34 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ | 80 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ |
OLD | NEW |