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 #include "chrome/browser/subresource_filter/chrome_subresource_filter_client.h" | 5 #include "chrome/browser/subresource_filter/chrome_subresource_filter_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER); | 109 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER); |
110 | 110 |
111 LogAction(kActionUIShown); | 111 LogAction(kActionUIShown); |
112 did_show_ui_for_navigation_ = true; | 112 did_show_ui_for_navigation_ = true; |
113 settings_manager_->OnDidShowUI(top_level_url); | 113 settings_manager_->OnDidShowUI(top_level_url); |
114 } else { | 114 } else { |
115 LogAction(kActionNavigationStarted); | 115 LogAction(kActionNavigationStarted); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 bool ChromeSubresourceFilterClient::ShouldSuppressActivation( | 119 bool ChromeSubresourceFilterClient::OnPageActivationComputed( |
120 content::NavigationHandle* navigation_handle) { | 120 content::NavigationHandle* navigation_handle, |
| 121 bool activated) { |
121 const GURL& url(navigation_handle->GetURL()); | 122 const GURL& url(navigation_handle->GetURL()); |
122 return navigation_handle->IsInMainFrame() && | 123 DCHECK(navigation_handle->IsInMainFrame()); |
123 (whitelisted_hosts_.find(url.host()) != whitelisted_hosts_.end() || | 124 // Return whether the activation should be whitelisted. |
124 settings_manager_->GetSitePermission(url) == CONTENT_SETTING_BLOCK); | 125 return whitelisted_hosts_.count(url.host()) || |
| 126 settings_manager_->GetSitePermission(url) == CONTENT_SETTING_BLOCK; |
125 } | 127 } |
126 | 128 |
127 void ChromeSubresourceFilterClient::WhitelistByContentSettings( | 129 void ChromeSubresourceFilterClient::WhitelistByContentSettings( |
128 const GURL& top_level_url) { | 130 const GURL& top_level_url) { |
129 settings_manager_->WhitelistSite(top_level_url); | 131 settings_manager_->WhitelistSite(top_level_url); |
130 } | 132 } |
131 | 133 |
132 void ChromeSubresourceFilterClient::WhitelistInCurrentWebContents( | 134 void ChromeSubresourceFilterClient::WhitelistInCurrentWebContents( |
133 const GURL& url) { | 135 const GURL& url) { |
134 if (url.SchemeIsHTTPOrHTTPS()) | 136 if (url.SchemeIsHTTPOrHTTPS()) |
135 whitelisted_hosts_.insert(url.host()); | 137 whitelisted_hosts_.insert(url.host()); |
136 } | 138 } |
137 | 139 |
138 // static | 140 // static |
139 void ChromeSubresourceFilterClient::LogAction(SubresourceFilterAction action) { | 141 void ChromeSubresourceFilterClient::LogAction(SubresourceFilterAction action) { |
140 UMA_HISTOGRAM_ENUMERATION("SubresourceFilter.Actions", action, | 142 UMA_HISTOGRAM_ENUMERATION("SubresourceFilter.Actions", action, |
141 kActionLastEntry); | 143 kActionLastEntry); |
142 } | 144 } |
143 | 145 |
144 subresource_filter::VerifiedRulesetDealer::Handle* | 146 subresource_filter::VerifiedRulesetDealer::Handle* |
145 ChromeSubresourceFilterClient::GetRulesetDealer() { | 147 ChromeSubresourceFilterClient::GetRulesetDealer() { |
146 subresource_filter::ContentRulesetService* ruleset_service = | 148 subresource_filter::ContentRulesetService* ruleset_service = |
147 g_browser_process->subresource_filter_ruleset_service(); | 149 g_browser_process->subresource_filter_ruleset_service(); |
148 return ruleset_service ? ruleset_service->ruleset_dealer() : nullptr; | 150 return ruleset_service ? ruleset_service->ruleset_dealer() : nullptr; |
149 } | 151 } |
OLD | NEW |