Chromium Code Reviews| 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, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 46 kActionContentSettingsBlockedGlobal, | 47 kActionContentSettingsBlockedGlobal, |
| 47 | 48 |
| 48 // A wildcard update. The current content settings API makes this a bit | 49 // 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 | 50 // 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 | 51 // problem because this can only be changed from the settings UI, which is |
| 51 // relatively rare. | 52 // relatively rare. |
| 52 // TODO(crbug.com/706061): Fix this once content settings API becomes more | 53 // TODO(crbug.com/706061): Fix this once content settings API becomes more |
| 53 // flexible. | 54 // flexible. |
| 54 kActionContentSettingsWildcardUpdate, | 55 kActionContentSettingsWildcardUpdate, |
| 55 | 56 |
| 57 // The UI was suppressed due to "smart" logic which tries not to spam the UI | |
| 58 // on navigations within a certain time period. | |
|
engedy
2017/04/12 14:02:50
nit: How about:
// on navigations on the same ori
Charlie Harrison
2017/04/12 17:53:44
Done.
| |
| 59 kActionUISuppressed, | |
| 60 | |
| 61 // The feature was blocked via content setting manually while smart UI was | |
| 62 // suppressing the UI. Potentially indicates that the smart UI is too | |
| 63 // aggressive if this happens frequently. This is a subset of | |
| 64 // kActionContentSettingsBlcoked. | |
|
engedy
2017/04/12 14:02:50
nit: typo
nit: Clarify what `being a subset` means
Charlie Harrison
2017/04/12 17:53:44
Done.
| |
| 65 kActionContentSettingsBlockedWhileUISuppressed, | |
| 66 | |
| 56 kActionLastEntry | 67 kActionLastEntry |
| 57 }; | 68 }; |
| 58 | 69 |
| 59 // Chrome implementation of SubresourceFilterClient. | 70 // Chrome implementation of SubresourceFilterClient. |
| 60 class ChromeSubresourceFilterClient | 71 class ChromeSubresourceFilterClient |
| 61 : public subresource_filter::SubresourceFilterClient { | 72 : public subresource_filter::SubresourceFilterClient { |
| 62 public: | 73 public: |
| 63 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); | 74 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); |
| 64 ~ChromeSubresourceFilterClient() override; | 75 ~ChromeSubresourceFilterClient() override; |
| 65 | 76 |
| 66 // SubresourceFilterClient: | 77 // SubresourceFilterClient: |
| 67 void ToggleNotificationVisibility(bool visibility) override; | 78 void ToggleNotificationVisibility(bool visibility) override; |
| 68 bool IsWhitelistedByContentSettings(const GURL& url) override; | 79 bool IsWhitelistedByContentSettings(const GURL& url) override; |
| 69 void WhitelistByContentSettings(const GURL& url) override; | 80 void WhitelistByContentSettings(const GURL& url) override; |
| 70 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() | 81 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() |
| 71 override; | 82 override; |
| 83 void OnActivationComputed( | |
| 84 const GURL& url, | |
| 85 const subresource_filter::ActivationState& state) override; | |
| 72 | 86 |
| 73 static void LogAction(SubresourceFilterAction action); | 87 static void LogAction(SubresourceFilterAction action); |
| 74 | 88 |
| 89 bool shown_for_navigation() const { return shown_for_navigation_; } | |
| 90 | |
| 75 private: | 91 private: |
| 76 ContentSetting GetContentSettingForUrl(const GURL& url); | 92 void OnDidShowUI(const GURL& url); |
| 93 | |
| 94 // Owned by the profile. | |
| 95 SubresourceFilterContentSettingsManager* settings_manager_; | |
| 96 | |
| 77 content::WebContents* web_contents_; | 97 content::WebContents* web_contents_; |
| 78 bool shown_for_navigation_; | 98 bool shown_for_navigation_; |
| 79 | 99 |
| 80 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); | 100 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); |
| 81 }; | 101 }; |
| 82 | 102 |
| 83 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ | 103 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ |
| OLD | NEW |