Skip to content

Commit fa6a5d8

Browse files
csharrisonCommit Bot
authored and
Commit Bot
committed
[subresource_filter] Don't populate metadata if we're suppressing UI
For abusive enforcement we don't want to show up in settings or Page Info, so make sure we don't populate the metadata in cases where we'd ship with suppress_notifications. Bug: 756089 Change-Id: I31967339737005e432ded66f69e583b7b60635ab Reviewed-on: https://chromium-review.googlesource.com/646792 Reviewed-by: Shivani Sharma <[email protected]> Commit-Queue: Charlie Harrison <[email protected]> Cr-Commit-Position: refs/heads/master@{#499098}
1 parent 94048e8 commit fa6a5d8

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

chrome/browser/subresource_filter/chrome_subresource_filter_client.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,17 @@ void ChromeSubresourceFilterClient::OnNewNavigationStarted() {
132132

133133
bool ChromeSubresourceFilterClient::OnPageActivationComputed(
134134
content::NavigationHandle* navigation_handle,
135-
bool activated) {
135+
bool activated,
136+
bool suppressing_notifications) {
136137
const GURL& url(navigation_handle->GetURL());
137138
DCHECK(navigation_handle->IsInMainFrame());
138139

139140
if (url.SchemeIsHTTPOrHTTPS()) {
140141
// With respect to persistent metadata, do not consider the site activated
141-
// if it is forced via devtools.
142+
// if it is forced via devtools, or if we are suppressing notifications.
142143
settings_manager_->ResetSiteMetadataBasedOnActivation(
143-
url, activated && !activated_via_devtools_);
144+
url,
145+
activated && !activated_via_devtools_ && !suppressing_notifications);
144146
}
145147

146148
// Return whether the activation should be whitelisted.

chrome/browser/subresource_filter/chrome_subresource_filter_client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class ChromeSubresourceFilterClient
111111
void ShowNotification() override;
112112
void OnNewNavigationStarted() override;
113113
bool OnPageActivationComputed(content::NavigationHandle* navigation_handle,
114-
bool activated) override;
114+
bool activated,
115+
bool suppressing_notifications) override;
115116
void WhitelistInCurrentWebContents(const GURL& url) override;
116117
subresource_filter::VerifiedRulesetDealer::Handle* GetRulesetDealer()
117118
override;

chrome/browser/subresource_filter/subresource_filter_unittest.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,22 @@ TEST_F(SubresourceFilterTest, UIShown_LogsRappor) {
268268
// The host is the same as the etld+1 in this case.
269269
EXPECT_EQ(url.host(), sample_string);
270270
}
271+
272+
TEST_F(SubresourceFilterTest, AbusiveEnforcement_NoMetadata) {
273+
subresource_filter::Configuration config(
274+
subresource_filter::ActivationLevel::ENABLED,
275+
subresource_filter::ActivationScope::ACTIVATION_LIST,
276+
subresource_filter::ActivationList::SUBRESOURCE_FILTER);
277+
config.activation_options.should_disable_ruleset_rules = true;
278+
config.activation_options.should_strengthen_popup_blocker = true;
279+
config.activation_options.should_suppress_notifications = true;
280+
281+
scoped_configuration().ResetConfiguration(std::move(config));
282+
283+
GURL url("https://a.test");
284+
ConfigureAsSubresourceFilterOnlyURL(url);
285+
SimulateNavigateAndCommit(url, main_rfh());
286+
EXPECT_TRUE(CreateAndNavigateDisallowedSubframe(main_rfh()));
287+
EXPECT_EQ(nullptr, GetSettingsManager()->GetSiteMetadata(url));
288+
EXPECT_FALSE(GetClient()->did_show_ui_for_navigation());
289+
}

components/subresource_filter/content/browser/subresource_filter_client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class SubresourceFilterClient {
3535
// Precondition: The navigation must be a main frame navigation.
3636
virtual bool OnPageActivationComputed(
3737
content::NavigationHandle* navigation_handle,
38-
bool activated) = 0;
38+
bool activated,
39+
bool suppressing_notifications) = 0;
3940

4041
// Adds |url| to a per-WebContents whitelist.
4142
virtual void WhitelistInCurrentWebContents(const GURL& url) = 0;

components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ void SubresourceFilterSafeBrowsingActivationThrottle::NotifyResult() {
210210
bool whitelisted = client_->OnPageActivationComputed(
211211
navigation_handle(),
212212
matched_configuration.activation_options.activation_level ==
213-
ActivationLevel::ENABLED);
213+
ActivationLevel::ENABLED,
214+
matched_configuration.activation_options.should_suppress_notifications);
214215

215216
// Only reset the activation decision reason if we would have activated.
216217
if (whitelisted && activation_decision == ActivationDecision::ACTIVATED) {

components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class MockSubresourceFilterClient : public SubresourceFilterClient {
8686
}
8787

8888
bool OnPageActivationComputed(content::NavigationHandle* handle,
89-
bool activated) override {
89+
bool activated,
90+
bool suppress_notifications) override {
9091
DCHECK(handle->IsInMainFrame());
9192
return whitelisted_hosts_.count(handle->GetURL().host());
9293
}

0 commit comments

Comments
 (0)