Commit 98302e62 authored by Roger Tawa's avatar Roger Tawa Committed by Commit Bot

Don't perform deep scan of uploads in incognito profiles.

Bug: 1012270
Change-Id: Ic35c3a7c331d353db8a938e11ea78d5ca38f6f9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847792Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Roger Tawa <rogerta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703794}
parent c4f7cc5d
...@@ -235,6 +235,10 @@ bool DeepScanningDialogDelegate::IsEnabled(Profile* profile, ...@@ -235,6 +235,10 @@ bool DeepScanningDialogDelegate::IsEnabled(Profile* profile,
if (!base::FeatureList::IsEnabled(kDeepScanningOfUploads)) if (!base::FeatureList::IsEnabled(kDeepScanningOfUploads))
return false; return false;
// If this is an incognitio profile, don't perform scans.
if (profile->IsOffTheRecord())
return false;
// If there's no DM token, the upload will fail. // If there's no DM token, the upload will fail.
if (GetDMToken().empty()) if (GetDMToken().empty())
return false; return false;
......
...@@ -68,7 +68,7 @@ class BaseTest : public testing::Test { ...@@ -68,7 +68,7 @@ class BaseTest : public testing::Test {
updater->GetList().emplace_back(url.host()); updater->GetList().emplace_back(url.host());
} }
Profile* profile() { return profile_; } TestingProfile* profile() { return profile_; }
private: private:
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
...@@ -230,6 +230,22 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabled) { ...@@ -230,6 +230,22 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabled) {
EXPECT_TRUE(data.do_malware_scan); EXPECT_TRUE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoScanInIncognito) {
GURL url(kTestUrl);
EnableFeatures({kDeepScanningOfUploads});
SetDMToken(kDmToken);
SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS);
SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS);
AddUrlToList(prefs::kDomainsToCheckForMalwareOfUploadedContent, url);
DeepScanningDialogDelegate::Data data;
EXPECT_TRUE(DeepScanningDialogDelegate::IsEnabled(profile(), url, &data));
// The same URL should not trigger a scan in incognito.
EXPECT_FALSE(DeepScanningDialogDelegate::IsEnabled(
profile()->GetOffTheRecordProfile(), url, &data));
}
class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest { class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest {
protected: protected:
void RunUntilDone() { run_loop_.Run(); } void RunUntilDone() { run_loop_.Run(); }
......
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