Commit 866524e0 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Revert "Add browser tests for DeepScanningDialogDelegate"

This reverts commit 28640451.

Reason for revert: build failures (https://ci.chromium.org/p/chromium/builders/ci/Mac10.11%20Tests/48184)

Original change's description:
> Add browser tests for DeepScanningDialogDelegate
> 
> These tests use the least possible amount of overrides to ensure
> DeepScanningDialogDelegate every requests/callbacks eventually resolves
> and returns to the caller.
> 
> Also add code to handle the web contents being destroyed and avoid ASAN
> issues.
> 
> Bug: 1041890
> Change-Id: Ibfe232354f0591ae9e854bf5a0163ede68d6faf9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083598
> Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
> Reviewed-by: Daniel Rubery <drubery@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#747713}

TBR=drubery@chromium.org,domfc@chromium.org

Change-Id: I6f6df269f31685f004d317e42670542e3e69941c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1041890
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090208Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747789}
parent 76aa2e6f
......@@ -163,7 +163,7 @@ class BinaryUploadService {
// Upload the given file contents for deep scanning. The results will be
// returned asynchronously by calling |request|'s |callback|. This must be
// called on the UI thread.
virtual void UploadForDeepScanning(std::unique_ptr<Request> request);
void UploadForDeepScanning(std::unique_ptr<Request> request);
void OnGetInstanceID(Request* request, const std::string& token);
......
......@@ -744,17 +744,14 @@ void DeepScanningDialogDelegate::FillAllResultsWith(bool status) {
std::fill(result_.paths_results.begin(), result_.paths_results.end(), status);
}
BinaryUploadService* DeepScanningDialogDelegate::GetBinaryUploadService() {
return g_browser_process->safe_browsing_service()->GetBinaryUploadService(
Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
}
void DeepScanningDialogDelegate::UploadTextForDeepScanning(
std::unique_ptr<BinaryUploadService::Request> request) {
DCHECK_EQ(
DlpDeepScanningClientRequest::WEB_CONTENT_UPLOAD,
request->deep_scanning_request().dlp_scan_request().content_source());
BinaryUploadService* upload_service = GetBinaryUploadService();
BinaryUploadService* upload_service =
g_browser_process->safe_browsing_service()->GetBinaryUploadService(
Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
if (upload_service)
upload_service->MaybeUploadForDeepScanning(std::move(request));
}
......@@ -766,7 +763,9 @@ void DeepScanningDialogDelegate::UploadFileForDeepScanning(
!data_.do_dlp_scan ||
(DlpDeepScanningClientRequest::FILE_UPLOAD ==
request->deep_scanning_request().dlp_scan_request().content_source()));
BinaryUploadService* upload_service = GetBinaryUploadService();
BinaryUploadService* upload_service =
g_browser_process->safe_browsing_service()->GetBinaryUploadService(
Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
if (upload_service)
upload_service->MaybeUploadForDeepScanning(std::move(request));
}
......
......@@ -29,7 +29,6 @@ class Profile;
namespace safe_browsing {
class BinaryUploadService;
class DeepScanningDialogViews;
// A tab modal dialog delegate that informs the user of a background deep
......@@ -307,10 +306,6 @@ class DeepScanningDialogDelegate {
// DeepScanningFinalResult enum.
void UpdateFinalResult(DeepScanningFinalResult message);
// Returns the BinaryUploadService used to upload content for deep scanning.
// Virtual to override in tests.
virtual BinaryUploadService* GetBinaryUploadService();
// The web contents that is attempting to access the data.
content::WebContents* web_contents_ = nullptr;
......
......@@ -176,8 +176,7 @@ DeepScanningDialogViews::DeepScanningDialogViews(
content::WebContents* web_contents,
DeepScanAccessPoint access_point,
bool is_file_scan)
: content::WebContentsObserver(web_contents),
delegate_(std::move(delegate)),
: delegate_(std::move(delegate)),
web_contents_(web_contents),
access_point_(std::move(access_point)),
is_file_scan_(is_file_scan) {
......@@ -230,10 +229,6 @@ ui::ModalType DeepScanningDialogViews::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
void DeepScanningDialogViews::WebContentsDestroyed() {
delete this;
}
void DeepScanningDialogViews::ShowResult(
DeepScanningDialogDelegate::DeepScanningFinalResult result) {
DCHECK(is_pending());
......
......@@ -11,7 +11,6 @@
#include "base/time/time.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_dialog_delegate.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/views/animation/bounds_animator.h"
#include "ui/views/controls/label.h"
#include "ui/views/window/dialog_delegate.h"
......@@ -39,8 +38,7 @@ class DeepScanningMessageView;
// Dialog shown for Deep Scanning to offer the possibility of cancelling the
// upload to the user.
class DeepScanningDialogViews : public views::DialogDelegate,
public content::WebContentsObserver {
class DeepScanningDialogViews : public views::DialogDelegate {
public:
// Enum used to represent what the dialog is currently showing.
enum class DeepScanningDialogStatus {
......@@ -121,9 +119,6 @@ class DeepScanningDialogViews : public views::DialogDelegate,
void DeleteDelegate() override;
ui::ModalType GetModalType() const override;
// content::WebContentsObserver:
void WebContentsDestroyed() override;
// Updates the dialog with the result, and simply delete it from memory if
// nothing should be shown.
void ShowResult(DeepScanningDialogDelegate::DeepScanningFinalResult result);
......
......@@ -1165,7 +1165,6 @@ if (!is_android) {
"../browser/safe_browsing/chrome_cleaner/reporter_runner_browsertest_win.cc",
"../browser/safe_browsing/cloud_content_scanning/deep_scanning_browsertest_base.cc",
"../browser/safe_browsing/cloud_content_scanning/deep_scanning_browsertest_base.h",
"../browser/safe_browsing/cloud_content_scanning/deep_scanning_dialog_delegate_browsertest.cc",
"../browser/safe_browsing/cloud_content_scanning/deep_scanning_dialog_views_browsertest.cc",
"../browser/safe_browsing/download_protection/download_protection_service_browsertest.cc",
"../browser/safe_browsing/test_safe_browsing_database_helper.cc",
......
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