Commit 7e6d5a9e authored by Justin Donnelly's avatar Justin Donnelly Committed by Commit Bot

[Project Code Inclusion] Remove use of "whitelist" in components/omnibox

Bug: 1149562
Change-Id: Iaf0d7104fd0f90100e7c112d65baa602638163bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542044Reviewed-by: default avatarOrin Jaworski <orinj@chromium.org>
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827958}
parent cfe2227f
...@@ -27,23 +27,22 @@ ...@@ -27,23 +27,22 @@
using in_memory_url_index::InMemoryURLIndexCacheItem; using in_memory_url_index::InMemoryURLIndexCacheItem;
// Initializes a whitelist of URL schemes. // Initializes a allowlist of URL schemes.
void InitializeSchemeWhitelist( void InitializeSchemeAllowlist(SchemeSet* allowlist,
SchemeSet* whitelist, const SchemeSet& client_schemes_to_allowlist) {
const SchemeSet& client_schemes_to_whitelist) { DCHECK(allowlist);
DCHECK(whitelist); if (!allowlist->empty())
if (!whitelist->empty())
return; // Nothing to do, already initialized. return; // Nothing to do, already initialized.
whitelist->insert(client_schemes_to_whitelist.begin(), allowlist->insert(client_schemes_to_allowlist.begin(),
client_schemes_to_whitelist.end()); client_schemes_to_allowlist.end());
whitelist->insert(std::string(url::kAboutScheme)); allowlist->insert(std::string(url::kAboutScheme));
whitelist->insert(std::string(url::kFileScheme)); allowlist->insert(std::string(url::kFileScheme));
whitelist->insert(std::string(url::kFtpScheme)); allowlist->insert(std::string(url::kFtpScheme));
whitelist->insert(std::string(url::kHttpScheme)); allowlist->insert(std::string(url::kHttpScheme));
whitelist->insert(std::string(url::kHttpsScheme)); allowlist->insert(std::string(url::kHttpsScheme));
whitelist->insert(std::string(url::kMailToScheme)); allowlist->insert(std::string(url::kMailToScheme));
} }
// Restore/SaveCacheObserver --------------------------------------------------- // Restore/SaveCacheObserver ---------------------------------------------------
...@@ -57,18 +56,14 @@ InMemoryURLIndex::SaveCacheObserver::~SaveCacheObserver() { ...@@ -57,18 +56,14 @@ InMemoryURLIndex::SaveCacheObserver::~SaveCacheObserver() {
// RebuildPrivateDataFromHistoryDBTask ----------------------------------------- // RebuildPrivateDataFromHistoryDBTask -----------------------------------------
InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask:: InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask::
RebuildPrivateDataFromHistoryDBTask( RebuildPrivateDataFromHistoryDBTask(InMemoryURLIndex* index,
InMemoryURLIndex* index, const SchemeSet& scheme_allowlist)
const SchemeSet& scheme_whitelist) : index_(index), scheme_allowlist_(scheme_allowlist), succeeded_(false) {}
: index_(index),
scheme_whitelist_(scheme_whitelist),
succeeded_(false) {
}
bool InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask::RunOnDBThread( bool InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask::RunOnDBThread(
history::HistoryBackend* backend, history::HistoryBackend* backend,
history::HistoryDatabase* db) { history::HistoryDatabase* db) {
data_ = URLIndexPrivateData::RebuildFromHistory(db, scheme_whitelist_); data_ = URLIndexPrivateData::RebuildFromHistory(db, scheme_allowlist_);
succeeded_ = data_.get() && !data_->Empty(); succeeded_ = data_.get() && !data_->Empty();
if (!succeeded_ && data_.get()) if (!succeeded_ && data_.get())
data_->Clear(); data_->Clear();
...@@ -90,7 +85,7 @@ InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model, ...@@ -90,7 +85,7 @@ InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model,
history::HistoryService* history_service, history::HistoryService* history_service,
TemplateURLService* template_url_service, TemplateURLService* template_url_service,
const base::FilePath& history_dir, const base::FilePath& history_dir,
const SchemeSet& client_schemes_to_whitelist) const SchemeSet& client_schemes_to_allowlist)
: bookmark_model_(bookmark_model), : bookmark_model_(bookmark_model),
history_service_(history_service), history_service_(history_service),
template_url_service_(template_url_service), template_url_service_(template_url_service),
...@@ -104,7 +99,7 @@ InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model, ...@@ -104,7 +99,7 @@ InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model,
restored_(false), restored_(false),
needs_to_be_cached_(false), needs_to_be_cached_(false),
listen_to_history_service_loaded_(false) { listen_to_history_service_loaded_(false) {
InitializeSchemeWhitelist(&scheme_whitelist_, client_schemes_to_whitelist); InitializeSchemeAllowlist(&scheme_allowlist_, client_schemes_to_allowlist);
// TODO(mrossetti): Register for language change notifications. // TODO(mrossetti): Register for language change notifications.
if (history_service_) if (history_service_)
history_service_->AddObserver(this); history_service_->AddObserver(this);
...@@ -173,7 +168,7 @@ void InMemoryURLIndex::OnURLVisited(history::HistoryService* history_service, ...@@ -173,7 +168,7 @@ void InMemoryURLIndex::OnURLVisited(history::HistoryService* history_service,
return; return;
} }
needs_to_be_cached_ |= private_data_->UpdateURL( needs_to_be_cached_ |= private_data_->UpdateURL(
history_service_, row, scheme_whitelist_, &private_data_tracker_); history_service_, row, scheme_allowlist_, &private_data_tracker_);
} }
void InMemoryURLIndex::OnURLsModified(history::HistoryService* history_service, void InMemoryURLIndex::OnURLsModified(history::HistoryService* history_service,
...@@ -192,7 +187,7 @@ void InMemoryURLIndex::OnURLsModified(history::HistoryService* history_service, ...@@ -192,7 +187,7 @@ void InMemoryURLIndex::OnURLsModified(history::HistoryService* history_service,
continue; continue;
} }
needs_to_be_cached_ |= private_data_->UpdateURL( needs_to_be_cached_ |= private_data_->UpdateURL(
history_service_, row, scheme_whitelist_, &private_data_tracker_); history_service_, row, scheme_allowlist_, &private_data_tracker_);
} }
} }
...@@ -238,7 +233,7 @@ bool InMemoryURLIndex::OnMemoryDump( ...@@ -238,7 +233,7 @@ bool InMemoryURLIndex::OnMemoryDump(
base::trace_event::ProcessMemoryDump* process_memory_dump) { base::trace_event::ProcessMemoryDump* process_memory_dump) {
size_t res = 0; size_t res = 0;
res += base::trace_event::EstimateMemoryUsage(scheme_whitelist_); res += base::trace_event::EstimateMemoryUsage(scheme_allowlist_);
// TODO(dyaroshev): Add support for scoped_refptr in // TODO(dyaroshev): Add support for scoped_refptr in
// base::trace_event::EstimateMemoryUsage. // base::trace_event::EstimateMemoryUsage.
...@@ -348,7 +343,7 @@ void InMemoryURLIndex::ScheduleRebuildFromHistory() { ...@@ -348,7 +343,7 @@ void InMemoryURLIndex::ScheduleRebuildFromHistory() {
FROM_HERE, FROM_HERE,
std::unique_ptr<history::HistoryDBTask>( std::unique_ptr<history::HistoryDBTask>(
new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask( new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask(
this, scheme_whitelist_)), this, scheme_allowlist_)),
&cache_reader_tracker_); &cache_reader_tracker_);
} }
...@@ -373,8 +368,8 @@ void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB( ...@@ -373,8 +368,8 @@ void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB(
void InMemoryURLIndex::RebuildFromHistory( void InMemoryURLIndex::RebuildFromHistory(
history::HistoryDatabase* history_db) { history::HistoryDatabase* history_db) {
private_data_tracker_.TryCancelAll(); private_data_tracker_.TryCancelAll();
private_data_ = URLIndexPrivateData::RebuildFromHistory(history_db, private_data_ =
scheme_whitelist_); URLIndexPrivateData::RebuildFromHistory(history_db, scheme_allowlist_);
} }
// Saving to Cache ------------------------------------------------------------- // Saving to Cache -------------------------------------------------------------
......
...@@ -106,7 +106,7 @@ class InMemoryURLIndex : public KeyedService, ...@@ -106,7 +106,7 @@ class InMemoryURLIndex : public KeyedService,
history::HistoryService* history_service, history::HistoryService* history_service,
TemplateURLService* template_url_service, TemplateURLService* template_url_service,
const base::FilePath& history_dir, const base::FilePath& history_dir,
const SchemeSet& client_schemes_to_whitelist); const SchemeSet& client_schemes_to_allowlist);
~InMemoryURLIndex() override; ~InMemoryURLIndex() override;
InMemoryURLIndex(const InMemoryURLIndex&) = delete; InMemoryURLIndex(const InMemoryURLIndex&) = delete;
InMemoryURLIndex& operator=(const InMemoryURLIndex&) = delete; InMemoryURLIndex& operator=(const InMemoryURLIndex&) = delete;
...@@ -159,7 +159,8 @@ class InMemoryURLIndex : public KeyedService, ...@@ -159,7 +159,8 @@ class InMemoryURLIndex : public KeyedService,
class RebuildPrivateDataFromHistoryDBTask : public history::HistoryDBTask { class RebuildPrivateDataFromHistoryDBTask : public history::HistoryDBTask {
public: public:
explicit RebuildPrivateDataFromHistoryDBTask( explicit RebuildPrivateDataFromHistoryDBTask(
InMemoryURLIndex* index, const SchemeSet& scheme_whitelist); InMemoryURLIndex* index,
const SchemeSet& scheme_allowlist);
RebuildPrivateDataFromHistoryDBTask( RebuildPrivateDataFromHistoryDBTask(
const RebuildPrivateDataFromHistoryDBTask&) = delete; const RebuildPrivateDataFromHistoryDBTask&) = delete;
RebuildPrivateDataFromHistoryDBTask& operator=( RebuildPrivateDataFromHistoryDBTask& operator=(
...@@ -173,7 +174,7 @@ class InMemoryURLIndex : public KeyedService, ...@@ -173,7 +174,7 @@ class InMemoryURLIndex : public KeyedService,
~RebuildPrivateDataFromHistoryDBTask() override; ~RebuildPrivateDataFromHistoryDBTask() override;
InMemoryURLIndex* index_; // Call back to this index at completion. InMemoryURLIndex* index_; // Call back to this index at completion.
SchemeSet scheme_whitelist_; // Schemes to be indexed. SchemeSet scheme_allowlist_; // Schemes to be indexed.
bool succeeded_; // Indicates if the rebuild was successful. bool succeeded_; // Indicates if the rebuild was successful.
scoped_refptr<URLIndexPrivateData> data_; // The rebuilt private data. scoped_refptr<URLIndexPrivateData> data_; // The rebuilt private data.
}; };
...@@ -272,8 +273,8 @@ class InMemoryURLIndex : public KeyedService, ...@@ -272,8 +273,8 @@ class InMemoryURLIndex : public KeyedService,
return &private_data_tracker_; return &private_data_tracker_;
} }
// Returns the set of whitelisted schemes. For unit testing only. // Returns the set of allowlisted schemes. For unit testing only.
const SchemeSet& scheme_whitelist() { return scheme_whitelist_; } const SchemeSet& scheme_allowlist() { return scheme_allowlist_; }
// The BookmarkModel; may be null when testing. // The BookmarkModel; may be null when testing.
bookmarks::BookmarkModel* bookmark_model_; bookmarks::BookmarkModel* bookmark_model_;
...@@ -290,8 +291,8 @@ class InMemoryURLIndex : public KeyedService, ...@@ -290,8 +291,8 @@ class InMemoryURLIndex : public KeyedService,
// be empty. // be empty.
base::FilePath history_dir_; base::FilePath history_dir_;
// Only URLs with a whitelisted scheme are indexed. // Only URLs with a allowlisted scheme are indexed.
SchemeSet scheme_whitelist_; SchemeSet scheme_allowlist_;
// The index's durable private data. // The index's durable private data.
scoped_refptr<URLIndexPrivateData> private_data_; scoped_refptr<URLIndexPrivateData> private_data_;
......
...@@ -273,7 +273,7 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms( ...@@ -273,7 +273,7 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
bool URLIndexPrivateData::UpdateURL( bool URLIndexPrivateData::UpdateURL(
history::HistoryService* history_service, history::HistoryService* history_service,
const history::URLRow& row, const history::URLRow& row,
const std::set<std::string>& scheme_whitelist, const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker) { base::CancelableTaskTracker* tracker) {
// The row may or may not already be in our index. If it is not already // The row may or may not already be in our index. If it is not already
// indexed and it qualifies then it gets indexed. If it is already // indexed and it qualifies then it gets indexed. If it is already
...@@ -288,7 +288,7 @@ bool URLIndexPrivateData::UpdateURL( ...@@ -288,7 +288,7 @@ bool URLIndexPrivateData::UpdateURL(
new_row.set_id(row_id); new_row.set_id(row_id);
row_was_updated = row_was_updated =
RowQualifiesAsSignificant(new_row, base::Time()) && RowQualifiesAsSignificant(new_row, base::Time()) &&
IndexRow(nullptr, history_service, new_row, scheme_whitelist, tracker); IndexRow(nullptr, history_service, new_row, scheme_allowlist, tracker);
} else if (RowQualifiesAsSignificant(row, base::Time())) { } else if (RowQualifiesAsSignificant(row, base::Time())) {
// This indexed row still qualifies and will be re-indexed. // This indexed row still qualifies and will be re-indexed.
// The url won't have changed but the title, visit count, etc. // The url won't have changed but the title, visit count, etc.
...@@ -427,7 +427,7 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RestoreFromFile( ...@@ -427,7 +427,7 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RestoreFromFile(
// static // static
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory( scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory(
history::HistoryDatabase* history_db, history::HistoryDatabase* history_db,
const std::set<std::string>& scheme_whitelist) { const std::set<std::string>& scheme_allowlist) {
if (!history_db) if (!history_db)
return nullptr; return nullptr;
...@@ -452,7 +452,7 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory( ...@@ -452,7 +452,7 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory(
for (history::URLRow row; history_enum.GetNextURL(&row);) { for (history::URLRow row; history_enum.GetNextURL(&row);) {
DCHECK(RowQualifiesAsSignificant(row, base::Time())); DCHECK(RowQualifiesAsSignificant(row, base::Time()));
// Do not use >= to account for case of -1 for unlimited urls. // Do not use >= to account for case of -1 for unlimited urls.
if (rebuilt_data->IndexRow(history_db, nullptr, row, scheme_whitelist, if (rebuilt_data->IndexRow(history_db, nullptr, row, scheme_allowlist,
nullptr) && nullptr) &&
num_urls_indexed++ == max_urls_indexed) { num_urls_indexed++ == max_urls_indexed) {
break; break;
...@@ -822,12 +822,12 @@ bool URLIndexPrivateData::IndexRow( ...@@ -822,12 +822,12 @@ bool URLIndexPrivateData::IndexRow(
history::HistoryDatabase* history_db, history::HistoryDatabase* history_db,
history::HistoryService* history_service, history::HistoryService* history_service,
const history::URLRow& row, const history::URLRow& row,
const std::set<std::string>& scheme_whitelist, const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker) { base::CancelableTaskTracker* tracker) {
const GURL& gurl(row.url()); const GURL& gurl(row.url());
// Index only URLs with a whitelisted scheme. // Index only URLs with a allowlisted scheme.
if (!URLSchemeIsWhitelisted(gurl, scheme_whitelist)) if (!URLSchemeIsAllowlisted(gurl, scheme_allowlist))
return false; return false;
const history::URLID row_id = row.id(); const history::URLID row_id = row.id();
...@@ -1297,10 +1297,10 @@ bool URLIndexPrivateData::RestoreWordStartsMap( ...@@ -1297,10 +1297,10 @@ bool URLIndexPrivateData::RestoreWordStartsMap(
} }
// static // static
bool URLIndexPrivateData::URLSchemeIsWhitelisted( bool URLIndexPrivateData::URLSchemeIsAllowlisted(
const GURL& gurl, const GURL& gurl,
const std::set<std::string>& whitelist) { const std::set<std::string>& allowlist) {
return whitelist.find(gurl.scheme()) != whitelist.end(); return allowlist.find(gurl.scheme()) != allowlist.end();
} }
bool URLIndexPrivateData::ShouldFilter( bool URLIndexPrivateData::ShouldFilter(
......
...@@ -85,12 +85,12 @@ class URLIndexPrivateData ...@@ -85,12 +85,12 @@ class URLIndexPrivateData
// exist and it meets the minimum 'quick' criteria. If the row already exists // exist and it meets the minimum 'quick' criteria. If the row already exists
// in the index then the index will be updated if the row still meets the // in the index then the index will be updated if the row still meets the
// criteria, otherwise the row will be removed from the index. Returns true // criteria, otherwise the row will be removed from the index. Returns true
// if the index was actually updated. |scheme_whitelist| is used to filter // if the index was actually updated. |scheme_allowlist| is used to filter
// non-qualifying schemes. |history_service| is used to schedule an update to // non-qualifying schemes. |history_service| is used to schedule an update to
// the recent visits component of this URL's entry in the index. // the recent visits component of this URL's entry in the index.
bool UpdateURL(history::HistoryService* history_service, bool UpdateURL(history::HistoryService* history_service,
const history::URLRow& row, const history::URLRow& row,
const std::set<std::string>& scheme_whitelist, const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker); base::CancelableTaskTracker* tracker);
// Updates the entry for |url_id| in the index, replacing its // Updates the entry for |url_id| in the index, replacing its
...@@ -125,7 +125,7 @@ class URLIndexPrivateData ...@@ -125,7 +125,7 @@ class URLIndexPrivateData
// success will contain the rebuilt data but upon failure will be empty. // success will contain the rebuilt data but upon failure will be empty.
static scoped_refptr<URLIndexPrivateData> RebuildFromHistory( static scoped_refptr<URLIndexPrivateData> RebuildFromHistory(
history::HistoryDatabase* history_db, history::HistoryDatabase* history_db,
const std::set<std::string>& scheme_whitelist); const std::set<std::string>& scheme_allowlist);
// Writes |private_data| as a cache file to |file_path| and returns success. // Writes |private_data| as a cache file to |file_path| and returns success.
static bool WritePrivateDataToCacheFileTask( static bool WritePrivateDataToCacheFileTask(
...@@ -174,7 +174,7 @@ class URLIndexPrivateData ...@@ -174,7 +174,7 @@ class URLIndexPrivateData
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TitleSearch); FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TitleSearch);
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TrimHistoryIds); FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TrimHistoryIds);
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TypedCharacterCaching); FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TypedCharacterCaching);
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, WhitelistedURLs); FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, AllowlistedURLs);
FRIEND_TEST_ALL_PREFIXES(LimitedInMemoryURLIndexTest, Initialization); FRIEND_TEST_ALL_PREFIXES(LimitedInMemoryURLIndexTest, Initialization);
// Support caching of term results so that we can optimize searches which // Support caching of term results so that we can optimize searches which
...@@ -262,7 +262,7 @@ class URLIndexPrivateData ...@@ -262,7 +262,7 @@ class URLIndexPrivateData
WordStarts* terms_to_word_starts_offsets); WordStarts* terms_to_word_starts_offsets);
// Indexes one URL history item as described by |row|. Returns true if the // Indexes one URL history item as described by |row|. Returns true if the
// row was actually indexed. |scheme_whitelist| is used to filter // row was actually indexed. |scheme_allowlist| is used to filter
// non-qualifying schemes. If |history_db| is not NULL then this function // non-qualifying schemes. If |history_db| is not NULL then this function
// uses the history database synchronously to get the URL's recent visits // uses the history database synchronously to get the URL's recent visits
// information. This mode should/ only be used on the historyDB thread. // information. This mode should/ only be used on the historyDB thread.
...@@ -272,7 +272,7 @@ class URLIndexPrivateData ...@@ -272,7 +272,7 @@ class URLIndexPrivateData
bool IndexRow(history::HistoryDatabase* history_db, bool IndexRow(history::HistoryDatabase* history_db,
history::HistoryService* history_service, history::HistoryService* history_service,
const history::URLRow& row, const history::URLRow& row,
const std::set<std::string>& scheme_whitelist, const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker); base::CancelableTaskTracker* tracker);
// Parses and indexes the words in the URL and page title of |row| and // Parses and indexes the words in the URL and page title of |row| and
...@@ -333,9 +333,9 @@ class URLIndexPrivateData ...@@ -333,9 +333,9 @@ class URLIndexPrivateData
bool RestoreWordStartsMap( bool RestoreWordStartsMap(
const in_memory_url_index::InMemoryURLIndexCacheItem& cache); const in_memory_url_index::InMemoryURLIndexCacheItem& cache);
// Determines if |gurl| has a whitelisted scheme and returns true if so. // Determines if |gurl| has a allowlisted scheme and returns true if so.
static bool URLSchemeIsWhitelisted(const GURL& gurl, static bool URLSchemeIsAllowlisted(const GURL& gurl,
const std::set<std::string>& whitelist); const std::set<std::string>& allowlist);
// Returns true if the URL associated with |history_id| is missing, malformed, // Returns true if the URL associated with |history_id| is missing, malformed,
// or otherwise should not be displayed. (Results from the default search // or otherwise should not be displayed. (Results from the default search
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment