#include "chrome/browser/enterprise/data_protection/data_protection_navigation_observer.h"
#include <map>
#include <optional>
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/values.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/enterprise/connectors/reporting/realtime_reporting_client_factory.h"
#include "chrome/browser/enterprise/connectors/test/deep_scanning_test_utils.h"
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h"
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h"
#include "chrome/browser/policy/dm_token_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/enterprise/connectors/core/common.h"
#include "components/enterprise/connectors/core/connectors_prefs.h"
#include "components/enterprise/data_controls/core/browser/features.h"
#include "components/enterprise/data_controls/core/browser/test_utils.h"
#include "components/policy/core/common/cloud/dm_token.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/policy/core/common/policy_types.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/writeable_pref_store.h"
#include "components/safe_browsing/core/browser/realtime/fake_url_lookup_service.h"
#include "components/safe_browsing/core/browser/realtime/url_lookup_service_base.h"
#include "components/safe_browsing/core/common/proto/realtimeapi.pb.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
namespace enterprise_data_protection {
namespace {
const char* kSkippedUrls[] = …;
content::Page& GetPageFromWebContents(content::WebContents* web_contents) { … }
safe_browsing::RTLookupResponse::ThreatInfo GetTestThreatInfo(
std::optional<std::string> watermark_text,
int64_t timestamp_seconds,
bool has_matched_rule = false) { … }
safe_browsing::RTLookupResponse CreateRTLookupResponse(
std::optional<std::string> watermark_text,
bool has_matched_rule) { … }
safe_browsing::RTLookupResponse CreateAuditRuleResponse() { … }
class FakeRealTimeUrlLookupService
: public safe_browsing::testing::FakeRealTimeUrlLookupService { … };
class DataProtectionNavigationObserverTest
: public content::RenderViewHostTestHarness { … };
}
TEST_F(DataProtectionNavigationObserverTest, TestWatermarkTextUpdated) { … }
TEST_F(DataProtectionNavigationObserverTest, MatchedAuditRuleHasEvent) { … }
TEST_F(DataProtectionNavigationObserverTest,
TestWatermarkTextUpdated_NoUrlCheck) { … }
TEST_F(DataProtectionNavigationObserverTest,
TestScreenshotUpdated_DataControls) { … }
TEST_F(DataProtectionNavigationObserverTest,
TestScreenshotUpdated_DataControls_NoUrlCheck) { … }
TEST_F(DataProtectionNavigationObserverTest, InvalidResponse_NoReport) { … }
TEST_F(DataProtectionNavigationObserverTest,
SkipSpecialURLs_CreateForNavigationIfNeeded) { … }
TEST_F(DataProtectionNavigationObserverTest,
SkipSpecialURLs_GetDataProtectionSettings) { … }
TEST_F(DataProtectionNavigationObserverTest, GetDataProtectionSettings) { … }
TEST_F(DataProtectionNavigationObserverTest,
GetDataProtectionSettings_NoUrlCheck) { … }
TEST_F(DataProtectionNavigationObserverTest,
GetDataProtectionSettings_DC_BlockScreenshot) { … }
TEST_F(DataProtectionNavigationObserverTest,
GetDataProtectionSettings_DC_BlockScreenshot_NoUrlCheck) { … }
TEST_F(DataProtectionNavigationObserverTest,
GetDataProtectionSettings_DC_BlockScreenshot_Redirect) { … }
TEST_F(DataProtectionNavigationObserverTest,
GetDataProtectionSettings_DC_BlockScreenshot_RedirectWithoutUrlCheck) { … }
namespace {
struct WatermarkStringParams { … };
class DataProtectionWatermarkStringTest
: public testing::TestWithParam<WatermarkStringParams> { … };
}
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(DataProtectionWatermarkStringTest,
TestGetWatermarkStringFromThreatInfo) { … }
}