#include "components/safe_browsing/core/browser/ping_manager.h"
#include "base/base64.h"
#include "base/base64url.h"
#include "base/files/file_enumerator.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/escape.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_file_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/safe_browsing/core/browser/db/v4_test_util.h"
#include "components/safe_browsing/core/browser/safe_browsing_hats_delegate.h"
#include "components/safe_browsing/core/browser/test_safe_browsing_token_fetcher.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safebrowsing_constants.h"
#include "google_apis/google_api_keys.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
Time;
GetUploadData;
HitReport;
ThreatSource;
_;
namespace safe_browsing {
using enum ExtendedReportingLevel;
class FakeSafeBrowsingHatsDelegate : public SafeBrowsingHatsDelegate { … };
class MockWebUIDelegate : public PingManager::WebUIDelegate { … };
class PingManagerTest : public testing::Test { … };
void PingManagerTest::SetUp() { … }
void PingManagerTest::TearDown() { … }
PingManager* PingManagerTest::ping_manager() { … }
void PingManagerTest::SetNewPingManager(
std::optional<base::RepeatingCallback<bool()>>
get_should_fetch_access_token,
std::optional<base::RepeatingCallback<ChromeUserPopulation()>>
get_user_population_callback,
std::optional<
base::RepeatingCallback<ChromeUserPopulation::PageLoadToken(GURL)>>
get_page_load_token_callback,
std::optional<base::RepeatingCallback<bool()>>
get_should_send_persisted_report) { … }
void PingManagerTest::SetUpFeatureList(bool should_enable_remove_cookies) { … }
std::string PingManagerTest::CallPersistThreatDetails(const std::string& url) { … }
TestSafeBrowsingTokenFetcher* PingManagerTest::SetUpTokenFetcher() { … }
FakeSafeBrowsingHatsDelegate* PingManagerTest::SetUpHatsDelegate() { … }
void PingManagerTest::RunReportThreatDetailsTest(
bool expect_access_token,
std::optional<ChromeUserPopulation> expected_user_population,
std::optional<std::string> expected_page_load_token_value,
bool expect_cookies_removed) { … }
TEST_F(PingManagerTest, TestSafeBrowsingHitUrl) { … }
TEST_F(PingManagerTest, TestThreatDetailsUrl) { … }
TEST_F(PingManagerTest, TestReportThreatDetails_EmptyReport) { … }
TEST_F(PingManagerTest, TestSanitizeThreatDetailsReport) { … }
TEST_F(PingManagerTest, TestSanitizeHitReport) { … }
TEST_F(PingManagerTest, ReportThreatDetailsWithAccessToken) { … }
TEST_F(PingManagerTest,
ReportThreatDetailsWithAccessToken_RemoveCookiesFeatureDisabled) { … }
TEST_F(PingManagerTest, ReportThreatDetailsWithUserPopulation) { … }
TEST_F(PingManagerTest, ReportThreatDetailsWithPageLoadToken) { … }
TEST_F(PingManagerTest, PersistThreatDetailsAtShutdown) { … }
TEST_F(PingManagerTest, PersistThreatDetailsAtShutdown_EmptyReport) { … }
TEST_F(PingManagerTest, SendPersistedThreatDetailsOnStartup) { … }
TEST_F(PingManagerTest, SendPersistedThreatDetailsOnStartup_MalformedReports) { … }
TEST_F(PingManagerTest, SendPersistedThreatDetailsOnStartup_EmptyDirectory) { … }
TEST_F(PingManagerTest,
SendPersistedThreatDetailsOnStartup_ShouldNotSendReport) { … }
TEST_F(PingManagerTest, ReportSafeBrowsingHit) { … }
TEST_F(PingManagerTest, AttachThreatDetailsAndLaunchSurvey) { … }
}