#include "chrome/browser/ui/webui/downloads/downloads_dom_handler.h"
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
#include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
#include "chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h"
#include "chrome/browser/ui/hats/trust_safety_sentiment_service_factory.h"
#include "chrome/browser/ui/webui/downloads/downloads.mojom.h"
#include "chrome/browser/ui/webui/downloads/mock_downloads_page.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/download/public/common/mock_download_item.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/mock_download_manager.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_web_ui.h"
#include "content/public/test/web_contents_tester.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
Return;
ReturnRef;
ReturnRefOfCopy;
const char kTestDangerousDownloadUrl[] = …;
const char kTestDangerousDownloadReferrerUrl[] = …;
class TestDownloadsDOMHandler : public DownloadsDOMHandler { … };
}
class DownloadsDOMHandlerTest : public testing::Test { … };
TEST_F(DownloadsDOMHandlerTest, ChecksForRemovedFiles) { … }
TEST_F(DownloadsDOMHandlerTest, HandleGetDownloads) { … }
TEST_F(DownloadsDOMHandlerTest, ClearAll) { … }
class DownloadsDOMHandlerWithFakeSafeBrowsingTest
: public DownloadsDOMHandlerTest { … };
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest, DiscardDangerous) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest, DiscardDangerous_IsDone) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest, DiscardDangerous_EmptyURL) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest,
DiscardDangerous_Incognito) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest,
SaveSuspiciousRequiringGesture) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest,
SaveSuspiciousRequiringGesture_InsecureDownload) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest,
SaveSuspiciousRequiringGesture_NoRecentInteraction) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest,
SaveDangerousFromDialogRequiringGesture) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest,
SaveDangerousFromDialogRequiringGesture_NoRecentInteraction) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTest,
RecordCancelBypassWarningDialog) { … }
class DownloadsDOMHandlerTestDangerousDownloadInterstitial
: public DownloadsDOMHandlerWithFakeSafeBrowsingTest { … };
TEST_F(DownloadsDOMHandlerTestDangerousDownloadInterstitial,
RecordOpenBypassWarningInterstitial) { … }
TEST_F(DownloadsDOMHandlerTestDangerousDownloadInterstitial,
RecordOpenSurveyOnDangerousInterstitial) { … }
TEST_F(DownloadsDOMHandlerTestDangerousDownloadInterstitial,
RecordCancelBypassWarningInterstitial) { … }
TEST_F(DownloadsDOMHandlerTestDangerousDownloadInterstitial,
SaveDangerousFromInterstitialNeedGesture) { … }
TEST_F(DownloadsDOMHandlerTestDangerousDownloadInterstitial,
SaveDangerousFromInterstitialNeedGesture_NoRecentInteraction) { … }
class DownloadsDOMHandlerWithFakeSafeBrowsingTestTrustSafetySentimentService
: public DownloadsDOMHandlerWithFakeSafeBrowsingTest { … };
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTestTrustSafetySentimentService,
DiscardDangerous_CallsTrustSafetySentimentService) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTestTrustSafetySentimentService,
SaveSuspicious_CallsTrustSafetySentimentService) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTestTrustSafetySentimentService,
SaveDangerousFromDialog_CallsTrustSafetySentimentService) { … }
TEST_F(DownloadsDOMHandlerWithFakeSafeBrowsingTestTrustSafetySentimentService,
SaveDangerousFromInterstitial_CallsTrustSafetySentimentService) { … }