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 <memory> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
| 11 #include <vector> |
10 | 12 |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "components/content_settings/core/common/content_settings.h" | 14 #include "components/content_settings/core/common/content_settings.h" |
13 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" | 15 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 16 #include "content/public/browser/web_contents_user_data.h" |
15 | 17 |
16 class GURL; | 18 class GURL; |
17 | 19 |
18 namespace content { | 20 namespace content { |
19 class NavigationHandle; | 21 class NavigationHandle; |
| 22 class NavigationThrottle; |
20 class WebContents; | 23 class WebContents; |
21 } // namespace content | 24 } // namespace content |
22 | 25 |
23 // This enum backs a histogram. Make sure new elements are only added to the | 26 // This enum backs a histogram. Make sure new elements are only added to the |
24 // end. Keep histograms.xml up to date with any changes. | 27 // end. Keep histograms.xml up to date with any changes. |
25 enum SubresourceFilterAction { | 28 enum SubresourceFilterAction { |
26 // Main frame navigation to a different document. | 29 // Main frame navigation to a different document. |
27 kActionNavigationStarted = 0, | 30 kActionNavigationStarted = 0, |
28 | 31 |
29 // Standard UI shown. On Desktop this is in the omnibox, | 32 // Standard UI shown. On Desktop this is in the omnibox, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Chrome implementation of SubresourceFilterClient. | 67 // Chrome implementation of SubresourceFilterClient. |
65 // TODO(csharrison): Make this a WebContentsObserver and own the throttle | 68 // TODO(csharrison): Make this a WebContentsObserver and own the throttle |
66 // manager directly. | 69 // manager directly. |
67 class ChromeSubresourceFilterClient | 70 class ChromeSubresourceFilterClient |
68 : public content::WebContentsUserData<ChromeSubresourceFilterClient>, | 71 : public content::WebContentsUserData<ChromeSubresourceFilterClient>, |
69 public subresource_filter::SubresourceFilterClient { | 72 public subresource_filter::SubresourceFilterClient { |
70 public: | 73 public: |
71 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); | 74 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); |
72 ~ChromeSubresourceFilterClient() override; | 75 ~ChromeSubresourceFilterClient() override; |
73 | 76 |
| 77 void MaybeAppendNavigationThrottles( |
| 78 content::NavigationHandle* navigation_handle, |
| 79 std::vector<std::unique_ptr<content::NavigationThrottle>>* throttles); |
| 80 |
74 // SubresourceFilterClient: | 81 // SubresourceFilterClient: |
75 void ToggleNotificationVisibility(bool visibility) override; | 82 void ToggleNotificationVisibility(bool visibility) override; |
76 bool ShouldSuppressActivation( | 83 bool ShouldSuppressActivation( |
77 content::NavigationHandle* navigation_handle) override; | 84 content::NavigationHandle* navigation_handle) override; |
78 void WhitelistByContentSettings(const GURL& url) override; | 85 void WhitelistByContentSettings(const GURL& url) override; |
79 void WhitelistInCurrentWebContents(const GURL& url) override; | 86 void WhitelistInCurrentWebContents(const GURL& url) override; |
80 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() | 87 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() |
81 override; | 88 override; |
82 | 89 |
83 bool did_show_ui_for_navigation() const { | 90 bool did_show_ui_for_navigation() const { |
84 return did_show_ui_for_navigation_; | 91 return did_show_ui_for_navigation_; |
85 } | 92 } |
86 | 93 |
87 static void LogAction(SubresourceFilterAction action); | 94 static void LogAction(SubresourceFilterAction action); |
88 | 95 |
89 private: | 96 private: |
90 ContentSetting GetContentSettingForUrl(const GURL& url); | 97 ContentSetting GetContentSettingForUrl(const GURL& url); |
91 std::set<std::string> whitelisted_hosts_; | 98 std::set<std::string> whitelisted_hosts_; |
92 content::WebContents* web_contents_; | 99 content::WebContents* web_contents_; |
93 bool did_show_ui_for_navigation_; | 100 bool did_show_ui_for_navigation_; |
94 | 101 |
95 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); | 102 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); |
96 }; | 103 }; |
97 | 104 |
98 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ | 105 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ |
OLD | NEW |