Commit 22603a0b authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Fix BinaryUploadService::IsAuthorized

can_upload_data_ was always set to true upon calling
MaybeUploadForDeepScanning. Removed this and changed tests so
reintroducing this bug will result in failing tests.

Change-Id: I49b63670aec2f95157103b51d59dd197278e87df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933733Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718679}
parent bc783e09
...@@ -83,7 +83,6 @@ BinaryUploadService::~BinaryUploadService() {} ...@@ -83,7 +83,6 @@ BinaryUploadService::~BinaryUploadService() {}
void BinaryUploadService::MaybeUploadForDeepScanning( void BinaryUploadService::MaybeUploadForDeepScanning(
std::unique_ptr<BinaryUploadService::Request> request) { std::unique_ptr<BinaryUploadService::Request> request) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
can_upload_data_ = true;
if (!can_upload_data_.has_value()) { if (!can_upload_data_.has_value()) {
IsAuthorized( IsAuthorized(
base::BindOnce(&BinaryUploadService::MaybeUploadForDeepScanningCallback, base::BindOnce(&BinaryUploadService::MaybeUploadForDeepScanningCallback,
...@@ -457,6 +456,10 @@ void BinaryUploadService::ResetAuthorizationData() { ...@@ -457,6 +456,10 @@ void BinaryUploadService::ResetAuthorizationData() {
IsAuthorized(base::DoNothing()); IsAuthorized(base::DoNothing());
} }
void BinaryUploadService::SetAuthForTesting(bool authorized) {
can_upload_data_ = authorized;
}
// static // static
bool BinaryUploadService::ShouldBlockFileSize(size_t file_size) { bool BinaryUploadService::ShouldBlockFileSize(size_t file_size) {
int block_large_file_transfer = g_browser_process->local_state()->GetInteger( int block_large_file_transfer = g_browser_process->local_state()->GetInteger(
......
...@@ -137,6 +137,9 @@ class BinaryUploadService { ...@@ -137,6 +137,9 @@ class BinaryUploadService {
// Resets |can_upload_data_|. Called every 24 hour by |timer_|. // Resets |can_upload_data_|. Called every 24 hour by |timer_|.
void ResetAuthorizationData(); void ResetAuthorizationData();
// Sets |can_upload_data_| for tests.
void SetAuthForTesting(bool authorized);
// Returns whether a download should be blocked based on file size alone. It // Returns whether a download should be blocked based on file size alone. It
// checks the enterprise policy BlockLargeFileTransfer to decide this. // checks the enterprise policy BlockLargeFileTransfer to decide this.
static bool ShouldBlockFileSize(size_t file_size); static bool ShouldBlockFileSize(size_t file_size);
......
...@@ -123,8 +123,8 @@ class BinaryUploadServiceTest : public testing::Test { ...@@ -123,8 +123,8 @@ class BinaryUploadServiceTest : public testing::Test {
void UploadForDeepScanning( void UploadForDeepScanning(
std::unique_ptr<BinaryUploadService::Request> request, std::unique_ptr<BinaryUploadService::Request> request,
bool authorized = true) { bool authorized = true) {
service_->MaybeUploadForDeepScanningCallback(std::move(request), service_->SetAuthForTesting(authorized);
authorized); service_->MaybeUploadForDeepScanning(std::move(request));
} }
void ReceiveMessageForRequest(BinaryUploadService::Request* request, void ReceiveMessageForRequest(BinaryUploadService::Request* request,
......
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