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_observer.h" |
14 | 15 |
15 class GURL; | 16 class GURL; |
| 17 class SubresourceFilterProfileContext; |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 class NavigationHandle; | 20 class NavigationHandle; |
19 class WebContents; | 21 class WebContents; |
20 } // namespace content | 22 } // namespace content |
21 | 23 |
22 // This enum backs a histogram. Make sure new elements are only added to the | 24 // 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. | 25 // end. Keep histograms.xml up to date with any changes. |
24 enum SubresourceFilterAction { | 26 enum SubresourceFilterAction { |
25 // Main frame navigation to a different document. | 27 // Main frame navigation to a different document. |
(...skipping 29 matching lines...) Expand all Loading... |
55 // relatively rare. | 57 // relatively rare. |
56 // TODO(crbug.com/706061): Fix this once content settings API becomes more | 58 // TODO(crbug.com/706061): Fix this once content settings API becomes more |
57 // flexible. | 59 // flexible. |
58 kActionContentSettingsWildcardUpdate, | 60 kActionContentSettingsWildcardUpdate, |
59 | 61 |
60 kActionLastEntry | 62 kActionLastEntry |
61 }; | 63 }; |
62 | 64 |
63 // Chrome implementation of SubresourceFilterClient. | 65 // Chrome implementation of SubresourceFilterClient. |
64 class ChromeSubresourceFilterClient | 66 class ChromeSubresourceFilterClient |
65 : public subresource_filter::SubresourceFilterClient { | 67 : public subresource_filter::SubresourceFilterClient, |
| 68 public content::WebContentsObserver { |
66 public: | 69 public: |
67 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); | 70 explicit ChromeSubresourceFilterClient(content::WebContents* web_contents); |
68 ~ChromeSubresourceFilterClient() override; | 71 ~ChromeSubresourceFilterClient() override; |
69 | 72 |
70 // SubresourceFilterClient: | 73 // SubresourceFilterClient: |
71 void ToggleNotificationVisibility(bool visibility) override; | 74 void ToggleNotificationVisibility(bool visibility) override; |
72 bool ShouldSuppressActivation( | 75 bool ShouldSuppressActivation( |
73 content::NavigationHandle* navigation_handle) override; | 76 content::NavigationHandle* navigation_handle) override; |
74 void WhitelistByContentSettings(const GURL& url) override; | 77 void WhitelistByContentSettings(const GURL& url) override; |
75 void WhitelistInCurrentWebContents(const GURL& url) override; | 78 void WhitelistInCurrentWebContents(const GURL& url) override; |
76 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() | 79 subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer() |
77 override; | 80 override; |
| 81 void OnPageActivated( |
| 82 const subresource_filter::ActivationState& state) override; |
78 | 83 |
79 bool did_show_ui_for_navigation() const { | 84 bool did_show_ui_for_navigation() const { |
80 return did_show_ui_for_navigation_; | 85 return did_show_ui_for_navigation_; |
81 } | 86 } |
82 | 87 |
83 static void LogAction(SubresourceFilterAction action); | 88 static void LogAction(SubresourceFilterAction action); |
84 | 89 |
85 private: | 90 private: |
| 91 // content::WebContentsObserver: |
| 92 void DidStartNavigation( |
| 93 content::NavigationHandle* navigation_handle) override; |
| 94 void WebContentsDestroyed() override; |
| 95 |
86 ContentSetting GetContentSettingForUrl(const GURL& url); | 96 ContentSetting GetContentSettingForUrl(const GURL& url); |
87 std::set<std::string> whitelisted_hosts_; | 97 std::set<std::string> whitelisted_hosts_; |
88 content::WebContents* web_contents_; | 98 |
| 99 // Owned by the profile. Must outlive this class. |
| 100 SubresourceFilterProfileContext* profile_context_; |
| 101 |
89 bool did_show_ui_for_navigation_; | 102 bool did_show_ui_for_navigation_; |
90 | 103 |
91 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); | 104 DISALLOW_COPY_AND_ASSIGN(ChromeSubresourceFilterClient); |
92 }; | 105 }; |
93 | 106 |
94 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ | 107 #endif // CHROME_BROWSER_SUBRESOURCE_FILTER_CHROME_SUBRESOURCE_FILTER_CLIENT_H_ |
OLD | NEW |