#include "chrome/browser/subresource_filter/subresource_filter_browser_test_harness.h"
#include <string_view>
#include <utility>
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/test_safe_browsing_database_helper.h"
#include "chrome/browser/subresource_filter/subresource_filter_profile_context_factory.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/blocked_content/safe_browsing_triggered_popup_blocker.h"
#include "components/content_settings/browser/page_specific_content_settings.h"
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/browser/db/v4_test_util.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.h"
#include "components/subresource_filter/content/browser/subresource_filter_profile_context.h"
#include "components/subresource_filter/content/browser/test_ruleset_publisher.h"
#include "components/subresource_filter/content/shared/browser/ruleset_service.h"
#include "components/subresource_filter/core/browser/verified_ruleset_dealer.h"
#include "components/subresource_filter/core/common/common_features.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace subresource_filter {
const char SubresourceFilterBrowserTest::kSubresourceLoadsTotalForPage[];
const char SubresourceFilterBrowserTest::kSubresourceLoadsEvaluatedForPage[];
const char SubresourceFilterBrowserTest::kSubresourceLoadsMatchedRulesForPage[];
const char SubresourceFilterBrowserTest::kSubresourceLoadsDisallowedForPage[];
const char SubresourceFilterBrowserTest::kEvaluationTotalWallDurationForPage[];
const char SubresourceFilterBrowserTest::kEvaluationTotalCPUDurationForPage[];
const char SubresourceFilterBrowserTest::kEvaluationWallDuration[];
const char SubresourceFilterBrowserTest::kEvaluationCPUDuration[];
const char SubresourceFilterBrowserTest::kActivationDecision[];
const char SubresourceFilterBrowserTest::kActivationListHistogram[];
const char SubresourceFilterBrowserTest::kPageLoadActivationStateHistogram[];
const char
SubresourceFilterBrowserTest::kPageLoadActivationStateDidInheritHistogram[];
const char SubresourceFilterBrowserTest::kSubresourceFilterActionsHistogram[];
MockSubresourceFilterObserver::MockSubresourceFilterObserver(
content::WebContents* web_contents) { … }
MockSubresourceFilterObserver::~MockSubresourceFilterObserver() = default;
SubresourceFilterSharedBrowserTest::SubresourceFilterSharedBrowserTest() =
default;
SubresourceFilterSharedBrowserTest::~SubresourceFilterSharedBrowserTest() =
default;
void SubresourceFilterSharedBrowserTest::SetUpOnMainThread() { … }
GURL SubresourceFilterSharedBrowserTest::GetTestUrl(
const std::string& relative_url) const { … }
content::WebContents* SubresourceFilterSharedBrowserTest::web_contents() { … }
content::RenderFrameHost* SubresourceFilterSharedBrowserTest::FindFrameByName(
const std::string& name) { … }
bool SubresourceFilterSharedBrowserTest::WasParsedScriptElementLoaded(
content::RenderFrameHost* rfh) { … }
void SubresourceFilterSharedBrowserTest::
ExpectParsedScriptElementLoadedStatusInFrames(
const std::vector<const char*>& frame_names,
const std::vector<bool>& expect_loaded) { … }
void SubresourceFilterSharedBrowserTest::ExpectFramesIncludedInLayout(
const std::vector<const char*>& frame_names,
const std::vector<bool>& expect_displayed) { … }
void SubresourceFilterSharedBrowserTest::NavigateFrame(const char* frame_name,
const GURL& url) { … }
SubresourceFilterBrowserTest::SubresourceFilterBrowserTest() { … }
SubresourceFilterBrowserTest::~SubresourceFilterBrowserTest() = default;
bool SubresourceFilterBrowserTest::AdsBlockedInContentSettings(
content::RenderFrameHost* frame_host) { … }
void SubresourceFilterBrowserTest::SetUp() { … }
void SubresourceFilterBrowserTest::TearDown() { … }
void SubresourceFilterBrowserTest::SetUpOnMainThread() { … }
std::unique_ptr<TestSafeBrowsingDatabaseHelper>
SubresourceFilterBrowserTest::CreateTestDatabase() { … }
void SubresourceFilterBrowserTest::ConfigureAsPhishingURL(const GURL& url) { … }
void SubresourceFilterBrowserTest::ConfigureAsSubresourceFilterOnlyURL(
const GURL& url) { … }
void SubresourceFilterBrowserTest::ConfigureURLWithWarning(
const GURL& url,
std::vector<safe_browsing::SubresourceFilterType> filter_types) { … }
bool SubresourceFilterBrowserTest::IsDynamicScriptElementLoaded(
content::RenderFrameHost* rfh) { … }
void SubresourceFilterBrowserTest::InsertDynamicFrameWithScript() { … }
void SubresourceFilterBrowserTest::NavigateFromRendererSide(const GURL& url) { … }
void SubresourceFilterBrowserTest::SetRulesetToDisallowURLsWithPathSuffix(
const std::string& suffix) { … }
void SubresourceFilterBrowserTest::SetRulesetToDisallowURLsWithSubstrings(
std::vector<std::string_view> substrings) { … }
void SubresourceFilterBrowserTest::SetRulesetWithRules(
const std::vector<proto::UrlRule>& rules) { … }
void SubresourceFilterBrowserTest::OpenAndPublishRuleset(
RulesetService* ruleset_service,
const base::FilePath& indexed_ruleset_path) { … }
void SubresourceFilterBrowserTest::ResetConfiguration(Configuration config) { … }
void SubresourceFilterBrowserTest::ResetConfigurationToEnableOnPhishingSites(
bool measure_performance) { … }
std::unique_ptr<TestSafeBrowsingDatabaseHelper>
SubresourceFilterListInsertingBrowserTest::CreateTestDatabase() { … }
SubresourceFilterPrerenderingBrowserTest::
SubresourceFilterPrerenderingBrowserTest()
: … { … }
SubresourceFilterPrerenderingBrowserTest::
~SubresourceFilterPrerenderingBrowserTest() = default;
void SubresourceFilterPrerenderingBrowserTest::SetUp() { … }
}