-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple business logic for newly supported regions into ads library #3805
Conversation
9bb0406
to
c29f0df
Compare
@tmancey is it still a draft or can be reviewed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS changes look good
da2f115
to
b1a44e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
@@ -1063,8 +1063,8 @@ void RewardsDOMHandler::GetAdsData(const base::ListValue *args) { | |||
|
|||
base::DictionaryValue ads_data; | |||
|
|||
auto is_supported_region = ads_service_->IsSupportedRegion(); | |||
ads_data.SetBoolean("adsIsSupported", is_supported_region); | |||
auto is_supported_locale = ads_service_->IsSupportedLocale(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From G C++ styleguide:
The fundamental rule is: use type deduction only to make the code clearer or safer, and do not use it merely to avoid the inconvenience of writing an explicit type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Legacy code to be fixed in a future refactor ticket as not related to this change. However new code will/does follow the Google style guide going forward
return false; | ||
} | ||
|
||
const auto schema_version = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above: implicit type deduction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
auto it = kSupportedRegions.find(region); | ||
if (it == kSupportedRegions.end()) { | ||
return false; | ||
for (const auto& schema : kSupportedRegionsSchemas) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not to use std::find_if
instead of loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to iterate all schema_version
elements in the std::map
to see if each sub std::map
contains the users region
auto locale = ads_client_->GetLocale(); | ||
auto region = helper::Locale::GetRegionCode(locale); | ||
bool AdsImpl::ShouldClassifyPagesIfTargeted() const { | ||
const auto locale = ads_client_->GetLocale(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above: implicit type deduction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
7b10ed6
to
4a99cca
Compare
2f3502d
to
42486f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewards changes looks good, please make sure that CI test passes
Fixes brave/brave-browser#6612
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
After-merge Checklist:
changes has landed on.