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 <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 #include "content/public/browser/web_contents_user_data.h" |
14 | 15 |
15 class GURL; | 16 class GURL; |
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. |
(...skipping 30 matching lines...) Expand all Loading... |
54 // problem because this can only be changed from the settings UI, which is | 55 // problem because this can only be changed from the settings UI, which is |
55 // relatively rare. | 56 // relatively rare. |
56 // TODO(crbug.com/706061): Fix this once content settings API becomes more | 57 // TODO(crbug.com/706061): Fix this once content settings API becomes more |
57 // flexible. | 58 // flexible. |
58 kActionContentSettingsWildcardUpdate, | 59 kActionContentSettingsWildcardUpdate, |
59 | 60 |
60 kActionLastEntry | 61 kActionLastEntry |
61 }; | 62 }; |
62 | 63 |
63 // Chrome implementation of SubresourceFilterClient. | 64 // Chrome implementation of SubresourceFilterClient. |
| 65 // TODO(csharrison): Make this a WebContentsObserver and own the throttle |
| 66 // manager directly. |
64 class ChromeSubresourceFilterClient | 67 class ChromeSubresourceFilterClient |
65 : public subresource_filter::SubresourceFilterClient { | 68 : public content::WebContentsUserData<ChromeSubresourceFilterClient>, |
| 69 public subresource_filter::SubresourceFilterClient { |
66 public: | 70 public: |
67 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); | 71 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); |
68 ~ChromeSubresourceFilterClient() override; | 72 ~ChromeSubresourceFilterClient() override; |
69 | 73 |
70 // SubresourceFilterClient: | 74 // SubresourceFilterClient: |
71 void ToggleNotificationVisibility(bool visibility) override; | 75 void ToggleNotificationVisibility(bool visibility) override; |
72 bool ShouldSuppressActivation( | 76 bool ShouldSuppressActivation( |
73 content::NavigationHandle* navigation_handle) override; | 77 content::NavigationHandle* navigation_handle) override; |
74 void WhitelistByContentSettings(const GURL& url) override; | 78 void WhitelistByContentSettings(const GURL& url) override; |
75 void WhitelistInCurrentWebContents(const GURL& url) override; | 79 void WhitelistInCurrentWebContents(const GURL& url) override; |
76 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() | 80 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() |
77 override; | 81 override; |
78 | 82 |
79 bool did_show_ui_for_navigation() const { | 83 bool did_show_ui_for_navigation() const { |
80 return did_show_ui_for_navigation_; | 84 return did_show_ui_for_navigation_; |
81 } | 85 } |
82 | 86 |
83 static void LogAction(SubresourceFilterAction action); | 87 static void LogAction(SubresourceFilterAction action); |
84 | 88 |
85 private: | 89 private: |
86 ContentSetting GetContentSettingForUrl(const GURL& url); | 90 ContentSetting GetContentSettingForUrl(const GURL& url); |
87 std::set<std::string> whitelisted_hosts_; | 91 std::set<std::string> whitelisted_hosts_; |
88 content::WebContents* web_contents_; | 92 content::WebContents* web_contents_; |
89 bool did_show_ui_for_navigation_; | 93 bool did_show_ui_for_navigation_; |
90 | 94 |
91 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); | 95 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); |
92 }; | 96 }; |
93 | 97 |
94 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ | 98 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ |
OLD | NEW |