Commit 93325bd7 authored by Illia Klimov's avatar Illia Klimov Committed by Commit Bot

Abusive origin permission revocation for disabled Safe Browsing.

This CL prevents abusive origin permission revocation for profiles with
disabled Safe Browsing.

Bug: 1151900
Change-Id: I87d117073363177d16b8957791ebf2badb307fb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2552599
Commit-Queue: Illia Klimov <elklm@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830237}
parent f5a325ec
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "components/permissions/permission_result.h" #include "components/permissions/permission_result.h"
#include "components/permissions/permission_uma_util.h" #include "components/permissions/permission_uma_util.h"
#include "components/permissions/permissions_client.h" #include "components/permissions/permissions_client.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/safe_browsing/core/db/database_manager.h" #include "components/safe_browsing/core/db/database_manager.h"
namespace { namespace {
...@@ -111,12 +113,9 @@ void AbusiveOriginPermissionRevocationRequest::CheckAndRevokeIfAbusive() { ...@@ -111,12 +113,9 @@ void AbusiveOriginPermissionRevocationRequest::CheckAndRevokeIfAbusive() {
DCHECK(profile_); DCHECK(profile_);
DCHECK(callback_); DCHECK(callback_);
if (!AbusiveOriginNotificationsPermissionRevocationConfig::IsEnabled()) { if (!AbusiveOriginNotificationsPermissionRevocationConfig::IsEnabled() ||
std::move(callback_).Run(Outcome::PERMISSION_NOT_REVOKED); !safe_browsing::IsSafeBrowsingEnabled(*profile_->GetPrefs()) ||
return; IsOriginExemptedFromFutureRevocations(profile_, origin_)) {
}
if (IsOriginExemptedFromFutureRevocations(profile_, origin_)) {
std::move(callback_).Run(Outcome::PERMISSION_NOT_REVOKED); std::move(callback_).Run(Outcome::PERMISSION_NOT_REVOKED);
return; return;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
class AbusiveOriginPermissionRevocationRequestTestBase : public testing::Test { class AbusiveOriginPermissionRevocationRequestTestBase : public testing::Test {
...@@ -306,6 +307,35 @@ TEST_F(AbusiveOriginPermissionRevocationRequestTest, ExemptAbusiveOriginTest) { ...@@ -306,6 +307,35 @@ TEST_F(AbusiveOriginPermissionRevocationRequestTest, ExemptAbusiveOriginTest) {
VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ASK); VerifyNotificationsPermission(origin_to_revoke, CONTENT_SETTING_ASK);
} }
TEST_F(AbusiveOriginPermissionRevocationRequestTest, SafeBrowsingDisabledTest) {
const GURL origin_to_revoke = GURL("https://origin.com/");
SetPermission(origin_to_revoke, CONTENT_SETTING_ALLOW);
AddToSafeBrowsingBlocklist(origin_to_revoke);
AddToPreloadDataBlocklist(origin_to_revoke, SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
QueryAndExpectDecisionForUrl(origin_to_revoke,
Outcome::PERMISSION_REVOKED_DUE_TO_ABUSE);
GetTestingProfile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled,
false);
// Permission should not be revoked because Safe Browsing is disabled.
const GURL origin_to_not_revoke = GURL("https://origin-not_revoked.com/");
SetPermission(origin_to_not_revoke, CONTENT_SETTING_ALLOW);
AddToSafeBrowsingBlocklist(origin_to_not_revoke);
AddToPreloadDataBlocklist(origin_to_not_revoke,
SiteReputation::ABUSIVE_CONTENT,
/*has_warning=*/false);
QueryAndExpectDecisionForUrl(origin_to_not_revoke,
Outcome::PERMISSION_NOT_REVOKED);
VerifyNotificationsPermission(origin_to_not_revoke, CONTENT_SETTING_ALLOW);
}
class AbusiveOriginPermissionRevocationRequestDisabledTest class AbusiveOriginPermissionRevocationRequestDisabledTest
: public AbusiveOriginPermissionRevocationRequestTestBase { : public AbusiveOriginPermissionRevocationRequestTestBase {
public: public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment