Chromium Code Reviews| Index: components/variations/study_filtering.cc |
| diff --git a/components/variations/study_filtering.cc b/components/variations/study_filtering.cc |
| index 479b9e959ec413d098e1345eb789dca144172c3b..637732dad7a0698b1fa672dfc4f66b6e0be839f4 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 spposed to filter for a specified set of countries. Note |
|
rkaplow
2016/11/11 21:21:10
supposed
jwd
2016/11/12 00:21:14
Done.
|
| + // 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) { |