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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.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()); |
| 124 // Return whether the activation should be whitelisted. |
| 125 return activated && |
123 (whitelisted_hosts_.find(url.host()) != whitelisted_hosts_.end() || | 126 (whitelisted_hosts_.find(url.host()) != whitelisted_hosts_.end() || |
124 settings_manager_->GetSitePermission(url) == CONTENT_SETTING_BLOCK); | 127 settings_manager_->GetSitePermission(url) == CONTENT_SETTING_BLOCK); |
125 } | 128 } |
126 | 129 |
127 void ChromeSubresourceFilterClient::WhitelistByContentSettings( | 130 void ChromeSubresourceFilterClient::WhitelistByContentSettings( |
128 const GURL& top_level_url) { | 131 const GURL& top_level_url) { |
129 settings_manager_->WhitelistSite(top_level_url); | 132 settings_manager_->WhitelistSite(top_level_url); |
130 } | 133 } |
131 | 134 |
132 void ChromeSubresourceFilterClient::WhitelistInCurrentWebContents( | 135 void ChromeSubresourceFilterClient::WhitelistInCurrentWebContents( |
133 const GURL& url) { | 136 const GURL& url) { |
134 if (url.SchemeIsHTTPOrHTTPS()) | 137 if (url.SchemeIsHTTPOrHTTPS()) |
135 whitelisted_hosts_.insert(url.host()); | 138 whitelisted_hosts_.insert(url.host()); |
136 } | 139 } |
137 | 140 |
138 // static | 141 // static |
139 void ChromeSubresourceFilterClient::LogAction(SubresourceFilterAction action) { | 142 void ChromeSubresourceFilterClient::LogAction(SubresourceFilterAction action) { |
140 UMA_HISTOGRAM_ENUMERATION("SubresourceFilter.Actions", action, | 143 UMA_HISTOGRAM_ENUMERATION("SubresourceFilter.Actions", action, |
141 kActionLastEntry); | 144 kActionLastEntry); |
142 } | 145 } |
143 | 146 |
144 subresource_filter::VerifiedRulesetDealer::Handle* | 147 subresource_filter::VerifiedRulesetDealer::Handle* |
145 ChromeSubresourceFilterClient::GetRulesetDealer() { | 148 ChromeSubresourceFilterClient::GetRulesetDealer() { |
146 subresource_filter::ContentRulesetService* ruleset_service = | 149 subresource_filter::ContentRulesetService* ruleset_service = |
147 g_browser_process->subresource_filter_ruleset_service(); | 150 g_browser_process->subresource_filter_ruleset_service(); |
148 return ruleset_service ? ruleset_service->ruleset_dealer() : nullptr; | 151 return ruleset_service ? ruleset_service->ruleset_dealer() : nullptr; |
149 } | 152 } |
OLD | NEW |