Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: components/variations/study_filtering.cc

Issue 2488173005: Adding support for exclude locales to variations. (Closed)
Patch Set: fix typo in comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/variations/proto/study.proto ('k') | components/variations/study_filtering_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/study_filtering.cc
diff --git a/components/variations/study_filtering.cc b/components/variations/study_filtering.cc
index 479b9e959ec413d098e1345eb789dca144172c3b..159b544f4e7d388e0fc3c49d251a82e8381af48a 100644
--- a/components/variations/study_filtering.cc
+++ b/components/variations/study_filtering.cc
@@ -106,15 +106,18 @@ bool CheckStudyHardwareClass(const Study_Filter& filter,
}
bool CheckStudyLocale(const Study_Filter& filter, const std::string& locale) {
- // An empty locale list matches all locales.
- if (filter.locale_size() == 0)
+ // Empty locale and exclude_locale lists matches all locales.
+ if (filter.locale_size() == 0 && filter.exclude_locale_size() == 0)
return true;
- for (int i = 0; i < filter.locale_size(); ++i) {
- if (filter.locale(i) == locale)
- return true;
- }
- return false;
+ // Check if we are supposed to filter for a specified set of countries. Note
+ // that this means this overrides the exclude_locale in case that ever occurs
+ // (which it shouldn't).
+ if (filter.locale_size() > 0)
+ return base::ContainsValue(filter.locale(), locale);
+
+ // Omit if matches any of the exclude entries.
+ return !base::ContainsValue(filter.exclude_locale(), locale);
}
bool CheckStudyPlatform(const Study_Filter& filter, Study_Platform platform) {
« no previous file with comments | « components/variations/proto/study.proto ('k') | components/variations/study_filtering_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698