Commit 3a607750 authored by Josh Karlin's avatar Josh Karlin Committed by Commit Bot

[Project Code Inclusion] Remove use of blacklist

This CL swaps 'blacklist' with 'blocklist' or 'block' throughout the
directory. A followup CL will migrate the backend database.

Bug: 1097286
Change-Id: I6f62ad1dfbcbdbc1c1ce22d3c550ebb129454bd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495607Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarPeter Williamson <petewil@chromium.org>
Commit-Queue: Josh Karlin <jkarlin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821887}
parent a21c3826
......@@ -100,10 +100,10 @@ public class ExploreSitesBridge {
}
/**
* Adds a site to the blacklist when the user chooses "remove" from the long press menu.
* Adds a site to the blocklist when the user chooses "remove" from the long press menu.
*/
public static void blacklistSite(Profile profile, String url) {
ExploreSitesBridgeJni.get().blacklistSite(profile, url);
public static void blockSite(Profile profile, String url) {
ExploreSitesBridgeJni.get().blockSite(profile, url);
}
/**
......@@ -164,7 +164,7 @@ public class ExploreSitesBridge {
void updateCatalogFromNetwork(
Profile profile, boolean isImmediateFetch, Callback<Boolean> callback);
void getSummaryImage(Profile profile, int pixelSize, Callback<Bitmap> callback);
void blacklistSite(Profile profile, String url);
void blockSite(Profile profile, String url);
void recordClick(Profile profile, String url, int type);
void getCatalog(Profile profile, int source, List<ExploreSitesCategory> result,
Callback<List<ExploreSitesCategory>> callback);
......
......@@ -139,7 +139,7 @@ public class ExploreSitesCategory {
public void addSite(ExploreSitesSite site) {
mSites.add(site);
if (site.getModel().get(ExploreSitesSite.BLACKLISTED_KEY)) {
if (site.getModel().get(ExploreSitesSite.BLOCKED_KEY)) {
mNumRemoved++;
}
}
......@@ -149,7 +149,7 @@ public class ExploreSitesCategory {
}
/**
* Get the number of rows that could be filled completely with sites, if no site is blacklisted.
* Get the number of rows that could be filled completely with sites, if no site is blocked.
* @param numColumns - number of columns wide the layout holding this category is. This
* parameter must not be zero.
*/
......@@ -164,19 +164,19 @@ public class ExploreSitesCategory {
public boolean removeSite(int tileIndex) {
if (tileIndex > mSites.size() || tileIndex < 0) return false;
// Find the siteIndex for the tileIndex by skipping over blacklisted sites.
// Find the siteIndex for the tileIndex by skipping over blocked sites.
int siteIndex = 0;
int validSiteCount = 0;
while (siteIndex < mSites.size()) {
// Skipping over blacklisted sites, look for the nth unblacklisted site.
if (!mSites.get(siteIndex).getModel().get(ExploreSitesSite.BLACKLISTED_KEY)) {
// Skipping over blocked sites, look for the nth allowed site.
if (!mSites.get(siteIndex).getModel().get(ExploreSitesSite.BLOCKED_KEY)) {
validSiteCount++;
}
// When we find the nth valid site, we have found the site index matching the tile.
// TileIndex is 0 based, validSiteCount is 1 based, so we add 1 to the tileIndex.
if (tileIndex + 1 == validSiteCount
&& !mSites.get(siteIndex).getModel().get(ExploreSitesSite.BLACKLISTED_KEY)) {
&& !mSites.get(siteIndex).getModel().get(ExploreSitesSite.BLOCKED_KEY)) {
break;
}
......@@ -184,7 +184,7 @@ public class ExploreSitesCategory {
}
if (siteIndex >= mSites.size()) return false;
mSites.get(siteIndex).getModel().set(ExploreSitesSite.BLACKLISTED_KEY, true);
mSites.get(siteIndex).getModel().set(ExploreSitesSite.BLOCKED_KEY, true);
// Reset the tile indices to account for removed tile.
mSites.get(siteIndex).getModel().set(
......@@ -192,7 +192,7 @@ public class ExploreSitesCategory {
for (int i = siteIndex; i < mSites.size(); ++i) {
ExploreSitesSite site = mSites.get(i);
if (!mSites.get(i).getModel().get(ExploreSitesSite.BLACKLISTED_KEY)) {
if (!mSites.get(i).getModel().get(ExploreSitesSite.BLOCKED_KEY)) {
site.getModel().set(ExploreSitesSite.TILE_INDEX_KEY, tileIndex);
tileIndex++;
}
......
......@@ -112,7 +112,7 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
@Override
public void removeItem() {
// Update the database on the C++ side.
ExploreSitesBridge.blacklistSite(mProfile, mSiteUrl);
ExploreSitesBridge.blockSite(mProfile, mSiteUrl);
// Remove from model (category).
mCategory.removeSite(mTileIndex);
......@@ -257,8 +257,8 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
for (ExploreSitesSite site : category.getSites()) {
if (tileIndex >= tileMax) break;
final PropertyModel siteModel = site.getModel();
// Skip blacklisted sites.
if (siteModel.get(ExploreSitesSite.BLACKLISTED_KEY)) continue;
// Skip blocked sites.
if (siteModel.get(ExploreSitesSite.BLOCKED_KEY)) continue;
ExploreSitesTileView tileView = (ExploreSitesTileView) mTileView.getChildAt(tileIndex);
tileView.initialize(mIconGenerator);
......@@ -310,7 +310,7 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
* An incomplete row is allowed if any of the following constraints are satisfied:
* - There are not enough sites to populate the first row.
* - There is more than one site in the last row.
* - There is one site in the last row as a result of the user blacklisting a site.
* - There is one site in the last row as a result of the user blocking a site.
*
* @param category The category from which the number of incomplete row will be calculated.
*/
......
......@@ -24,19 +24,18 @@ public class ExploreSitesSite {
new PropertyModel.ReadableObjectPropertyKey<>();
public static final PropertyModel.WritableObjectPropertyKey<Bitmap> ICON_KEY =
new PropertyModel.WritableObjectPropertyKey<>();
static final PropertyModel.WritableBooleanPropertyKey BLACKLISTED_KEY =
static final PropertyModel.WritableBooleanPropertyKey BLOCKED_KEY =
new PropertyModel.WritableBooleanPropertyKey();
private PropertyModel mModel;
public ExploreSitesSite(int id, String title, String url, boolean isBlacklisted) {
public ExploreSitesSite(int id, String title, String url, boolean isBlocked) {
mModel = new PropertyModel
.Builder(ID_KEY, TILE_INDEX_KEY, TITLE_KEY, URL_KEY, ICON_KEY,
BLACKLISTED_KEY)
.Builder(ID_KEY, TILE_INDEX_KEY, TITLE_KEY, URL_KEY, ICON_KEY, BLOCKED_KEY)
.with(ID_KEY, id)
.with(TITLE_KEY, title)
.with(URL_KEY, url)
.with(BLACKLISTED_KEY, isBlacklisted)
.with(BLOCKED_KEY, isBlocked)
.with(TILE_INDEX_KEY, DEFAULT_TILE_INDEX)
.build();
}
......@@ -47,8 +46,8 @@ public class ExploreSitesSite {
@CalledByNative
private static void createSiteInCategory(int siteId, String title, String url,
boolean isBlacklisted, ExploreSitesCategory category) {
ExploreSitesSite site = new ExploreSitesSite(siteId, title, url, isBlacklisted);
boolean isBlocked, ExploreSitesCategory category) {
ExploreSitesSite site = new ExploreSitesSite(siteId, title, url, isBlocked);
category.addSite(site);
}
}
......@@ -44,8 +44,8 @@ public class ExploreSitesCategoryUnitTest {
assertEquals(siteId, category.getSites().get(0).getModel().get(ExploreSitesSite.ID_KEY));
assertEquals(title, category.getSites().get(0).getModel().get(ExploreSitesSite.TITLE_KEY));
assertEquals(url, category.getSites().get(0).getModel().get(ExploreSitesSite.URL_KEY));
assertTrue(category.getSites().get(0).getModel().get(ExploreSitesSite.BLACKLISTED_KEY));
assertFalse(category.getSites().get(1).getModel().get(ExploreSitesSite.BLACKLISTED_KEY));
assertTrue(category.getSites().get(0).getModel().get(ExploreSitesSite.BLOCKED_KEY));
assertFalse(category.getSites().get(1).getModel().get(ExploreSitesSite.BLOCKED_KEY));
}
@Test
......@@ -82,8 +82,8 @@ public class ExploreSitesCategoryUnitTest {
assertEquals(4, category.getSites().size());
assertEquals(2, category.getNumDisplayed());
assertTrue(category.getSites().get(1).getModel().get(ExploreSitesSite.BLACKLISTED_KEY));
assertTrue(category.getSites().get(2).getModel().get(ExploreSitesSite.BLACKLISTED_KEY));
assertTrue(category.getSites().get(1).getModel().get(ExploreSitesSite.BLOCKED_KEY));
assertTrue(category.getSites().get(2).getModel().get(ExploreSitesSite.BLOCKED_KEY));
// The fourth site should now be at tile index '1' (the second tile).
assertEquals(1, category.getSites().get(3).getModel().get(ExploreSitesSite.TILE_INDEX_KEY));
}
......
......@@ -2548,8 +2548,8 @@ static_library("browser") {
"android/document/document_web_contents_delegate.h",
"android/dom_distiller/distiller_ui_handle_android.cc",
"android/dom_distiller/distiller_ui_handle_android.h",
"android/explore_sites/blacklist_site_task.cc",
"android/explore_sites/blacklist_site_task.h",
"android/explore_sites/block_site_task.cc",
"android/explore_sites/block_site_task.h",
"android/explore_sites/catalog.cc",
"android/explore_sites/catalog.h",
"android/explore_sites/clear_activities_task.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 "chrome/browser/android/explore_sites/blacklist_site_task.h"
#include "chrome/browser/android/explore_sites/block_site_task.h"
#include "base/bind.h"
#include "base/logging.h"
......@@ -16,7 +16,7 @@
namespace explore_sites {
namespace {
static const char kBlacklistSiteSql[] = R"(INSERT INTO site_blacklist
static const char kBlockSiteSql[] = R"(INSERT INTO site_blacklist
(url, date_removed)
VALUES
(?, ?);)";
......@@ -25,7 +25,7 @@ static const char kClearSiteFromActivitySql[] =
"DELETE FROM activity WHERE url = ?;";
} // namespace
bool BlacklistSiteTaskSync(std::string url, sql::Database* db) {
bool BlockSiteTaskSync(std::string url, sql::Database* db) {
if (!db || url.empty())
return false;
......@@ -42,13 +42,13 @@ bool BlacklistSiteTaskSync(std::string url, sql::Database* db) {
time_t unix_time = time_now.ToTimeT();
// Then insert the URL.
sql::Statement blacklist_statement(
db->GetCachedStatement(SQL_FROM_HERE, kBlacklistSiteSql));
sql::Statement block_statement(
db->GetCachedStatement(SQL_FROM_HERE, kBlockSiteSql));
int col = 0;
blacklist_statement.BindString(col++, url);
blacklist_statement.BindInt64(col++, unix_time);
blacklist_statement.Run();
block_statement.BindString(col++, url);
block_statement.BindInt64(col++, unix_time);
block_statement.Run();
// Then clear all matching activity.
sql::Statement clear_activity_statement(
......@@ -60,23 +60,23 @@ bool BlacklistSiteTaskSync(std::string url, sql::Database* db) {
return transaction.Commit();
}
BlacklistSiteTask::BlacklistSiteTask(ExploreSitesStore* store, std::string url)
BlockSiteTask::BlockSiteTask(ExploreSitesStore* store, std::string url)
: store_(store), url_(url) {}
BlacklistSiteTask::~BlacklistSiteTask() = default;
BlockSiteTask::~BlockSiteTask() = default;
void BlacklistSiteTask::Run() {
store_->Execute(base::BindOnce(&BlacklistSiteTaskSync, url_),
base::BindOnce(&BlacklistSiteTask::FinishedExecuting,
void BlockSiteTask::Run() {
store_->Execute(base::BindOnce(&BlockSiteTaskSync, url_),
base::BindOnce(&BlockSiteTask::FinishedExecuting,
weak_ptr_factory_.GetWeakPtr()),
false);
}
void BlacklistSiteTask::FinishedExecuting(bool result) {
void BlockSiteTask::FinishedExecuting(bool result) {
complete_ = true;
result_ = result;
TaskComplete();
DVLOG(1) << "Finished adding a site to the blacklist, result: " << result;
DVLOG(1) << "Finished adding a site to the blocklist, result: " << result;
}
} // namespace explore_sites
......@@ -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 CHROME_BROWSER_ANDROID_EXPLORE_SITES_BLACKLIST_SITE_TASK_H_
#define CHROME_BROWSER_ANDROID_EXPLORE_SITES_BLACKLIST_SITE_TASK_H_
#ifndef CHROME_BROWSER_ANDROID_EXPLORE_SITES_BLOCK_SITE_TASK_H_
#define CHROME_BROWSER_ANDROID_EXPLORE_SITES_BLOCK_SITE_TASK_H_
#include "chrome/browser/android/explore_sites/catalog.pb.h"
#include "chrome/browser/android/explore_sites/explore_sites_store.h"
......@@ -14,12 +14,12 @@ using offline_pages::Task;
namespace explore_sites {
// Takes a URL that the user has asked us to remove, and adds it to a blacklist
// Takes a URL that the user has asked us to remove, and adds it to a blocklist
// of sites we will stop showing in Explore on Sites.
class BlacklistSiteTask : public Task {
class BlockSiteTask : public Task {
public:
BlacklistSiteTask(ExploreSitesStore* store, std::string url);
~BlacklistSiteTask() override;
BlockSiteTask(ExploreSitesStore* store, std::string url);
~BlockSiteTask() override;
bool complete() const { return complete_; }
bool result() const { return result_; }
......@@ -37,9 +37,9 @@ class BlacklistSiteTask : public Task {
bool result_ = false;
BooleanCallback callback_;
base::WeakPtrFactory<BlacklistSiteTask> weak_ptr_factory_{this};
base::WeakPtrFactory<BlockSiteTask> weak_ptr_factory_{this};
};
} // namespace explore_sites
#endif // CHROME_BROWSER_ANDROID_EXPLORE_SITES_BLACKLIST_SITE_TASK_H_
#endif // CHROME_BROWSER_ANDROID_EXPLORE_SITES_BLOCK_SITE_TASK_H_
......@@ -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 "chrome/browser/android/explore_sites/blacklist_site_task.h"
#include "chrome/browser/android/explore_sites/block_site_task.h"
#include <memory>
......@@ -24,10 +24,10 @@ using InitializationStatus = ExploreSitesStore::InitializationStatus;
const char kGoogleUrl[] = "https://www.google.com";
class ExploreSitesBlacklistSiteTest : public TaskTestBase {
class ExploreSitesBlockSiteTest : public TaskTestBase {
public:
ExploreSitesBlacklistSiteTest() = default;
~ExploreSitesBlacklistSiteTest() override = default;
ExploreSitesBlockSiteTest() = default;
~ExploreSitesBlockSiteTest() override = default;
void SetUp() override {
store_ = std::make_unique<ExploreSitesStore>(task_runner());
......@@ -44,7 +44,7 @@ class ExploreSitesBlacklistSiteTest : public TaskTestBase {
RunUntilIdle();
}
void OnAddToBlacklisTaskDone(bool success) {
void OnAddToBlocklisTaskDone(bool success) {
success_ = success;
callback_called_ = true;
}
......@@ -60,10 +60,10 @@ class ExploreSitesBlacklistSiteTest : public TaskTestBase {
bool success_;
bool callback_called_;
DISALLOW_COPY_AND_ASSIGN(ExploreSitesBlacklistSiteTest);
DISALLOW_COPY_AND_ASSIGN(ExploreSitesBlockSiteTest);
};
void ExploreSitesBlacklistSiteTest::PopulateActivity() {
void ExploreSitesBlockSiteTest::PopulateActivity() {
ExecuteSync(base::BindLambdaForTesting([&](sql::Database* db) {
sql::Statement insert_activity(db->GetUniqueStatement(R"(
INSERT INTO activity
......@@ -76,10 +76,10 @@ VALUES
}));
}
TEST_F(ExploreSitesBlacklistSiteTest, StoreFailure) {
TEST_F(ExploreSitesBlockSiteTest, StoreFailure) {
store()->SetInitializationStatusForTesting(InitializationStatus::kFailure,
false);
BlacklistSiteTask task(store(), kGoogleUrl);
BlockSiteTask task(store(), kGoogleUrl);
RunTask(&task);
// A database failure should be completed but return with an error.
......@@ -87,16 +87,16 @@ TEST_F(ExploreSitesBlacklistSiteTest, StoreFailure) {
EXPECT_FALSE(task.result());
}
TEST_F(ExploreSitesBlacklistSiteTest, EmptyUrlTask) {
TEST_F(ExploreSitesBlockSiteTest, EmptyUrlTask) {
PopulateActivity();
BlacklistSiteTask task(store(), "");
BlockSiteTask task(store(), "");
RunTask(&task);
// The task should be completed but return with an error.
EXPECT_TRUE(task.complete());
EXPECT_FALSE(task.result());
// Check that DB's site_blacklist table is empty
// Check that DB's site_blocklist table is empty
// and that activity table is not modified.
ExecuteSync(base::BindLambdaForTesting([&](sql::Database* db) {
sql::Statement cat_count_s(
......@@ -113,16 +113,16 @@ TEST_F(ExploreSitesBlacklistSiteTest, EmptyUrlTask) {
}));
}
TEST_F(ExploreSitesBlacklistSiteTest, ValidUrlTask) {
TEST_F(ExploreSitesBlockSiteTest, ValidUrlTask) {
PopulateActivity();
BlacklistSiteTask task(store(), kGoogleUrl);
BlockSiteTask task(store(), kGoogleUrl);
RunTask(&task);
// Task should complete successfully
EXPECT_TRUE(task.complete());
EXPECT_TRUE(task.result());
// Check that DB's site_blacklist table contains kGoogleUrl and that
// Check that DB's site_blocklist table contains kGoogleUrl and that
// kGoogleUrl-related activity is removed from the activity table.
ExecuteSync(base::BindLambdaForTesting([&](sql::Database* db) {
sql::Statement cat_count_s(
......
......@@ -14,7 +14,7 @@ using offline_pages::Task;
namespace explore_sites {
// Takes a URL that the user has asked us to remove, and adds it to a blacklist
// Takes a URL that the user has asked us to remove, and adds it to a blocklist
// of sites we will stop showing in Explore on Sites.
class ClearActivitiesTask : public Task {
public:
......
......@@ -14,7 +14,7 @@ using offline_pages::Task;
namespace explore_sites {
// Takes a URL that the user has asked us to remove, and adds it to a blacklist
// Takes a URL that the user has asked us to remove, and adds it to a blocklist
// of sites we will stop showing in Explore on Sites.
class ClearCatalogTask : public Task {
public:
......
......@@ -98,7 +98,7 @@ VALUES
std::pair<int, int> GetCatalogSizes() {
int site_count = -1;
int category_count = -1;
// Check that DB's site_blacklist table is empty.
// Check that DB's blocklist table is empty.
ExecuteSync(base::BindLambdaForTesting([&](sql::Database* db) {
sql::Statement site_count_s(
db->GetUniqueStatement("SELECT COUNT(*) FROM sites"));
......
......@@ -62,7 +62,7 @@ void CatalogReady(ScopedJavaGlobalRef<jobject>(j_result_obj),
for (auto& site : category.sites) {
Java_ExploreSitesSite_createSiteInCategory(
env, site.site_id, ConvertUTF8ToJavaString(env, site.title),
ConvertUTF8ToJavaString(env, site.url.spec()), site.is_blacklisted,
ConvertUTF8ToJavaString(env, site.url.spec()), site.is_blocked,
j_category);
}
}
......@@ -259,10 +259,9 @@ void JNI_ExploreSitesBridge_UpdateCatalogFromNetwork(
ScopedJavaGlobalRef<jobject>(j_callback_obj)));
}
void JNI_ExploreSitesBridge_BlacklistSite(
JNIEnv* env,
const JavaParamRef<jobject>& j_profile,
const JavaParamRef<jstring>& j_url) {
void JNI_ExploreSitesBridge_BlockSite(JNIEnv* env,
const JavaParamRef<jobject>& j_profile,
const JavaParamRef<jstring>& j_url) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
std::string url = ConvertJavaStringToUTF8(env, j_url);
ExploreSitesService* service =
......@@ -272,7 +271,7 @@ void JNI_ExploreSitesBridge_BlacklistSite(
return;
}
service->BlacklistSite(url);
service->BlockSite(url);
}
void JNI_ExploreSitesBridge_RecordClick(JNIEnv* env,
......
......@@ -71,13 +71,13 @@ bool CreateActivityTable(sql::Database* db) {
return db->Execute(kActivityTableCreationSql);
}
static const char kSiteBlacklistTableCreationSql[] =
static const char kSiteBlocklistTableCreationSql[] =
"CREATE TABLE IF NOT EXISTS site_blacklist ("
"url TEXT NOT NULL UNIQUE, "
"date_removed INTEGER NOT NULL);"; // stored as unix timestamp
bool CreateSiteBlacklistTable(sql::Database* db) {
return db->Execute(kSiteBlacklistTableCreationSql);
bool CreateSiteBlocklistTable(sql::Database* db) {
return db->Execute(kSiteBlocklistTableCreationSql);
}
bool CreateLatestSchema(sql::Database* db) {
......@@ -86,7 +86,7 @@ bool CreateLatestSchema(sql::Database* db) {
return false;
if (!CreateCategoriesTable(db) || !CreateSitesTable(db) ||
!CreateSiteBlacklistTable(db) || !CreateActivityTable(db)) {
!CreateSiteBlocklistTable(db) || !CreateActivityTable(db)) {
return false;
}
......
......@@ -41,8 +41,8 @@ class ExploreSitesService : public KeyedService {
// Record the click on a site and category referenced by its type.
virtual void RecordClick(const std::string& url, int category_type) = 0;
// Add the url to the blacklist.
virtual void BlacklistSite(const std::string& url) = 0;
// Add the url to the blocklist.
virtual void BlockSite(const std::string& url) = 0;
// Remove the activity history from the specified time range.
virtual void ClearActivities(base::Time begin,
......
......@@ -10,7 +10,7 @@
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/post_task.h"
#include "chrome/browser/android/explore_sites/blacklist_site_task.h"
#include "chrome/browser/android/explore_sites/block_site_task.h"
#include "chrome/browser/android/explore_sites/catalog.pb.h"
#include "chrome/browser/android/explore_sites/clear_activities_task.h"
#include "chrome/browser/android/explore_sites/clear_catalog_task.h"
......@@ -136,10 +136,10 @@ void ExploreSitesServiceImpl::RecordClick(const std::string& url,
explore_sites_store_.get(), url, category_type));
}
void ExploreSitesServiceImpl::BlacklistSite(const std::string& url) {
// Add the url to the blacklist table in the database.
void ExploreSitesServiceImpl::BlockSite(const std::string& url) {
// Add the url to the blocklist table in the database.
task_queue_.AddTask(
std::make_unique<BlacklistSiteTask>(explore_sites_store_.get(), url));
std::make_unique<BlockSiteTask>(explore_sites_store_.get(), url));
// TODO(https://crbug.com/893845): Remove cached category icon if affected.
}
......@@ -245,7 +245,7 @@ std::unique_ptr<Catalog> ValidateCatalog(std::unique_ptr<Catalog> catalog) {
Site* new_site = new_category->add_sites();
new_site->Swap(&site);
// We want to use a canonicalized URL in the database so that blacklisting
// We want to use a canonicalized URL in the database so that blocking
// will always work. Typically this will cause a trailing slash to be
// added if it's missing.
new_site->set_site_url(url.spec());
......
......@@ -49,7 +49,7 @@ class ExploreSitesServiceImpl : public ExploreSitesService,
const std::string& accept_languages,
BooleanCallback callback) override;
void RecordClick(const std::string& url, int category_type) override;
void BlacklistSite(const std::string& url) override;
void BlockSite(const std::string& url) override;
void ClearActivities(base::Time begin,
base::Time end,
base::OnceClosure callback) override;
......
......@@ -574,7 +574,7 @@ TEST_F(ExploreSitesServiceImplTest, UnparseableCatalogHistograms) {
ExploreSitesCatalogError::kParseFailure, 1);
}
TEST_F(ExploreSitesServiceImplTest, BlacklistNonCanonicalUrls) {
TEST_F(ExploreSitesServiceImplTest, BlockNonCanonicalUrls) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(chrome::android::kExploreSites);
......@@ -597,7 +597,7 @@ TEST_F(ExploreSitesServiceImplTest, BlacklistNonCanonicalUrls) {
// This will fail if canonicalization does not work correctly because
// kSite1Url is the canonicalized version of the URL inserted in to the
// database.
service()->BlacklistSite(kSite1Url);
service()->BlockSite(kSite1Url);
PumpLoop();
service()->GetCatalog(base::BindOnce(
......@@ -605,8 +605,8 @@ TEST_F(ExploreSitesServiceImplTest, BlacklistNonCanonicalUrls) {
PumpLoop();
EXPECT_EQ(2U, database_categories()->at(0).sites.size());
EXPECT_TRUE(database_categories()->at(0).sites.at(0).is_blacklisted);
EXPECT_FALSE(database_categories()->at(0).sites.at(1).is_blacklisted);
EXPECT_TRUE(database_categories()->at(0).sites.at(0).is_blocked);
EXPECT_FALSE(database_categories()->at(0).sites.at(1).is_blocked);
}
TEST_F(ExploreSitesServiceImplTest, CountryCodeDefault) {
......
......@@ -10,12 +10,12 @@ ExploreSitesSite::ExploreSitesSite(int site_id,
int category_id,
GURL url,
std::string title,
bool is_blacklisted)
bool is_blocked)
: site_id(site_id),
category_id(category_id),
url(url),
title(title),
is_blacklisted(is_blacklisted) {}
is_blocked(is_blocked) {}
ExploreSitesSite::ExploreSitesSite(ExploreSitesSite&& other) = default;
......
......@@ -26,7 +26,7 @@ struct ExploreSitesSite {
int category_id,
GURL url,
std::string title,
bool is_blacklisted);
bool is_blocked);
ExploreSitesSite(ExploreSitesSite&& other);
virtual ~ExploreSitesSite();
......@@ -34,7 +34,7 @@ struct ExploreSitesSite {
int category_id;
GURL url;
std::string title;
bool is_blacklisted;
bool is_blocked;
DISALLOW_COPY_AND_ASSIGN(ExploreSitesSite);
};
......@@ -89,7 +89,7 @@ enum class ExploreSitesRequestStatus {
// Request failed with error indicating that the request can not be serviced
// by the server.
kShouldSuspendBadRequest = 2,
// The request was blocked by a URL blacklist configured by the domain
// The request was blocked by a URL blocklist configured by the domain
// administrator.
kShouldSuspendBlockedByAdministrator = 3,
// kMaxValue should always be the last type.
......
......@@ -147,12 +147,11 @@ GetCatalogSync(bool update_current, sql::Database* db) {
site_statement.BindInt64(0, category.category_id);
while (site_statement.Step()) {
category.sites.emplace_back(
site_statement.ColumnInt(0), // site_id
category.category_id,
GURL(site_statement.ColumnString(1)), // url
site_statement.ColumnString(2), // title
site_statement.ColumnBool(3)); // is_blacklisted
category.sites.emplace_back(site_statement.ColumnInt(0), // site_id
category.category_id,
GURL(site_statement.ColumnString(1)), // url
site_statement.ColumnString(2), // title
site_statement.ColumnBool(3)); // is_blocked
}
if (!site_statement.Succeeded())
return std::make_pair(GetCatalogStatus::kFailed, nullptr);
......
......@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/test/bind_test_util.h"
#include "base/test/mock_callback.h"
#include "chrome/browser/android/explore_sites/blacklist_site_task.h"
#include "chrome/browser/android/explore_sites/block_site_task.h"
#include "chrome/browser/android/explore_sites/explore_sites_schema.h"
#include "components/offline_pages/task/task.h"
#include "components/offline_pages/task/task_test_base.h"
......@@ -42,7 +42,7 @@ void ValidateTestingCatalog(GetCatalogTask::CategoryList* catalog) {
EXPECT_EQ("https://www.example.com/1", site->url.spec());
EXPECT_EQ(4, site->category_id);
EXPECT_EQ("example_1", site->title);
EXPECT_FALSE(site->is_blacklisted);
EXPECT_FALSE(site->is_blocked);
cat = &catalog->at(1);
EXPECT_EQ(5, cat->category_id);
......@@ -57,11 +57,11 @@ void ValidateTestingCatalog(GetCatalogTask::CategoryList* catalog) {
EXPECT_EQ("https://www.example.com/2", site->url.spec());
EXPECT_EQ(5, site->category_id);
EXPECT_EQ("example_2", site->title);
EXPECT_FALSE(site->is_blacklisted);
EXPECT_FALSE(site->is_blocked);
}
// Same as above, sites blacklisted are clearly marked.
void ValidateBlacklistTestingCatalog(GetCatalogTask::CategoryList* catalog) {
// Same as above, blocked sites are clearly marked.
void ValidateBlockedSitesTestingCatalog(GetCatalogTask::CategoryList* catalog) {
EXPECT_FALSE(catalog == nullptr);
EXPECT_EQ(2U, catalog->size());
......@@ -78,7 +78,7 @@ void ValidateBlacklistTestingCatalog(GetCatalogTask::CategoryList* catalog) {
EXPECT_EQ("https://www.example.com/1", site->url.spec());
EXPECT_EQ(4, site->category_id);
EXPECT_EQ("example_1", site->title);
EXPECT_FALSE(site->is_blacklisted);
EXPECT_FALSE(site->is_blocked);
cat = &catalog->at(1);
EXPECT_EQ(5, cat->category_id);
......@@ -93,7 +93,7 @@ void ValidateBlacklistTestingCatalog(GetCatalogTask::CategoryList* catalog) {
EXPECT_EQ("https://www.example.com/2", site->url.spec());
EXPECT_EQ(5, site->category_id);
EXPECT_EQ("example_2", site->title);
EXPECT_TRUE(site->is_blacklisted);
EXPECT_TRUE(site->is_blocked);
}
void ExpectSuccessGetCatalogResult(
......@@ -103,11 +103,11 @@ void ExpectSuccessGetCatalogResult(
ValidateTestingCatalog(catalog.get());
}
void ExpectBlacklistGetCatalogResult(
void ExpectBlockedGetCatalogResult(
GetCatalogStatus status,
std::unique_ptr<GetCatalogTask::CategoryList> catalog) {
EXPECT_EQ(GetCatalogStatus::kSuccess, status);
ValidateBlacklistTestingCatalog(catalog.get());
ValidateBlockedSitesTestingCatalog(catalog.get());
}
void ExpectEmptyGetCatalogResult(
......@@ -151,7 +151,7 @@ class ExploreSitesGetCatalogTaskTest : public TaskTestBase {
std::pair<std::string, std::string> GetCurrentAndDownloadingVersion();
int GetNumberOfCategoriesInDB();
int GetNumberOfSitesInDB();
void BlacklistSite(std::string url);
void BlockSite(std::string url);
private:
std::unique_ptr<ExploreSitesStore> store_;
......@@ -263,10 +263,10 @@ int ExploreSitesGetCatalogTaskTest::GetNumberOfSitesInDB() {
return result;
}
void ExploreSitesGetCatalogTaskTest::BlacklistSite(std::string url) {
BlacklistSiteTask task(store(), url);
void ExploreSitesGetCatalogTaskTest::BlockSite(std::string url) {
BlockSiteTask task(store(), url);
RunTask(&task);
// We don't actively wait for completion, so we rely on the blacklist request
// We don't actively wait for completion, so we rely on the block request
// clearing the task queue before the task in the test proper runs.
}
......@@ -299,13 +299,13 @@ TEST_F(ExploreSitesGetCatalogTaskTest, SimpleCatalog) {
EXPECT_EQ(4, GetNumberOfSitesInDB());
}
// This tests that sites on the blacklist do not show up when we do a get
// This tests that blocked sites do not show up when we do a get
// catalog task.
TEST_F(ExploreSitesGetCatalogTaskTest, BlasklistedSitesMarkedBlacklisted) {
BlacklistSite("https://www.example.com/2");
TEST_F(ExploreSitesGetCatalogTaskTest, BlasklistedSitesMarkedAsBlocked) {
BlockSite("https://www.example.com/2");
PopulateTestingCatalog();
GetCatalogTask task(store(), false,
base::BindOnce(&ExpectBlacklistGetCatalogResult));
base::BindOnce(&ExpectBlockedGetCatalogResult));
RunTask(&task);
}
......
......@@ -179,7 +179,7 @@ TEST_F(ExploreSitesGetImagesTaskTest, SiteExistsAndHasFavicon) {
EXPECT_EQ("bytes3", std::string(result3.begin(), result3.end()));
}
TEST_F(ExploreSitesGetImagesTaskTest, SitesExistAndNotBlacklisted) {
TEST_F(ExploreSitesGetImagesTaskTest, SitesExistAndNotBlocked) {
PopulateTestingCatalog();
GetImagesTask task(store(), 3, 4, StoreResult());
RunTask(&task);
......@@ -191,7 +191,7 @@ TEST_F(ExploreSitesGetImagesTaskTest, SitesExistAndNotBlacklisted) {
EXPECT_EQ("bytes3", std::string(result2.begin(), result2.end()));
}
TEST_F(ExploreSitesGetImagesTaskTest, SitesExistAndBlacklisted) {
TEST_F(ExploreSitesGetImagesTaskTest, SitesExistAndBlocked) {
PopulateTestingCatalog();
ExecuteSync(base::BindLambdaForTesting([&](sql::Database* db) {
sql::Statement insert(db->GetUniqueStatement(R"(
......
......@@ -11,7 +11,7 @@
namespace explore_sites {
// Takes a URL that the user has asked us to remove, and adds it to a blacklist
// Takes a URL that the user has asked us to remove, and adds it to a blocklist
// of sites we will stop showing in Explore on Sites.
class MostVisitedClient
: public ntp_tiles::MostVisitedSites::ExploreSitesClient {
......
......@@ -3784,7 +3784,7 @@ test("unit_tests") {
"../browser/android/contextualsearch/contextual_search_delegate_unittest.cc",
"../browser/android/contextualsearch/contextual_search_field_trial_unittest.cc",
"../browser/android/customtabs/detached_resource_request_unittest.cc",
"../browser/android/explore_sites/blacklist_site_task_unittest.cc",
"../browser/android/explore_sites/block_site_task_unittest.cc",
"../browser/android/explore_sites/clear_activities_task_unittest.cc",
"../browser/android/explore_sites/clear_catalog_task_unittest.cc",
"../browser/android/explore_sites/explore_sites_feature_unittest.cc",
......
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