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 @@
using in_memory_url_index::InMemoryURLIndexCacheItem;
// Initializes a whitelist of URL schemes.
void InitializeSchemeWhitelist(
SchemeSet* whitelist,
const SchemeSet& client_schemes_to_whitelist) {
DCHECK(whitelist);
if (!whitelist->empty())
// Initializes a allowlist of URL schemes.
void InitializeSchemeAllowlist(SchemeSet* allowlist,
const SchemeSet& client_schemes_to_allowlist) {
DCHECK(allowlist);
if (!allowlist->empty())
return; // Nothing to do, already initialized.
whitelist->insert(client_schemes_to_whitelist.begin(),
client_schemes_to_whitelist.end());
allowlist->insert(client_schemes_to_allowlist.begin(),
client_schemes_to_allowlist.end());
whitelist->insert(std::string(url::kAboutScheme));
whitelist->insert(std::string(url::kFileScheme));
whitelist->insert(std::string(url::kFtpScheme));
whitelist->insert(std::string(url::kHttpScheme));
whitelist->insert(std::string(url::kHttpsScheme));
whitelist->insert(std::string(url::kMailToScheme));
allowlist->insert(std::string(url::kAboutScheme));
allowlist->insert(std::string(url::kFileScheme));
allowlist->insert(std::string(url::kFtpScheme));
allowlist->insert(std::string(url::kHttpScheme));
allowlist->insert(std::string(url::kHttpsScheme));
allowlist->insert(std::string(url::kMailToScheme));
}
// Restore/SaveCacheObserver ---------------------------------------------------
......@@ -57,18 +56,14 @@ InMemoryURLIndex::SaveCacheObserver::~SaveCacheObserver() {
// RebuildPrivateDataFromHistoryDBTask -----------------------------------------
InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask::
RebuildPrivateDataFromHistoryDBTask(
InMemoryURLIndex* index,
const SchemeSet& scheme_whitelist)
: index_(index),
scheme_whitelist_(scheme_whitelist),
succeeded_(false) {
}
RebuildPrivateDataFromHistoryDBTask(InMemoryURLIndex* index,
const SchemeSet& scheme_allowlist)
: index_(index), scheme_allowlist_(scheme_allowlist), succeeded_(false) {}
bool InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask::RunOnDBThread(
history::HistoryBackend* backend,
history::HistoryDatabase* db) {
data_ = URLIndexPrivateData::RebuildFromHistory(db, scheme_whitelist_);
data_ = URLIndexPrivateData::RebuildFromHistory(db, scheme_allowlist_);
succeeded_ = data_.get() && !data_->Empty();
if (!succeeded_ && data_.get())
data_->Clear();
......@@ -90,7 +85,7 @@ InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model,
history::HistoryService* history_service,
TemplateURLService* template_url_service,
const base::FilePath& history_dir,
const SchemeSet& client_schemes_to_whitelist)
const SchemeSet& client_schemes_to_allowlist)
: bookmark_model_(bookmark_model),
history_service_(history_service),
template_url_service_(template_url_service),
......@@ -104,7 +99,7 @@ InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model,
restored_(false),
needs_to_be_cached_(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.
if (history_service_)
history_service_->AddObserver(this);
......@@ -173,7 +168,7 @@ void InMemoryURLIndex::OnURLVisited(history::HistoryService* history_service,
return;
}
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,
......@@ -192,7 +187,7 @@ void InMemoryURLIndex::OnURLsModified(history::HistoryService* history_service,
continue;
}
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(
base::trace_event::ProcessMemoryDump* process_memory_dump) {
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
// base::trace_event::EstimateMemoryUsage.
......@@ -348,7 +343,7 @@ void InMemoryURLIndex::ScheduleRebuildFromHistory() {
FROM_HERE,
std::unique_ptr<history::HistoryDBTask>(
new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask(
this, scheme_whitelist_)),
this, scheme_allowlist_)),
&cache_reader_tracker_);
}
......@@ -373,8 +368,8 @@ void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB(
void InMemoryURLIndex::RebuildFromHistory(
history::HistoryDatabase* history_db) {
private_data_tracker_.TryCancelAll();
private_data_ = URLIndexPrivateData::RebuildFromHistory(history_db,
scheme_whitelist_);
private_data_ =
URLIndexPrivateData::RebuildFromHistory(history_db, scheme_allowlist_);
}
// Saving to Cache -------------------------------------------------------------
......
......@@ -106,7 +106,7 @@ class InMemoryURLIndex : public KeyedService,
history::HistoryService* history_service,
TemplateURLService* template_url_service,
const base::FilePath& history_dir,
const SchemeSet& client_schemes_to_whitelist);
const SchemeSet& client_schemes_to_allowlist);
~InMemoryURLIndex() override;
InMemoryURLIndex(const InMemoryURLIndex&) = delete;
InMemoryURLIndex& operator=(const InMemoryURLIndex&) = delete;
......@@ -159,7 +159,8 @@ class InMemoryURLIndex : public KeyedService,
class RebuildPrivateDataFromHistoryDBTask : public history::HistoryDBTask {
public:
explicit RebuildPrivateDataFromHistoryDBTask(
InMemoryURLIndex* index, const SchemeSet& scheme_whitelist);
InMemoryURLIndex* index,
const SchemeSet& scheme_allowlist);
RebuildPrivateDataFromHistoryDBTask(
const RebuildPrivateDataFromHistoryDBTask&) = delete;
RebuildPrivateDataFromHistoryDBTask& operator=(
......@@ -173,7 +174,7 @@ class InMemoryURLIndex : public KeyedService,
~RebuildPrivateDataFromHistoryDBTask() override;
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.
scoped_refptr<URLIndexPrivateData> data_; // The rebuilt private data.
};
......@@ -272,8 +273,8 @@ class InMemoryURLIndex : public KeyedService,
return &private_data_tracker_;
}
// Returns the set of whitelisted schemes. For unit testing only.
const SchemeSet& scheme_whitelist() { return scheme_whitelist_; }
// Returns the set of allowlisted schemes. For unit testing only.
const SchemeSet& scheme_allowlist() { return scheme_allowlist_; }
// The BookmarkModel; may be null when testing.
bookmarks::BookmarkModel* bookmark_model_;
......@@ -290,8 +291,8 @@ class InMemoryURLIndex : public KeyedService,
// be empty.
base::FilePath history_dir_;
// Only URLs with a whitelisted scheme are indexed.
SchemeSet scheme_whitelist_;
// Only URLs with a allowlisted scheme are indexed.
SchemeSet scheme_allowlist_;
// The index's durable private data.
scoped_refptr<URLIndexPrivateData> private_data_;
......
......@@ -273,7 +273,7 @@ ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
bool URLIndexPrivateData::UpdateURL(
history::HistoryService* history_service,
const history::URLRow& row,
const std::set<std::string>& scheme_whitelist,
const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker) {
// 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
......@@ -288,7 +288,7 @@ bool URLIndexPrivateData::UpdateURL(
new_row.set_id(row_id);
row_was_updated =
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())) {
// This indexed row still qualifies and will be re-indexed.
// The url won't have changed but the title, visit count, etc.
......@@ -427,7 +427,7 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RestoreFromFile(
// static
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory(
history::HistoryDatabase* history_db,
const std::set<std::string>& scheme_whitelist) {
const std::set<std::string>& scheme_allowlist) {
if (!history_db)
return nullptr;
......@@ -452,7 +452,7 @@ scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory(
for (history::URLRow row; history_enum.GetNextURL(&row);) {
DCHECK(RowQualifiesAsSignificant(row, base::Time()));
// 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) &&
num_urls_indexed++ == max_urls_indexed) {
break;
......@@ -822,12 +822,12 @@ bool URLIndexPrivateData::IndexRow(
history::HistoryDatabase* history_db,
history::HistoryService* history_service,
const history::URLRow& row,
const std::set<std::string>& scheme_whitelist,
const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker) {
const GURL& gurl(row.url());
// Index only URLs with a whitelisted scheme.
if (!URLSchemeIsWhitelisted(gurl, scheme_whitelist))
// Index only URLs with a allowlisted scheme.
if (!URLSchemeIsAllowlisted(gurl, scheme_allowlist))
return false;
const history::URLID row_id = row.id();
......@@ -1297,10 +1297,10 @@ bool URLIndexPrivateData::RestoreWordStartsMap(
}
// static
bool URLIndexPrivateData::URLSchemeIsWhitelisted(
bool URLIndexPrivateData::URLSchemeIsAllowlisted(
const GURL& gurl,
const std::set<std::string>& whitelist) {
return whitelist.find(gurl.scheme()) != whitelist.end();
const std::set<std::string>& allowlist) {
return allowlist.find(gurl.scheme()) != allowlist.end();
}
bool URLIndexPrivateData::ShouldFilter(
......
......@@ -85,12 +85,12 @@ class URLIndexPrivateData
// 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
// 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
// the recent visits component of this URL's entry in the index.
bool UpdateURL(history::HistoryService* history_service,
const history::URLRow& row,
const std::set<std::string>& scheme_whitelist,
const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker);
// Updates the entry for |url_id| in the index, replacing its
......@@ -125,7 +125,7 @@ class URLIndexPrivateData
// success will contain the rebuilt data but upon failure will be empty.
static scoped_refptr<URLIndexPrivateData> RebuildFromHistory(
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.
static bool WritePrivateDataToCacheFileTask(
......@@ -174,7 +174,7 @@ class URLIndexPrivateData
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TitleSearch);
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TrimHistoryIds);
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TypedCharacterCaching);
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, WhitelistedURLs);
FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, AllowlistedURLs);
FRIEND_TEST_ALL_PREFIXES(LimitedInMemoryURLIndexTest, Initialization);
// Support caching of term results so that we can optimize searches which
......@@ -262,7 +262,7 @@ class URLIndexPrivateData
WordStarts* terms_to_word_starts_offsets);
// 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
// uses the history database synchronously to get the URL's recent visits
// information. This mode should/ only be used on the historyDB thread.
......@@ -272,7 +272,7 @@ class URLIndexPrivateData
bool IndexRow(history::HistoryDatabase* history_db,
history::HistoryService* history_service,
const history::URLRow& row,
const std::set<std::string>& scheme_whitelist,
const std::set<std::string>& scheme_allowlist,
base::CancelableTaskTracker* tracker);
// Parses and indexes the words in the URL and page title of |row| and
......@@ -333,9 +333,9 @@ class URLIndexPrivateData
bool RestoreWordStartsMap(
const in_memory_url_index::InMemoryURLIndexCacheItem& cache);
// Determines if |gurl| has a whitelisted scheme and returns true if so.
static bool URLSchemeIsWhitelisted(const GURL& gurl,
const std::set<std::string>& whitelist);
// Determines if |gurl| has a allowlisted scheme and returns true if so.
static bool URLSchemeIsAllowlisted(const GURL& gurl,
const std::set<std::string>& allowlist);
// Returns true if the URL associated with |history_id| is missing, malformed,
// 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