Commit 1162b1a8 authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Set EventResult to ALLOWED when uploads are not delayed

The previous behaviour had those events reported with whatever verdict
Chrome received afterwards, which is inaccurate as the upload was
allowed.

Bug: 1120952
Change-Id: Ie503eac951a835aacbb977cd014e8ca31db4f4d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2406536Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806678}
parent 3c6a7577
......@@ -152,9 +152,15 @@ bool* UIEnabledStorage() {
return &enabled;
}
EventResult CalculateEventResult(bool allowed, bool should_warn) {
return allowed ? EventResult::ALLOWED
: (should_warn ? EventResult::WARNED : EventResult::BLOCKED);
EventResult CalculateEventResult(
const enterprise_connectors::AnalysisSettings& settings,
bool allowed_by_scan_result,
bool should_warn) {
bool wait_for_verdict = settings.block_until_verdict ==
enterprise_connectors::BlockUntilVerdict::BLOCK;
return (allowed_by_scan_result || !wait_for_verdict)
? EventResult::ALLOWED
: (should_warn ? EventResult::WARNED : EventResult::BLOCKED);
}
} // namespace
......@@ -410,7 +416,7 @@ void DeepScanningDialogDelegate::StringRequestCallback(
"text/plain",
extensions::SafeBrowsingPrivateEventRouter::kTriggerWebContentUpload,
access_point_, content_size, result, response,
CalculateEventResult(text_complies, should_warn));
CalculateEventResult(data_.settings, text_complies, should_warn));
if (!text_complies) {
if (should_warn) {
......@@ -445,7 +451,7 @@ void DeepScanningDialogDelegate::CompleteFileRequestCallback(
file_info_[index].sha256, mime_type,
extensions::SafeBrowsingPrivateEventRouter::kTriggerFileUpload,
access_point_, file_info_[index].size, result, response,
CalculateEventResult(file_complies, should_warn));
CalculateEventResult(data_.settings, file_complies, should_warn));
++file_result_count_;
......
......@@ -816,7 +816,11 @@ IN_PROC_BROWSER_TEST_P(DeepScanningDialogDelegateDelayDeliveryUntilVerdictTest,
/*dlp_verdict*/ dlp_verdict,
/*mimetypes*/ DocMimeTypes(),
/*size*/ std::string("foo content").size(),
/*result*/ EventResultToString(EventResult::BLOCKED));
// If the policy allows immediate delivery of the file, then the result is
// ALLOWED even if the verdict obtained afterwards is BLOCKED.
/*result*/
EventResultToString(expected_result() ? EventResult::ALLOWED
: EventResult::BLOCKED));
bool called = false;
base::RunLoop run_loop;
......
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