summaryrefslogtreecommitdiff
path: root/chromium/components/subresource_filter/core
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-29 16:35:13 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-02-01 15:33:35 +0000
commitc8c2d1901aec01e934adf561a9fdf0cc776cdef8 (patch)
tree9157c3d9815e5870799e070b113813bec53e0535 /chromium/components/subresource_filter/core
parentabefd5095b41dac94ca451d784ab6e27372e981a (diff)
downloadqtwebengine-chromium-c8c2d1901aec01e934adf561a9fdf0cc776cdef8.tar.gz
BASELINE: Update Chromium to 64.0.3282.139
Change-Id: I1cae68fe9c94ff7608b26b8382fc19862cdb293a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/subresource_filter/core')
-rw-r--r--chromium/components/subresource_filter/core/browser/ruleset_service.cc12
-rw-r--r--chromium/components/subresource_filter/core/browser/subresource_filter_constants.h9
-rw-r--r--chromium/components/subresource_filter/core/browser/subresource_filter_features.cc54
-rw-r--r--chromium/components/subresource_filter/core/browser/subresource_filter_features.h19
-rw-r--r--chromium/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc93
-rw-r--r--chromium/components/subresource_filter/core/common/activation_list.cc6
-rw-r--r--chromium/components/subresource_filter/core/common/activation_list.h8
-rw-r--r--chromium/components/subresource_filter/core/common/first_party_origin_unittest.cc12
-rw-r--r--chromium/components/subresource_filter/core/common/indexed_ruleset.cc20
-rw-r--r--chromium/components/subresource_filter/core/common/test_ruleset_creator.cc8
10 files changed, 32 insertions, 209 deletions
diff --git a/chromium/components/subresource_filter/core/browser/ruleset_service.cc b/chromium/components/subresource_filter/core/browser/ruleset_service.cc
index ece8d8bf0a5..896b289d7cb 100644
--- a/chromium/components/subresource_filter/core/browser/ruleset_service.cc
+++ b/chromium/components/subresource_filter/core/browser/ruleset_service.cc
@@ -73,7 +73,7 @@ void RecordIndexAndWriteRulesetResult(
// ruleset, and it is expected that version updates will be frequent enough.
class SentinelFile {
public:
- SentinelFile(base::FilePath& version_directory)
+ explicit SentinelFile(const base::FilePath& version_directory)
: path_(IndexedRulesetLocator::GetSentinelFilePath(version_directory)) {}
bool IsPresent() { return base::PathExists(path_); }
@@ -273,7 +273,7 @@ void RulesetService::IndexAndStoreAndPublishRulesetIfNeeded(
IndexedRulesetVersion RulesetService::IndexAndWriteRuleset(
const base::FilePath& indexed_ruleset_base_dir,
const UnindexedRulesetInfo& unindexed_ruleset_info) {
- base::ThreadRestrictions::AssertIOAllowed();
+ base::AssertBlockingAllowed();
base::File unindexed_ruleset_file(
unindexed_ruleset_info.ruleset_path,
@@ -411,13 +411,14 @@ RulesetService::IndexAndWriteRulesetResult RulesetService::WriteRuleset(
// Due to the same-version check in IndexAndStoreAndPublishRulesetIfNeeded, we
// would not normally find a pre-existing copy at this point unless the
// previous write was interrupted.
- if (!base::DeleteFile(indexed_ruleset_version_dir, true)) {
+ if (!base::DeleteFile(indexed_ruleset_version_dir, true))
return IndexAndWriteRulesetResult::FAILED_DELETE_PREEXISTING;
- }
+ base::FilePath scratch_dir_with_new_indexed_ruleset = scratch_dir.Take();
base::File::Error error;
- if (!(*g_replace_file_func)(scratch_dir.GetPath(),
+ if (!(*g_replace_file_func)(scratch_dir_with_new_indexed_ruleset,
indexed_ruleset_version_dir, &error)) {
+ base::DeleteFile(scratch_dir_with_new_indexed_ruleset, true);
// While enumerators of base::File::Error all have negative values, the
// histogram records the absolute values.
UMA_HISTOGRAM_ENUMERATION("SubresourceFilter.WriteRuleset.ReplaceFileError",
@@ -425,7 +426,6 @@ RulesetService::IndexAndWriteRulesetResult RulesetService::WriteRuleset(
return IndexAndWriteRulesetResult::FAILED_REPLACE_FILE;
}
- scratch_dir.Take();
return IndexAndWriteRulesetResult::SUCCESS;
}
diff --git a/chromium/components/subresource_filter/core/browser/subresource_filter_constants.h b/chromium/components/subresource_filter/core/browser/subresource_filter_constants.h
index c0ffa07073c..3d5e0dacff5 100644
--- a/chromium/components/subresource_filter/core/browser/subresource_filter_constants.h
+++ b/chromium/components/subresource_filter/core/browser/subresource_filter_constants.h
@@ -73,15 +73,6 @@ constexpr char kDisallowSubframeConsoleMessageSuffix[] =
constexpr char kLearnMoreLink[] =
"https://support.google.com/chrome/?p=blocked_ads";
-constexpr char kDisallowNewWindowMessage[] =
- "Chrome prevented this site from opening a new tab or window. Learn more "
- "at https://www.chromestatus.com/feature/5243055179300864";
-
-constexpr char kDisallowNewWindowWarningMessage[] =
- "Chrome might start preventing this site from opening new tabs or windows "
- "in the future. Learn more at "
- "https://www.chromestatus.com/feature/5243055179300864";
-
} // namespace subresource_filter
#endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_CONSTANTS_H_
diff --git a/chromium/components/subresource_filter/core/browser/subresource_filter_features.cc b/chromium/components/subresource_filter/core/browser/subresource_filter_features.cc
index 8e07e3c0b4f..955e759a0bb 100644
--- a/chromium/components/subresource_filter/core/browser/subresource_filter_features.cc
+++ b/chromium/components/subresource_filter/core/browser/subresource_filter_features.cc
@@ -93,11 +93,6 @@ ActivationList ParseActivationList(std::string activation_lists_string) {
} else if (activation_lists.CaseInsensitiveContains(
kActivationListBetterAds)) {
return ActivationList::BETTER_ADS;
- } else if (activation_lists.CaseInsensitiveContains(
- kActivationListAbusiveAds)) {
- return ActivationList::ABUSIVE_ADS;
- } else if (activation_lists.CaseInsensitiveContains(kActivationListAllAds)) {
- return ActivationList::ALL_ADS;
}
return ActivationList::NONE;
}
@@ -130,12 +125,8 @@ std::vector<Configuration> FillEnabledPresetConfigurations(
&Configuration::MakePresetForLiveRunOnPhishingSites},
{kPresetPerformanceTestingDryRunOnAllSites, false,
&Configuration::MakePresetForPerformanceTestingDryRunOnAllSites},
- {kPresetLiveRunForAbusiveAds, false,
- &Configuration::MakePresetForLiveRunForAbusiveAds},
{kPresetLiveRunForBetterAds, false,
- &Configuration::MakePresetForLiveRunForBetterAds},
- {kPresetLiveRunForAllAds, false,
- &Configuration::MakePresetForLiveRunForAllAds}};
+ &Configuration::MakePresetForLiveRunForBetterAds}};
CommaSeparatedStrings enabled_presets(
TakeVariationParamOrReturnEmpty(params, kEnablePresetsParameterName));
@@ -185,13 +176,6 @@ Configuration ParseExperimentalConfiguration(
ParseBool(TakeVariationParamOrReturnEmpty(
params, kWhitelistSiteOnReloadParameterName));
- configuration.activation_options.should_strengthen_popup_blocker =
- ParseBool(TakeVariationParamOrReturnEmpty(
- params, kStrengthenPopupBlockerParameterName));
-
- configuration.activation_options.should_disable_ruleset_rules =
- ParseBool(TakeVariationParamOrReturnEmpty(params, kDisableRulesetRules));
-
// GeneralSettings:
configuration.general_settings.ruleset_flavor =
TakeVariationParamOrReturnEmpty(params, kRulesetFlavorParameterName);
@@ -273,8 +257,6 @@ const char kActivationListSocialEngineeringAdsInterstitial[] =
const char kActivationListPhishingInterstitial[] = "phishing_interstitial";
const char kActivationListSubresourceFilter[] = "subresource_filter";
const char kActivationListBetterAds[] = "better_ads";
-const char kActivationListAbusiveAds[] = "abusive_ads";
-const char kActivationListAllAds[] = "all_ads";
const char kActivationPriorityParameterName[] = "activation_priority";
@@ -282,9 +264,6 @@ const char kPerformanceMeasurementRateParameterName[] =
"performance_measurement_rate";
const char kSuppressNotificationsParameterName[] = "suppress_notifications";
const char kWhitelistSiteOnReloadParameterName[] = "whitelist_site_on_reload";
-const char kStrengthenPopupBlockerParameterName[] = "strengthen_popup_blocker";
-const char kDisableRulesetRules[] = "disable_ruleset_rules";
-
const char kRulesetFlavorParameterName[] = "ruleset_flavor";
const char kEnablePresetsParameterName[] = "enable_presets";
@@ -292,11 +271,8 @@ const char kDisablePresetsParameterName[] = "disable_presets";
const char kPresetLiveRunOnPhishingSites[] = "liverun_on_phishing_sites";
const char kPresetPerformanceTestingDryRunOnAllSites[] =
"performance_testing_dryrun_on_all_sites";
-const char kPresetLiveRunForAbusiveAds[] =
- "liverun_on_abusive_ad_violating_sites";
const char kPresetLiveRunForBetterAds[] =
"liverun_on_better_ads_violating_sites";
-const char kPresetLiveRunForAllAds[] = "liverun_on_all_ads_violating_sites";
// Configuration --------------------------------------------------------------
@@ -328,18 +304,6 @@ Configuration Configuration::MakeForForcedActivation() {
}
// static
-Configuration Configuration::MakePresetForLiveRunForAbusiveAds() {
- Configuration config(ActivationLevel::ENABLED,
- ActivationScope::ACTIVATION_LIST,
- ActivationList::ABUSIVE_ADS);
- config.activation_options.should_disable_ruleset_rules = true;
- config.activation_options.should_suppress_notifications = true;
- config.activation_options.should_strengthen_popup_blocker = true;
- config.activation_conditions.priority = 750;
- return config;
-}
-
-// static
Configuration Configuration::MakePresetForLiveRunForBetterAds() {
Configuration config(ActivationLevel::ENABLED,
ActivationScope::ACTIVATION_LIST,
@@ -348,16 +312,6 @@ Configuration Configuration::MakePresetForLiveRunForBetterAds() {
return config;
}
-// static
-Configuration Configuration::MakePresetForLiveRunForAllAds() {
- Configuration config(ActivationLevel::ENABLED,
- ActivationScope::ACTIVATION_LIST,
- ActivationList::ALL_ADS);
- config.activation_options.should_strengthen_popup_blocker = true;
- config.activation_conditions.priority = 850;
- return config;
-}
-
Configuration::Configuration() = default;
Configuration::Configuration(ActivationLevel activation_level,
ActivationScope activation_scope,
@@ -382,8 +336,6 @@ bool Configuration::operator==(const Configuration& rhs) const {
config.activation_options.performance_measurement_rate,
config.activation_options.should_whitelist_site_on_reload,
config.activation_options.should_suppress_notifications,
- config.activation_options.should_strengthen_popup_blocker,
- config.activation_options.should_disable_ruleset_rules,
config.general_settings.ruleset_flavor);
};
return tie(*this) == tie(rhs);
@@ -416,10 +368,6 @@ std::unique_ptr<base::trace_event::TracedValue> Configuration::ToTracedValue()
activation_options.should_suppress_notifications);
value->SetBoolean("should_whitelist_site_on_reload",
activation_options.should_whitelist_site_on_reload);
- value->SetBoolean("should_strengthen_popup_blocker",
- activation_options.should_strengthen_popup_blocker);
- value->SetBoolean("should_disable_ruleset_rules",
- activation_options.should_disable_ruleset_rules);
value->SetString("ruleset_flavor",
StreamToString(general_settings.ruleset_flavor));
return value;
diff --git a/chromium/components/subresource_filter/core/browser/subresource_filter_features.h b/chromium/components/subresource_filter/core/browser/subresource_filter_features.h
index e8b10627b9c..e16c5bb8e87 100644
--- a/chromium/components/subresource_filter/core/browser/subresource_filter_features.h
+++ b/chromium/components/subresource_filter/core/browser/subresource_filter_features.h
@@ -91,13 +91,6 @@ struct Configuration {
// Whether to whitelist a site when a page loaded from that site is
// reloaded.
bool should_whitelist_site_on_reload = false;
-
- // Whether to apply a more powerful popup blocker on pages with activation.
- bool should_strengthen_popup_blocker = false;
-
- // Whether to disable rules from the ruleset. In practice this might be used
- // if e.g. only popup blocking behavior is desired.
- bool should_disable_ruleset_rules = false;
};
// General settings that apply outside of the scope of a navigation.
@@ -134,12 +127,8 @@ struct Configuration {
// 4.) Update unittests to cover the new preset.
static Configuration MakePresetForLiveRunOnPhishingSites();
static Configuration MakePresetForPerformanceTestingDryRunOnAllSites();
- static Configuration MakePresetForLiveRunForAbusiveAds();
static Configuration MakePresetForLiveRunForBetterAds();
- // Site violates abusive and better ads standards.
- static Configuration MakePresetForLiveRunForAllAds();
-
// Not really a preset, but used as the configuration for forcing activation
// (e.g. via devtools).
static Configuration MakeForForcedActivation();
@@ -221,8 +210,6 @@ extern const char kActivationListSocialEngineeringAdsInterstitial[];
extern const char kActivationListPhishingInterstitial[];
extern const char kActivationListSubresourceFilter[];
extern const char kActivationListBetterAds[];
-extern const char kActivationListAbusiveAds[];
-extern const char kActivationListAllAds[];
extern const char kActivationPriorityParameterName[];
@@ -232,19 +219,13 @@ extern const char kSuppressNotificationsParameterName[];
extern const char kWhitelistSiteOnReloadParameterName[];
-extern const char kStrengthenPopupBlockerParameterName[];
-
-extern const char kDisableRulesetRules[];
-
extern const char kRulesetFlavorParameterName[];
extern const char kEnablePresetsParameterName[];
extern const char kDisablePresetsParameterName[];
extern const char kPresetLiveRunOnPhishingSites[];
extern const char kPresetPerformanceTestingDryRunOnAllSites[];
-extern const char kPresetLiveRunForAbusiveAds[];
extern const char kPresetLiveRunForBetterAds[];
-extern const char kPresetLiveRunForAllAds[];
} // namespace subresource_filter
diff --git a/chromium/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc b/chromium/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc
index d004fd5c46f..eab8df584bb 100644
--- a/chromium/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc
+++ b/chromium/components/subresource_filter/core/browser/subresource_filter_features_unittest.cc
@@ -253,8 +253,6 @@ TEST(SubresourceFilterFeaturesTest, ActivationList) {
{true, kActivationListSocialEngineeringAdsInterstitial,
ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL},
{true, kActivationListBetterAds, ActivationList::BETTER_ADS},
- {true, kActivationListAbusiveAds, ActivationList::ABUSIVE_ADS},
- {true, kActivationListAllAds, ActivationList::ALL_ADS},
{true, kActivationListPhishingInterstitial,
ActivationList::PHISHING_INTERSTITIAL},
{true, socEngPhising.c_str(), ActivationList::NONE},
@@ -431,40 +429,6 @@ TEST(SubresourceFilterFeaturesTest, WhitelistSiteOnReload) {
}
}
-TEST(SubresourceFilterFeaturesTest, StrengthenPopupBlocker) {
- const struct {
- bool feature_enabled;
- const char* strengthen_popup_blocker_param;
- bool expected_strengthen_popup_blocker_value;
- } kTestCases[] = {{false, "", false},
- {false, "true", false},
- {false, "false", false},
- {false, "invalid value", false},
- {true, "", false},
- {true, "false", false},
- {true, "invalid value", false},
- {true, "True", true},
- {true, "TRUE", true},
- {true, "true", true}};
- for (const auto& test_case : kTestCases) {
- SCOPED_TRACE(::testing::Message("Enabled = ") << test_case.feature_enabled);
- SCOPED_TRACE(::testing::Message("StrengthenPopupBlockerParam = \"")
- << test_case.strengthen_popup_blocker_param << "\"");
-
- ScopedExperimentalStateToggle scoped_experimental_state(
- test_case.feature_enabled ? base::FeatureList::OVERRIDE_ENABLE_FEATURE
- : base::FeatureList::OVERRIDE_USE_DEFAULT,
- {{kStrengthenPopupBlockerParameterName,
- test_case.strengthen_popup_blocker_param}});
-
- Configuration actual_configuration;
- ExpectAndRetrieveExactlyOneEnabledConfig(&actual_configuration);
- EXPECT_EQ(test_case.expected_strengthen_popup_blocker_value,
- actual_configuration.activation_options
- .should_strengthen_popup_blocker);
- }
-}
-
TEST(SubresourceFilterFeaturesTest, RulesetFlavor) {
const struct {
bool feature_enabled;
@@ -582,36 +546,6 @@ TEST(SubresourceFilterFeaturesTest,
{kPerformanceMeasurementRateParameterName, "1.0"}});
}
-TEST(SubresourceFilterFeaturesTest, PresetForLiveRunOnAbusiveAdsSites) {
- ExpectPresetCanBeEnabledByName(
- Configuration::MakePresetForLiveRunForAbusiveAds(),
- kPresetLiveRunForAbusiveAds);
- const Configuration config =
- Configuration::MakePresetForLiveRunForAbusiveAds();
- ExpectPresetIsEquivalentToVariationParams(
- config, {{kActivationLevelParameterName, kActivationLevelEnabled},
- {kActivationScopeParameterName, kActivationScopeActivationList},
- {kActivationListsParameterName, kActivationListAbusiveAds},
- {kActivationPriorityParameterName, "750"},
- {kSuppressNotificationsParameterName, "true"},
- {kDisableRulesetRules, "true"},
- {kStrengthenPopupBlockerParameterName, "true"}});
-
- EXPECT_EQ(ActivationList::ABUSIVE_ADS,
- config.activation_conditions.activation_list);
- EXPECT_EQ(ActivationScope::ACTIVATION_LIST,
- config.activation_conditions.activation_scope);
- EXPECT_EQ(750, config.activation_conditions.priority);
- EXPECT_FALSE(config.activation_conditions.forced_activation);
- EXPECT_EQ(ActivationLevel::ENABLED,
- config.activation_options.activation_level);
- EXPECT_EQ(0.0, config.activation_options.performance_measurement_rate);
- EXPECT_TRUE(config.activation_options.should_suppress_notifications);
- EXPECT_FALSE(config.activation_options.should_whitelist_site_on_reload);
- EXPECT_TRUE(config.activation_options.should_strengthen_popup_blocker);
- EXPECT_TRUE(config.activation_options.should_disable_ruleset_rules);
-}
-
TEST(SubresourceFilterFeaturesTest, PresetForLiveRunOnBetterAdsSites) {
ExpectPresetCanBeEnabledByName(
Configuration::MakePresetForLiveRunForBetterAds(),
@@ -634,33 +568,6 @@ TEST(SubresourceFilterFeaturesTest, PresetForLiveRunOnBetterAdsSites) {
EXPECT_EQ(0.0, config.activation_options.performance_measurement_rate);
EXPECT_FALSE(config.activation_options.should_suppress_notifications);
EXPECT_FALSE(config.activation_options.should_whitelist_site_on_reload);
- EXPECT_FALSE(config.activation_options.should_strengthen_popup_blocker);
- EXPECT_FALSE(config.activation_options.should_disable_ruleset_rules);
-}
-
-TEST(SubresourceFilterFeaturesTest, PresetForLiveRunOnAllAdsSites) {
- ExpectPresetCanBeEnabledByName(Configuration::MakePresetForLiveRunForAllAds(),
- kPresetLiveRunForAllAds);
- const Configuration config = Configuration::MakePresetForLiveRunForAllAds();
- ExpectPresetIsEquivalentToVariationParams(
- config, {{kActivationLevelParameterName, kActivationLevelEnabled},
- {kActivationScopeParameterName, kActivationScopeActivationList},
- {kActivationListsParameterName, kActivationListAllAds},
- {kActivationPriorityParameterName, "850"},
- {kStrengthenPopupBlockerParameterName, "true"}});
- EXPECT_EQ(ActivationList::ALL_ADS,
- config.activation_conditions.activation_list);
- EXPECT_EQ(ActivationScope::ACTIVATION_LIST,
- config.activation_conditions.activation_scope);
- EXPECT_EQ(850, config.activation_conditions.priority);
- EXPECT_FALSE(config.activation_conditions.forced_activation);
- EXPECT_EQ(ActivationLevel::ENABLED,
- config.activation_options.activation_level);
- EXPECT_EQ(0.0, config.activation_options.performance_measurement_rate);
- EXPECT_FALSE(config.activation_options.should_suppress_notifications);
- EXPECT_FALSE(config.activation_options.should_whitelist_site_on_reload);
- EXPECT_TRUE(config.activation_options.should_strengthen_popup_blocker);
- EXPECT_FALSE(config.activation_options.should_disable_ruleset_rules);
}
TEST(SubresourceFilterFeaturesTest, ConfigurationPriorities) {
diff --git a/chromium/components/subresource_filter/core/common/activation_list.cc b/chromium/components/subresource_filter/core/common/activation_list.cc
index e3ad196be24..0ee9d6a6eaa 100644
--- a/chromium/components/subresource_filter/core/common/activation_list.cc
+++ b/chromium/components/subresource_filter/core/common/activation_list.cc
@@ -27,12 +27,6 @@ std::ostream& operator<<(std::ostream& os, const ActivationList& type) {
case ActivationList::BETTER_ADS:
os << "BETTER_ADS";
break;
- case ActivationList::ABUSIVE_ADS:
- os << "ABUSIVE_ADS";
- break;
- case ActivationList::ALL_ADS:
- os << "ALL_ADS";
- break;
default:
NOTREACHED();
break;
diff --git a/chromium/components/subresource_filter/core/common/activation_list.h b/chromium/components/subresource_filter/core/common/activation_list.h
index eff38cabccc..830aba1cb38 100644
--- a/chromium/components/subresource_filter/core/common/activation_list.h
+++ b/chromium/components/subresource_filter/core/common/activation_list.h
@@ -20,14 +20,8 @@ enum class ActivationList : int {
// Site violates the better ads standard.
BETTER_ADS,
- // Site shows abusive ads.
- ABUSIVE_ADS,
-
- // Site violates the better ads standard and shows abusive ads.
- ALL_ADS,
-
// Make sure new elements added update the LAST value.
- LAST = ALL_ADS
+ LAST = BETTER_ADS
};
// For logging use only.
diff --git a/chromium/components/subresource_filter/core/common/first_party_origin_unittest.cc b/chromium/components/subresource_filter/core/common/first_party_origin_unittest.cc
index b8f02e17126..68e271e73e8 100644
--- a/chromium/components/subresource_filter/core/common/first_party_origin_unittest.cc
+++ b/chromium/components/subresource_filter/core/common/first_party_origin_unittest.cc
@@ -12,7 +12,7 @@ namespace subresource_filter {
TEST(FirstPartyOriginTest, AllSameDomain) {
const std::string kDomain = "sub.example.co.uk";
- FirstPartyOrigin first_party(url::Origin(GURL("https://" + kDomain)));
+ FirstPartyOrigin first_party(url::Origin::Create(GURL("https://" + kDomain)));
for (int index = 0; index < 5; ++index) {
GURL url("https://" + kDomain + "/path?q=" + base::IntToString(index));
EXPECT_FALSE(FirstPartyOrigin::IsThirdParty(url, first_party.origin()));
@@ -23,7 +23,7 @@ TEST(FirstPartyOriginTest, AllSameDomain) {
TEST(FirstPartyOriginTest, AllFirstParty) {
const std::string kDomain = "example.co.uk";
- FirstPartyOrigin first_party(url::Origin(GURL("https://" + kDomain)));
+ FirstPartyOrigin first_party(url::Origin::Create(GURL("https://" + kDomain)));
for (int index = 0; index < 5; ++index) {
GURL url("https://sub" + base::IntToString(index) + "." + kDomain + "/suf");
EXPECT_FALSE(FirstPartyOrigin::IsThirdParty(url, first_party.origin()));
@@ -34,7 +34,7 @@ TEST(FirstPartyOriginTest, AllFirstParty) {
TEST(FirstPartyOriginTest, AllThirdParty) {
const std::string kDomain = "example.co.uk";
- FirstPartyOrigin first_party(url::Origin(GURL("https://" + kDomain)));
+ FirstPartyOrigin first_party(url::Origin::Create(GURL("https://" + kDomain)));
for (int index = 0; index < 5; ++index) {
GURL url("https://example" + base::IntToString(index) + ".co.uk/path?k=v");
EXPECT_TRUE(FirstPartyOrigin::IsThirdParty(url, first_party.origin()));
@@ -56,7 +56,8 @@ TEST(FirstPartyOriginTest, MixedFirstAndThirdParties) {
{"data:text/plain,example.com", true},
};
- FirstPartyOrigin first_party(url::Origin(GURL("https://example.com")));
+ FirstPartyOrigin first_party(
+ url::Origin::Create(GURL("https://example.com")));
for (const auto& test_case : kTestCases) {
GURL url(test_case.url);
EXPECT_EQ(test_case.is_third_party,
@@ -71,7 +72,8 @@ TEST(FirstPartyOriginTest, EmptyHostUrls) {
"data:text/plain;base64,ABACABA",
};
- FirstPartyOrigin first_party(url::Origin(GURL("https://example.com")));
+ FirstPartyOrigin first_party(
+ url::Origin::Create(GURL("https://example.com")));
for (auto* url_string : kUrls) {
GURL url(url_string);
EXPECT_TRUE(FirstPartyOrigin::IsThirdParty(url, first_party.origin()));
diff --git a/chromium/components/subresource_filter/core/common/indexed_ruleset.cc b/chromium/components/subresource_filter/core/common/indexed_ruleset.cc
index 18c9faae76e..9378b0623ad 100644
--- a/chromium/components/subresource_filter/core/common/indexed_ruleset.cc
+++ b/chromium/components/subresource_filter/core/common/indexed_ruleset.cc
@@ -5,20 +5,24 @@
#include "components/subresource_filter/core/common/indexed_ruleset.h"
#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "components/subresource_filter/core/common/first_party_origin.h"
-#include "components/subresource_filter/core/common/time_measurements.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace subresource_filter {
+namespace {
namespace proto = url_pattern_index::proto;
+using FindRuleStrategy =
+ url_pattern_index::UrlPatternIndexMatcher::FindRuleStrategy;
+} // namespace
// RulesetIndexer --------------------------------------------------------------
// static
-const int RulesetIndexer::kIndexedFormatVersion = 18;
+const int RulesetIndexer::kIndexedFormatVersion = 19;
RulesetIndexer::RulesetIndexer()
: blacklist_(&builder_), whitelist_(&builder_), deactivation_(&builder_) {}
@@ -62,8 +66,8 @@ void RulesetIndexer::Finish() {
bool IndexedRulesetMatcher::Verify(const uint8_t* buffer, size_t size) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("loading"),
"IndexedRulesetMatcher::Verify");
- SCOPED_UMA_HISTOGRAM_MICRO_TIMER(
- "SubresourceFilter.IndexRuleset.Verify.WallDuration");
+ SCOPED_UMA_HISTOGRAM_TIMER(
+ "SubresourceFilter.IndexRuleset.Verify2.WallDuration");
flatbuffers::Verifier verifier(buffer, size);
return flat::VerifyIndexedRulesetBuffer(verifier);
}
@@ -82,7 +86,7 @@ bool IndexedRulesetMatcher::ShouldDisableFilteringForDocument(
document_url, parent_document_origin, proto::ELEMENT_TYPE_UNSPECIFIED,
activation_type,
FirstPartyOrigin::IsThirdParty(document_url, parent_document_origin),
- false);
+ false, FindRuleStrategy::kAny);
}
bool IndexedRulesetMatcher::ShouldDisallowResourceLoad(
@@ -93,10 +97,12 @@ bool IndexedRulesetMatcher::ShouldDisallowResourceLoad(
const bool is_third_party = first_party.IsThirdParty(url);
return !!blacklist_.FindMatch(url, first_party.origin(), element_type,
proto::ACTIVATION_TYPE_UNSPECIFIED,
- is_third_party, disable_generic_rules) &&
+ is_third_party, disable_generic_rules,
+ FindRuleStrategy::kAny) &&
!whitelist_.FindMatch(url, first_party.origin(), element_type,
proto::ACTIVATION_TYPE_UNSPECIFIED,
- is_third_party, disable_generic_rules);
+ is_third_party, disable_generic_rules,
+ FindRuleStrategy::kAny);
}
} // namespace subresource_filter
diff --git a/chromium/components/subresource_filter/core/common/test_ruleset_creator.cc b/chromium/components/subresource_filter/core/common/test_ruleset_creator.cc
index ba02d32f048..f6c22260464 100644
--- a/chromium/components/subresource_filter/core/common/test_ruleset_creator.cc
+++ b/chromium/components/subresource_filter/core/common/test_ruleset_creator.cc
@@ -29,7 +29,7 @@ static_assert(CHAR_BIT == 8, "Assumed char was 8 bits.");
void WriteRulesetContents(const std::vector<uint8_t>& contents,
base::FilePath path) {
- base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::ScopedAllowBlockingForTesting allow_blocking;
int ruleset_size_as_int = base::checked_cast<int>(contents.size());
int num_bytes_written =
base::WriteFile(path, reinterpret_cast<const char*>(contents.data()),
@@ -70,7 +70,7 @@ TestRuleset::~TestRuleset() = default;
// static
base::File TestRuleset::Open(const TestRuleset& ruleset) {
- base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::ScopedAllowBlockingForTesting allow_blocking;
base::File file;
file.Initialize(ruleset.path, base::File::FLAG_OPEN | base::File::FLAG_READ |
base::File::FLAG_SHARE_DELETE);
@@ -115,7 +115,7 @@ TestRulesetCreator::TestRulesetCreator()
: scoped_temp_dir_(base::MakeUnique<base::ScopedTempDir>()) {}
TestRulesetCreator::~TestRulesetCreator() {
- base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::ScopedAllowBlockingForTesting allow_blocking;
scoped_temp_dir_.reset();
}
@@ -172,7 +172,7 @@ void TestRulesetCreator::CreateUnindexedRulesetWithRules(
void TestRulesetCreator::GetUniqueTemporaryPath(base::FilePath* path) {
DCHECK(path);
- base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::ScopedAllowBlockingForTesting allow_blocking;
ASSERT_TRUE(scoped_temp_dir_->IsValid() ||
scoped_temp_dir_->CreateUniqueTempDir());
*path = scoped_temp_dir_->GetPath().AppendASCII(