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