Deleted hardcoded country list for search promo
fix https://github.com/brave/brave-browser/issues/25087 We'll control allowed country list via griffin instead of using hardcoded country list.
This commit is contained in:
@@ -18,8 +18,6 @@ static_library("brave_search_conversion") {
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//brave/components/l10n/browser",
|
||||
"//brave/components/l10n/common",
|
||||
"//brave/components/search_engines",
|
||||
"//components/prefs",
|
||||
"//components/search_engines",
|
||||
@@ -39,12 +37,10 @@ source_set("unit_tests") {
|
||||
":brave_search_conversion",
|
||||
"//base",
|
||||
"//base/test:test_support",
|
||||
"//brave/components/l10n/browser",
|
||||
"//brave/components/search_engines",
|
||||
"//components/prefs",
|
||||
"//components/prefs:test_support",
|
||||
"//components/search_engines",
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -10,30 +10,19 @@
|
||||
#include "brave/components/brave_search_conversion/features.h"
|
||||
#include "brave/components/brave_search_conversion/types.h"
|
||||
#include "brave/components/brave_search_conversion/utils.h"
|
||||
#include "brave/components/l10n/browser/locale_helper.h"
|
||||
#include "brave/components/search_engines/brave_prepopulated_engines.h"
|
||||
#include "components/prefs/testing_pref_service.h"
|
||||
#include "components/search_engines/template_url.h"
|
||||
#include "components/search_engines/template_url_data_util.h"
|
||||
#include "components/search_engines/template_url_service.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace brave_search_conversion {
|
||||
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
|
||||
class LocaleHelperMock : public brave_l10n::LocaleHelper {
|
||||
public:
|
||||
MOCK_CONST_METHOD0(GetLocale, std::string());
|
||||
};
|
||||
|
||||
class BraveSearchConversionTest : public testing::Test {
|
||||
public:
|
||||
BraveSearchConversionTest() : template_url_service_(nullptr, 0) {}
|
||||
void SetUp() override {
|
||||
SetMockLocale("en-US");
|
||||
RegisterPrefs(pref_service_.registry());
|
||||
auto provider_data = TemplateURLDataFromPrepopulatedEngine(
|
||||
TemplateURLPrepopulateData::brave_search);
|
||||
@@ -58,18 +47,9 @@ class BraveSearchConversionTest : public testing::Test {
|
||||
: brave_search_template_url_.get());
|
||||
}
|
||||
|
||||
void SetMockLocale(const std::string& locale) {
|
||||
// Set promotion supported locale.
|
||||
locale_helper_mock_ = std::make_unique<NiceMock<LocaleHelperMock>>();
|
||||
brave_l10n::LocaleHelper::GetInstance()->SetForTesting(
|
||||
locale_helper_mock_.get());
|
||||
ON_CALL(*locale_helper_mock_, GetLocale()).WillByDefault(Return(locale));
|
||||
}
|
||||
|
||||
std::unique_ptr<TemplateURL> brave_search_template_url_;
|
||||
std::unique_ptr<TemplateURL> brave_search_tor_template_url_;
|
||||
std::unique_ptr<TemplateURL> bing_template_url_;
|
||||
std::unique_ptr<LocaleHelperMock> locale_helper_mock_;
|
||||
TestingPrefServiceSimple pref_service_;
|
||||
TemplateURLService template_url_service_;
|
||||
};
|
||||
@@ -77,6 +57,7 @@ class BraveSearchConversionTest : public testing::Test {
|
||||
TEST_F(BraveSearchConversionTest, DefaultValueTest) {
|
||||
EXPECT_FALSE(base::FeatureList::IsEnabled(features::kOmniboxButton));
|
||||
EXPECT_FALSE(base::FeatureList::IsEnabled(features::kOmniboxBanner));
|
||||
EXPECT_FALSE(base::FeatureList::IsEnabled(features::kNTP));
|
||||
EXPECT_EQ(ConversionType::kNone,
|
||||
GetConversionType(&pref_service_, &template_url_service_));
|
||||
EXPECT_EQ(GURL("https://search.brave.com/search?q=brave&action=makeDefault"),
|
||||
@@ -114,16 +95,4 @@ TEST_F(BraveSearchConversionTest, ConversionTypeTest) {
|
||||
GetConversionType(&pref_service_, &template_url_service_));
|
||||
}
|
||||
|
||||
TEST_F(BraveSearchConversionTest, SupportedCountryTest) {
|
||||
// Below 5 regions are supported for search conversion promotion.
|
||||
EXPECT_TRUE(IsPromotionEnabledCountry("US"));
|
||||
EXPECT_TRUE(IsPromotionEnabledCountry("CA"));
|
||||
EXPECT_TRUE(IsPromotionEnabledCountry("DE"));
|
||||
EXPECT_TRUE(IsPromotionEnabledCountry("FR"));
|
||||
EXPECT_TRUE(IsPromotionEnabledCountry("GB"));
|
||||
|
||||
EXPECT_FALSE(IsPromotionEnabledCountry("KR"));
|
||||
EXPECT_FALSE(IsPromotionEnabledCountry("AZ"));
|
||||
}
|
||||
|
||||
} // namespace brave_search_conversion
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#include "brave/components/brave_search_conversion/features.h"
|
||||
#include "brave/components/brave_search_conversion/pref_names.h"
|
||||
#include "brave/components/brave_search_conversion/types.h"
|
||||
#include "brave/components/l10n/browser/locale_helper.h"
|
||||
#include "brave/components/l10n/common/locale_util.h"
|
||||
#include "brave/components/search_engines/brave_prepopulated_engines.h"
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
@@ -26,12 +24,6 @@
|
||||
|
||||
namespace brave_search_conversion {
|
||||
|
||||
bool IsPromotionEnabledCountry(const std::string& country_code) {
|
||||
constexpr base::StringPiece kSupportedCountries[] = {"US", "CA", "DE", "FR",
|
||||
"GB"};
|
||||
return base::Contains(kSupportedCountries, country_code);
|
||||
}
|
||||
|
||||
bool IsNTPPromotionEnabled(PrefService* prefs, TemplateURLService* service) {
|
||||
DCHECK(prefs);
|
||||
DCHECK(service);
|
||||
@@ -47,12 +39,6 @@ bool IsNTPPromotionEnabled(PrefService* prefs, TemplateURLService* service) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string locale =
|
||||
brave_l10n::LocaleHelper::GetInstance()->GetLocale();
|
||||
const std::string country_code = brave_l10n::GetCountryCode(locale);
|
||||
if (!IsPromotionEnabledCountry(country_code))
|
||||
return false;
|
||||
|
||||
return base::FeatureList::IsEnabled(features::kNTP);
|
||||
}
|
||||
|
||||
@@ -71,12 +57,6 @@ ConversionType GetConversionType(PrefService* prefs,
|
||||
return ConversionType::kNone;
|
||||
}
|
||||
|
||||
const std::string locale =
|
||||
brave_l10n::LocaleHelper::GetInstance()->GetLocale();
|
||||
const std::string country_code = brave_l10n::GetCountryCode(locale);
|
||||
if (!IsPromotionEnabledCountry(country_code))
|
||||
return ConversionType::kNone;
|
||||
|
||||
if (base::FeatureList::IsEnabled(features::kOmniboxButton))
|
||||
return ConversionType::kButton;
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ void RegisterPrefs(PrefRegistrySimple* registry);
|
||||
void SetDismissed(PrefService* prefs);
|
||||
GURL GetPromoURL(const std::u16string& search_term);
|
||||
GURL GetPromoURL(const std::string& search_term);
|
||||
bool IsPromotionEnabledCountry(const std::string& country_code);
|
||||
bool IsBraveSearchConversionFetureEnabled();
|
||||
|
||||
} // namespace brave_search_conversion
|
||||
|
||||
Reference in New Issue
Block a user