diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/previews | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/previews')
31 files changed, 937 insertions, 896 deletions
diff --git a/chromium/components/previews/DEPS b/chromium/components/previews/DEPS index 03135a11a14..17d1bf68d3d 100644 --- a/chromium/components/previews/DEPS +++ b/chromium/components/previews/DEPS @@ -2,7 +2,7 @@ include_rules = [ # Previews is a layered component; subdirectories must introduce # allowances of //content dependencies as appropriate. "-components", - "-components/data_reduction_proxy/", - "+components/data_reduction_proxy/core/browser/", + "-components/data_reduction_proxy", + "+components/data_reduction_proxy/core/browser", "-components/previews/content", ]
\ No newline at end of file diff --git a/chromium/components/previews/content/BUILD.gn b/chromium/components/previews/content/BUILD.gn index 6e05b72df2f..1c6330e7e0e 100644 --- a/chromium/components/previews/content/BUILD.gn +++ b/chromium/components/previews/content/BUILD.gn @@ -17,7 +17,7 @@ static_library("content") { deps = [ "//base", - "//components/blacklist/opt_out_blacklist", + "//components/blocklist/opt_out_blocklist", "//components/data_reduction_proxy/core/browser", "//components/optimization_guide", "//components/optimization_guide/proto:optimization_guide_proto", @@ -43,7 +43,7 @@ source_set("unit_tests") { deps = [ ":content", "//base", - "//components/blacklist/opt_out_blacklist", + "//components/blocklist/opt_out_blocklist", "//components/data_reduction_proxy/core/browser", "//components/data_reduction_proxy/core/common", "//components/optimization_guide", diff --git a/chromium/components/previews/content/DEPS b/chromium/components/previews/content/DEPS index 39e29e96860..db5594d7ff8 100644 --- a/chromium/components/previews/content/DEPS +++ b/chromium/components/previews/content/DEPS @@ -1,5 +1,5 @@ include_rules = [ - "+components/blacklist/opt_out_blacklist", + "+components/blocklist/opt_out_blocklist", "+components/data_reduction_proxy/core/browser", "+components/data_reduction_proxy/core/common", "+components/keyed_service", diff --git a/chromium/components/previews/content/previews_decider_impl.cc b/chromium/components/previews/content/previews_decider_impl.cc index dc22202f2d6..d53bea918bc 100644 --- a/chromium/components/previews/content/previews_decider_impl.cc +++ b/chromium/components/previews/content/previews_decider_impl.cc @@ -19,7 +19,7 @@ #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/time/clock.h" -#include "components/blacklist/opt_out_blacklist/opt_out_store.h" +#include "components/blocklist/opt_out_blocklist/opt_out_store.h" #include "components/previews/content/previews_ui_service.h" #include "components/previews/content/previews_user_data.h" #include "components/previews/core/previews_experiments.h" @@ -94,7 +94,7 @@ bool IsCommitTimePreview(PreviewsType type) { } // namespace PreviewsDeciderImpl::PreviewsDeciderImpl(base::Clock* clock) - : blacklist_ignored_(switches::ShouldIgnorePreviewsBlacklist()), + : blocklist_ignored_(switches::ShouldIgnorePreviewsBlocklist()), clock_(clock), page_id_(1u) {} @@ -104,41 +104,41 @@ PreviewsDeciderImpl::~PreviewsDeciderImpl() { void PreviewsDeciderImpl::Initialize( PreviewsUIService* previews_ui_service, - std::unique_ptr<blacklist::OptOutStore> previews_opt_out_store, + std::unique_ptr<blocklist::OptOutStore> previews_opt_out_store, std::unique_ptr<PreviewsOptimizationGuide> previews_opt_guide, const PreviewsIsEnabledCallback& is_enabled_callback, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_previews) { + blocklist::BlocklistData::AllowedTypesAndVersions allowed_previews) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(!is_enabled_callback.is_null()); is_enabled_callback_ = is_enabled_callback; previews_ui_service_ = previews_ui_service; previews_opt_guide_ = std::move(previews_opt_guide); - previews_black_list_ = std::make_unique<PreviewsBlackList>( + previews_block_list_ = std::make_unique<PreviewsBlockList>( std::move(previews_opt_out_store), clock_, this, std::move(allowed_previews)); } -void PreviewsDeciderImpl::OnNewBlacklistedHost(const std::string& host, +void PreviewsDeciderImpl::OnNewBlocklistedHost(const std::string& host, base::Time time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_ui_service_->OnNewBlacklistedHost(host, time); + previews_ui_service_->OnNewBlocklistedHost(host, time); } -void PreviewsDeciderImpl::OnUserBlacklistedStatusChange(bool blacklisted) { +void PreviewsDeciderImpl::OnUserBlocklistedStatusChange(bool blocklisted) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_ui_service_->OnUserBlacklistedStatusChange(blacklisted); + previews_ui_service_->OnUserBlocklistedStatusChange(blocklisted); } -void PreviewsDeciderImpl::OnBlacklistCleared(base::Time time) { +void PreviewsDeciderImpl::OnBlocklistCleared(base::Time time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_ui_service_->OnBlacklistCleared(time); + previews_ui_service_->OnBlocklistCleared(time); } -void PreviewsDeciderImpl::SetPreviewsBlacklistForTesting( - std::unique_ptr<PreviewsBlackList> previews_back_list) { +void PreviewsDeciderImpl::SetPreviewsBlocklistForTesting( + std::unique_ptr<PreviewsBlockList> previews_block_list) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_black_list_ = std::move(previews_back_list); + previews_block_list_ = std::move(previews_block_list); } void PreviewsDeciderImpl::LogPreviewNavigation(const GURL& url, @@ -170,22 +170,22 @@ void PreviewsDeciderImpl::AddPreviewNavigation(const GURL& url, uint64_t page_id) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); base::Time time = - previews_black_list_->AddPreviewNavigation(url, opt_out, type); + previews_block_list_->AddPreviewNavigation(url, opt_out, type); LogPreviewNavigation(url, opt_out, type, time, page_id); } -void PreviewsDeciderImpl::ClearBlackList(base::Time begin_time, +void PreviewsDeciderImpl::ClearBlockList(base::Time begin_time, base::Time end_time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_black_list_->ClearBlackList(begin_time, end_time); + previews_block_list_->ClearBlockList(begin_time, end_time); } -void PreviewsDeciderImpl::SetIgnorePreviewsBlacklistDecision(bool ignored) { +void PreviewsDeciderImpl::SetIgnorePreviewsBlocklistDecision(bool ignored) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - blacklist_ignored_ = ignored; - previews_ui_service_->OnIgnoreBlacklistDecisionStatusChanged( - blacklist_ignored_); + blocklist_ignored_ = ignored; + previews_ui_service_->OnIgnoreBlocklistDecisionStatusChanged( + blocklist_ignored_); } bool PreviewsDeciderImpl::ShouldAllowPreviewAtNavigationStart( @@ -319,14 +319,14 @@ PreviewsEligibilityReason PreviewsDeciderImpl::DeterminePreviewEligibility( } } - // Skip blacklist checks if the blacklist is ignored or defer check until + // Skip blocklist checks if the blocklist is ignored or defer check until // commit time if preview type is to be decided at commit time. - if (!blacklist_ignored_ && !IsCommitTimePreview(type)) { + if (!blocklist_ignored_ && !IsCommitTimePreview(type)) { PreviewsEligibilityReason status = - CheckLocalBlacklist(url, type, is_drp_server_preview, passed_reasons); + CheckLocalBlocklist(url, type, is_drp_server_preview, passed_reasons); if (status != PreviewsEligibilityReason::ALLOWED) { if (type == PreviewsType::LITE_PAGE) { - previews_data->set_black_listed_for_lite_page(true); + previews_data->set_block_listed_for_lite_page(true); } return status; } @@ -335,14 +335,14 @@ PreviewsEligibilityReason PreviewsDeciderImpl::DeterminePreviewEligibility( return PreviewsEligibilityReason::ALLOWED; } -PreviewsEligibilityReason PreviewsDeciderImpl::CheckLocalBlacklist( +PreviewsEligibilityReason PreviewsDeciderImpl::CheckLocalBlocklist( const GURL& url, PreviewsType type, bool is_drp_server_preview, std::vector<PreviewsEligibilityReason>* passed_reasons) const { - if (!previews_black_list_) - return PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE; - passed_reasons->push_back(PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE); + if (!previews_block_list_) + return PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE; + passed_reasons->push_back(PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE); // Trigger the USER_RECENTLY_OPTED_OUT rule when a reload on a preview has // occurred recently. No need to push_back the eligibility reason as it will @@ -353,11 +353,11 @@ PreviewsEligibilityReason PreviewsDeciderImpl::CheckLocalBlacklist( return PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT; } - // The blacklist will disallow certain hosts for periods of time based on + // The blocklist will disallow certain hosts for periods of time based on // user's opting out of the preview. - return previews_black_list_->IsLoadedAndAllowed( + return previews_block_list_->IsLoadedAndAllowed( url, type, - is_drp_server_preview && ignore_long_term_blacklist_for_server_previews_, + is_drp_server_preview && ignore_long_term_blocklist_for_server_previews_, passed_reasons); } @@ -394,11 +394,11 @@ bool PreviewsDeciderImpl::ShouldCommitPreview( } } - // Check local blacklist for commit-time preview (if blacklist not ignored). - if (!blacklist_ignored_ && IsCommitTimePreview(type)) { + // Check local blocklist for commit-time preview (if blocklist not ignored). + if (!blocklist_ignored_ && IsCommitTimePreview(type)) { std::vector<PreviewsEligibilityReason> passed_reasons; PreviewsEligibilityReason status = - CheckLocalBlacklist(committed_url, type, false, &passed_reasons); + CheckLocalBlocklist(committed_url, type, false, &passed_reasons); if (status != PreviewsEligibilityReason::ALLOWED) { LogPreviewDecisionMade(status, committed_url, clock_->Now(), type, std::move(passed_reasons), previews_data); @@ -454,7 +454,7 @@ PreviewsDeciderImpl::ShouldCommitPreviewPerOptimizationHints( passed_reasons->push_back( PreviewsEligibilityReason::PAGE_LOAD_PREDICTION_NOT_PAINFUL); - // Check if request URL is whitelisted by the optimization guide. + // Check if request URL is allowlisted by the optimization guide. if (!previews_opt_guide_->CanApplyPreview(previews_data, navigation_handle, type)) { return PreviewsEligibilityReason::NOT_ALLOWED_BY_OPTIMIZATION_GUIDE; @@ -495,11 +495,11 @@ uint64_t PreviewsDeciderImpl::GeneratePageId() { return ++page_id_; } -void PreviewsDeciderImpl::SetIgnoreLongTermBlackListForServerPreviews( - bool ignore_long_term_blacklist_for_server_previews) { +void PreviewsDeciderImpl::SetIgnoreLongTermBlockListForServerPreviews( + bool ignore_long_term_blocklist_for_server_previews) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - ignore_long_term_blacklist_for_server_previews_ = - ignore_long_term_blacklist_for_server_previews; + ignore_long_term_blocklist_for_server_previews_ = + ignore_long_term_blocklist_for_server_previews; } void PreviewsDeciderImpl::SetEffectiveConnectionType( diff --git a/chromium/components/previews/content/previews_decider_impl.h b/chromium/components/previews/content/previews_decider_impl.h index b9b1a0b4038..73a9178e803 100644 --- a/chromium/components/previews/content/previews_decider_impl.h +++ b/chromium/components/previews/content/previews_decider_impl.h @@ -18,11 +18,11 @@ #include "base/sequence_checker.h" #include "base/single_thread_task_runner.h" #include "base/time/time.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_data.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_delegate.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_data.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_delegate.h" #include "components/previews/content/previews_decider.h" #include "components/previews/content/previews_optimization_guide.h" -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include "components/previews/core/previews_experiments.h" #include "components/previews/core/previews_logger.h" #include "net/nqe/effective_connection_type.h" @@ -32,7 +32,7 @@ namespace base { class Clock; } -namespace blacklist { +namespace blocklist { class OptOutStore; } @@ -49,24 +49,24 @@ typedef base::RepeatingCallback<bool(PreviewsType)> PreviewsIsEnabledCallback; // previews/ objects. Created on the UI thread, but used only on the IO thread // after initialization. class PreviewsDeciderImpl : public PreviewsDecider, - public blacklist::OptOutBlacklistDelegate { + public blocklist::OptOutBlocklistDelegate { public: explicit PreviewsDeciderImpl(base::Clock* clock); ~PreviewsDeciderImpl() override; - // blacklist::OptOutBlacklistDelegate: - void OnNewBlacklistedHost(const std::string& host, base::Time time) override; - void OnUserBlacklistedStatusChange(bool blacklisted) override; - void OnBlacklistCleared(base::Time time) override; + // blocklist::OptOutBlocklistDelegate: + void OnNewBlocklistedHost(const std::string& host, base::Time time) override; + void OnUserBlocklistedStatusChange(bool blocklisted) override; + void OnBlocklistCleared(base::Time time) override; - // Initializes the blacklist and and stores the passed in members. + // Initializes the blocklist and and stores the passed in members. // |previews_ui_service| owns |this|, and shares the same lifetime. virtual void Initialize( PreviewsUIService* previews_ui_service, - std::unique_ptr<blacklist::OptOutStore> previews_opt_out_store, + std::unique_ptr<blocklist::OptOutStore> previews_opt_out_store, std::unique_ptr<PreviewsOptimizationGuide> previews_opt_guide, const PreviewsIsEnabledCallback& is_enabled_callback, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_previews); + blocklist::BlocklistData::AllowedTypesAndVersions allowed_previews); // Adds log message of the navigation asynchronously. void LogPreviewNavigation(const GURL& url, @@ -90,24 +90,24 @@ class PreviewsDeciderImpl : public PreviewsDecider, std::vector<PreviewsEligibilityReason>&& passed_reasons, PreviewsUserData* user_data) const; - // Adds a navigation to |url| to the black list with result |opt_out|. + // Adds a navigation to |url| to the block list with result |opt_out|. void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type, uint64_t page_id); - // Clears the history of the black list between |begin_time| and |end_time|, + // Clears the history of the block list between |begin_time| and |end_time|, // both inclusive. Additional, clears the appropriate data from the hint // cache. TODO(mcrouse): Rename to denote clearing all necessary data, - // including the Fetched hints and the blacklist. - void ClearBlackList(base::Time begin_time, base::Time end_time); + // including the Fetched hints and the blocklist. + void ClearBlockList(base::Time begin_time, base::Time end_time); // Change the status of whether to ignore the decisions made by - // PreviewsBlackList to |ignored|. Virtualized in testing. - virtual void SetIgnorePreviewsBlacklistDecision(bool ignored); + // PreviewsBlockList to |ignored|. Virtualized in testing. + virtual void SetIgnorePreviewsBlocklistDecision(bool ignored); - // The previews black list that decides whether a navigation can use previews. - PreviewsBlackList* black_list() const { return previews_black_list_.get(); } + // The previews block list that decides whether a navigation can use previews. + PreviewsBlockList* block_list() const { return previews_block_list_.get(); } // PreviewsDecider implementation: bool ShouldAllowPreviewAtNavigationStart( @@ -119,9 +119,9 @@ class PreviewsDeciderImpl : public PreviewsDecider, content::NavigationHandle* navigation_handle, PreviewsType type) const override; - // Set whether to ignore the long term blacklist rules for server previews. - void SetIgnoreLongTermBlackListForServerPreviews( - bool ignore_long_term_blacklist_for_server_previews); + // Set whether to ignore the long term blocklist rules for server previews. + void SetIgnoreLongTermBlockListForServerPreviews( + bool ignore_long_term_blocklist_for_server_previews); bool AreCommitTimePreviewsAvailable( content::NavigationHandle* navigation_handle) override; @@ -142,9 +142,9 @@ class PreviewsDeciderImpl : public PreviewsDecider, void AddPreviewReload(); protected: - // Sets a blacklist for testing. - void SetPreviewsBlacklistForTesting( - std::unique_ptr<PreviewsBlackList> previews_back_list); + // Sets a blocklist for testing. + void SetPreviewsBlocklistForTesting( + std::unique_ptr<PreviewsBlockList> previews_back_list); private: // Returns whether the preview |type| should be considered for |url|. @@ -163,8 +163,8 @@ class PreviewsDeciderImpl : public PreviewsDecider, bool is_drp_server_preview, std::vector<PreviewsEligibilityReason>* passed_reasons) const; - // Returns previews eligibility with respect to the local blacklist. - PreviewsEligibilityReason CheckLocalBlacklist( + // Returns previews eligibility with respect to the local blocklist. + PreviewsEligibilityReason CheckLocalBlocklist( const GURL& url, PreviewsType type, bool is_drp_server_preview, @@ -192,20 +192,20 @@ class PreviewsDeciderImpl : public PreviewsDecider, // The UI service object owns |this| and exists as long as |this| does. PreviewsUIService* previews_ui_service_; - std::unique_ptr<PreviewsBlackList> previews_black_list_; + std::unique_ptr<PreviewsBlockList> previews_block_list_; // Holds optimization guidance from the server. std::unique_ptr<PreviewsOptimizationGuide> previews_opt_guide_; - // Whether the decisions made by PreviewsBlackList should be ignored or not. + // Whether the decisions made by PreviewsBlockList should be ignored or not. // This can be changed by chrome://interventions-internals to test/debug the // behavior of Previews decisions. // This is related to a test flag and should only be true when the user has - // set it in flags. See previews::IsPreviewsBlacklistIgnoredViaFlag. - bool blacklist_ignored_; + // set it in flags. See previews::IsPreviewsBlocklistIgnoredViaFlag. + bool blocklist_ignored_; - // Whether to ignore the blacklist for server previews. - bool ignore_long_term_blacklist_for_server_previews_ = false; + // Whether to ignore the blocklist for server previews. + bool ignore_long_term_blocklist_for_server_previews_ = false; // The estimate of how slow a user's connection is. Used for triggering // Previews. diff --git a/chromium/components/previews/content/previews_decider_impl_unittest.cc b/chromium/components/previews/content/previews_decider_impl_unittest.cc index d03f79ad24f..3cdf1983e4f 100644 --- a/chromium/components/previews/content/previews_decider_impl_unittest.cc +++ b/chromium/components/previews/content/previews_decider_impl_unittest.cc @@ -33,10 +33,10 @@ #include "base/time/default_clock.h" #include "base/time/time.h" #include "build/build_config.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_data.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_delegate.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_item.h" -#include "components/blacklist/opt_out_blacklist/opt_out_store.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_data.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_delegate.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_item.h" +#include "components/blocklist/opt_out_blocklist/opt_out_store.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" #include "components/optimization_guide/optimization_guide_prefs.h" #include "components/optimization_guide/proto_database_provider_test_base.h" @@ -44,7 +44,7 @@ #include "components/prefs/testing_pref_service.h" #include "components/previews/content/previews_ui_service.h" #include "components/previews/content/previews_user_data.h" -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include "components/previews/core/previews_experiments.h" #include "components/previews/core/previews_features.h" #include "components/previews/core/previews_logger.h" @@ -62,15 +62,15 @@ // TODO(crbug.com/961023): Fix memory leaks in tests and re-enable on LSAN. #ifdef LEAK_SANITIZER -#define MAYBE_TestSetBlacklistBoolDueToBlackListState \ - DISABLED_TestSetBlacklistBoolDueToBlackListState -#define MAYBE_TestDisallowPreviewBecauseOfBlackListState \ - DISABLED_TestDisallowPreviewBecauseOfBlackListState +#define MAYBE_TestSetBlocklistBoolDueToBlockListState \ + DISABLED_TestSetBlocklistBoolDueToBlockListState +#define MAYBE_TestDisallowPreviewBecauseOfBlockListState \ + DISABLED_TestDisallowPreviewBecauseOfBlockListState #else -#define MAYBE_TestSetBlacklistBoolDueToBlackListState \ - TestSetBlacklistBoolDueToBlackListState -#define MAYBE_TestDisallowPreviewBecauseOfBlackListState \ - TestDisallowPreviewBecauseOfBlackListState +#define MAYBE_TestSetBlocklistBoolDueToBlockListState \ + TestSetBlocklistBoolDueToBlockListState +#define MAYBE_TestDisallowPreviewBecauseOfBlockListState \ + TestDisallowPreviewBecauseOfBlockListState #endif namespace previews { @@ -109,32 +109,32 @@ bool IsPreviewFieldTrialEnabled(PreviewsType type) { return false; } -// Stub class of PreviewsBlackList to control IsLoadedAndAllowed outcome when +// Stub class of PreviewsBlockList to control IsLoadedAndAllowed outcome when // testing PreviewsDeciderImpl. -class TestPreviewsBlackList : public PreviewsBlackList { +class TestPreviewsBlockList : public PreviewsBlockList { public: - TestPreviewsBlackList(PreviewsEligibilityReason status, - blacklist::OptOutBlacklistDelegate* blacklist_delegate) - : PreviewsBlackList(nullptr, + TestPreviewsBlockList(PreviewsEligibilityReason status, + blocklist::OptOutBlocklistDelegate* blocklist_delegate) + : PreviewsBlockList(nullptr, base::DefaultClock::GetInstance(), - blacklist_delegate, + blocklist_delegate, {}), status_(status) {} - ~TestPreviewsBlackList() override {} + ~TestPreviewsBlockList() override = default; - // PreviewsBlackList: + // PreviewsBlockList: PreviewsEligibilityReason IsLoadedAndAllowed( const GURL& url, PreviewsType type, - bool ignore_long_term_black_list_rules, + bool ignore_long_term_block_list_rules, std::vector<PreviewsEligibilityReason>* passed_reasons) const override { std::vector<PreviewsEligibilityReason> ordered_reasons = { - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT}; - if (!ignore_long_term_black_list_rules) { - ordered_reasons.push_back(PreviewsEligibilityReason::USER_BLACKLISTED); - ordered_reasons.push_back(PreviewsEligibilityReason::HOST_BLACKLISTED); + if (!ignore_long_term_block_list_rules) { + ordered_reasons.push_back(PreviewsEligibilityReason::USER_BLOCKLISTED); + ordered_reasons.push_back(PreviewsEligibilityReason::HOST_BLOCKLISTED); } for (auto reason : ordered_reasons) { @@ -189,19 +189,19 @@ class TestPreviewsOptimizationGuide const GURL url = navigation_handle->GetURL(); if (type == PreviewsType::NOSCRIPT) { - return url.host().compare("whitelisted.example.com") == 0 || - url.host().compare("noscript_only_whitelisted.example.com") == 0; + return url.host().compare("allowlisted.example.com") == 0 || + url.host().compare("noscript_only_allowlisted.example.com") == 0; } if (type == PreviewsType::RESOURCE_LOADING_HINTS || type == PreviewsType::DEFER_ALL_SCRIPT) { - return url.host().compare("whitelisted.example.com") == 0; + return url.host().compare("allowlisted.example.com") == 0; } return false; } // Returns whether the URL associated with |navigation_handle| should be - // blacklisted from |type|. - bool IsBlacklisted(content::NavigationHandle* navigation_handle, + // blocklisted from |type|. + bool IsBlocklisted(content::NavigationHandle* navigation_handle, PreviewsType type) const { return false; } @@ -218,11 +218,11 @@ class TestPreviewsUIService : public PreviewsUIService { public: TestPreviewsUIService( std::unique_ptr<PreviewsDeciderImpl> previews_decider_impl, - std::unique_ptr<blacklist::OptOutStore> previews_opt_out_store, + std::unique_ptr<blocklist::OptOutStore> previews_opt_out_store, std::unique_ptr<PreviewsOptimizationGuide> previews_opt_guide, const PreviewsIsEnabledCallback& is_enabled_callback, std::unique_ptr<PreviewsLogger> logger, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_types, + blocklist::BlocklistData::AllowedTypesAndVersions allowed_types, network::NetworkQualityTracker* network_quality_tracker) : PreviewsUIService(std::move(previews_decider_impl), std::move(previews_opt_out_store), @@ -231,22 +231,22 @@ class TestPreviewsUIService : public PreviewsUIService { std::move(logger), std::move(allowed_types), network_quality_tracker), - user_blacklisted_(false), - blacklist_ignored_(false) {} + user_blocklisted_(false), + blocklist_ignored_(false) {} // PreviewsUIService: - void OnNewBlacklistedHost(const std::string& host, base::Time time) override { - host_blacklisted_ = host; - host_blacklisted_time_ = time; + void OnNewBlocklistedHost(const std::string& host, base::Time time) override { + host_blocklisted_ = host; + host_blocklisted_time_ = time; } - void OnUserBlacklistedStatusChange(bool blacklisted) override { - user_blacklisted_ = blacklisted; + void OnUserBlocklistedStatusChange(bool blocklisted) override { + user_blocklisted_ = blocklisted; } - void OnBlacklistCleared(base::Time time) override { - blacklist_cleared_time_ = time; + void OnBlocklistCleared(base::Time time) override { + blocklist_cleared_time_ = time; } - void OnIgnoreBlacklistDecisionStatusChanged(bool ignored) override { - blacklist_ignored_ = ignored; + void OnIgnoreBlocklistDecisionStatusChanged(bool ignored) override { + blocklist_ignored_ = ignored; } // Expose passed in LogPreviewDecision parameters. @@ -281,14 +281,14 @@ class TestPreviewsUIService : public PreviewsUIService { return navigation_page_ids_; } - // Expose passed in params for hosts and user blacklist event. - std::string host_blacklisted() const { return host_blacklisted_; } - base::Time host_blacklisted_time() const { return host_blacklisted_time_; } - bool user_blacklisted() const { return user_blacklisted_; } - base::Time blacklist_cleared_time() const { return blacklist_cleared_time_; } + // Expose passed in params for hosts and user blocklist event. + std::string host_blocklisted() const { return host_blocklisted_; } + base::Time host_blocklisted_time() const { return host_blocklisted_time_; } + bool user_blocklisted() const { return user_blocklisted_; } + base::Time blocklist_cleared_time() const { return blocklist_cleared_time_; } - // Expose the status of blacklist decisions ignored. - bool blacklist_ignored() const { return blacklist_ignored_; } + // Expose the status of blocklist decisions ignored. + bool blocklist_ignored() const { return blocklist_ignored_; } private: // PreviewsUIService: @@ -319,11 +319,11 @@ class TestPreviewsUIService : public PreviewsUIService { decision_ids_.push_back(page_id); } - // Passed in params for blacklist status events. - std::string host_blacklisted_; - base::Time host_blacklisted_time_; - bool user_blacklisted_; - base::Time blacklist_cleared_time_; + // Passed in params for blocklist status events. + std::string host_blocklisted_; + base::Time host_blocklisted_time_; + bool user_blocklisted_; + base::Time blocklist_cleared_time_; // Passed in LogPreviewDecision parameters. std::vector<PreviewsEligibilityReason> decision_reasons_; @@ -340,8 +340,8 @@ class TestPreviewsUIService : public PreviewsUIService { std::vector<PreviewsType> navigation_types_; std::vector<uint64_t> navigation_page_ids_; - // Whether the blacklist decisions are ignored or not. - bool blacklist_ignored_; + // Whether the blocklist decisions are ignored or not. + bool blocklist_ignored_; }; class TestPreviewsDeciderImpl : public PreviewsDeciderImpl { @@ -350,38 +350,38 @@ class TestPreviewsDeciderImpl : public PreviewsDeciderImpl { : PreviewsDeciderImpl(clock) {} ~TestPreviewsDeciderImpl() override {} - // Expose the injecting blacklist method from PreviewsDeciderImpl, and inject - // |blacklist| into |this|. - void InjectTestBlacklist(std::unique_ptr<PreviewsBlackList> blacklist) { - SetPreviewsBlacklistForTesting(std::move(blacklist)); + // Expose the injecting blocklist method from PreviewsDeciderImpl, and inject + // |blocklist| into |this|. + void InjectTestBlocklist(std::unique_ptr<PreviewsBlockList> blocklist) { + SetPreviewsBlocklistForTesting(std::move(blocklist)); } }; -void RunLoadCallback(blacklist::LoadBlackListCallback callback, - std::unique_ptr<blacklist::BlacklistData> data) { +void RunLoadCallback(blocklist::LoadBlockListCallback callback, + std::unique_ptr<blocklist::BlocklistData> data) { std::move(callback).Run(std::move(data)); } -class TestOptOutStore : public blacklist::OptOutStore { +class TestOptOutStore : public blocklist::OptOutStore { public: TestOptOutStore() {} ~TestOptOutStore() override {} private: - // blacklist::OptOutStore implementation: + // blocklist::OptOutStore implementation: void AddEntry(bool opt_out, const std::string& host_name, int type, base::Time now) override {} - void LoadBlackList(std::unique_ptr<blacklist::BlacklistData> data, - blacklist::LoadBlackListCallback callback) override { + void LoadBlockList(std::unique_ptr<blocklist::BlocklistData> data, + blocklist::LoadBlockListCallback callback) override { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&RunLoadCallback, std::move(callback), std::move(data))); } - void ClearBlackList(base::Time begin_time, base::Time end_time) override {} + void ClearBlockList(base::Time begin_time, base::Time end_time) override {} }; class PreviewsDeciderImplTest @@ -412,9 +412,9 @@ class PreviewsDeciderImplTest ui_service_.reset(); } - void InitializeUIServiceWithoutWaitingForBlackList( + void InitializeUIServiceWithoutWaitingForBlockList( bool include_previews_opt_guide) { - blacklist::BlacklistData::AllowedTypesAndVersions allowed_types; + blocklist::BlocklistData::AllowedTypesAndVersions allowed_types; allowed_types[static_cast<int>(PreviewsType::OFFLINE)] = 0; allowed_types[static_cast<int>(PreviewsType::LITE_PAGE)] = 0; allowed_types[static_cast<int>(PreviewsType::NOSCRIPT)] = 0; @@ -439,7 +439,7 @@ class PreviewsDeciderImplTest } void InitializeUIService(bool include_previews_opt_guide = true) { - InitializeUIServiceWithoutWaitingForBlackList(include_previews_opt_guide); + InitializeUIServiceWithoutWaitingForBlockList(include_previews_opt_guide); task_environment_.RunUntilIdle(); base::RunLoop().RunUntilIdle(); } @@ -508,10 +508,10 @@ TEST_F(PreviewsDeciderImplTest, TestDisallowBasicAuthentication) { } // Tests most of the reasons that a preview could be disallowed because of the -// state of the blacklist. Excluded values are USER_RECENTLY_OPTED_OUT, -// USER_BLACKLISTED, HOST_BLACKLISTED. These are internal to the blacklist. +// state of the blocklist. Excluded values are USER_RECENTLY_OPTED_OUT, +// USER_BLOCKLISTED, HOST_BLOCKLISTED. These are internal to the blocklist. TEST_F(PreviewsDeciderImplTest, - MAYBE_TestDisallowPreviewBecauseOfBlackListState) { + MAYBE_TestDisallowPreviewBecauseOfBlockListState) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); @@ -521,46 +521,46 @@ TEST_F(PreviewsDeciderImplTest, content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); - InitializeUIServiceWithoutWaitingForBlackList( + InitializeUIServiceWithoutWaitingForBlockList( /*include_previews_opt_guide=*/true); - // The blacklist is not loaded yet. + // The blocklist is not loaded yet. EXPECT_FALSE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::OFFLINE)); histogram_tester.ExpectBucketCount( "Previews.EligibilityReason", - static_cast<int>(PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED), + static_cast<int>(PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED), 1); histogram_tester.ExpectBucketCount( "Previews.EligibilityReason.Offline", - static_cast<int>(PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED), + static_cast<int>(PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED), 1); base::RunLoop().RunUntilIdle(); histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 1); - // Return one of the failing statuses from the blacklist; cause the blacklist - // to not be loaded by clearing the blacklist. + // Return one of the failing statuses from the blocklist; cause the blocklist + // to not be loaded by clearing the blocklist. base::Time now = base::Time::Now(); - previews_decider_impl()->ClearBlackList(now, now); + previews_decider_impl()->ClearBlockList(now, now); EXPECT_FALSE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::OFFLINE)); histogram_tester.ExpectBucketCount( "Previews.EligibilityReason.Offline", - static_cast<int>(PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED), + static_cast<int>(PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED), 2); histogram_tester.ExpectBucketCount( "Previews.EligibilityReason", - static_cast<int>(PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED), + static_cast<int>(PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED), 2); histogram_tester.ExpectTotalCount("Previews.EligibilityReason.NoScript", 0); variations::testing::ClearAllVariationParams(); } -TEST_F(PreviewsDeciderImplTest, MAYBE_TestSetBlacklistBoolDueToBlackListState) { +TEST_F(PreviewsDeciderImplTest, MAYBE_TestSetBlocklistBoolDueToBlockListState) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); @@ -570,16 +570,16 @@ TEST_F(PreviewsDeciderImplTest, MAYBE_TestSetBlacklistBoolDueToBlackListState) { navigation_handle.set_url(GURL("https://www.google.com")); base::HistogramTester histogram_tester; - InitializeUIServiceWithoutWaitingForBlackList( + InitializeUIServiceWithoutWaitingForBlockList( /*include_previews_opt_guide=*/true); base::RunLoop().RunUntilIdle(); previews_decider_impl()->AddPreviewNavigation( GURL("https://www.google.com"), true, PreviewsType::LITE_PAGE, 1); - EXPECT_FALSE(user_data.black_listed_for_lite_page()); + EXPECT_FALSE(user_data.block_listed_for_lite_page()); EXPECT_FALSE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::LITE_PAGE)); - EXPECT_TRUE(user_data.black_listed_for_lite_page()); + EXPECT_TRUE(user_data.block_listed_for_lite_page()); } TEST_F(PreviewsDeciderImplTest, @@ -860,22 +860,11 @@ TEST_F(PreviewsDeciderImplTest, NoScriptFeatureDefaultBehavior) { PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); -#if defined(OS_ANDROID) - // Enabled by default on Android. NOSCRIPT always allowed at navigation start - // to handle asynchronous loading of page hints; non-whitelisted ones are - // later blocked on commit. - EXPECT_TRUE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( - &user_data, &navigation_handle, false, PreviewsType::NOSCRIPT)); - histogram_tester.ExpectTotalCount("Previews.EligibilityReason.NoScript", 1); - histogram_tester.ExpectBucketCount( - "Previews.EligibilityReason.NoScript", - static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1); -#else // !defined(OS_ANDROID) + // Disabled by default on non-Android. EXPECT_FALSE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::NOSCRIPT)); histogram_tester.ExpectTotalCount("Previews.EligibilityReason.NoScript", 0); -#endif // defined(OS_ANDROID) } TEST_F(PreviewsDeciderImplTest, NoScriptNotAllowedWithoutOptimizationHints) { @@ -904,7 +893,7 @@ TEST_F(PreviewsDeciderImplTest, NoScriptNotAllowedWithoutOptimizationHints) { } } -TEST_F(PreviewsDeciderImplTest, NoScriptAllowedByFeatureWithWhitelist) { +TEST_F(PreviewsDeciderImplTest, NoScriptAllowedByFeatureWithAllowlist) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kNoScriptPreviews}, {}); @@ -915,14 +904,14 @@ TEST_F(PreviewsDeciderImplTest, NoScriptAllowedByFeatureWithWhitelist) { PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); - // First verify preview allowed for non-whitelisted url; they're always + // First verify preview allowed for non-allowlisted url; they're always // allowed at navigation start to enable asynchronous loading of page hints. EXPECT_TRUE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::NOSCRIPT)); - // Now verify preview allowed for whitelisted url. - content::MockNavigationHandle whitelisted_navigation_handle; - whitelisted_navigation_handle.set_url(GURL("https://www.google.com")); + // Now verify preview allowed for allowlisted url. + content::MockNavigationHandle allowlisted_navigation_handle; + allowlisted_navigation_handle.set_url(GURL("https://www.google.com")); EXPECT_TRUE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::NOSCRIPT)); @@ -931,13 +920,13 @@ TEST_F(PreviewsDeciderImplTest, NoScriptAllowedByFeatureWithWhitelist) { static_cast<int>(PreviewsEligibilityReason::ALLOWED), 2); } -TEST_F(PreviewsDeciderImplTest, NoScriptCommitTimeWhitelistCheck) { +TEST_F(PreviewsDeciderImplTest, NoScriptCommitTimeAllowlistCheck) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kNoScriptPreviews}, {}); InitializeUIService(); - // First verify not allowed for non-whitelisted url. + // First verify not allowed for non-allowlisted url. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); base::HistogramTester histogram_tester; @@ -954,13 +943,13 @@ TEST_F(PreviewsDeciderImplTest, NoScriptCommitTimeWhitelistCheck) { 1); } - // Now verify preview for whitelisted url. + // Now verify preview for allowlisted url. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_TRUE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::NOSCRIPT)); @@ -968,13 +957,13 @@ TEST_F(PreviewsDeciderImplTest, NoScriptCommitTimeWhitelistCheck) { histogram_tester.ExpectTotalCount("Previews.EligibilityReason.NoScript", 0); } - // Verify preview not allowed for whitelisted url when network is not slow. + // Verify preview not allowed for allowlisted url when network is not slow. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_3G); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::NOSCRIPT)); @@ -985,13 +974,13 @@ TEST_F(PreviewsDeciderImplTest, NoScriptCommitTimeWhitelistCheck) { 1); } - // Verify preview not allowed for whitelisted url for unknown network quality. + // Verify preview not allowed for allowlisted url for unknown network quality. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); user_data.set_navigation_ect(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN); EXPECT_FALSE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::NOSCRIPT)); @@ -1014,7 +1003,7 @@ TEST_F(PreviewsDeciderImplTest, NoScriptCommitTimeWhitelistCheck) { base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); user_data.set_navigation_ect(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN); EXPECT_TRUE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::NOSCRIPT)); @@ -1022,21 +1011,21 @@ TEST_F(PreviewsDeciderImplTest, NoScriptCommitTimeWhitelistCheck) { histogram_tester.ExpectTotalCount("Previews.EligibilityReason.NoScript", 0); } - // Verify preview not allowed when blacklist is unavailable. + // Verify preview not allowed when blocklist is unavailable. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); base::HistogramTester histogram_tester; - previews_decider_impl()->InjectTestBlacklist(nullptr /* blacklist */); + previews_decider_impl()->InjectTestBlocklist(nullptr /* blocklist */); PreviewsUserData user_data(kDefaultPageId); user_data.set_navigation_ect(net::EFFECTIVE_CONNECTION_TYPE_2G); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::NOSCRIPT)); histogram_tester.ExpectUniqueSample( "Previews.EligibilityReason.NoScript", - static_cast<int>(PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE), 1); + static_cast<int>(PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE), 1); } } @@ -1065,7 +1054,7 @@ TEST_F(PreviewsDeciderImplTest, base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::RESOURCE_LOADING_HINTS)); @@ -1082,7 +1071,7 @@ TEST_F(PreviewsDeciderImplTest, } TEST_F(PreviewsDeciderImplTest, - ResourceLoadingHintsAllowedByFeatureAndWhitelist) { + ResourceLoadingHintsAllowedByFeatureAndAllowlist) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kResourceLoadingHints}, {}); @@ -1096,9 +1085,9 @@ TEST_F(PreviewsDeciderImplTest, base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); - // Check whitelisted URL. + // Check allowlisted URL. EXPECT_TRUE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::RESOURCE_LOADING_HINTS)); @@ -1131,13 +1120,13 @@ TEST_F(PreviewsDeciderImplTest, static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1); } -TEST_F(PreviewsDeciderImplTest, ResourceLoadingHintsCommitTimeWhitelistCheck) { +TEST_F(PreviewsDeciderImplTest, ResourceLoadingHintsCommitTimeAllowlistCheck) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kResourceLoadingHints}, {}); InitializeUIService(); - // First verify not allowed for non-whitelisted url. + // First verify not allowed for non-allowlisted url. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); base::HistogramTester histogram_tester; @@ -1154,13 +1143,13 @@ TEST_F(PreviewsDeciderImplTest, ResourceLoadingHintsCommitTimeWhitelistCheck) { 1); } - // Now verify preview for whitelisted url. + // Now verify preview for allowlisted url. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_TRUE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::RESOURCE_LOADING_HINTS)); @@ -1169,13 +1158,13 @@ TEST_F(PreviewsDeciderImplTest, ResourceLoadingHintsCommitTimeWhitelistCheck) { "Previews.EligibilityReason.ResourceLoadingHints", 0); } - // Verify preview not allowed for whitelisted url when network is not slow. + // Verify preview not allowed for allowlisted url when network is not slow. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_4G); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::RESOURCE_LOADING_HINTS)); @@ -1186,13 +1175,13 @@ TEST_F(PreviewsDeciderImplTest, ResourceLoadingHintsCommitTimeWhitelistCheck) { 1); } - // Verify preview not allowed for whitelisted url for offline network quality. + // Verify preview not allowed for allowlisted url for offline network quality. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_OFFLINE); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::RESOURCE_LOADING_HINTS)); @@ -1233,7 +1222,7 @@ TEST_F(PreviewsDeciderImplTest, base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::DEFER_ALL_SCRIPT)); histogram_tester.ExpectUniqueSample( @@ -1248,7 +1237,7 @@ TEST_F(PreviewsDeciderImplTest, 1); } -TEST_F(PreviewsDeciderImplTest, DeferAllScriptAllowedByFeatureAndWhitelist) { +TEST_F(PreviewsDeciderImplTest, DeferAllScriptAllowedByFeatureAndAllowlist) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kDeferAllScriptPreviews}, {}); @@ -1262,9 +1251,9 @@ TEST_F(PreviewsDeciderImplTest, DeferAllScriptAllowedByFeatureAndWhitelist) { base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); - // Check whitelisted URL. + // Check allowlisted URL. EXPECT_TRUE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::DEFER_ALL_SCRIPT)); EXPECT_EQ(test_ect, user_data.navigation_ect()); @@ -1295,13 +1284,13 @@ TEST_F(PreviewsDeciderImplTest, static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1); } -TEST_F(PreviewsDeciderImplTest, DeferAllScriptCommitTimeWhitelistCheck) { +TEST_F(PreviewsDeciderImplTest, DeferAllScriptCommitTimeAllowlistCheck) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kDeferAllScriptPreviews}, {}); InitializeUIService(); - // First verify not allowed for non-whitelisted url. + // First verify not allowed for non-allowlisted url. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); base::HistogramTester histogram_tester; @@ -1318,13 +1307,13 @@ TEST_F(PreviewsDeciderImplTest, DeferAllScriptCommitTimeWhitelistCheck) { 1); } - // Now verify preview for whitelisted url. + // Now verify preview for allowlisted url. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_TRUE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::DEFER_ALL_SCRIPT)); @@ -1333,13 +1322,13 @@ TEST_F(PreviewsDeciderImplTest, DeferAllScriptCommitTimeWhitelistCheck) { "Previews.EligibilityReason.DeferAllScript", 0); } - // Verify preview not allowed for whitelisted url when network is not slow. + // Verify preview not allowed for allowlisted url when network is not slow. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_4G); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::DEFER_ALL_SCRIPT)); @@ -1350,13 +1339,13 @@ TEST_F(PreviewsDeciderImplTest, DeferAllScriptCommitTimeWhitelistCheck) { 1); } - // Verify preview not allowed for whitelisted url for offline network quality. + // Verify preview not allowed for allowlisted url for offline network quality. { ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_OFFLINE); base::HistogramTester histogram_tester; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_FALSE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, PreviewsType::DEFER_ALL_SCRIPT)); @@ -1394,7 +1383,7 @@ TEST_F(PreviewsDeciderImplTest, LogPreviewDecisionMadePassInCorrectParams) { scoped_feature_list.InitAndEnableFeature(features::kPreviews); InitializeUIService(); const PreviewsEligibilityReason reason( - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE); + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE); const GURL url("http://www.url_a.com/url_a"); const base::Time time = base::Time::Now(); const PreviewsType type = PreviewsType::OFFLINE; @@ -1429,16 +1418,16 @@ TEST_F(PreviewsDeciderImplTest, LogPreviewDecisionMadePassInCorrectParams) { TEST_F( PreviewsDeciderImplTest, - LogDecisionMadeBlacklistUnavailableAtNavigationStartForNonCommitTimePreview) { + LogDecisionMadeBlocklistUnavailableAtNavigationStartForNonCommitTimePreview) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(); - auto expected_reason = PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE; + auto expected_reason = PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE; auto expected_type = PreviewsType::OFFLINE; - previews_decider_impl()->InjectTestBlacklist(nullptr /* blacklist */); + previews_decider_impl()->InjectTestBlocklist(nullptr /* blocklist */); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); @@ -1454,7 +1443,7 @@ TEST_F( TEST_F( PreviewsDeciderImplTest, - LogDecisionMadeBlacklistUnavailableAtNavigationStartForCommitTimePreview) { + LogDecisionMadeBlocklistUnavailableAtNavigationStartForCommitTimePreview) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kNoScriptPreviews}, {}); @@ -1463,7 +1452,7 @@ TEST_F( auto expected_reason = PreviewsEligibilityReason::ALLOWED; auto expected_type = PreviewsType::NOSCRIPT; - previews_decider_impl()->InjectTestBlacklist(nullptr /* blacklist */); + previews_decider_impl()->InjectTestBlocklist(nullptr /* blocklist */); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); @@ -1477,17 +1466,17 @@ TEST_F( ::testing::Contains(expected_type)); } -TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlacklistStatusesDefault) { +TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlocklistStatusesDefault) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(); PreviewsEligibilityReason expected_reasons[] = { - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT, - PreviewsEligibilityReason::USER_BLACKLISTED, - PreviewsEligibilityReason::HOST_BLACKLISTED, + PreviewsEligibilityReason::USER_BLOCKLISTED, + PreviewsEligibilityReason::HOST_BLOCKLISTED, }; auto expected_type = PreviewsType::OFFLINE; @@ -1496,10 +1485,10 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlacklistStatusesDefault) { for (size_t i = 0; i < reasons_size; i++) { auto expected_reason = expected_reasons[i]; - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>(expected_reason, + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>(expected_reason, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; @@ -1518,7 +1507,7 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlacklistStatusesDefault) { } } -TEST_F(PreviewsDeciderImplTest, ShouldCommitPreviewBlacklistStatuses) { +TEST_F(PreviewsDeciderImplTest, ShouldCommitPreviewBlocklistStatuses) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kNoScriptPreviews}, {}); @@ -1527,15 +1516,15 @@ TEST_F(PreviewsDeciderImplTest, ShouldCommitPreviewBlacklistStatuses) { PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); - // First verify URL is allowed for no blacklist status. + // First verify URL is allowed for no blocklist status. EXPECT_TRUE(previews_decider_impl()->ShouldCommitPreview( &user_data, &navigation_handle, expected_type)); PreviewsEligibilityReason expected_reasons[] = { - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT, - PreviewsEligibilityReason::USER_BLACKLISTED, - PreviewsEligibilityReason::HOST_BLACKLISTED, + PreviewsEligibilityReason::USER_BLOCKLISTED, + PreviewsEligibilityReason::HOST_BLOCKLISTED, }; const size_t reasons_size = 4; @@ -1543,10 +1532,10 @@ TEST_F(PreviewsDeciderImplTest, ShouldCommitPreviewBlacklistStatuses) { for (size_t i = 0; i < reasons_size; i++) { auto expected_reason = expected_reasons[i]; - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>(expected_reason, + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>(expected_reason, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); @@ -1564,7 +1553,7 @@ TEST_F(PreviewsDeciderImplTest, ShouldCommitPreviewBlacklistStatuses) { } } -TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlacklistStatusesIgnore) { +TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlocklistStatusesIgnore) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); @@ -1572,21 +1561,21 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeBlacklistStatusesIgnore) { auto expected_reason = PreviewsEligibilityReason::ALLOWED; auto expected_type = PreviewsType::OFFLINE; - PreviewsEligibilityReason blacklist_decisions[] = { - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason blocklist_decisions[] = { + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT, - PreviewsEligibilityReason::USER_BLACKLISTED, - PreviewsEligibilityReason::HOST_BLACKLISTED, + PreviewsEligibilityReason::USER_BLOCKLISTED, + PreviewsEligibilityReason::HOST_BLOCKLISTED, }; - previews_decider_impl()->SetIgnorePreviewsBlacklistDecision( + previews_decider_impl()->SetIgnorePreviewsBlocklistDecision( true /* ignored */); - for (auto blacklist_decision : blacklist_decisions) { - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>(blacklist_decision, + for (auto blocklist_decision : blocklist_decisions) { + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>(blocklist_decision, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); @@ -1610,15 +1599,15 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeMediaSuffixesAreExcluded) { auto expected_reason = PreviewsEligibilityReason::EXCLUDED_BY_MEDIA_SUFFIX; auto expected_type = PreviewsType::RESOURCE_LOADING_HINTS; - PreviewsEligibilityReason blacklist_decisions[] = { - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason blocklist_decisions[] = { + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, }; - for (auto blacklist_decision : blacklist_decisions) { - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>(blacklist_decision, + for (auto blocklist_decision : blocklist_decisions) { + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>(blocklist_decision, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com/video.mp4")); @@ -1634,14 +1623,14 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeMediaSuffixesAreExcluded) { } } -TEST_F(PreviewsDeciderImplTest, IgnoreFlagDoesNotCheckBlacklist) { +TEST_F(PreviewsDeciderImplTest, IgnoreFlagDoesNotCheckBlocklist) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(); ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); - previews_decider_impl()->SetIgnorePreviewsBlacklistDecision( + previews_decider_impl()->SetIgnorePreviewsBlocklistDecision( true /* ignored */); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; @@ -1694,10 +1683,10 @@ TEST_F(PreviewsDeciderImplTest, {features::kPreviews, features::kResourceLoadingHints}, {}); InitializeUIService(); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( PreviewsEligibilityReason::ALLOWED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); auto expected_reason = PreviewsEligibilityReason::ALLOWED; auto expected_type = PreviewsType::RESOURCE_LOADING_HINTS; @@ -1736,10 +1725,10 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadePageLoadNotPainful) { scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(/*include_previews_opt_guide=*/true); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( PreviewsEligibilityReason::ALLOWED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_4G); @@ -1778,10 +1767,10 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeNetworkNotSlow) { scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(/*include_previews_opt_guide=*/false); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( PreviewsEligibilityReason::ALLOWED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_4G); @@ -1819,10 +1808,10 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeReloadDisallowed) { scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( PreviewsEligibilityReason::ALLOWED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); PreviewsUserData user_data(kDefaultPageId); @@ -1858,21 +1847,21 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeReloadDisallowed) { } } -TEST_F(PreviewsDeciderImplTest, IgnoreBlacklistEnabledViaFlag) { +TEST_F(PreviewsDeciderImplTest, IgnoreBlocklistEnabledViaFlag) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {features::kPreviews, features::kOfflinePreviews}, {}); base::test::ScopedCommandLine scoped_command_line; base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine(); - command_line->AppendSwitch(switches::kIgnorePreviewsBlacklist); - ASSERT_TRUE(switches::ShouldIgnorePreviewsBlacklist()); + command_line->AppendSwitch(switches::kIgnorePreviewsBlocklist); + ASSERT_TRUE(switches::ShouldIgnorePreviewsBlocklist()); InitializeUIService(); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( - PreviewsEligibilityReason::HOST_BLACKLISTED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( + PreviewsEligibilityReason::HOST_BLOCKLISTED, previews_decider_impl()); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; @@ -1892,11 +1881,11 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeAllowClientPreviewsWithECT) { {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( PreviewsEligibilityReason::ALLOWED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); @@ -1910,11 +1899,11 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeAllowClientPreviewsWithECT) { PreviewsEligibilityReason::DEVICE_OFFLINE, PreviewsEligibilityReason::PAGE_LOAD_PREDICTION_NOT_PAINFUL, PreviewsEligibilityReason::RELOAD_DISALLOWED, - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE, - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE, + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT, - PreviewsEligibilityReason::USER_BLACKLISTED, - PreviewsEligibilityReason::HOST_BLACKLISTED, + PreviewsEligibilityReason::USER_BLOCKLISTED, + PreviewsEligibilityReason::HOST_BLOCKLISTED, }; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; @@ -1943,11 +1932,11 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeAllowHintPreviewWithoutECT) { {features::kPreviews, features::kNoScriptPreviews}, {}); InitializeUIService(); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( PreviewsEligibilityReason::ALLOWED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_2G); @@ -1961,7 +1950,7 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeAllowHintPreviewWithoutECT) { }; PreviewsUserData user_data(kDefaultPageId); content::MockNavigationHandle navigation_handle; - navigation_handle.set_url(GURL("https://whitelisted.example.com")); + navigation_handle.set_url(GURL("https://allowlisted.example.com")); EXPECT_TRUE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, expected_type)); base::RunLoop().RunUntilIdle(); @@ -1980,53 +1969,53 @@ TEST_F(PreviewsDeciderImplTest, LogDecisionMadeAllowHintPreviewWithoutECT) { } } -TEST_F(PreviewsDeciderImplTest, OnNewBlacklistedHostCallsUIMethodCorrectly) { +TEST_F(PreviewsDeciderImplTest, OnNewBlocklistedHostCallsUIMethodCorrectly) { InitializeUIService(); std::string expected_host = "example.com"; base::Time expected_time = base::Time::Now(); - previews_decider_impl()->OnNewBlacklistedHost(expected_host, expected_time); + previews_decider_impl()->OnNewBlocklistedHost(expected_host, expected_time); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(expected_host, ui_service()->host_blacklisted()); - EXPECT_EQ(expected_time, ui_service()->host_blacklisted_time()); + EXPECT_EQ(expected_host, ui_service()->host_blocklisted()); + EXPECT_EQ(expected_time, ui_service()->host_blocklisted_time()); } -TEST_F(PreviewsDeciderImplTest, OnUserBlacklistedCallsUIMethodCorrectly) { +TEST_F(PreviewsDeciderImplTest, OnUserBlocklistedCallsUIMethodCorrectly) { InitializeUIService(); - previews_decider_impl()->OnUserBlacklistedStatusChange( - true /* blacklisted */); + previews_decider_impl()->OnUserBlocklistedStatusChange( + true /* blocklisted */); base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(ui_service()->user_blacklisted()); + EXPECT_TRUE(ui_service()->user_blocklisted()); - previews_decider_impl()->OnUserBlacklistedStatusChange( - false /* blacklisted */); + previews_decider_impl()->OnUserBlocklistedStatusChange( + false /* blocklisted */); base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(ui_service()->user_blacklisted()); + EXPECT_FALSE(ui_service()->user_blocklisted()); } -TEST_F(PreviewsDeciderImplTest, OnBlacklistClearedCallsUIMethodCorrectly) { +TEST_F(PreviewsDeciderImplTest, OnBlocklistClearedCallsUIMethodCorrectly) { InitializeUIService(); base::Time expected_time = base::Time::Now(); - previews_decider_impl()->OnBlacklistCleared(expected_time); + previews_decider_impl()->OnBlocklistCleared(expected_time); base::RunLoop().RunUntilIdle(); - EXPECT_EQ(expected_time, ui_service()->blacklist_cleared_time()); + EXPECT_EQ(expected_time, ui_service()->blocklist_cleared_time()); } TEST_F(PreviewsDeciderImplTest, - OnIgnoreBlacklistDecisionStatusChangedCalledCorrect) { + OnIgnoreBlocklistDecisionStatusChangedCalledCorrect) { InitializeUIService(); - previews_decider_impl()->SetIgnorePreviewsBlacklistDecision( + previews_decider_impl()->SetIgnorePreviewsBlocklistDecision( true /* ignored */); base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(ui_service()->blacklist_ignored()); + EXPECT_TRUE(ui_service()->blocklist_ignored()); - previews_decider_impl()->SetIgnorePreviewsBlacklistDecision( + previews_decider_impl()->SetIgnorePreviewsBlocklistDecision( false /* ignored */); base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(ui_service()->blacklist_ignored()); + EXPECT_FALSE(ui_service()->blocklist_ignored()); } TEST_F(PreviewsDeciderImplTest, GeneratePageIdMakesUniqueNonZero) { @@ -2048,10 +2037,10 @@ TEST_F(PreviewsDeciderImplTest, TestIgnoreLongTermRule) { {features::kPreviews, features::kOfflinePreviews}, {}); InitializeUIService(); - std::unique_ptr<TestPreviewsBlackList> blacklist = - std::make_unique<TestPreviewsBlackList>( - PreviewsEligibilityReason::HOST_BLACKLISTED, previews_decider_impl()); - previews_decider_impl()->InjectTestBlacklist(std::move(blacklist)); + std::unique_ptr<TestPreviewsBlockList> blocklist = + std::make_unique<TestPreviewsBlockList>( + PreviewsEligibilityReason::HOST_BLOCKLISTED, previews_decider_impl()); + previews_decider_impl()->InjectTestBlocklist(std::move(blocklist)); // DataReductionProxy LitePage checks NQE on their own. ReportEffectiveConnectionType(net::EFFECTIVE_CONNECTION_TYPE_3G); @@ -2059,11 +2048,11 @@ TEST_F(PreviewsDeciderImplTest, TestIgnoreLongTermRule) { content::MockNavigationHandle navigation_handle; navigation_handle.set_url(GURL("https://www.google.com")); base::HistogramTester histogram_tester; - previews_decider_impl()->SetIgnoreLongTermBlackListForServerPreviews(false); + previews_decider_impl()->SetIgnoreLongTermBlockListForServerPreviews(false); EXPECT_FALSE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::LITE_PAGE)); - previews_decider_impl()->SetIgnoreLongTermBlackListForServerPreviews(true); + previews_decider_impl()->SetIgnoreLongTermBlockListForServerPreviews(true); EXPECT_TRUE(previews_decider_impl()->ShouldAllowPreviewAtNavigationStart( &user_data, &navigation_handle, false, PreviewsType::LITE_PAGE)); } diff --git a/chromium/components/previews/content/previews_optimization_guide.cc b/chromium/components/previews/content/previews_optimization_guide.cc index c96480d5b8b..98f2391e699 100644 --- a/chromium/components/previews/content/previews_optimization_guide.cc +++ b/chromium/components/previews/content/previews_optimization_guide.cc @@ -140,7 +140,8 @@ bool PreviewsOptimizationGuide::CanApplyPreview( optimization_guide::OptimizationMetadata optimization_metadata; optimization_guide::OptimizationGuideDecision decision = optimization_guide_decider_->CanApplyOptimization( - navigation_handle, *optimization_type, &optimization_metadata); + navigation_handle->GetURL(), *optimization_type, + &optimization_metadata); if (!ShouldApplyPreviewWithDecision(type, decision)) return false; @@ -186,7 +187,7 @@ bool PreviewsOptimizationGuide::AreCommitTimePreviewsAvailable( } if (optimization_guide_decider_->CanApplyOptimization( - navigation_handle, optimization_type, + navigation_handle->GetURL(), optimization_type, /*optimization_metadata=*/nullptr) != optimization_guide::OptimizationGuideDecision::kFalse) { might_have_hint = true; diff --git a/chromium/components/previews/content/previews_optimization_guide.h b/chromium/components/previews/content/previews_optimization_guide.h index 55710719964..2ea060fbc9b 100644 --- a/chromium/components/previews/content/previews_optimization_guide.h +++ b/chromium/components/previews/content/previews_optimization_guide.h @@ -32,6 +32,9 @@ class PreviewsOptimizationGuide { public: explicit PreviewsOptimizationGuide( optimization_guide::OptimizationGuideDecider* optimization_guide_decider); + PreviewsOptimizationGuide(const PreviewsOptimizationGuide&) = delete; + PreviewsOptimizationGuide& operator=(const PreviewsOptimizationGuide&) = + delete; virtual ~PreviewsOptimizationGuide(); // Returns whether a Preview should be shown for the current conditions. @@ -67,8 +70,6 @@ class PreviewsOptimizationGuide { // The optimization types registered with |optimization_guide_decider_|. const base::flat_set<optimization_guide::proto::OptimizationType> registered_optimization_types_; - - DISALLOW_COPY_AND_ASSIGN(PreviewsOptimizationGuide); }; } // namespace previews diff --git a/chromium/components/previews/content/previews_optimization_guide_unittest.cc b/chromium/components/previews/content/previews_optimization_guide_unittest.cc index d78cc7b1fdd..884b40b0a1d 100644 --- a/chromium/components/previews/content/previews_optimization_guide_unittest.cc +++ b/chromium/components/previews/content/previews_optimization_guide_unittest.cc @@ -78,12 +78,12 @@ class TestOptimizationGuideDecider } optimization_guide::OptimizationGuideDecision CanApplyOptimization( - content::NavigationHandle* navigation_handle, + const GURL& url, optimization_guide::proto::OptimizationType optimization_type, optimization_guide::OptimizationMetadata* optimization_metadata) override { - auto response_iter = responses_.find( - std::make_tuple(navigation_handle->GetURL(), optimization_type)); + auto response_iter = + responses_.find(std::make_tuple(url, optimization_type)); if (response_iter == responses_.end()) return optimization_guide::OptimizationGuideDecision::kFalse; @@ -187,7 +187,7 @@ class PreviewsOptimizationGuideTest : public testing::Test { optimization_guide_decider()->SetResponses(responses); } - GURL blacklisted_lpr_url() { return GURL("https://blacklistedlpr.com/123"); } + GURL blocklisted_lpr_url() { return GURL("https://blocklistedlpr.com/123"); } GURL hint_not_loaded_url() { return GURL("https://hintnotloaded.com/123"); } diff --git a/chromium/components/previews/content/previews_ui_service.cc b/chromium/components/previews/content/previews_ui_service.cc index a4e3fe48c25..421ccc21d49 100644 --- a/chromium/components/previews/content/previews_ui_service.cc +++ b/chromium/components/previews/content/previews_ui_service.cc @@ -14,11 +14,11 @@ namespace previews { PreviewsUIService::PreviewsUIService( std::unique_ptr<PreviewsDeciderImpl> previews_decider_impl, - std::unique_ptr<blacklist::OptOutStore> previews_opt_out_store, + std::unique_ptr<blocklist::OptOutStore> previews_opt_out_store, std::unique_ptr<PreviewsOptimizationGuide> previews_opt_guide, const PreviewsIsEnabledCallback& is_enabled_callback, std::unique_ptr<PreviewsLogger> logger, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_previews, + blocklist::BlocklistData::AllowedTypesAndVersions allowed_previews, network::NetworkQualityTracker* network_quality_tracker) : previews_decider_impl_(std::move(previews_decider_impl)), logger_(std::move(logger)), @@ -66,30 +66,30 @@ void PreviewsUIService::LogPreviewDecisionMade( std::move(passed_reasons), page_id); } -void PreviewsUIService::OnNewBlacklistedHost(const std::string& host, +void PreviewsUIService::OnNewBlocklistedHost(const std::string& host, base::Time time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - logger_->OnNewBlacklistedHost(host, time); + logger_->OnNewBlocklistedHost(host, time); } -void PreviewsUIService::OnUserBlacklistedStatusChange(bool blacklisted) { +void PreviewsUIService::OnUserBlocklistedStatusChange(bool blocklisted) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - logger_->OnUserBlacklistedStatusChange(blacklisted); + logger_->OnUserBlocklistedStatusChange(blocklisted); } -void PreviewsUIService::OnBlacklistCleared(base::Time time) { +void PreviewsUIService::OnBlocklistCleared(base::Time time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - logger_->OnBlacklistCleared(time); + logger_->OnBlocklistCleared(time); } -void PreviewsUIService::SetIgnorePreviewsBlacklistDecision(bool ignored) { +void PreviewsUIService::SetIgnorePreviewsBlocklistDecision(bool ignored) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_decider_impl_->SetIgnorePreviewsBlacklistDecision(ignored); + previews_decider_impl_->SetIgnorePreviewsBlocklistDecision(ignored); } -void PreviewsUIService::OnIgnoreBlacklistDecisionStatusChanged(bool ignored) { +void PreviewsUIService::OnIgnoreBlocklistDecisionStatusChanged(bool ignored) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - logger_->OnIgnoreBlacklistDecisionStatusChanged(ignored); + logger_->OnIgnoreBlocklistDecisionStatusChanged(ignored); } PreviewsLogger* PreviewsUIService::previews_logger() const { @@ -102,19 +102,19 @@ PreviewsDeciderImpl* PreviewsUIService::previews_decider_impl() const { return previews_decider_impl_.get(); } -// When triggering previews, prevent long term black list rules. -void PreviewsUIService::SetIgnoreLongTermBlackListForServerPreviews( - bool ignore_long_term_black_list_rules_allowed) { +// When triggering previews, prevent long term block list rules. +void PreviewsUIService::SetIgnoreLongTermBlockListForServerPreviews( + bool ignore_long_term_block_list_rules_allowed) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_decider_impl_->SetIgnoreLongTermBlackListForServerPreviews( - ignore_long_term_black_list_rules_allowed); + previews_decider_impl_->SetIgnoreLongTermBlockListForServerPreviews( + ignore_long_term_block_list_rules_allowed); } -void PreviewsUIService::ClearBlackList(base::Time begin_time, +void PreviewsUIService::ClearBlockList(base::Time begin_time, base::Time end_time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - previews_decider_impl_->ClearBlackList(begin_time, end_time); + previews_decider_impl_->ClearBlockList(begin_time, end_time); } void PreviewsUIService::OnEffectiveConnectionTypeChanged( diff --git a/chromium/components/previews/content/previews_ui_service.h b/chromium/components/previews/content/previews_ui_service.h index f54a2a2dd93..4ee10328911 100644 --- a/chromium/components/previews/content/previews_ui_service.h +++ b/chromium/components/previews/content/previews_ui_service.h @@ -14,11 +14,11 @@ #include "base/memory/weak_ptr.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_data.h" -#include "components/blacklist/opt_out_blacklist/opt_out_store.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_data.h" +#include "components/blocklist/opt_out_blocklist/opt_out_store.h" #include "components/previews/content/previews_decider_impl.h" #include "components/previews/content/previews_optimization_guide.h" -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include "components/previews/core/previews_experiments.h" #include "components/previews/core/previews_logger.h" #include "net/nqe/effective_connection_type.h" @@ -36,11 +36,11 @@ class PreviewsUIService public: PreviewsUIService( std::unique_ptr<PreviewsDeciderImpl> previews_decider_impl, - std::unique_ptr<blacklist::OptOutStore> previews_opt_out_store, + std::unique_ptr<blocklist::OptOutStore> previews_opt_out_store, std::unique_ptr<PreviewsOptimizationGuide> previews_opt_guide, const PreviewsIsEnabledCallback& is_enabled_callback, std::unique_ptr<PreviewsLogger> logger, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_previews, + blocklist::BlocklistData::AllowedTypesAndVersions allowed_previews, network::NetworkQualityTracker* network_quality_tracker); ~PreviewsUIService() override; @@ -48,39 +48,39 @@ class PreviewsUIService void OnEffectiveConnectionTypeChanged( net::EffectiveConnectionType type) override; - // Adds a navigation to |url| to the black list with result |opt_out|. + // Adds a navigation to |url| to the block list with result |opt_out|. void AddPreviewNavigation(const GURL& url, PreviewsType type, bool opt_out, uint64_t page_id); - // Clears the history of the black list between |begin_time| and |end_time|. - void ClearBlackList(base::Time begin_time, base::Time end_time); + // Clears the history of the block list between |begin_time| and |end_time|. + void ClearBlockList(base::Time begin_time, base::Time end_time); - // Notifies |logger_| that |host| has been blacklisted at |time|. Virtualized + // Notifies |logger_| that |host| has been blocklisted at |time|. Virtualized // in testing. - virtual void OnNewBlacklistedHost(const std::string& host, base::Time time); + virtual void OnNewBlocklistedHost(const std::string& host, base::Time time); - // Notifies |logger_| that the user blacklisted state has changed. Where - // |blacklisted| is the new user blacklisted status. Virtualized in testing. - virtual void OnUserBlacklistedStatusChange(bool blacklisted); + // Notifies |logger_| that the user blocklisted state has changed. Where + // |blocklisted| is the new user blocklisted status. Virtualized in testing. + virtual void OnUserBlocklistedStatusChange(bool blocklisted); - // Notifies |logger_| that the blacklist is cleared at |time|. Virtualized in + // Notifies |logger_| that the blocklist is cleared at |time|. Virtualized in // testing. - virtual void OnBlacklistCleared(base::Time time); + virtual void OnBlocklistCleared(base::Time time); - // Change the status of whether to ignored or consider PreviewsBlackList + // Change the status of whether to ignored or consider PreviewsBlockList // decisions in |previews_decider_impl_|. This method is called when users - // interact with the UI (i.e. click on the "Ignore Blacklist" button). + // interact with the UI (i.e. click on the "Ignore Blocklist" button). // Virtualized in testing. - virtual void SetIgnorePreviewsBlacklistDecision(bool ignored); + virtual void SetIgnorePreviewsBlocklistDecision(bool ignored); - // Notifies |logger_| whether PreviewsBlackList decisions are ignored or not. + // Notifies |logger_| whether PreviewsBlockList decisions are ignored or not. // This method is listening for notification from PreviewsDeciderImpl for when - // the blacklist ignore status is changed so that |logger_| can update all + // the blocklist ignore status is changed so that |logger_| can update all // PreviewsLoggerObservers so that multiple instances of the page have the // same status. Virtualized in testing. - virtual void OnIgnoreBlacklistDecisionStatusChanged(bool ignored); + virtual void OnIgnoreBlocklistDecisionStatusChanged(bool ignored); // Log the navigation to PreviewsLogger. Virtualized in testing. virtual void LogPreviewNavigation(const GURL& url, @@ -120,9 +120,9 @@ class PreviewsUIService // non-null. PreviewsDeciderImpl* previews_decider_impl() const; - // When triggering previews, prevent long term black list rules. - void SetIgnoreLongTermBlackListForServerPreviews( - bool ignore_long_term_black_list_rules_allowed); + // When triggering previews, prevent long term block list rules. + void SetIgnoreLongTermBlockListForServerPreviews( + bool ignore_long_term_block_list_rules_allowed); private: // The decision making object for Previews triggering. Guaranteed to be @@ -130,7 +130,7 @@ class PreviewsUIService std::unique_ptr<previews::PreviewsDeciderImpl> previews_decider_impl_; // A log object to keep track of events such as previews navigations, - // blacklist actions, etc. + // blocklist actions, etc. std::unique_ptr<PreviewsLogger> logger_; // Used to remove |this| from observing. diff --git a/chromium/components/previews/content/previews_ui_service_unittest.cc b/chromium/components/previews/content/previews_ui_service_unittest.cc index fa84e64f2c7..4066d78c0c0 100644 --- a/chromium/components/previews/content/previews_ui_service_unittest.cc +++ b/chromium/components/previews/content/previews_ui_service_unittest.cc @@ -12,9 +12,9 @@ #include "base/single_thread_task_runner.h" #include "base/test/task_environment.h" #include "base/time/default_clock.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_data.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_data.h" #include "components/previews/content/previews_decider_impl.h" -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include "components/previews/core/previews_experiments.h" #include "components/previews/core/previews_logger.h" #include "services/network/test/test_network_quality_tracker.h" @@ -33,7 +33,7 @@ class TestPreviewsUIService : public PreviewsUIService { public: TestPreviewsUIService( std::unique_ptr<PreviewsDeciderImpl> previews_decider_impl, - std::unique_ptr<blacklist::OptOutStore> previews_opt_out_store, + std::unique_ptr<blocklist::OptOutStore> previews_opt_out_store, std::unique_ptr<PreviewsOptimizationGuide> previews_opt_guide, std::unique_ptr<PreviewsLogger> logger, network::TestNetworkQualityTracker* test_network_quality_tracker) @@ -42,7 +42,7 @@ class TestPreviewsUIService : public PreviewsUIService { std::move(previews_opt_guide), base::BindRepeating(&MockedPreviewsIsEnabled), std::move(logger), - blacklist::BlacklistData::AllowedTypesAndVersions(), + blocklist::BlocklistData::AllowedTypesAndVersions(), test_network_quality_tracker) {} ~TestPreviewsUIService() override {} }; @@ -50,11 +50,7 @@ class TestPreviewsUIService : public PreviewsUIService { // Mock class of PreviewsLogger for checking passed in parameters. class TestPreviewsLogger : public PreviewsLogger { public: - TestPreviewsLogger() - : decision_page_id_(0), - navigation_opt_out_(false), - user_blacklisted_(false), - blacklist_ignored_(false) {} + TestPreviewsLogger() : decision_page_id_(0), navigation_opt_out_(false) {} // PreviewsLogger: void LogPreviewNavigation(const GURL& url, @@ -84,21 +80,21 @@ class TestPreviewsLogger : public PreviewsLogger { decision_page_id_ = page_id; } - void OnNewBlacklistedHost(const std::string& host, base::Time time) override { - host_blacklisted_ = host; - host_blacklisted_time_ = time; + void OnNewBlocklistedHost(const std::string& host, base::Time time) override { + host_blocklisted_ = host; + host_blocklisted_time_ = time; } - void OnUserBlacklistedStatusChange(bool blacklisted) override { - user_blacklisted_ = blacklisted; + void OnUserBlocklistedStatusChange(bool blocklisted) override { + user_blocklisted_ = blocklisted; } - void OnBlacklistCleared(base::Time time) override { - blacklist_cleared_time_ = time; + void OnBlocklistCleared(base::Time time) override { + blocklist_cleared_time_ = time; } - void OnIgnoreBlacklistDecisionStatusChanged(bool ignored) override { - blacklist_ignored_ = ignored; + void OnIgnoreBlocklistDecisionStatusChanged(bool ignored) override { + blocklist_ignored_ = ignored; } // Return the passed in LogPreviewDecision parameters. @@ -119,14 +115,14 @@ class TestPreviewsLogger : public PreviewsLogger { PreviewsType navigation_type() const { return navigation_type_; } uint64_t navigation_page_id() const { return navigation_page_id_; } - // Return the passed in OnBlacklist events. - std::string host_blacklisted() const { return host_blacklisted_; } - base::Time host_blacklisted_time() const { return host_blacklisted_time_; } - bool user_blacklisted() const { return user_blacklisted_; } - base::Time blacklist_cleared_time() const { return blacklist_cleared_time_; } + // Return the passed in OnBlocklist events. + std::string host_blocklisted() const { return host_blocklisted_; } + base::Time host_blocklisted_time() const { return host_blocklisted_time_; } + bool user_blocklisted() const { return user_blocklisted_; } + base::Time blocklist_cleared_time() const { return blocklist_cleared_time_; } - // Return the status of blacklist ignored. - bool blacklist_ignored() const { return blacklist_ignored_; } + // Return the status of blocklist ignored. + bool blocklist_ignored() const { return blocklist_ignored_; } private: // Passed in LogPreviewDecision parameters. @@ -144,34 +140,33 @@ class TestPreviewsLogger : public PreviewsLogger { PreviewsType navigation_type_; uint64_t navigation_page_id_; - // Passed in OnBlacklist events. - std::string host_blacklisted_; - base::Time host_blacklisted_time_; - bool user_blacklisted_; - base::Time blacklist_cleared_time_; + // Passed in OnBlocklist events. + std::string host_blocklisted_; + base::Time host_blocklisted_time_; + bool user_blocklisted_ = false; + base::Time blocklist_cleared_time_; - // Passed in blacklist ignored status. - bool blacklist_ignored_; + // Passed in blocklist ignored status. + bool blocklist_ignored_ = false; }; class TestPreviewsDeciderImpl : public PreviewsDeciderImpl { public: TestPreviewsDeciderImpl() - : PreviewsDeciderImpl(base::DefaultClock::GetInstance()), - blacklist_ignored_(false) {} + : PreviewsDeciderImpl(base::DefaultClock::GetInstance()) {} // PreviewsDeciderImpl: - void SetIgnorePreviewsBlacklistDecision(bool ignored) override { - blacklist_ignored_ = ignored; + void SetIgnorePreviewsBlocklistDecision(bool ignored) override { + blocklist_ignored_ = ignored; } - // Exposed the status of blacklist decisions ignored for testing + // Exposed the status of blocklist decisions ignored for testing // PreviewsUIService. - bool blacklist_ignored() const { return blacklist_ignored_; } + bool blocklist_ignored() const { return blocklist_ignored_; } private: - // Whether the blacklist decisions are ignored or not. - bool blacklist_ignored_; + // Whether the blocklist decisions are ignored or not. + bool blocklist_ignored_ = false; }; class PreviewsUIServiceTest : public testing::Test { @@ -256,7 +251,7 @@ TEST_F(PreviewsUIServiceTest, TestLogPreviewNavigationPassInCorrectParams) { TEST_F(PreviewsUIServiceTest, TestLogPreviewDecisionMadePassesCorrectParams) { PreviewsEligibilityReason reason_a = - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE; + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE; const GURL url_a("http://www.url_a.com/url_a"); const base::Time time_a = base::Time::Now(); PreviewsType type_a = PreviewsType::OFFLINE; @@ -314,47 +309,47 @@ TEST_F(PreviewsUIServiceTest, TestLogPreviewDecisionMadePassesCorrectParams) { } } -TEST_F(PreviewsUIServiceTest, TestOnNewBlacklistedHostPassesCorrectParams) { +TEST_F(PreviewsUIServiceTest, TestOnNewBlocklistedHostPassesCorrectParams) { const std::string expected_host = "example.com"; const base::Time expected_time = base::Time::Now(); - ui_service()->OnNewBlacklistedHost(expected_host, expected_time); + ui_service()->OnNewBlocklistedHost(expected_host, expected_time); - EXPECT_EQ(expected_host, logger_ptr_->host_blacklisted()); - EXPECT_EQ(expected_time, logger_ptr_->host_blacklisted_time()); + EXPECT_EQ(expected_host, logger_ptr_->host_blocklisted()); + EXPECT_EQ(expected_time, logger_ptr_->host_blocklisted_time()); } -TEST_F(PreviewsUIServiceTest, TestOnUserBlacklistedPassesCorrectParams) { - ui_service()->OnUserBlacklistedStatusChange(true /* blacklisted */); - EXPECT_TRUE(logger_ptr_->user_blacklisted()); +TEST_F(PreviewsUIServiceTest, TestOnUserBlocklistedPassesCorrectParams) { + ui_service()->OnUserBlocklistedStatusChange(true /* blocklisted */); + EXPECT_TRUE(logger_ptr_->user_blocklisted()); - ui_service()->OnUserBlacklistedStatusChange(false /* blacklisted */); - EXPECT_FALSE(logger_ptr_->user_blacklisted()); + ui_service()->OnUserBlocklistedStatusChange(false /* blocklisted */); + EXPECT_FALSE(logger_ptr_->user_blocklisted()); } -TEST_F(PreviewsUIServiceTest, TestOnBlacklistClearedPassesCorrectParams) { +TEST_F(PreviewsUIServiceTest, TestOnBlocklistClearedPassesCorrectParams) { const base::Time expected_time = base::Time::Now(); - ui_service()->OnBlacklistCleared(expected_time); + ui_service()->OnBlocklistCleared(expected_time); - EXPECT_EQ(expected_time, logger_ptr_->blacklist_cleared_time()); + EXPECT_EQ(expected_time, logger_ptr_->blocklist_cleared_time()); } TEST_F(PreviewsUIServiceTest, - TestSetIgnorePreviewsBlacklistDecisionPassesCorrectParams) { - ui_service()->SetIgnorePreviewsBlacklistDecision(true /* ignored */); + TestSetIgnorePreviewsBlocklistDecisionPassesCorrectParams) { + ui_service()->SetIgnorePreviewsBlocklistDecision(true /* ignored */); base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(previews_decider_impl()->blacklist_ignored()); + EXPECT_TRUE(previews_decider_impl()->blocklist_ignored()); - ui_service()->SetIgnorePreviewsBlacklistDecision(false /* ignored */); + ui_service()->SetIgnorePreviewsBlocklistDecision(false /* ignored */); base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(previews_decider_impl()->blacklist_ignored()); + EXPECT_FALSE(previews_decider_impl()->blocklist_ignored()); } -TEST_F(PreviewsUIServiceTest, TestOnIgnoreBlacklistDecisionStatusChanged) { - ui_service()->OnIgnoreBlacklistDecisionStatusChanged(true /* ignored */); - EXPECT_TRUE(logger_ptr_->blacklist_ignored()); +TEST_F(PreviewsUIServiceTest, TestOnIgnoreBlocklistDecisionStatusChanged) { + ui_service()->OnIgnoreBlocklistDecisionStatusChanged(true /* ignored */); + EXPECT_TRUE(logger_ptr_->blocklist_ignored()); - ui_service()->OnIgnoreBlacklistDecisionStatusChanged(false /* ignored */); - EXPECT_FALSE(logger_ptr_->blacklist_ignored()); + ui_service()->OnIgnoreBlocklistDecisionStatusChanged(false /* ignored */); + EXPECT_FALSE(logger_ptr_->blocklist_ignored()); } } // namespace previews diff --git a/chromium/components/previews/content/previews_user_data.cc b/chromium/components/previews/content/previews_user_data.cc index 626cf485665..7730f58f76e 100644 --- a/chromium/components/previews/content/previews_user_data.cc +++ b/chromium/components/previews/content/previews_user_data.cc @@ -5,6 +5,7 @@ #include "components/previews/content/previews_user_data.h" #include "base/rand_util.h" +#include "content/public/browser/render_frame_host.h" namespace previews { @@ -24,7 +25,7 @@ PreviewsUserData::PreviewsUserData(const PreviewsUserData& other) cache_control_no_transform_directive_( other.cache_control_no_transform_directive_), offline_preview_used_(other.offline_preview_used_), - black_listed_for_lite_page_(other.black_listed_for_lite_page_), + block_listed_for_lite_page_(other.block_listed_for_lite_page_), committed_previews_type_without_holdback_( other.committed_previews_type_without_holdback_), allowed_previews_state_without_holdback_( @@ -34,6 +35,17 @@ PreviewsUserData::PreviewsUserData(const PreviewsUserData& other) coin_flip_holdback_result_(other.coin_flip_holdback_result_), preview_eligibility_reasons_(other.preview_eligibility_reasons_) {} +PreviewsUserData::DocumentDataHolder::DocumentDataHolder( + content::RenderFrameHost* render_frame_host) { + // PreviewsUserData and DocumentDataHolder should only be made for main + // frames. + // TODO(crbug.com/1090679): This should be page-associated instead of just + // document-associated. Use PageUserData when it's available. + DCHECK(!render_frame_host->GetParent()); +} + +PreviewsUserData::DocumentDataHolder::~DocumentDataHolder() = default; + void PreviewsUserData::SetCommittedPreviewsType( previews::PreviewsType previews_type) { DCHECK(committed_previews_type_without_holdback_ == PreviewsType::NONE); @@ -106,4 +118,5 @@ content::PreviewsState PreviewsUserData::CommittedPreviewsState() const { return committed_previews_state_without_holdback_; } +RENDER_DOCUMENT_HOST_USER_DATA_KEY_IMPL(PreviewsUserData::DocumentDataHolder) } // namespace previews diff --git a/chromium/components/previews/content/previews_user_data.h b/chromium/components/previews/content/previews_user_data.h index bf0c0d6e497..d6e46cb631d 100644 --- a/chromium/components/previews/content/previews_user_data.h +++ b/chromium/components/previews/content/previews_user_data.h @@ -13,13 +13,25 @@ #include "base/macros.h" #include "base/optional.h" #include "base/time/time.h" -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include "components/previews/core/previews_experiments.h" +#include "content/public/browser/render_document_host_user_data.h" #include "content/public/common/previews_state.h" namespace previews { -// A representation of previews information related to a navigation. +// A representation of previews information related to a navigation. We create +// a PreviewsUserData on every navigation, and when the navigation finishes, we +// make a copy of it and hold it in DocumentDataHolder so that the lifetime +// is tied to the document. +// For normal navigations, we will use the PreviewsUserData we made during the +// navigation. +// For navigations where we restore the page from the back-forward cache, we +// should instead used the cached PreviewsUserData that's associated with the +// document (the PreviewsUserData that's made during the original navigation +// the page, instead of the back navigation that triggers the restoration of +// the page so that the Previews UI will be consistent with the preserved +// page contents). // TODO(ryansturm): rename this to remove UserData. class PreviewsUserData { public: @@ -72,12 +84,12 @@ class PreviewsUserData { } // Whether a lite page preview was prevented from being shown due to the - // blacklist. - bool black_listed_for_lite_page() const { - return black_listed_for_lite_page_; + // blocklist. + bool block_listed_for_lite_page() const { + return block_listed_for_lite_page_; } - void set_black_listed_for_lite_page(bool black_listed_for_lite_page) { - black_listed_for_lite_page_ = black_listed_for_lite_page; + void set_block_listed_for_lite_page(bool block_listed_for_lite_page) { + block_listed_for_lite_page_ = block_listed_for_lite_page; } // Returns whether the Cache-Control:no-transform directive has been @@ -150,6 +162,33 @@ class PreviewsUserData { coin_flip_holdback_result_ = coin_flip_holdback_result; } + void CopyData(const PreviewsUserData& other); + + class DocumentDataHolder + : public content::RenderDocumentHostUserData<DocumentDataHolder> { + public: + ~DocumentDataHolder() override; + PreviewsUserData* GetPreviewsUserData() { + return previews_user_data_.get(); + } + void SetPreviewsUserData( + std::unique_ptr<PreviewsUserData> previews_user_data) { + previews_user_data_ = std::move(previews_user_data); + } + + using content::RenderDocumentHostUserData< + DocumentDataHolder>::GetOrCreateForCurrentDocument; + using content::RenderDocumentHostUserData< + DocumentDataHolder>::GetForCurrentDocument; + + private: + explicit DocumentDataHolder(content::RenderFrameHost* render_frame_host); + friend class content::RenderDocumentHostUserData<DocumentDataHolder>; + + std::unique_ptr<PreviewsUserData> previews_user_data_; + RENDER_DOCUMENT_HOST_USER_DATA_KEY_DECL(); + }; + private: // A session unique ID related to this navigation. const uint64_t page_id_; @@ -176,8 +215,8 @@ class PreviewsUserData { bool offline_preview_used_ = false; // Whether a lite page preview was prevented from being shown due to the - // blacklist. - bool black_listed_for_lite_page_ = false; + // blocklist. + bool block_listed_for_lite_page_ = false; // The committed previews type, if any. Is not influenced by the coin flip // holdback. diff --git a/chromium/components/previews/content/previews_user_data_unittest.cc b/chromium/components/previews/content/previews_user_data_unittest.cc index 54b3103f628..4dfda8c5e90 100644 --- a/chromium/components/previews/content/previews_user_data_unittest.cc +++ b/chromium/components/previews/content/previews_user_data_unittest.cc @@ -23,14 +23,14 @@ TEST(PreviewsUserDataTest, TestSetEligibilityReason) { data.EligibilityReasonForPreview(PreviewsType::OFFLINE)); data.SetEligibilityReasonForPreview( - PreviewsType::NOSCRIPT, PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE); + PreviewsType::NOSCRIPT, PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE); data.SetEligibilityReasonForPreview( PreviewsType::NOSCRIPT, - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED); + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED); EXPECT_EQ(base::nullopt, data.EligibilityReasonForPreview(PreviewsType::OFFLINE)); - EXPECT_EQ(PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + EXPECT_EQ(PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, data.EligibilityReasonForPreview(PreviewsType::NOSCRIPT)); } @@ -43,14 +43,14 @@ TEST(PreviewsUserDataTest, DeepCopy) { EXPECT_EQ(0, data->data_savings_inflation_percent()); EXPECT_FALSE(data->cache_control_no_transform_directive()); EXPECT_EQ(previews::PreviewsType::NONE, data->CommittedPreviewsType()); - EXPECT_FALSE(data->black_listed_for_lite_page()); + EXPECT_FALSE(data->block_listed_for_lite_page()); EXPECT_FALSE(data->offline_preview_used()); data->set_data_savings_inflation_percent(123); data->set_cache_control_no_transform_directive(); data->SetCommittedPreviewsType(previews::PreviewsType::NOSCRIPT); data->set_offline_preview_used(true); - data->set_black_listed_for_lite_page(true); + data->set_block_listed_for_lite_page(true); PreviewsUserData data_copy(*data); EXPECT_EQ(id, data_copy.page_id()); @@ -59,7 +59,7 @@ TEST(PreviewsUserDataTest, DeepCopy) { EXPECT_TRUE(data_copy.cache_control_no_transform_directive()); EXPECT_EQ(previews::PreviewsType::NOSCRIPT, data_copy.CommittedPreviewsType()); - EXPECT_TRUE(data_copy.black_listed_for_lite_page()); + EXPECT_TRUE(data_copy.block_listed_for_lite_page()); EXPECT_TRUE(data_copy.offline_preview_used()); } diff --git a/chromium/components/previews/core/BUILD.gn b/chromium/components/previews/core/BUILD.gn index b7bb20d728c..434a0ae94d3 100644 --- a/chromium/components/previews/core/BUILD.gn +++ b/chromium/components/previews/core/BUILD.gn @@ -4,8 +4,8 @@ static_library("core") { sources = [ - "previews_black_list.cc", - "previews_black_list.h", + "previews_block_list.cc", + "previews_block_list.h", "previews_experiments.cc", "previews_experiments.h", "previews_features.cc", @@ -19,7 +19,7 @@ static_library("core") { deps = [ "//base", - "//components/blacklist/opt_out_blacklist", + "//components/blocklist/opt_out_blocklist", "//components/variations", "//net:net", "//third_party/re2", @@ -30,7 +30,7 @@ static_library("core") { source_set("unit_tests") { testonly = true sources = [ - "previews_black_list_unittest.cc", + "previews_block_list_unittest.cc", "previews_experiments_unittest.cc", "previews_logger_unittest.cc", ] @@ -39,7 +39,7 @@ source_set("unit_tests") { ":core", "//base", "//base/test:test_support", - "//components/blacklist/opt_out_blacklist", + "//components/blocklist/opt_out_blocklist", "//components/variations", "//net:net", "//net:test_support", diff --git a/chromium/components/previews/core/DEPS b/chromium/components/previews/core/DEPS index 9f3afce04d6..f92b369965b 100644 --- a/chromium/components/previews/core/DEPS +++ b/chromium/components/previews/core/DEPS @@ -1,5 +1,5 @@ include_rules = [ - "+components/blacklist/opt_out_blacklist", + "+components/blocklist/opt_out_blocklist", "+components/variations", "+net", "+third_party/re2", diff --git a/chromium/components/previews/core/previews_black_list.cc b/chromium/components/previews/core/previews_black_list.cc deleted file mode 100644 index 93cdaba1a49..00000000000 --- a/chromium/components/previews/core/previews_black_list.cc +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/previews/core/previews_black_list.h" - -#include "base/bind.h" -#include "base/check.h" -#include "base/memory/ptr_util.h" -#include "base/metrics/histogram.h" -#include "base/metrics/histogram_macros.h" -#include "base/notreached.h" -#include "base/optional.h" -#include "base/strings/stringprintf.h" -#include "base/time/clock.h" -#include "components/previews/core/previews_experiments.h" -#include "url/gurl.h" - -namespace previews { - -namespace { - -PreviewsEligibilityReason BlacklistReasonToPreviewsReason( - blacklist::BlacklistReason reason) { - switch (reason) { - case blacklist::BlacklistReason::kBlacklistNotLoaded: - return PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED; - case blacklist::BlacklistReason::kUserOptedOutInSession: - return PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT; - case blacklist::BlacklistReason::kUserOptedOutInGeneral: - return PreviewsEligibilityReason::USER_BLACKLISTED; - case blacklist::BlacklistReason::kUserOptedOutOfHost: - return PreviewsEligibilityReason::HOST_BLACKLISTED; - case blacklist::BlacklistReason::kUserOptedOutOfType: - NOTREACHED() << "Previews does not support type-base blacklisting"; - return PreviewsEligibilityReason::ALLOWED; - case blacklist::BlacklistReason::kAllowed: - return PreviewsEligibilityReason::ALLOWED; - } -} - -} - -PreviewsBlackList::PreviewsBlackList( - std::unique_ptr<blacklist::OptOutStore> opt_out_store, - base::Clock* clock, - blacklist::OptOutBlacklistDelegate* blacklist_delegate, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_types) - : blacklist::OptOutBlacklist(std::move(opt_out_store), - clock, - blacklist_delegate), - allowed_types_(std::move(allowed_types)) { - DCHECK(blacklist_delegate); - Init(); -} - -bool PreviewsBlackList::ShouldUseSessionPolicy(base::TimeDelta* duration, - size_t* history, - int* threshold) const { - *duration = params::SingleOptOutDuration(); - *history = 1; - *threshold = 1; - return true; -} - -bool PreviewsBlackList::ShouldUsePersistentPolicy(base::TimeDelta* duration, - size_t* history, - int* threshold) const { - *history = params::MaxStoredHistoryLengthForHostIndifferentBlackList(); - *threshold = params::HostIndifferentBlackListOptOutThreshold(); - *duration = params::HostIndifferentBlackListPerHostDuration(); - return true; -} -bool PreviewsBlackList::ShouldUseHostPolicy(base::TimeDelta* duration, - size_t* history, - int* threshold, - size_t* max_hosts) const { - *max_hosts = params::MaxInMemoryHostsInBlackList(); - *history = params::MaxStoredHistoryLengthForPerHostBlackList(); - *threshold = params::PerHostBlackListOptOutThreshold(); - *duration = params::PerHostBlackListDuration(); - return true; -} -bool PreviewsBlackList::ShouldUseTypePolicy(base::TimeDelta* duration, - size_t* history, - int* threshold) const { - return false; -} - -blacklist::BlacklistData::AllowedTypesAndVersions -PreviewsBlackList::GetAllowedTypes() const { - return allowed_types_; -} - -PreviewsBlackList::~PreviewsBlackList() {} - -base::Time PreviewsBlackList::AddPreviewNavigation(const GURL& url, - bool opt_out, - PreviewsType type) { - DCHECK(url.has_host()); - UMA_HISTOGRAM_BOOLEAN("Previews.OptOut.UserOptedOut", opt_out); - base::BooleanHistogram::FactoryGet( - base::StringPrintf("Previews.OptOut.UserOptedOut.%s", - GetStringNameForType(type).c_str()), - base::HistogramBase::kUmaTargetedHistogramFlag) - ->Add(opt_out); - - return blacklist::OptOutBlacklist::AddEntry(url.host(), opt_out, - static_cast<int>(type)); -} - -PreviewsEligibilityReason PreviewsBlackList::IsLoadedAndAllowed( - const GURL& url, - PreviewsType type, - bool ignore_long_term_black_list_rules, - std::vector<PreviewsEligibilityReason>* passed_reasons) const { - DCHECK(url.has_host()); - - std::vector<blacklist::BlacklistReason> passed_blacklist_reasons; - blacklist::BlacklistReason reason = - blacklist::OptOutBlacklist::IsLoadedAndAllowed( - url.host(), static_cast<int>(type), ignore_long_term_black_list_rules, - &passed_blacklist_reasons); - for (auto passed_reason : passed_blacklist_reasons) { - passed_reasons->push_back(BlacklistReasonToPreviewsReason(passed_reason)); - } - - return BlacklistReasonToPreviewsReason(reason); -} - -} // namespace previews diff --git a/chromium/components/previews/core/previews_block_list.cc b/chromium/components/previews/core/previews_block_list.cc new file mode 100644 index 00000000000..3aba7aec71a --- /dev/null +++ b/chromium/components/previews/core/previews_block_list.cc @@ -0,0 +1,131 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/previews/core/previews_block_list.h" + +#include "base/bind.h" +#include "base/check.h" +#include "base/memory/ptr_util.h" +#include "base/metrics/histogram.h" +#include "base/metrics/histogram_macros.h" +#include "base/notreached.h" +#include "base/optional.h" +#include "base/strings/stringprintf.h" +#include "base/time/clock.h" +#include "components/previews/core/previews_experiments.h" +#include "url/gurl.h" + +namespace previews { + +namespace { + +PreviewsEligibilityReason BlocklistReasonToPreviewsReason( + blocklist::BlocklistReason reason) { + switch (reason) { + case blocklist::BlocklistReason::kBlocklistNotLoaded: + return PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED; + case blocklist::BlocklistReason::kUserOptedOutInSession: + return PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT; + case blocklist::BlocklistReason::kUserOptedOutInGeneral: + return PreviewsEligibilityReason::USER_BLOCKLISTED; + case blocklist::BlocklistReason::kUserOptedOutOfHost: + return PreviewsEligibilityReason::HOST_BLOCKLISTED; + case blocklist::BlocklistReason::kUserOptedOutOfType: + NOTREACHED() << "Previews does not support type-base blocklisting"; + return PreviewsEligibilityReason::ALLOWED; + case blocklist::BlocklistReason::kAllowed: + return PreviewsEligibilityReason::ALLOWED; + } +} + +} // namespace + +PreviewsBlockList::PreviewsBlockList( + std::unique_ptr<blocklist::OptOutStore> opt_out_store, + base::Clock* clock, + blocklist::OptOutBlocklistDelegate* blocklist_delegate, + blocklist::BlocklistData::AllowedTypesAndVersions allowed_types) + : blocklist::OptOutBlocklist(std::move(opt_out_store), + clock, + blocklist_delegate), + allowed_types_(std::move(allowed_types)) { + DCHECK(blocklist_delegate); + Init(); +} + +bool PreviewsBlockList::ShouldUseSessionPolicy(base::TimeDelta* duration, + size_t* history, + int* threshold) const { + *duration = params::SingleOptOutDuration(); + *history = 1; + *threshold = 1; + return true; +} + +bool PreviewsBlockList::ShouldUsePersistentPolicy(base::TimeDelta* duration, + size_t* history, + int* threshold) const { + *history = params::MaxStoredHistoryLengthForHostIndifferentBlockList(); + *threshold = params::HostIndifferentBlockListOptOutThreshold(); + *duration = params::HostIndifferentBlockListPerHostDuration(); + return true; +} +bool PreviewsBlockList::ShouldUseHostPolicy(base::TimeDelta* duration, + size_t* history, + int* threshold, + size_t* max_hosts) const { + *max_hosts = params::MaxInMemoryHostsInBlockList(); + *history = params::MaxStoredHistoryLengthForPerHostBlockList(); + *threshold = params::PerHostBlockListOptOutThreshold(); + *duration = params::PerHostBlockListDuration(); + return true; +} +bool PreviewsBlockList::ShouldUseTypePolicy(base::TimeDelta* duration, + size_t* history, + int* threshold) const { + return false; +} + +blocklist::BlocklistData::AllowedTypesAndVersions +PreviewsBlockList::GetAllowedTypes() const { + return allowed_types_; +} + +PreviewsBlockList::~PreviewsBlockList() = default; + +base::Time PreviewsBlockList::AddPreviewNavigation(const GURL& url, + bool opt_out, + PreviewsType type) { + DCHECK(url.has_host()); + UMA_HISTOGRAM_BOOLEAN("Previews.OptOut.UserOptedOut", opt_out); + base::BooleanHistogram::FactoryGet( + base::StringPrintf("Previews.OptOut.UserOptedOut.%s", + GetStringNameForType(type).c_str()), + base::HistogramBase::kUmaTargetedHistogramFlag) + ->Add(opt_out); + + return blocklist::OptOutBlocklist::AddEntry(url.host(), opt_out, + static_cast<int>(type)); +} + +PreviewsEligibilityReason PreviewsBlockList::IsLoadedAndAllowed( + const GURL& url, + PreviewsType type, + bool ignore_long_term_block_list_rules, + std::vector<PreviewsEligibilityReason>* passed_reasons) const { + DCHECK(url.has_host()); + + std::vector<blocklist::BlocklistReason> passed_blocklist_reasons; + blocklist::BlocklistReason reason = + blocklist::OptOutBlocklist::IsLoadedAndAllowed( + url.host(), static_cast<int>(type), ignore_long_term_block_list_rules, + &passed_blocklist_reasons); + for (auto passed_reason : passed_blocklist_reasons) { + passed_reasons->push_back(BlocklistReasonToPreviewsReason(passed_reason)); + } + + return BlocklistReasonToPreviewsReason(reason); +} + +} // namespace previews diff --git a/chromium/components/previews/core/previews_black_list.h b/chromium/components/previews/core/previews_block_list.h index 31946d1c5de..84b184cc8f9 100644 --- a/chromium/components/previews/core/previews_black_list.h +++ b/chromium/components/previews/core/previews_block_list.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ -#define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ +#ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLOCK_LIST_H_ +#define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLOCK_LIST_H_ #include <stdint.h> @@ -16,9 +16,9 @@ #include "base/macros.h" #include "base/optional.h" #include "base/time/time.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_delegate.h" -#include "components/blacklist/opt_out_blacklist/opt_out_store.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_delegate.h" +#include "components/blocklist/opt_out_blocklist/opt_out_store.h" #include "components/previews/core/previews_experiments.h" class GURL; @@ -34,34 +34,34 @@ namespace previews { enum class PreviewsEligibilityReason { // The preview navigation was allowed. ALLOWED = 0, - // The black list was not initialized. - BLACKLIST_UNAVAILABLE = 1, - // The black list has not loaded from disk yet. - BLACKLIST_DATA_NOT_LOADED = 2, + // The block list was not initialized. + BLOCKLIST_UNAVAILABLE = 1, + // The block list has not loaded from disk yet. + BLOCKLIST_DATA_NOT_LOADED = 2, // The user has opted out of a preview recently. USER_RECENTLY_OPTED_OUT = 3, // The user has opted out of previews often, and is no longer shown previews // on any host. - USER_BLACKLISTED = 4, + USER_BLOCKLISTED = 4, // The user has opted out of previews on a specific host often, and was not // not shown a previews on that host. - HOST_BLACKLISTED = 5, + HOST_BLOCKLISTED = 5, // The network quality estimate is not available. NETWORK_QUALITY_UNAVAILABLE = 6, // The network was fast enough to not warrant previews. NETWORK_NOT_SLOW = 7, // If the page was reloaded, the user should not be shown a stale preview. RELOAD_DISALLOWED = 8, - // DEPRECATED: The host is explicitly blacklisted by the server, so the user + // DEPRECATED: The host is explicitly blocklisted by the server, so the user // was not shown // a preview. // Replaced by NOT_ALLOWED_BY_OPTIMIZATION_GUIDE. - DEPRECATED_HOST_BLACKLISTED_BY_SERVER = 9, - // DEPRECATED: The host is not whitelisted by the server for a preview + DEPRECATED_HOST_BLOCKLISTED_BY_SERVER = 9, + // DEPRECATED: The host is not allowlisted by the server for a preview // decision that uses // server optimization hints. // Replaced by NOT_ALLOWED_BY_OPTIMIZATION_GUIDE. - DEPRECATED_HOST_NOT_WHITELISTED_BY_SERVER = 10, + DEPRECATED_HOST_NOT_ALLOWLISTED_BY_SERVER = 10, // The preview is allowed but without an expected check of server optimization // hints because they are not enabled (features::kOptimizationHints). ALLOWED_WITHOUT_OPTIMIZATION_HINTS = 11, @@ -95,25 +95,25 @@ enum class PreviewsEligibilityReason { LAST, }; -// Manages the state of black listed domains for the previews experiment. Loads -// the stored black list from |opt_out_store| and manages an in memory black -// list on the IO thread. Updates to the black list are stored in memory and +// Manages the state of block listed domains for the previews experiment. Loads +// the stored block list from |opt_out_store| and manages an in memory block +// list on the IO thread. Updates to the block list are stored in memory and // pushed to the store. Asynchronous modifications are stored in a queue and -// executed in order. Reading from the black list is always synchronous, and if -// the black list is not currently loaded (e.g., at startup, after clearing -// browsing history), domains are reported as black listed. The list stores no -// more than previews::params::MaxInMemoryHostsInBlackList hosts in-memory, +// executed in order. Reading from the block list is always synchronous, and if +// the block list is not currently loaded (e.g., at startup, after clearing +// browsing history), domains are reported as block listed. The list stores no +// more than previews::params::MaxInMemoryHostsInBlockList hosts in-memory, // which defaults to 100. -class PreviewsBlackList : public blacklist::OptOutBlacklist { +class PreviewsBlockList : public blocklist::OptOutBlocklist { public: - PreviewsBlackList( - std::unique_ptr<blacklist::OptOutStore> opt_out_store, + PreviewsBlockList( + std::unique_ptr<blocklist::OptOutStore> opt_out_store, base::Clock* clock, - blacklist::OptOutBlacklistDelegate* blacklist_delegate, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_types); - ~PreviewsBlackList() override; + blocklist::OptOutBlocklistDelegate* blocklist_delegate, + blocklist::BlocklistData::AllowedTypesAndVersions allowed_types); + ~PreviewsBlockList() override; - // Asynchronously adds a new navigation to to the in-memory black list and + // Asynchronously adds a new navigation to to the in-memory block list and // backing store. |opt_out| is whether the user opted out of the preview or // navigated away from the page without opting out. |type| is only passed to // the backing store. If the in memory map has reached the max number of hosts @@ -125,17 +125,17 @@ class PreviewsBlackList : public blacklist::OptOutBlacklist { PreviewsType type); // Synchronously determines if |host_name| should be allowed to show previews. - // Returns the reason the blacklist disallowed the preview, or + // Returns the reason the blocklist disallowed the preview, or // PreviewsEligibilityReason::ALLOWED if the preview is allowed. Record // checked reasons in |passed_reasons|. Virtualized in testing. virtual PreviewsEligibilityReason IsLoadedAndAllowed( const GURL& url, PreviewsType type, - bool ignore_long_term_black_list_rules, + bool ignore_long_term_block_list_rules, std::vector<PreviewsEligibilityReason>* passed_reasons) const; protected: - // blacklist::OptOutBlacklist (virtual for testing): + // blocklist::OptOutBlocklist (virtual for testing): bool ShouldUseSessionPolicy(base::TimeDelta* duration, size_t* history, int* threshold) const override; @@ -149,15 +149,15 @@ class PreviewsBlackList : public blacklist::OptOutBlacklist { bool ShouldUseTypePolicy(base::TimeDelta* duration, size_t* history, int* threshold) const override; - blacklist::BlacklistData::AllowedTypesAndVersions GetAllowedTypes() + blocklist::BlocklistData::AllowedTypesAndVersions GetAllowedTypes() const override; private: - const blacklist::BlacklistData::AllowedTypesAndVersions allowed_types_; + const blocklist::BlocklistData::AllowedTypesAndVersions allowed_types_; - DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); + DISALLOW_COPY_AND_ASSIGN(PreviewsBlockList); }; } // namespace previews -#endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ +#endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLOCK_LIST_H_ diff --git a/chromium/components/previews/core/previews_black_list_unittest.cc b/chromium/components/previews/core/previews_block_list_unittest.cc index 88d79f53fe3..eb46c01df50 100644 --- a/chromium/components/previews/core/previews_black_list_unittest.cc +++ b/chromium/components/previews/core/previews_block_list_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include <algorithm> #include <map> @@ -22,9 +22,9 @@ #include "base/test/task_environment.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_delegate.h" -#include "components/blacklist/opt_out_blacklist/opt_out_blacklist_item.h" -#include "components/blacklist/opt_out_blacklist/opt_out_store.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_delegate.h" +#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_item.h" +#include "components/blocklist/opt_out_blocklist/opt_out_store.h" #include "components/previews/core/previews_experiments.h" #include "components/variations/variations_associated_data.h" #include "testing/gmock/include/gmock/gmock.h" @@ -35,62 +35,62 @@ namespace previews { namespace { -// Mock class to test that PreviewsBlackList notifies the delegate with correct -// events (e.g. New host blacklisted, user blacklisted, and blacklist cleared). -class TestOptOutBlacklistDelegate : public blacklist::OptOutBlacklistDelegate { +// Mock class to test that PreviewsBlockList notifies the delegate with correct +// events (e.g. New host blocklisted, user blocklisted, and blocklist cleared). +class TestOptOutBlocklistDelegate : public blocklist::OptOutBlocklistDelegate { public: - TestOptOutBlacklistDelegate() {} + TestOptOutBlocklistDelegate() = default; - // blacklist::OptOutBlacklistDelegate: - void OnNewBlacklistedHost(const std::string& host, base::Time time) override { + // blocklist::OptOutBlocklistDelegate: + void OnNewBlocklistedHost(const std::string& host, base::Time time) override { } - void OnUserBlacklistedStatusChange(bool blacklisted) override {} - void OnBlacklistCleared(base::Time time) override {} + void OnUserBlocklistedStatusChange(bool blocklisted) override {} + void OnBlocklistCleared(base::Time time) override {} }; -class TestPreviewsBlackList : public PreviewsBlackList { +class TestPreviewsBlockList : public PreviewsBlockList { public: - TestPreviewsBlackList( - std::unique_ptr<blacklist::OptOutStore> opt_out_store, + TestPreviewsBlockList( + std::unique_ptr<blocklist::OptOutStore> opt_out_store, base::Clock* clock, - blacklist::OptOutBlacklistDelegate* blacklist_delegate, - blacklist::BlacklistData::AllowedTypesAndVersions allowed_types) - : PreviewsBlackList(std::move(opt_out_store), + blocklist::OptOutBlocklistDelegate* blocklist_delegate, + blocklist::BlocklistData::AllowedTypesAndVersions allowed_types) + : PreviewsBlockList(std::move(opt_out_store), clock, - blacklist_delegate, + blocklist_delegate, allowed_types) {} - ~TestPreviewsBlackList() override {} + ~TestPreviewsBlockList() override = default; bool ShouldUseSessionPolicy(base::TimeDelta* duration, size_t* history, int* threshold) const override { - return PreviewsBlackList::ShouldUseSessionPolicy(duration, history, + return PreviewsBlockList::ShouldUseSessionPolicy(duration, history, threshold); } bool ShouldUsePersistentPolicy(base::TimeDelta* duration, size_t* history, int* threshold) const override { - return PreviewsBlackList::ShouldUsePersistentPolicy(duration, history, + return PreviewsBlockList::ShouldUsePersistentPolicy(duration, history, threshold); } bool ShouldUseHostPolicy(base::TimeDelta* duration, size_t* history, int* threshold, size_t* max_hosts) const override { - return PreviewsBlackList::ShouldUseHostPolicy(duration, history, threshold, + return PreviewsBlockList::ShouldUseHostPolicy(duration, history, threshold, max_hosts); } bool ShouldUseTypePolicy(base::TimeDelta* duration, size_t* history, int* threshold) const override { - return PreviewsBlackList::ShouldUseTypePolicy(duration, history, threshold); + return PreviewsBlockList::ShouldUseTypePolicy(duration, history, threshold); } }; -class PreviewsBlackListTest : public testing::Test { +class PreviewsBlockListTest : public testing::Test { public: - PreviewsBlackListTest() : passed_reasons_({}) {} - ~PreviewsBlackListTest() override {} + PreviewsBlockListTest() : passed_reasons_({}) {} + ~PreviewsBlockListTest() override = default; void TearDown() override { variations::testing::ClearAllVariationParams(); } @@ -103,10 +103,10 @@ class PreviewsBlackListTest : public testing::Test { params_.clear(); } - blacklist::BlacklistData::AllowedTypesAndVersions allowed_types; + blocklist::BlocklistData::AllowedTypesAndVersions allowed_types; allowed_types[static_cast<int>(PreviewsType::OFFLINE)] = 0; - black_list_ = std::make_unique<TestPreviewsBlackList>( - nullptr, &test_clock_, &blacklist_delegate_, std::move(allowed_types)); + block_list_ = std::make_unique<TestPreviewsBlockList>( + nullptr, &test_clock_, &blocklist_delegate_, std::move(allowed_types)); passed_reasons_ = {}; } @@ -132,11 +132,14 @@ class PreviewsBlackListTest : public testing::Test { } void SetHostDurationParam(int duration_in_days) { + // TODO(crbug.com/1092102): Migrate to per_host_black_list_duration_in_days params_["per_host_black_list_duration_in_days"] = base::NumberToString(duration_in_days); } void SetHostIndifferentDurationParam(int duration_in_days) { + // TODO(crbug.com/1092102): Migrate to + // host_indifferent_block_list_duration_in_days params_["host_indifferent_black_list_duration_in_days"] = base::NumberToString(duration_in_days); } @@ -146,44 +149,45 @@ class PreviewsBlackListTest : public testing::Test { base::NumberToString(single_opt_out_duration); } - void SetMaxHostInBlackListParam(size_t max_hosts_in_blacklist) { + void SetMaxHostInBlockListParam(size_t max_hosts_in_blocklist) { + // TODO(crbug.com/1092102): Migrate to max_hosts_in_blocklist params_["max_hosts_in_blacklist"] = - base::NumberToString(max_hosts_in_blacklist); + base::NumberToString(max_hosts_in_blocklist); } protected: base::test::SingleThreadTaskEnvironment task_environment_; - // Observer to |black_list_|. - TestOptOutBlacklistDelegate blacklist_delegate_; + // Observer to |block_list_|. + TestOptOutBlocklistDelegate blocklist_delegate_; base::SimpleTestClock test_clock_; std::map<std::string, std::string> params_; - std::unique_ptr<TestPreviewsBlackList> black_list_; + std::unique_ptr<TestPreviewsBlockList> block_list_; std::vector<PreviewsEligibilityReason> passed_reasons_; private: - DISALLOW_COPY_AND_ASSIGN(PreviewsBlackListTest); + DISALLOW_COPY_AND_ASSIGN(PreviewsBlockListTest); }; -TEST_F(PreviewsBlackListTest, AddPreviewUMA) { +TEST_F(PreviewsBlockListTest, AddPreviewUMA) { base::HistogramTester histogram_tester; const GURL url("http://www.url.com"); StartTest(); - black_list_->AddPreviewNavigation(url, false, PreviewsType::OFFLINE); + block_list_->AddPreviewNavigation(url, false, PreviewsType::OFFLINE); histogram_tester.ExpectUniqueSample("Previews.OptOut.UserOptedOut.Offline", 0, 1); histogram_tester.ExpectUniqueSample("Previews.OptOut.UserOptedOut", 0, 1); - black_list_->AddPreviewNavigation(url, true, PreviewsType::OFFLINE); + block_list_->AddPreviewNavigation(url, true, PreviewsType::OFFLINE); histogram_tester.ExpectBucketCount("Previews.OptOut.UserOptedOut.Offline", 1, 1); histogram_tester.ExpectBucketCount("Previews.OptOut.UserOptedOut", 1, 1); } -TEST_F(PreviewsBlackListTest, SessionParams) { +TEST_F(PreviewsBlockListTest, SessionParams) { int duration_seconds = 5; SetSingleOptOutDurationParam(duration_seconds); @@ -194,13 +198,13 @@ TEST_F(PreviewsBlackListTest, SessionParams) { int threshold = 0; EXPECT_TRUE( - black_list_->ShouldUseSessionPolicy(&duration, &history, &threshold)); + block_list_->ShouldUseSessionPolicy(&duration, &history, &threshold)); EXPECT_EQ(base::TimeDelta::FromSeconds(duration_seconds), duration); EXPECT_EQ(1u, history); EXPECT_EQ(1, threshold); } -TEST_F(PreviewsBlackListTest, PersistentParams) { +TEST_F(PreviewsBlockListTest, PersistentParams) { int duration_days = 5; size_t expected_history = 6; int expected_threshold = 4; @@ -215,13 +219,13 @@ TEST_F(PreviewsBlackListTest, PersistentParams) { int threshold = 0; EXPECT_TRUE( - black_list_->ShouldUsePersistentPolicy(&duration, &history, &threshold)); + block_list_->ShouldUsePersistentPolicy(&duration, &history, &threshold)); EXPECT_EQ(base::TimeDelta::FromDays(duration_days), duration); EXPECT_EQ(expected_history, history); EXPECT_EQ(expected_threshold, threshold); } -TEST_F(PreviewsBlackListTest, HostParams) { +TEST_F(PreviewsBlockListTest, HostParams) { int duration_days = 5; size_t expected_history = 6; int expected_threshold = 4; @@ -229,7 +233,7 @@ TEST_F(PreviewsBlackListTest, HostParams) { SetHostThresholdParam(expected_threshold); SetHostHistoryParam(expected_history); SetHostDurationParam(duration_days); - SetMaxHostInBlackListParam(expected_max_hosts); + SetMaxHostInBlockListParam(expected_max_hosts); StartTest(); @@ -238,7 +242,7 @@ TEST_F(PreviewsBlackListTest, HostParams) { int threshold = 0; size_t max_hosts = 0; - EXPECT_TRUE(black_list_->ShouldUseHostPolicy(&duration, &history, &threshold, + EXPECT_TRUE(block_list_->ShouldUseHostPolicy(&duration, &history, &threshold, &max_hosts)); EXPECT_EQ(base::TimeDelta::FromDays(duration_days), duration); EXPECT_EQ(expected_history, history); @@ -246,9 +250,9 @@ TEST_F(PreviewsBlackListTest, HostParams) { EXPECT_EQ(expected_max_hosts, max_hosts); } -TEST_F(PreviewsBlackListTest, TypeParams) { +TEST_F(PreviewsBlockListTest, TypeParams) { StartTest(); - EXPECT_FALSE(black_list_->ShouldUseTypePolicy(nullptr, nullptr, nullptr)); + EXPECT_FALSE(block_list_->ShouldUseTypePolicy(nullptr, nullptr, nullptr)); } } // namespace diff --git a/chromium/components/previews/core/previews_experiments.cc b/chromium/components/previews/core/previews_experiments.cc index 6b3f87d42c0..baabd1dc9e7 100644 --- a/chromium/components/previews/core/previews_experiments.cc +++ b/chromium/components/previews/core/previews_experiments.cc @@ -6,9 +6,9 @@ #include "base/command_line.h" #include "base/feature_list.h" -#include "base/logging.h" #include "base/metrics/field_trial.h" #include "base/metrics/field_trial_params.h" +#include "base/notreached.h" #include "base/optional.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" @@ -21,12 +21,12 @@ namespace previews { namespace { -// The group of client-side previews experiments. This controls paramters of the -// client side blacklist. +// The group of client-side previews experiments. This controls parameters of +// the client side blocklist. const char kClientSidePreviewsFieldTrial[] = "ClientSidePreviews"; // Name for the version parameter of a field trial. Version changes will -// result in older blacklist entries being removed. +// result in older blocklist entries being removed. const char kVersion[] = "version"; // Parameter to clarify that the preview for a UserConsistent study should @@ -128,38 +128,44 @@ const base::Feature& GetNoScriptPreviewsFeature() { namespace params { -size_t MaxStoredHistoryLengthForPerHostBlackList() { +size_t MaxStoredHistoryLengthForPerHostBlockList() { return GetParamValueAsSizeT(kClientSidePreviewsFieldTrial, "per_host_max_stored_history_length", 4); } -size_t MaxStoredHistoryLengthForHostIndifferentBlackList() { +size_t MaxStoredHistoryLengthForHostIndifferentBlockList() { return GetParamValueAsSizeT(kClientSidePreviewsFieldTrial, "host_indifferent_max_stored_history_length", 10); } -size_t MaxInMemoryHostsInBlackList() { +size_t MaxInMemoryHostsInBlockList() { + // TODO(crbug.com/1092102): Migrate exeriment parameter name to + // max_hosts_in_blocklist. return GetParamValueAsSizeT(kClientSidePreviewsFieldTrial, "max_hosts_in_blacklist", 100); } -int PerHostBlackListOptOutThreshold() { +int PerHostBlockListOptOutThreshold() { return GetParamValueAsInt(kClientSidePreviewsFieldTrial, "per_host_opt_out_threshold", 2); } -int HostIndifferentBlackListOptOutThreshold() { +int HostIndifferentBlockListOptOutThreshold() { return GetParamValueAsInt(kClientSidePreviewsFieldTrial, "host_indifferent_opt_out_threshold", 6); } -base::TimeDelta PerHostBlackListDuration() { +base::TimeDelta PerHostBlockListDuration() { + // TODO(crbug.com/1092102): Migrate exeriment parameter name to + // per_host_block_list_duration_in_days. return base::TimeDelta::FromDays( GetParamValueAsInt(kClientSidePreviewsFieldTrial, "per_host_black_list_duration_in_days", 30)); } -base::TimeDelta HostIndifferentBlackListPerHostDuration() { +base::TimeDelta HostIndifferentBlockListPerHostDuration() { + // TODO(crbug.com/1092102): Migrate exeriment parameter name to + // host_indifferent_block_list_duration_in_days/ return base::TimeDelta::FromDays( GetParamValueAsInt(kClientSidePreviewsFieldTrial, "host_indifferent_black_list_duration_in_days", 30)); @@ -278,7 +284,7 @@ int DeferAllScriptPreviewsVersion() { } int NoScriptPreviewsInflationPercent() { - // The default value was determined from lab experiment data of whitelisted + // The default value was determined from lab experiment data of allowlisted // URLs. It may be improved once there is enough UKM live experiment data // via the field trial param. return GetFieldTrialParamByFeatureAsInt(GetNoScriptPreviewsFeature(), diff --git a/chromium/components/previews/core/previews_experiments.h b/chromium/components/previews/core/previews_experiments.h index 29ad994d4d1..7c461a1a71d 100644 --- a/chromium/components/previews/core/previews_experiments.h +++ b/chromium/components/previews/core/previews_experiments.h @@ -76,30 +76,30 @@ std::string GetStringNameForType(PreviewsType type); namespace params { -// The maximum number of recent previews navigations the black list looks at to -// determine if a host is blacklisted. -size_t MaxStoredHistoryLengthForPerHostBlackList(); +// The maximum number of recent previews navigations the block list looks at to +// determine if a host is blocklisted. +size_t MaxStoredHistoryLengthForPerHostBlockList(); -// The maximum number of recent previews navigations the black list looks at to +// The maximum number of recent previews navigations the block list looks at to // determine if all previews navigations are disallowed. -size_t MaxStoredHistoryLengthForHostIndifferentBlackList(); +size_t MaxStoredHistoryLengthForHostIndifferentBlockList(); -// The maximum number of hosts allowed in the in memory black list. -size_t MaxInMemoryHostsInBlackList(); +// The maximum number of hosts allowed in the in memory block list. +size_t MaxInMemoryHostsInBlockList(); // The number of recent navigations that were opted out of for a given host that -// would trigger that host to be blacklisted. -int PerHostBlackListOptOutThreshold(); +// would trigger that host to be blocklisted. +int PerHostBlockListOptOutThreshold(); // The number of recent navigations that were opted out of that would trigger // all previews navigations to be disallowed. -int HostIndifferentBlackListOptOutThreshold(); +int HostIndifferentBlockListOptOutThreshold(); -// The amount of time a host remains blacklisted due to opt outs. -base::TimeDelta PerHostBlackListDuration(); +// The amount of time a host remains blocklisted due to opt outs. +base::TimeDelta PerHostBlockListDuration(); // The amount of time all previews navigations are disallowed due to opt outs. -base::TimeDelta HostIndifferentBlackListPerHostDuration(); +base::TimeDelta HostIndifferentBlockListPerHostDuration(); // The amount of time after any opt out that no previews should be shown. base::TimeDelta SingleOptOutDuration(); @@ -128,7 +128,7 @@ bool IsNoScriptPreviewsEnabled(); bool IsResourceLoadingHintsEnabled(); bool IsDeferAllScriptPreviewsEnabled(); -// The blacklist version for each preview type. +// The blocklist version for each preview type. int OfflinePreviewsVersion(); int NoScriptPreviewsVersion(); int ResourceLoadingHintsVersion(); diff --git a/chromium/components/previews/core/previews_experiments_unittest.cc b/chromium/components/previews/core/previews_experiments_unittest.cc index 13c8fde6525..99a899066d9 100644 --- a/chromium/components/previews/core/previews_experiments_unittest.cc +++ b/chromium/components/previews/core/previews_experiments_unittest.cc @@ -29,17 +29,17 @@ const char kPreviewsFieldTrial[] = "Previews"; const char kEnabled[] = "Enabled"; // Verifies that the default params are correct, and that custom params can be -// set, for both the previews blacklist and offline previews. -TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { +// set, for both the previews blocklist and offline previews. +TEST(PreviewsExperimentsTest, TestParamsForBlockListAndOffline) { // Verify that the default params are correct. - EXPECT_EQ(4u, params::MaxStoredHistoryLengthForPerHostBlackList()); - EXPECT_EQ(10u, params::MaxStoredHistoryLengthForHostIndifferentBlackList()); - EXPECT_EQ(100u, params::MaxInMemoryHostsInBlackList()); - EXPECT_EQ(2, params::PerHostBlackListOptOutThreshold()); - EXPECT_EQ(6, params::HostIndifferentBlackListOptOutThreshold()); - EXPECT_EQ(base::TimeDelta::FromDays(30), params::PerHostBlackListDuration()); + EXPECT_EQ(4u, params::MaxStoredHistoryLengthForPerHostBlockList()); + EXPECT_EQ(10u, params::MaxStoredHistoryLengthForHostIndifferentBlockList()); + EXPECT_EQ(100u, params::MaxInMemoryHostsInBlockList()); + EXPECT_EQ(2, params::PerHostBlockListOptOutThreshold()); + EXPECT_EQ(6, params::HostIndifferentBlockListOptOutThreshold()); + EXPECT_EQ(base::TimeDelta::FromDays(30), params::PerHostBlockListDuration()); EXPECT_EQ(base::TimeDelta::FromDays(30), - params::HostIndifferentBlackListPerHostDuration()); + params::HostIndifferentBlockListPerHostDuration()); EXPECT_EQ(base::TimeDelta::FromSeconds(60 * 5), params::SingleOptOutDuration()); EXPECT_EQ(base::TimeDelta::FromDays(7), @@ -51,6 +51,7 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { EXPECT_EQ(0, params::OfflinePreviewsVersion()); // Set some custom params. Somewhat random yet valid values. + // TODO(crbug.com/1092102) : Migrate blacklist names to blocklist. std::map<std::string, std::string> custom_params = { {"per_host_max_stored_history_length", "3"}, {"host_indifferent_max_stored_history_length", "4"}, @@ -69,14 +70,14 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial( kClientSidePreviewsFieldTrial, kEnabled)); - EXPECT_EQ(3u, params::MaxStoredHistoryLengthForPerHostBlackList()); - EXPECT_EQ(4u, params::MaxStoredHistoryLengthForHostIndifferentBlackList()); - EXPECT_EQ(13u, params::MaxInMemoryHostsInBlackList()); - EXPECT_EQ(12, params::PerHostBlackListOptOutThreshold()); - EXPECT_EQ(84, params::HostIndifferentBlackListOptOutThreshold()); - EXPECT_EQ(base::TimeDelta::FromDays(99), params::PerHostBlackListDuration()); + EXPECT_EQ(3u, params::MaxStoredHistoryLengthForPerHostBlockList()); + EXPECT_EQ(4u, params::MaxStoredHistoryLengthForHostIndifferentBlockList()); + EXPECT_EQ(13u, params::MaxInMemoryHostsInBlockList()); + EXPECT_EQ(12, params::PerHostBlockListOptOutThreshold()); + EXPECT_EQ(84, params::HostIndifferentBlockListOptOutThreshold()); + EXPECT_EQ(base::TimeDelta::FromDays(99), params::PerHostBlockListDuration()); EXPECT_EQ(base::TimeDelta::FromDays(64), - params::HostIndifferentBlackListPerHostDuration()); + params::HostIndifferentBlockListPerHostDuration()); EXPECT_EQ(base::TimeDelta::FromSeconds(28), params::SingleOptOutDuration()); EXPECT_EQ(base::TimeDelta::FromDays(12), params::OfflinePreviewFreshnessDuration()); diff --git a/chromium/components/previews/core/previews_features.cc b/chromium/components/previews/core/previews_features.cc index d22d4021119..3f4e492be69 100644 --- a/chromium/components/previews/core/previews_features.cc +++ b/chromium/components/previews/core/previews_features.cc @@ -29,11 +29,7 @@ const base::Feature kOfflinePreviews{"OfflinePreviews", // Support for enabling NoScript previews which includes a base feature // and a UserConsistent-specific experiment feature. const base::FeatureState kNoScriptDefaultFeatureState = -#if defined(OS_ANDROID) - base::FEATURE_ENABLED_BY_DEFAULT; -#else // !defined(OS_ANDROID) base::FEATURE_DISABLED_BY_DEFAULT; -#endif // defined(OS_ANDROID) const base::Feature kNoScriptPreviews{"NoScriptPreviews", kNoScriptDefaultFeatureState}; const base::Feature kNoScriptPreviewsUserConsistentStudy{ diff --git a/chromium/components/previews/core/previews_logger.cc b/chromium/components/previews/core/previews_logger.cc index fb1bc2194d1..12165283e22 100644 --- a/chromium/components/previews/core/previews_logger.cc +++ b/chromium/components/previews/core/previews_logger.cc @@ -36,22 +36,22 @@ std::string GetReasonDescription(PreviewsEligibilityReason reason, case PreviewsEligibilityReason::ALLOWED: DCHECK(!want_inverse_description); return "Allowed"; - case PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE: - return want_inverse_description ? "Blacklist not null" - : "Blacklist failed to be created"; - case PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED: - return want_inverse_description ? "Blacklist loaded from disk" - : "Blacklist not loaded from disk yet"; + case PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE: + return want_inverse_description ? "Blocklist not null" + : "Blocklist failed to be created"; + case PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED: + return want_inverse_description ? "Blocklist loaded from disk" + : "Blocklist not loaded from disk yet"; case PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT: return want_inverse_description ? "User did not opt out recently" : "User recently opted out"; - case PreviewsEligibilityReason::USER_BLACKLISTED: - return want_inverse_description ? "Not all previews are blacklisted" - : "All previews are blacklisted"; - case PreviewsEligibilityReason::HOST_BLACKLISTED: + case PreviewsEligibilityReason::USER_BLOCKLISTED: + return want_inverse_description ? "Not all previews are blocklisted" + : "All previews are blocklisted"; + case PreviewsEligibilityReason::HOST_BLOCKLISTED: return want_inverse_description - ? "Host is not blacklisted on all previews" - : "All previews on this host are blacklisted"; + ? "Host is not blocklisted on all previews" + : "All previews on this host are blocklisted"; case PreviewsEligibilityReason::NETWORK_QUALITY_UNAVAILABLE: return want_inverse_description ? "Network quality available" : "Network quality unavailable"; @@ -61,12 +61,12 @@ std::string GetReasonDescription(PreviewsEligibilityReason reason, return want_inverse_description ? "Page reloads allowed" : "Page reloads do not show previews for this preview type"; - case PreviewsEligibilityReason::DEPRECATED_HOST_BLACKLISTED_BY_SERVER: - return want_inverse_description ? "Host not blacklisted by server rules" - : "Host blacklisted by server rules"; - case PreviewsEligibilityReason::DEPRECATED_HOST_NOT_WHITELISTED_BY_SERVER: - return want_inverse_description ? "Host whitelisted by server rules" - : "Host not whitelisted by server rules"; + case PreviewsEligibilityReason::DEPRECATED_HOST_BLOCKLISTED_BY_SERVER: + return want_inverse_description ? "Host not blocklisted by server rules" + : "Host blocklisted by server rules"; + case PreviewsEligibilityReason::DEPRECATED_HOST_NOT_ALLOWLISTED_BY_SERVER: + return want_inverse_description ? "Host allowlisted by server rules" + : "Host not allowlisted by server rules"; case PreviewsEligibilityReason::ALLOWED_WITHOUT_OPTIMIZATION_HINTS: return want_inverse_description ? "Not allowed (without server rule check)" @@ -147,15 +147,15 @@ PreviewsLogger::MessageLog::MessageLog(const MessageLog& other) page_id(other.page_id) {} PreviewsLogger::PreviewsLogger() - : blacklist_ignored_(switches::ShouldIgnorePreviewsBlacklist()) {} + : blocklist_ignored_(switches::ShouldIgnorePreviewsBlocklist()) {} PreviewsLogger::~PreviewsLogger() {} void PreviewsLogger::AddAndNotifyObserver(PreviewsLoggerObserver* observer) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); observer_list_.AddObserver(observer); - // Notify the status of blacklist decisions ingored. - observer->OnIgnoreBlacklistDecisionStatusChanged(blacklist_ignored_); + // Notify the status of blocklist decisions ignored. + observer->OnIgnoreBlocklistDecisionStatusChanged(blocklist_ignored_); // Merge navigation logs and decision logs in chronological order, and push // them to |observer|. @@ -182,11 +182,11 @@ void PreviewsLogger::AddAndNotifyObserver(PreviewsLoggerObserver* observer) { } } - // Push the current state of blacklist (user blacklisted state and all - // blacklisted hosts). - observer->OnUserBlacklistedStatusChange(user_blacklisted_status_); - for (auto entry : blacklisted_hosts_) { - observer->OnNewBlacklistedHost(entry.first, entry.second); + // Push the current state of blocklist (user blocklisted state and all + // blocklisted hosts). + observer->OnUserBlocklistedStatusChange(user_blocklisted_status_); + for (auto entry : blocklisted_hosts_) { + observer->OnNewBlocklistedHost(entry.first, entry.second); } } @@ -264,38 +264,38 @@ void PreviewsLogger::LogPreviewDecisionMade( time, page_id); } -void PreviewsLogger::OnNewBlacklistedHost(const std::string& host, +void PreviewsLogger::OnNewBlocklistedHost(const std::string& host, base::Time time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - blacklisted_hosts_[host] = time; + blocklisted_hosts_[host] = time; for (auto& observer : observer_list_) { - observer.OnNewBlacklistedHost(host, time); + observer.OnNewBlocklistedHost(host, time); } } -void PreviewsLogger::OnUserBlacklistedStatusChange(bool blacklisted) { +void PreviewsLogger::OnUserBlocklistedStatusChange(bool blocklisted) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - user_blacklisted_status_ = blacklisted; + user_blocklisted_status_ = blocklisted; for (auto& observer : observer_list_) { - observer.OnUserBlacklistedStatusChange(blacklisted); + observer.OnUserBlocklistedStatusChange(blocklisted); } } -void PreviewsLogger::OnBlacklistCleared(base::Time time) { +void PreviewsLogger::OnBlocklistCleared(base::Time time) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - blacklisted_hosts_.clear(); + blocklisted_hosts_.clear(); navigations_logs_.clear(); decisions_logs_.clear(); for (auto& observer : observer_list_) { - observer.OnBlacklistCleared(time); + observer.OnBlocklistCleared(time); } } -void PreviewsLogger::OnIgnoreBlacklistDecisionStatusChanged(bool ignored) { +void PreviewsLogger::OnIgnoreBlocklistDecisionStatusChanged(bool ignored) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - blacklist_ignored_ = ignored; + blocklist_ignored_ = ignored; for (auto& observer : observer_list_) { - observer.OnIgnoreBlacklistDecisionStatusChanged(ignored); + observer.OnIgnoreBlocklistDecisionStatusChanged(ignored); } } diff --git a/chromium/components/previews/core/previews_logger.h b/chromium/components/previews/core/previews_logger.h index 1e4ac446825..b046e144f1b 100644 --- a/chromium/components/previews/core/previews_logger.h +++ b/chromium/components/previews/core/previews_logger.h @@ -14,7 +14,7 @@ #include "base/observer_list.h" #include "base/sequence_checker.h" #include "base/time/time.h" -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include "components/previews/core/previews_experiments.h" #include "url/gurl.h" @@ -90,7 +90,7 @@ class PreviewsLogger { uint64_t page_id); // Add a MessageLog for the a decision that was made about the state of - // previews and blacklist. |passed_reasons| is an ordered list of + // previews and blocklist. |passed_reasons| is an ordered list of // PreviewsEligibilityReasons that got pass the decision. The method takes // ownership of |passed_reasons|. |page_id| generated by PreviewsDeciderImpl, // used for grouping log messages together, messages that don't need to be @@ -103,32 +103,32 @@ class PreviewsLogger { std::vector<PreviewsEligibilityReason>&& passed_reasons, uint64_t page_id); - // Notify observers that |host| is blacklisted at |time|. Virtualized in + // Notify observers that |host| is blocklisted at |time|. Virtualized in // testing. - virtual void OnNewBlacklistedHost(const std::string& host, base::Time time); + virtual void OnNewBlocklistedHost(const std::string& host, base::Time time); - // Notify observers that user blacklisted state has changed to |blacklisted|. + // Notify observers that user blocklisted state has changed to |blocklisted|. // Virtualized in testing. - virtual void OnUserBlacklistedStatusChange(bool blacklisted); + virtual void OnUserBlocklistedStatusChange(bool blocklisted); - // Notify observers that the blacklist is cleared at |time|. Virtualized in + // Notify observers that the blocklist is cleared at |time|. Virtualized in // testing. - virtual void OnBlacklistCleared(base::Time time); + virtual void OnBlocklistCleared(base::Time time); - // Notify observers that the status of whether blacklist decisions are ignored + // Notify observers that the status of whether blocklist decisions are ignored // or not. Virtualized in testing. - virtual void OnIgnoreBlacklistDecisionStatusChanged(bool ignored); + virtual void OnIgnoreBlocklistDecisionStatusChanged(bool ignored); private: - // Keeping track of all blacklisted host to notify new observers. - std::unordered_map<std::string, base::Time> blacklisted_hosts_; + // Keeping track of all blocklisted host to notify new observers. + std::unordered_map<std::string, base::Time> blocklisted_hosts_; - // The current user blacklisted status. - bool user_blacklisted_status_ = false; + // The current user blocklisted status. + bool user_blocklisted_status_ = false; - // The current status of whether PreviewsBlackList decisions are ignored or + // The current status of whether PreviewsBlockList decisions are ignored or // not. - bool blacklist_ignored_ = false; + bool blocklist_ignored_ = false; // Collection of recorded navigation log messages. std::list<MessageLog> navigations_logs_; diff --git a/chromium/components/previews/core/previews_logger_observer.h b/chromium/components/previews/core/previews_logger_observer.h index 6b48e56fb54..e1ebc798fee 100644 --- a/chromium/components/previews/core/previews_logger_observer.h +++ b/chromium/components/previews/core/previews_logger_observer.h @@ -19,19 +19,19 @@ class PreviewsLoggerObserver { virtual void OnNewMessageLogAdded( const PreviewsLogger::MessageLog& message) = 0; - // Notifies this observer that |host| is blacklisted at |time|. - virtual void OnNewBlacklistedHost(const std::string& host, + // Notifies this observer that |host| is blocklisted at |time|. + virtual void OnNewBlocklistedHost(const std::string& host, base::Time time) = 0; - // Notifies this observer that the user blacklisted state has changed to - // |blacklisted|. - virtual void OnUserBlacklistedStatusChange(bool blacklisted) = 0; + // Notifies this observer that the user blocklisted state has changed to + // |blocklisted|. + virtual void OnUserBlocklistedStatusChange(bool blocklisted) = 0; - // Notifies this observer that the blacklist is cleared at |time|. - virtual void OnBlacklistCleared(base::Time time) = 0; + // Notifies this observer that the blocklist is cleared at |time|. + virtual void OnBlocklistCleared(base::Time time) = 0; - // Notify this observer that PreviewsBlackList decisions is ignored or not. - virtual void OnIgnoreBlacklistDecisionStatusChanged(bool ignored) = 0; + // Notify this observer that PreviewsBlockList decisions is ignored or not. + virtual void OnIgnoreBlocklistDecisionStatusChanged(bool ignored) = 0; // Notify this observer that |this| is the last observer to be removed from // the Logger's observers list. diff --git a/chromium/components/previews/core/previews_logger_unittest.cc b/chromium/components/previews/core/previews_logger_unittest.cc index b8bf2b4e9bb..569d35c36ec 100644 --- a/chromium/components/previews/core/previews_logger_unittest.cc +++ b/chromium/components/previews/core/previews_logger_unittest.cc @@ -14,7 +14,7 @@ #include "base/strings/string_split.h" #include "base/test/scoped_command_line.h" #include "base/time/time.h" -#include "components/previews/core/previews_black_list.h" +#include "components/previews/core/previews_block_list.h" #include "components/previews/core/previews_logger_observer.h" #include "components/previews/core/previews_switches.h" #include "testing/gtest/include/gtest/gtest.h" @@ -32,14 +32,9 @@ const size_t kMaximumDecisionLogs = 25; // mojo::InterventionsInternalsPage. class TestPreviewsLoggerObserver : public PreviewsLoggerObserver { public: - TestPreviewsLoggerObserver() - : host_blacklisted_called_(false), - user_status_change_calls_(0), - blacklist_cleared_called_(false), - blacklist_ignored_(false), - last_removed_notified_(false) {} + TestPreviewsLoggerObserver() = default; - ~TestPreviewsLoggerObserver() override {} + ~TestPreviewsLoggerObserver() override = default; // PreviewsLoggerObserver: void OnNewMessageLogAdded( @@ -47,20 +42,20 @@ class TestPreviewsLoggerObserver : public PreviewsLoggerObserver { message_ = std::make_unique<PreviewsLogger::MessageLog>(message); messages_.push_back(*message_); } - void OnNewBlacklistedHost(const std::string& host, base::Time time) override { - host_blacklisted_called_ = true; - blacklisted_hosts_[host] = time; + void OnNewBlocklistedHost(const std::string& host, base::Time time) override { + host_blocklisted_called_ = true; + blocklisted_hosts_[host] = time; } - void OnUserBlacklistedStatusChange(bool blacklisted) override { + void OnUserBlocklistedStatusChange(bool blocklisted) override { ++user_status_change_calls_; - user_blacklisted_ = blacklisted; + user_blocklisted_ = blocklisted; } - void OnBlacklistCleared(base::Time time) override { - blacklist_cleared_called_ = true; - blacklist_cleared_time_ = time; + void OnBlocklistCleared(base::Time time) override { + blocklist_cleared_called_ = true; + blocklist_cleared_time_ = time; } - void OnIgnoreBlacklistDecisionStatusChanged(bool ignored) override { - blacklist_ignored_ = ignored; + void OnIgnoreBlocklistDecisionStatusChanged(bool ignored) override { + blocklist_ignored_ = ignored; } void OnLastObserverRemove() override { last_removed_notified_ = true; } @@ -72,18 +67,18 @@ class TestPreviewsLoggerObserver : public PreviewsLoggerObserver { return messages_; } - // Expose blacklist events info for testing. - const std::unordered_map<std::string, base::Time>& blacklisted_hosts() { - return blacklisted_hosts_; + // Expose blocklist events info for testing. + const std::unordered_map<std::string, base::Time>& blocklisted_hosts() { + return blocklisted_hosts_; } - bool host_blacklisted_called() const { return host_blacklisted_called_; } + bool host_blocklisted_called() const { return host_blocklisted_called_; } size_t user_status_change_calls() const { return user_status_change_calls_; } - bool blacklist_cleared_called() const { return blacklist_cleared_called_; } - bool user_blacklisted() const { return user_blacklisted_; } - base::Time blacklist_cleared_time() const { return blacklist_cleared_time_; } + bool blocklist_cleared_called() const { return blocklist_cleared_called_; } + bool user_blocklisted() const { return user_blocklisted_; } + base::Time blocklist_cleared_time() const { return blocklist_cleared_time_; } - // Expose whether PreviewsBlackList decisions are ignored or not. - bool blacklist_ignored() const { return blacklist_ignored_; } + // Expose whether PreviewsBlockList decisions are ignored or not. + bool blocklist_ignored() const { return blocklist_ignored_; } // Expose whether observer is notified that it is the last observer to be // removed for testing. @@ -96,19 +91,19 @@ class TestPreviewsLoggerObserver : public PreviewsLoggerObserver { // The passed in MessageLog in OnNewMessageLogAdded. std::unique_ptr<PreviewsLogger::MessageLog> message_; - // Received blacklisted event info. - std::unordered_map<std::string, base::Time> blacklisted_hosts_; - bool user_blacklisted_; - base::Time blacklist_cleared_time_; - bool host_blacklisted_called_; - size_t user_status_change_calls_; - bool blacklist_cleared_called_; + // Received blocklisted event info. + std::unordered_map<std::string, base::Time> blocklisted_hosts_; + bool user_blocklisted_; + base::Time blocklist_cleared_time_; + bool host_blocklisted_called_ = false; + size_t user_status_change_calls_ = 0; + bool blocklist_cleared_called_ = false; - // BlacklistPreviews decision is ignored or not. - bool blacklist_ignored_; + // BlocklistPreviews decision is ignored or not. + bool blocklist_ignored_ = false; // Whether |this| is the last observer to be removed. - bool last_removed_notified_; + bool last_removed_notified_ = false; }; class PreviewsLoggerTest : public testing::Test { @@ -160,7 +155,7 @@ TEST_F(PreviewsLoggerTest, LogPreviewDecisionMadeLogMessage) { PreviewsType type_a = PreviewsType::OFFLINE; PreviewsType type_b = PreviewsType::LITE_PAGE; PreviewsEligibilityReason reason_a = - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE; + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE; std::vector<PreviewsEligibilityReason> passed_reasons_a = {}; PreviewsEligibilityReason reason_b = PreviewsEligibilityReason::NETWORK_NOT_SLOW; @@ -186,7 +181,7 @@ TEST_F(PreviewsLoggerTest, LogPreviewDecisionMadeLogMessage) { EXPECT_EQ(expected_size, actual.size()); std::string expected_description_a = - "Offline preview - Blacklist failed to be created"; + "Offline preview - Blocklist failed to be created"; EXPECT_EQ(kPreviewsDecisionMadeEventType, actual[0].event_type); EXPECT_EQ(expected_description_a, actual[0].event_description); EXPECT_EQ(url_a, actual[0].url); @@ -257,7 +252,7 @@ TEST_F(PreviewsLoggerTest, LogPreviewNavigationLogMessage) { TEST_F(PreviewsLoggerTest, PreviewsLoggerOnlyKeepsCertainNumberOfDecisionLogs) { PreviewsType type = PreviewsType::OFFLINE; PreviewsEligibilityReason reason = - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE; + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE; const base::Time time = base::Time::Now(); const GURL url("http://www.url_.com/url_"); const uint64_t page_id = 1234; @@ -298,7 +293,7 @@ TEST_F(PreviewsLoggerTest, PreviewsType type = PreviewsType::OFFLINE; PreviewsEligibilityReason final_reason = - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE; + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE; std::vector<PreviewsEligibilityReason> passed_reasons = { PreviewsEligibilityReason::NETWORK_NOT_SLOW}; const GURL urls[] = { @@ -408,33 +403,33 @@ TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionAllowedChecked) { TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionUnavailabeFailed) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE, + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE, true /* final_reason */); - std::string expected_description = "Blacklist failed to be created"; + std::string expected_description = "Blocklist failed to be created"; EXPECT_EQ(expected_description, actual_description); } TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionUnavailabeChecked) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE, + PreviewsEligibilityReason::BLOCKLIST_UNAVAILABLE, false /* final_reason */); - std::string expected_description = "Blacklist not null"; + std::string expected_description = "Blocklist not null"; EXPECT_EQ(expected_description, actual_description); } TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionNotLoadedFailed) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, true /* final_reason */); - std::string expected_description = "Blacklist not loaded from disk yet"; + std::string expected_description = "Blocklist not loaded from disk yet"; EXPECT_EQ(expected_description, actual_description); } TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionNotLoadedChecked) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED, + PreviewsEligibilityReason::BLOCKLIST_DATA_NOT_LOADED, false /* final_reason */); - std::string expected_description = "Blacklist loaded from disk"; + std::string expected_description = "Blocklist loaded from disk"; EXPECT_EQ(expected_description, actual_description); } @@ -456,33 +451,33 @@ TEST_F(PreviewsLoggerTest, EXPECT_EQ(expected_description, actual_description); } -TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionBlacklistedFailed) { +TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionBlocklistedFailed) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::USER_BLACKLISTED, true /* final_reason */); - std::string expected_description = "All previews are blacklisted"; + PreviewsEligibilityReason::USER_BLOCKLISTED, true /* final_reason */); + std::string expected_description = "All previews are blocklisted"; EXPECT_EQ(expected_description, actual_description); } -TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionBlacklistedChecked) { +TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionBlocklistedChecked) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::USER_BLACKLISTED, false /* final_reason */); - std::string expected_description = "Not all previews are blacklisted"; + PreviewsEligibilityReason::USER_BLOCKLISTED, false /* final_reason */); + std::string expected_description = "Not all previews are blocklisted"; EXPECT_EQ(expected_description, actual_description); } -TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionHostBlacklistedFailed) { +TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionHostBlocklistedFailed) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::HOST_BLACKLISTED, true /* final_reason */); + PreviewsEligibilityReason::HOST_BLOCKLISTED, true /* final_reason */); std::string expected_description = - "All previews on this host are blacklisted"; + "All previews on this host are blocklisted"; EXPECT_EQ(expected_description, actual_description); } TEST_F(PreviewsLoggerTest, - LogPreviewDecisionDescriptionHostBlacklistedChecked) { + LogPreviewDecisionDescriptionHostBlocklistedChecked) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::HOST_BLACKLISTED, false /* final_reason */); - std::string expected_description = "Host is not blacklisted on all previews"; + PreviewsEligibilityReason::HOST_BLOCKLISTED, false /* final_reason */); + std::string expected_description = "Host is not blocklisted on all previews"; EXPECT_EQ(expected_description, actual_description); } @@ -539,35 +534,35 @@ TEST_F(PreviewsLoggerTest, TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionServerRulesFailed) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::DEPRECATED_HOST_BLACKLISTED_BY_SERVER, + PreviewsEligibilityReason::DEPRECATED_HOST_BLOCKLISTED_BY_SERVER, true /* final_reason */); - std::string expected_description = "Host blacklisted by server rules"; + std::string expected_description = "Host blocklisted by server rules"; EXPECT_EQ(expected_description, actual_description); } TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionServerRulesChecked) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::DEPRECATED_HOST_BLACKLISTED_BY_SERVER, + PreviewsEligibilityReason::DEPRECATED_HOST_BLOCKLISTED_BY_SERVER, false /* final_reason */); - std::string expected_description = "Host not blacklisted by server rules"; + std::string expected_description = "Host not blocklisted by server rules"; EXPECT_EQ(expected_description, actual_description); } TEST_F(PreviewsLoggerTest, - LogPreviewDecisionDescriptionNotWhitelisedByServerFailed) { + LogPreviewDecisionDescriptionNotAllowistedByServerFailed) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::DEPRECATED_HOST_NOT_WHITELISTED_BY_SERVER, + PreviewsEligibilityReason::DEPRECATED_HOST_NOT_ALLOWLISTED_BY_SERVER, true /* final_reason */); - std::string expected_description = "Host not whitelisted by server rules"; + std::string expected_description = "Host not allowlisted by server rules"; EXPECT_EQ(expected_description, actual_description); } TEST_F(PreviewsLoggerTest, - LogPreviewDecisionDescriptionNotWhitelisedByServerChecked) { + LogPreviewDecisionDescriptionNotAllowlistedByServerChecked) { std::string actual_description = LogPreviewDecisionAndGetReasonDescription( - PreviewsEligibilityReason::DEPRECATED_HOST_NOT_WHITELISTED_BY_SERVER, + PreviewsEligibilityReason::DEPRECATED_HOST_NOT_ALLOWLISTED_BY_SERVER, false /* final_reason */); - std::string expected_description = "Host whitelisted by server rules"; + std::string expected_description = "Host allowlisted by server rules"; EXPECT_EQ(expected_description, actual_description); } @@ -641,7 +636,7 @@ TEST_F(PreviewsLoggerTest, LogPreviewDecisionDescriptionPageLoadPainful) { EXPECT_EQ(expected_description, actual_description); } -TEST_F(PreviewsLoggerTest, NotifyObserversOfNewBlacklistedHost) { +TEST_F(PreviewsLoggerTest, NotifyObserversOfNewBlocklistedHost) { TestPreviewsLoggerObserver observers[3]; const size_t number_of_obs = 3; @@ -655,20 +650,20 @@ TEST_F(PreviewsLoggerTest, NotifyObserversOfNewBlacklistedHost) { const std::string expected_host = "example.com"; const base::Time expected_time = base::Time::Now(); const size_t expected_size = 1; - logger_->OnNewBlacklistedHost(expected_host, expected_time); + logger_->OnNewBlocklistedHost(expected_host, expected_time); for (size_t i = 0; i < number_of_obs; i++) { if (i != removed_observer) { - EXPECT_TRUE(observers[i].host_blacklisted_called()); - EXPECT_EQ(expected_size, observers[i].blacklisted_hosts().size()); + EXPECT_TRUE(observers[i].host_blocklisted_called()); + EXPECT_EQ(expected_size, observers[i].blocklisted_hosts().size()); EXPECT_EQ(expected_time, - observers[i].blacklisted_hosts().find(expected_host)->second); + observers[i].blocklisted_hosts().find(expected_host)->second); } } - EXPECT_FALSE(observers[removed_observer].host_blacklisted_called()); + EXPECT_FALSE(observers[removed_observer].host_blocklisted_called()); } -TEST_F(PreviewsLoggerTest, NotifyObserversWhenUserBlacklisted) { +TEST_F(PreviewsLoggerTest, NotifyObserversWhenUserBlocklisted) { TestPreviewsLoggerObserver observers[3]; const size_t number_of_obs = 3; @@ -678,20 +673,20 @@ TEST_F(PreviewsLoggerTest, NotifyObserversWhenUserBlacklisted) { const size_t removed_observer = 1; logger_->RemoveObserver(&observers[removed_observer]); - logger_->OnUserBlacklistedStatusChange(true /* blacklisted */); + logger_->OnUserBlocklistedStatusChange(true /* blocklisted */); const size_t expected_times = 2; for (size_t i = 0; i < number_of_obs; i++) { if (i != removed_observer) { EXPECT_EQ(expected_times, observers[i].user_status_change_calls()); - EXPECT_TRUE(observers[i].user_blacklisted()); + EXPECT_TRUE(observers[i].user_blocklisted()); } } EXPECT_EQ(expected_times - 1, observers[removed_observer].user_status_change_calls()); } -TEST_F(PreviewsLoggerTest, NotifyObserversWhenUserNotBlacklisted) { +TEST_F(PreviewsLoggerTest, NotifyObserversWhenUserNotBlocklisted) { TestPreviewsLoggerObserver observers[3]; const size_t number_of_obs = 3; @@ -701,20 +696,20 @@ TEST_F(PreviewsLoggerTest, NotifyObserversWhenUserNotBlacklisted) { const size_t removed_observer = 1; logger_->RemoveObserver(&observers[removed_observer]); - logger_->OnUserBlacklistedStatusChange(false /* blacklisted */); + logger_->OnUserBlocklistedStatusChange(false /* blocklisted */); const size_t expected_times = 2; for (size_t i = 0; i < number_of_obs; i++) { if (i != removed_observer) { EXPECT_EQ(expected_times, observers[i].user_status_change_calls()); - EXPECT_FALSE(observers[i].user_blacklisted()); + EXPECT_FALSE(observers[i].user_blocklisted()); } } EXPECT_EQ(expected_times - 1, observers[removed_observer].user_status_change_calls()); } -TEST_F(PreviewsLoggerTest, NotifyObserversWhenBlacklistCleared) { +TEST_F(PreviewsLoggerTest, NotifyObserversWhenBlocklistCleared) { TestPreviewsLoggerObserver observers[3]; const size_t number_of_obs = 3; @@ -726,18 +721,18 @@ TEST_F(PreviewsLoggerTest, NotifyObserversWhenBlacklistCleared) { logger_->RemoveObserver(&observers[removed_observer]); const base::Time expected_time = base::Time::Now(); - logger_->OnBlacklistCleared(expected_time); + logger_->OnBlocklistCleared(expected_time); for (size_t i = 0; i < number_of_obs; i++) { if (i != removed_observer) { - EXPECT_TRUE(observers[i].blacklist_cleared_called()); - EXPECT_EQ(expected_time, observers[i].blacklist_cleared_time()); + EXPECT_TRUE(observers[i].blocklist_cleared_called()); + EXPECT_EQ(expected_time, observers[i].blocklist_cleared_time()); } } - EXPECT_FALSE(observers[removed_observer].blacklist_cleared_called()); + EXPECT_FALSE(observers[removed_observer].blocklist_cleared_called()); } -TEST_F(PreviewsLoggerTest, ObserverNotifiedOfUserBlacklistedStateWhenAdded) { +TEST_F(PreviewsLoggerTest, ObserverNotifiedOfUserBlocklistedStateWhenAdded) { TestPreviewsLoggerObserver observer; const std::string host0 = "example0.com"; @@ -745,20 +740,20 @@ TEST_F(PreviewsLoggerTest, ObserverNotifiedOfUserBlacklistedStateWhenAdded) { const base::Time time0 = base::Time::Now(); const base::Time time1 = base::Time::Now(); - logger_->OnUserBlacklistedStatusChange(true /* blacklisted */); - logger_->OnNewBlacklistedHost(host0, time0); - logger_->OnNewBlacklistedHost(host1, time1); + logger_->OnUserBlocklistedStatusChange(true /* blocklisted */); + logger_->OnNewBlocklistedHost(host0, time0); + logger_->OnNewBlocklistedHost(host1, time1); logger_->AddAndNotifyObserver(&observer); const size_t expected_times = 1; EXPECT_EQ(expected_times, observer.user_status_change_calls()); const size_t expected_size = 2; - EXPECT_EQ(expected_size, observer.blacklisted_hosts().size()); - EXPECT_EQ(time0, observer.blacklisted_hosts().find(host0)->second); - EXPECT_EQ(time1, observer.blacklisted_hosts().find(host1)->second); + EXPECT_EQ(expected_size, observer.blocklisted_hosts().size()); + EXPECT_EQ(time0, observer.blocklisted_hosts().find(host0)->second); + EXPECT_EQ(time1, observer.blocklisted_hosts().find(host1)->second); } -TEST_F(PreviewsLoggerTest, NotifyObserversBlacklistIgnoredUpdate) { +TEST_F(PreviewsLoggerTest, NotifyObserversBlocklistIgnoredUpdate) { TestPreviewsLoggerObserver observers[3]; const size_t number_of_obs = 3; for (size_t i = 0; i < number_of_obs; i++) { @@ -766,50 +761,50 @@ TEST_F(PreviewsLoggerTest, NotifyObserversBlacklistIgnoredUpdate) { } for (size_t i = 0; i < number_of_obs; i++) { - EXPECT_FALSE(observers[i].blacklist_ignored()); + EXPECT_FALSE(observers[i].blocklist_ignored()); } const size_t removed_observer = 1; logger_->RemoveObserver(&observers[removed_observer]); - logger_->OnIgnoreBlacklistDecisionStatusChanged(true /* ignored */); + logger_->OnIgnoreBlocklistDecisionStatusChanged(true /* ignored */); for (size_t i = 0; i < number_of_obs; i++) { if (i != removed_observer) { - EXPECT_TRUE(observers[i].blacklist_ignored()); + EXPECT_TRUE(observers[i].blocklist_ignored()); } } - EXPECT_FALSE(observers[removed_observer].blacklist_ignored()); + EXPECT_FALSE(observers[removed_observer].blocklist_ignored()); } -TEST_F(PreviewsLoggerTest, ObserverNotifiedOfBlacklistIgnoreStatusOnAdd) { - logger_->OnIgnoreBlacklistDecisionStatusChanged(true /* ignored */); +TEST_F(PreviewsLoggerTest, ObserverNotifiedOfBlocklistIgnoreStatusOnAdd) { + logger_->OnIgnoreBlocklistDecisionStatusChanged(true /* ignored */); TestPreviewsLoggerObserver observer; - EXPECT_FALSE(observer.blacklist_ignored()); + EXPECT_FALSE(observer.blocklist_ignored()); logger_->AddAndNotifyObserver(&observer); - EXPECT_TRUE(observer.blacklist_ignored()); + EXPECT_TRUE(observer.blocklist_ignored()); } TEST_F(PreviewsLoggerTest, - ObserverNotifiedOfBlacklistIgnoreStatusDisabledViaFlag) { + ObserverNotifiedOfBlocklistIgnoreStatusDisabledViaFlag) { ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kIgnorePreviewsBlacklist)); + switches::kIgnorePreviewsBlocklist)); TestPreviewsLoggerObserver observer; PreviewsLogger logger; logger.AddAndNotifyObserver(&observer); - EXPECT_FALSE(observer.blacklist_ignored()); + EXPECT_FALSE(observer.blocklist_ignored()); } TEST_F(PreviewsLoggerTest, - ObserverNotifiedOfBlacklistIgnoreStatusEnabledViaFlag) { + ObserverNotifiedOfBlocklistIgnoreStatusEnabledViaFlag) { base::test::ScopedCommandLine scoped_command_line; base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine(); - command_line->AppendSwitch(switches::kIgnorePreviewsBlacklist); - ASSERT_TRUE(switches::ShouldIgnorePreviewsBlacklist()); + command_line->AppendSwitch(switches::kIgnorePreviewsBlocklist); + ASSERT_TRUE(switches::ShouldIgnorePreviewsBlocklist()); TestPreviewsLoggerObserver observer; PreviewsLogger logger; logger.AddAndNotifyObserver(&observer); - EXPECT_TRUE(observer.blacklist_ignored()); + EXPECT_TRUE(observer.blocklist_ignored()); } TEST_F(PreviewsLoggerTest, LastObserverRemovedIsNotified) { @@ -824,7 +819,7 @@ TEST_F(PreviewsLoggerTest, LastObserverRemovedIsNotified) { EXPECT_TRUE(observers[number_of_obs - 1].last_removed_notified()); } -TEST_F(PreviewsLoggerTest, ClearBufferLogsWhenBlacklistCleared) { +TEST_F(PreviewsLoggerTest, ClearBufferLogsWhenBlocklistCleared) { const std::string type = "Event_"; const std::string description = "Some description"; const GURL url("http://www.url_.com/url_"); @@ -833,7 +828,7 @@ TEST_F(PreviewsLoggerTest, ClearBufferLogsWhenBlacklistCleared) { logger_->LogMessage(type, description, url, now, page_id); - logger_->OnBlacklistCleared(base::Time::Now()); + logger_->OnBlocklistCleared(base::Time::Now()); TestPreviewsLoggerObserver observer; logger_->AddAndNotifyObserver(&observer); diff --git a/chromium/components/previews/core/previews_switches.cc b/chromium/components/previews/core/previews_switches.cc index 2ec70f0f659..4bc1ac01791 100644 --- a/chromium/components/previews/core/previews_switches.cc +++ b/chromium/components/previews/core/previews_switches.cc @@ -9,9 +9,9 @@ namespace previews { namespace switches { -bool ShouldIgnorePreviewsBlacklist() { +bool ShouldIgnorePreviewsBlocklist() { return base::CommandLine::ForCurrentProcess()->HasSwitch( - kIgnorePreviewsBlacklist) || + kIgnorePreviewsBlocklist) || base::CommandLine::ForCurrentProcess()->HasSwitch( kForceEnablePreviews); } @@ -21,8 +21,9 @@ bool ShouldIgnorePreviewsBlacklist() { const char kDoNotRequireLitePageRedirectInfoBar[] = "dont-require-litepage-redirect-infobar"; -// Ignore decisions made by PreviewsBlackList. -const char kIgnorePreviewsBlacklist[] = "ignore-previews-blacklist"; +// Ignore decisions made by PreviewsBlockList. +// TODO(crbug.com/1092105) : Migrate this to ignore-previews-blacklist. +const char kIgnorePreviewsBlocklist[] = "ignore-previews-blacklist"; // Force enable all available previews on every page load. const char kForceEnablePreviews[] = "force-enable-lite-pages"; diff --git a/chromium/components/previews/core/previews_switches.h b/chromium/components/previews/core/previews_switches.h index 7a20630d850..4fa61a4a5e0 100644 --- a/chromium/components/previews/core/previews_switches.h +++ b/chromium/components/previews/core/previews_switches.h @@ -8,12 +8,12 @@ namespace previews { namespace switches { -// Whether the previews blacklist should be ignored, according to command line +// Whether the previews blocklist should be ignored, according to command line // switches. -bool ShouldIgnorePreviewsBlacklist(); +bool ShouldIgnorePreviewsBlocklist(); extern const char kDoNotRequireLitePageRedirectInfoBar[]; -extern const char kIgnorePreviewsBlacklist[]; +extern const char kIgnorePreviewsBlocklist[]; extern const char kForceEnablePreviews[]; extern const char kEnableDeferAllScriptWithoutOptimizationHints[]; |