From 22b4e4cec6291ea02c98a0fd8130266b8cd4bf73 Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Thu, 26 Mar 2020 10:55:44 +0000 Subject: [PATCH] Send platform, build channel and country code as part of ad confirmation calls where it meets privacy standards --- browser/brave_stats_updater.cc | 1 + browser/brave_stats_updater_util.cc | 8 -- browser/brave_stats_updater_util.h | 2 - common/BUILD.gn | 2 + common/brave_channel_info.cc | 21 +++++ common/brave_channel_info.h | 18 +++++ .../brave_rewards/browser/android_util.cc | 2 + .../browser/rewards_service_impl.cc | 3 + components/p3a/BUILD.gn | 1 + components/p3a/brave_p3a_service.cc | 1 + test/BUILD.gn | 1 + .../bat-native-ads/include/bat/ads/ad_info.h | 1 + vendor/bat-native-ads/src/bat/ads/ad_info.cc | 7 ++ .../src/bat/ads/ad_notification_info.cc | 3 + .../src/bat/ads/internal/ad_notifications.cc | 11 +++ .../src/bat/ads/internal/ad_notifications.h | 3 + .../src/bat/ads/internal/ads_impl.cc | 1 + vendor/bat-native-confirmations/BUILD.gn | 37 +++++++++ .../include/bat/confirmations/ad_info.h | 1 + .../internal/confirmation_info.h | 1 + .../internal/confirmations_impl.cc | 5 ++ .../internal/confirmations_impl.h | 2 + .../internal/create_confirmation_request.cc | 30 +++++++- .../internal/create_confirmation_request.h | 8 +- .../confirmations/internal/platform_helper.cc | 44 +++++++++++ .../confirmations/internal/platform_helper.h | 40 ++++++++++ .../internal/platform_helper_android.cc | 26 +++++++ .../internal/platform_helper_android.h | 32 ++++++++ .../internal/platform_helper_ios.h | 32 ++++++++ .../internal/platform_helper_ios.mm | 28 +++++++ .../internal/platform_helper_linux.cc | 26 +++++++ .../internal/platform_helper_linux.h | 32 ++++++++ .../internal/platform_helper_mac.h | 32 ++++++++ .../internal/platform_helper_mac.mm | 28 +++++++ .../internal/platform_helper_mock.h | 30 ++++++++ .../internal/platform_helper_win.cc | 26 +++++++ .../internal/platform_helper_win.h | 32 ++++++++ .../confirmations/internal/redeem_token.cc | 7 +- .../confirmations/internal/static_values.h | 76 +++++++++++++++++++ .../bat/ledger/public/interfaces/ledger.mojom | 1 + .../src/bat/ledger/internal/ledger_impl.cc | 1 + vendor/brave-ios/Ads/BATAdNotification.h | 1 + vendor/brave-ios/Ads/BATAdNotification.mm | 2 + 43 files changed, 651 insertions(+), 15 deletions(-) create mode 100644 common/brave_channel_info.cc create mode 100644 common/brave_channel_info.h create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.cc create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.h create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.cc create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.h create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.h create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.mm create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.cc create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.h create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.h create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.mm create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mock.h create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.cc create mode 100644 vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.h diff --git a/browser/brave_stats_updater.cc b/browser/brave_stats_updater.cc index c29cda7e79af..9d724afc1880 100644 --- a/browser/brave_stats_updater.cc +++ b/browser/brave_stats_updater.cc @@ -12,6 +12,7 @@ #include "brave/browser/brave_stats_updater_params.h" #include "brave/browser/brave_stats_updater_util.h" #include "brave/browser/version_info.h" +#include "brave/common/brave_channel_info.h" #include "brave/common/pref_names.h" #include "brave/components/brave_referrals/buildflags/buildflags.h" #include "chrome/browser/browser_process.h" diff --git a/browser/brave_stats_updater_util.cc b/browser/brave_stats_updater_util.cc index 584a5edca412..3ebcb06c2d6d 100644 --- a/browser/brave_stats_updater_util.cc +++ b/browser/brave_stats_updater_util.cc @@ -11,7 +11,6 @@ #include "base/strings/string_piece.h" #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" -#include "chrome/common/channel_info.h" namespace brave { @@ -22,13 +21,6 @@ std::string GetDateAsYMD(const base::Time& time) { exploded.day_of_month); } -std::string GetChannelName() { - std::string channel = chrome::GetChannelName(); - if (channel.empty()) - channel = "release"; - return channel; -} - std::string GetPlatformIdentifier() { #if defined(OS_WIN) if (base::SysInfo::OperatingSystemArchitecture() == "x86") diff --git a/browser/brave_stats_updater_util.h b/browser/brave_stats_updater_util.h index 2a66ee68f32e..d3830ee49d9e 100644 --- a/browser/brave_stats_updater_util.h +++ b/browser/brave_stats_updater_util.h @@ -15,8 +15,6 @@ namespace brave { std::string GetDateAsYMD(const base::Time& time); -std::string GetChannelName(); - std::string GetPlatformIdentifier(); int GetIsoWeekNumber(const base::Time& time); diff --git a/common/BUILD.gn b/common/BUILD.gn index af38dc651bd1..724893bf0485 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -47,6 +47,8 @@ source_set("switches") { source_set("common") { sources = [ + "brave_channel_info.cc", + "brave_channel_info.h", "brave_content_client.cc", "brave_content_client.h", "brave_features.cc", diff --git a/common/brave_channel_info.cc b/common/brave_channel_info.cc new file mode 100644 index 000000000000..e793bf1638a1 --- /dev/null +++ b/common/brave_channel_info.cc @@ -0,0 +1,21 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/common/brave_channel_info.h" + +#include "chrome/common/channel_info.h" + +namespace brave { + +std::string GetChannelName() { + std::string channel_name = chrome::GetChannelName(); + if (channel_name.empty()) { + channel_name = "release"; + } + + return channel_name; +} + +} // namespace brave diff --git a/common/brave_channel_info.h b/common/brave_channel_info.h new file mode 100644 index 000000000000..73e49b170afd --- /dev/null +++ b/common/brave_channel_info.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMMON_BRAVE_CHANNEL_INFO_H_ +#define BRAVE_COMMON_BRAVE_CHANNEL_INFO_H_ + +#include + +namespace brave { + +std::string GetChannelName(); + +} + +#endif // BRAVE_COMMON_BRAVE_CHANNEL_INFO_H_ + diff --git a/components/brave_rewards/browser/android_util.cc b/components/brave_rewards/browser/android_util.cc index b9dde3cbd726..02abf7397b45 100644 --- a/components/brave_rewards/browser/android_util.cc +++ b/components/brave_rewards/browser/android_util.cc @@ -5,6 +5,7 @@ #include "base/json/json_reader.h" #include "brave/components/brave_rewards/browser/android_util.h" +#include "brave/common/brave_channel_info.h" namespace android_util { @@ -12,6 +13,7 @@ ledger::ClientInfoPtr GetAndroidClientInfo() { auto info = ledger::ClientInfo::New(); info->platform = ledger::Platform::ANDROID_R; info->os = ledger::OperatingSystem::UNDEFINED; + info->channel = brave::GetChannelName(); return info; } diff --git a/components/brave_rewards/browser/rewards_service_impl.cc b/components/brave_rewards/browser/rewards_service_impl.cc index a6be450e805a..4a3de427a074 100644 --- a/components/brave_rewards/browser/rewards_service_impl.cc +++ b/components/brave_rewards/browser/rewards_service_impl.cc @@ -38,6 +38,7 @@ #include "brave/base/containers/utils.h" #include "brave/browser/ui/webui/brave_rewards_source.h" #include "brave/components/brave_rewards/common/pref_names.h" +#include "brave/common/brave_channel_info.h" #include "brave/common/pref_names.h" #include "brave/components/brave_ads/browser/ads_service.h" #include "brave/components/brave_ads/browser/ads_service_factory.h" @@ -3273,6 +3274,8 @@ ledger::ClientInfoPtr GetDesktopClientInfo() { info->os = ledger::OperatingSystem::UNDEFINED; #endif + info->channel = brave::GetChannelName(); + return info; } diff --git a/components/p3a/BUILD.gn b/components/p3a/BUILD.gn index 601d86c63f6a..e0cbfbaa3cf6 100644 --- a/components/p3a/BUILD.gn +++ b/components/p3a/BUILD.gn @@ -26,6 +26,7 @@ source_set("p3a") { ] deps = [ + "//brave/common", "//brave/components/p3a:buildflags", "//brave/components/brave_prochlo", "//brave/components/brave_prochlo:prochlo_proto", diff --git a/components/p3a/brave_p3a_service.cc b/components/p3a/brave_p3a_service.cc index 51163191d903..74a533e640db 100644 --- a/components/p3a/brave_p3a_service.cc +++ b/components/p3a/brave_p3a_service.cc @@ -19,6 +19,7 @@ #include "base/trace_event/trace_event.h" #include "brave/browser/brave_stats_updater_util.h" #include "brave/browser/version_info.h" +#include "brave/common/brave_channel_info.h" #include "brave/common/pref_names.h" #include "brave/components/brave_prochlo/prochlo_message.pb.h" #include "brave/components/p3a/brave_p3a_log_store.h" diff --git a/test/BUILD.gn b/test/BUILD.gn index 4d12610bb20e..a3a49e5fcf37 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -357,6 +357,7 @@ test("brave_unit_tests") { "//brave/vendor/bat-native-ads/src/bat/ads/internal/ads_tabs_unittest.cc", "//brave/vendor/bat-native-ads/src/bat/ads/internal/ads_client_mock.cc", "//brave/vendor/bat-native-ads/src/bat/ads/internal/ads_client_mock.h", + "//brave/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mock.h", "//brave/vendor/bat-native-confirmations/src/bat/confirmations/internal/ad_grants_unittest.cc", "//brave/vendor/bat-native-confirmations/src/bat/confirmations/internal/payments_unittest.cc", "//brave/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_create_confirmation_request_unittest.cc", diff --git a/vendor/bat-native-ads/include/bat/ads/ad_info.h b/vendor/bat-native-ads/include/bat/ads/ad_info.h index b17be63dd652..11695f58b9a1 100644 --- a/vendor/bat-native-ads/include/bat/ads/ad_info.h +++ b/vendor/bat-native-ads/include/bat/ads/ad_info.h @@ -29,6 +29,7 @@ struct ADS_EXPORT AdInfo { std::string creative_set_id; std::string category; std::string target_url; + std::string geo_target; }; } // namespace ads diff --git a/vendor/bat-native-ads/src/bat/ads/ad_info.cc b/vendor/bat-native-ads/src/bat/ads/ad_info.cc index f4d72ad14a39..182124816ae2 100644 --- a/vendor/bat-native-ads/src/bat/ads/ad_info.cc +++ b/vendor/bat-native-ads/src/bat/ads/ad_info.cc @@ -51,6 +51,10 @@ Result AdInfo::FromJson( target_url = document["url"].GetString(); } + if (document.HasMember("geo_target")) { + geo_target = document["geo_target"].GetString(); + } + return SUCCESS; } @@ -71,6 +75,9 @@ void SaveToJson( writer->String("url"); writer->String(info.target_url.c_str()); + writer->String("geo_target"); + writer->String(info.geo_target.c_str()); + writer->EndObject(); } diff --git a/vendor/bat-native-ads/src/bat/ads/ad_notification_info.cc b/vendor/bat-native-ads/src/bat/ads/ad_notification_info.cc index 75262583d112..36fcada53322 100644 --- a/vendor/bat-native-ads/src/bat/ads/ad_notification_info.cc +++ b/vendor/bat-native-ads/src/bat/ads/ad_notification_info.cc @@ -101,6 +101,9 @@ void SaveToJson( writer->String("url"); writer->String(info.target_url.c_str()); + writer->String("geo_target"); + writer->String(info.geo_target.c_str()); + writer->EndObject(); } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.cc b/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.cc index 2d851aa9f769..78d22e291565 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.cc @@ -31,6 +31,7 @@ const char kNotificationCategoryKey[] = "category"; const char kNotificationTitleKey[] = "advertiser"; const char kNotificationBodyKey[] = "text"; const char kNotificationTargetUrlKey[] = "url"; +const char kNotificationGeoTargetKey[] = "geo_target"; AdNotifications::AdNotifications( AdsImpl* ads, @@ -214,6 +215,10 @@ bool AdNotifications::GetNotificationFromDictionary( return false; } + if (!GetGeoTargetFromDictionary(dictionary, ¬ification_info.geo_target)) { + return false; + } + *info = notification_info; return true; @@ -269,6 +274,12 @@ bool AdNotifications::GetTargetUrlFromDictionary( return GetStringFromDictionary(kNotificationTargetUrlKey, dictionary, value); } +bool AdNotifications::GetGeoTargetFromDictionary( + base::DictionaryValue* dictionary, + std::string* value) const { + return GetStringFromDictionary(kNotificationGeoTargetKey, dictionary, value); +} + bool AdNotifications::GetStringFromDictionary( const std::string& key, base::DictionaryValue* dictionary, diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.h b/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.h index 4f9cb9e69a39..cd302ed5ed1b 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/ad_notifications.h @@ -87,6 +87,9 @@ class AdNotifications { bool GetTargetUrlFromDictionary( base::DictionaryValue* dictionary, std::string* value) const; + bool GetGeoTargetFromDictionary( + base::DictionaryValue* dictionary, + std::string* value) const; bool GetStringFromDictionary( const std::string& key, diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc b/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc index 5baa82eb67ed..bc4127fd1746 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc @@ -1464,6 +1464,7 @@ bool AdsImpl::ShowAdNotification( ad_notification->title = info.title; ad_notification->body = info.body; ad_notification->target_url = helper::Uri::GetUri(info.target_url); + ad_notification->geo_target = info.geo_targets.at(0); BLOG(INFO) << "Ad notification shown:" << std::endl << " uuid: " << ad_notification->uuid diff --git a/vendor/bat-native-confirmations/BUILD.gn b/vendor/bat-native-confirmations/BUILD.gn index 19449991e272..17cdd6eaa068 100644 --- a/vendor/bat-native-confirmations/BUILD.gn +++ b/vendor/bat-native-confirmations/BUILD.gn @@ -75,6 +75,8 @@ source_set("bat-native-confirmations") { "src/bat/confirmations/internal/ledger_serve_helper.cc", "src/bat/confirmations/internal/ledger_serve_helper.h", "src/bat/confirmations/internal/logging.h", + "src/bat/confirmations/internal/platform_helper.cc", + "src/bat/confirmations/internal/platform_helper.h", "src/bat/confirmations/internal/payment_info.h", "src/bat/confirmations/internal/payments.cc", "src/bat/confirmations/internal/payments.h", @@ -100,6 +102,41 @@ source_set("bat-native-confirmations") { "src/bat/confirmations/internal/unblinded_tokens.h", ] + if (is_android) { + sources += [ + "src/bat/confirmations/internal/platform_helper_android.cc", + "src/bat/confirmations/internal/platform_helper_android.h", + ] + } + + if (is_linux) { + sources += [ + "src/bat/confirmations/internal/platform_helper_linux.cc", + "src/bat/confirmations/internal/platform_helper_linux.h", + ] + } + + if (is_mac) { + sources += [ + "src/bat/confirmations/internal/platform_helper_mac.mm", + "src/bat/confirmations/internal/platform_helper_mac.h", + ] + } + + if (is_ios) { + sources += [ + "src/bat/confirmations/internal/platform_helper_ios.mm", + "src/bat/confirmations/internal/platform_helper_ios.h", + ] + } + + if (is_win) { + sources += [ + "src/bat/confirmations/internal/platform_helper_win.cc", + "src/bat/confirmations/internal/platform_helper_win.h", + ] + } + public_deps = [ ":challenge_bypass_libs", ] diff --git a/vendor/bat-native-confirmations/include/bat/confirmations/ad_info.h b/vendor/bat-native-confirmations/include/bat/confirmations/ad_info.h index 3acc8c10e3f5..c457c73633b1 100644 --- a/vendor/bat-native-confirmations/include/bat/confirmations/ad_info.h +++ b/vendor/bat-native-confirmations/include/bat/confirmations/ad_info.h @@ -23,6 +23,7 @@ struct CONFIRMATIONS_EXPORT AdInfo { std::string creative_set_id; std::string category; std::string target_url; + std::string geo_target; }; } // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmation_info.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmation_info.h index 02574e594114..bd613db514c8 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmation_info.h +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmation_info.h @@ -34,6 +34,7 @@ struct ConfirmationInfo { BlindedToken blinded_payment_token; std::string credential; uint64_t timestamp_in_seconds; + std::string country_code; bool created; }; diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.cc b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.cc index 116bef93f036..ffe286aefb29 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.cc +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.cc @@ -56,6 +56,10 @@ ConfirmationsImpl::~ConfirmationsImpl() { StopPayingOutRedeemedTokens(); } +ConfirmationsClient* ConfirmationsImpl::get_client() const { + return confirmations_client_; +} + void ConfirmationsImpl::Initialize( OnInitializeCallback callback) { BLOG(INFO) << "Initializing confirmations"; @@ -1143,6 +1147,7 @@ void ConfirmationsImpl::ConfirmAd( << std::endl << " creativeSetId: " << info.creative_set_id << std::endl << " category: " << info.category << std::endl << " targetUrl: " << info.target_url + << std::endl << " geoTarget: " << info.geo_target << std::endl << " confirmationType: " << std::string(confirmation_type); redeem_token_->Redeem(info, confirmation_type); diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.h index 4b5848f73dfc..317f98beb1e5 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.h +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/confirmations_impl.h @@ -33,6 +33,8 @@ class ConfirmationsImpl : public Confirmations { explicit ConfirmationsImpl(ConfirmationsClient* confirmations_client); ~ConfirmationsImpl() override; + ConfirmationsClient* get_client() const; + void Initialize(OnInitializeCallback callback) override; // Wallet diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.cc b/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.cc index 60cde1ac87f1..3209f5e68e08 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.cc +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.cc @@ -8,14 +8,20 @@ #include "bat/confirmations/internal/token_info.h" #include "bat/confirmations/internal/create_confirmation_request.h" #include "bat/confirmations/internal/ads_serve_helper.h" +#include "bat/confirmations/internal/platform_helper.h" #include "bat/confirmations/internal/security_helper.h" +#include "bat/confirmations/internal/static_values.h" #include "base/logging.h" #include "base/json/json_writer.h" #include "base/values.h" namespace confirmations { -CreateConfirmationRequest::CreateConfirmationRequest() = default; +CreateConfirmationRequest::CreateConfirmationRequest( + ConfirmationsImpl* confirmations) + : confirmations_(confirmations) { + DCHECK(confirmations_); +} CreateConfirmationRequest::~CreateConfirmationRequest() = default; @@ -79,6 +85,28 @@ std::string CreateConfirmationRequest::CreateConfirmationRequestDTO( auto type = std::string(info.type); payload.SetKey("type", base::Value(type)); + std::string country_code = info.country_code; + const auto iter = kLargeAnonymityCountryCodes.find(country_code); + if (iter != kLargeAnonymityCountryCodes.end()) { + const bool large_anonymity_country_code = iter->second; + if (large_anonymity_country_code) { + const auto iter = kPrivacyCountryCodes.find(country_code); + if (iter != kPrivacyCountryCodes.end()) { + country_code = "??"; + } + + payload.SetKey("countryCode", base::Value(country_code)); + } + } + + const std::string platform = PlatformHelper::GetInstance()->GetPlatformName(); + if (!platform.empty()) { + payload.SetKey("platform", base::Value(platform)); + } + + const auto client_info = confirmations_->get_client()->GetClientInfo(); + payload.SetKey("channelName", base::Value(client_info->channel)); + std::string json; base::JSONWriter::Write(payload, &json); diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.h index 5d8e4dc56447..87b6bcbd8a13 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.h +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/create_confirmation_request.h @@ -18,12 +18,15 @@ using challenge_bypass_ristretto::BlindedToken; namespace confirmations { +class ConfirmationsImpl; struct ConfirmationInfo; struct TokenInfo; class CreateConfirmationRequest { public: - CreateConfirmationRequest(); + CreateConfirmationRequest( + ConfirmationsImpl* confirmations); + ~CreateConfirmationRequest(); std::string BuildUrl( @@ -46,6 +49,9 @@ class CreateConfirmationRequest { std::string CreateCredential( const TokenInfo& token_info, const std::string& payload) const; + + private: + ConfirmationsImpl* confirmations_; // NOT OWNED }; } // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.cc b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.cc new file mode 100644 index 000000000000..daf5d5707bb4 --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.cc @@ -0,0 +1,44 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "bat/confirmations/internal/platform_helper.h" + +namespace confirmations { + +namespace { +const char kDefaultPlatform[] = ""; +} // namespace + +PlatformHelper* g_platform_helper_for_testing = nullptr; + +PlatformHelper::PlatformHelper() = default; + +PlatformHelper::~PlatformHelper() = default; + +void PlatformHelper::set_for_testing( + PlatformHelper* platform_helper) { + g_platform_helper_for_testing = platform_helper; +} + +std::string PlatformHelper::GetPlatformName() const { + return kDefaultPlatform; +} + +PlatformHelper* PlatformHelper::GetInstance() { + if (g_platform_helper_for_testing) { + return g_platform_helper_for_testing; + } + + return GetInstanceImpl(); +} + +#if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_LINUX) && !defined(OS_ANDROID) && !defined(OS_IOS) // NOLINT +PlatformHelper* PlatformHelper::GetInstanceImpl() { + // Return a default platform helper for unsupported platforms + return base::Singleton::get(); +} +#endif + +} // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.h new file mode 100644 index 000000000000..ab800df474da --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_H_ +#define BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_H_ + +#include + +#include "base/macros.h" +#include "base/memory/singleton.h" +#include "build/build_config.h" + +namespace confirmations { + +class PlatformHelper { + public: + static PlatformHelper* GetInstance(); + + void set_for_testing( + PlatformHelper* platform_helper); + + // Should return the platform + virtual std::string GetPlatformName() const; + + protected: + PlatformHelper(); + virtual ~PlatformHelper(); + + static PlatformHelper* GetInstanceImpl(); + + private: + friend struct base::DefaultSingletonTraits; + DISALLOW_COPY_AND_ASSIGN(PlatformHelper); +}; + +} // namespace confirmations + +#endif // BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_H_ diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.cc b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.cc new file mode 100644 index 000000000000..3db71ddb5ae5 --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.cc @@ -0,0 +1,26 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "bat/confirmations/internal/platform_helper_android.h" + +namespace confirmations { + +PlatformHelperAndroid::PlatformHelperAndroid() = default; + +PlatformHelperAndroid::~PlatformHelperAndroid() = default; + +std::string PlatformHelperAndroid::GetPlatformName() const { + return "android"; +} + +PlatformHelperAndroid* PlatformHelperAndroid::GetInstanceImpl() { + return base::Singleton::get(); +} + +LocaleHelper* LocaleHelper::GetInstanceImpl() { + return LocaleHelperAndroid::GetInstanceImpl(); +} + +} // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.h new file mode 100644 index 000000000000..1debb2c188db --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_android.h @@ -0,0 +1,32 @@ +/* Copyright (c) 202- The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_ANDROID_H_ +#define BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_ANDROID_H_ + +#include + +#include "bat/confirmations/internal/platform_helper.h" + +namespace confirmations { + +class PlatformHelperAndroid : public PlatformHelper { + public: + static PlatformHelperAndroid* GetInstanceImpl(); + + private: + PlatformHelperAndroid() = default; + ~PlatformHelperAndroid() override = default; + + // PlatformHelper impl + std::string GetPlatformName() const override; + + friend struct base::DefaultSingletonTraits; + DISALLOW_COPY_AND_ASSIGN(PlatformHelperAndroid); +}; + +} // namespace confirmations + +#endif // BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_ANDROID_H_ diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.h new file mode 100644 index 000000000000..e1677db246bb --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_IOS_H_ +#define BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_IOS_H_ + +#include + +#include "bat/confirmations/internal/platform_helper.h" + +namespace confirmations { + +class PlatformHelperIOS : public PlatformHelper { + public: + static PlatformHelperIOS* GetInstanceImpl(); + + private: + PlatformHelperIOS() = default; + ~PlatformHelperIOS() override = default; + + // PlatformHelper impl + std::string GetPlatformName() const override; + + friend struct base::DefaultSingletonTraits; + DISALLOW_COPY_AND_ASSIGN(PlatformHelperIOS); +}; + +} // namespace confirmations + +#endif // BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_IOS_H_ diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.mm b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.mm new file mode 100644 index 000000000000..7e8b3dfb3cde --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_ios.mm @@ -0,0 +1,28 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "bat/confirmations/internal/platform_helper_ios.h" + +#import + +namespace confirmations { + +PlatformHelperIOS::PlatformHelperIOS() = default; + +PlatformHelperIOS::~PlatformHelperIOS() = default; + +std::string PlatformHelperIOS::GetPlatformName() const { + return "ios"; +} + +PlatformHelperIOS* PlatformHelperIOS::GetInstanceImpl() { + return base::Singleton::get(); +} + +PlatformHelper* PlatformHelper::GetInstanceImpl() { + return PlatformHelperIOS::GetInstanceImpl(); +} + +} // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.cc b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.cc new file mode 100644 index 000000000000..bb2f6003bc21 --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.cc @@ -0,0 +1,26 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "bat/confirmations/internal/platform_helper_linux.h" + +namespace confirmations { + +PlatformHelperLinux::PlatformHelperLinux() = default; + +PlatformHelperLinux::~PlatformHelperLinux() = default; + +std::string PlatformHelperLinux::GetPlatformName() const { + return "linux"; +} + +PlatformHelperLinux* PlatformHelperLinux::GetInstanceImpl() { + return base::Singleton::get(); +} + +PlatformHelper* PlatformHelper::GetInstanceImpl() { + return PlatformHelperLinux::GetInstanceImpl(); +} + +} // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.h new file mode 100644 index 000000000000..888512268b4f --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_linux.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_H_ +#define BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_H_ + +#include + +#include "bat/confirmations/internal/platform_helper.h" + +namespace confirmations { + +class PlatformHelperLinux : public PlatformHelper { + public: + static PlatformHelperLinux* GetInstanceImpl(); + + private: + PlatformHelperLinux(); + ~PlatformHelperLinux() override; + + // PlatformHelper impl + std::string GetPlatform() const override; + + friend struct base::DefaultSingletonTraits; + DISALLOW_COPY_AND_ASSIGN(PlatformHelperLinux); +}; + +} // namespace confirmations + +#endif // BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_LINUX_H_ diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.h new file mode 100644 index 000000000000..345ba59bcd17 --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_MAC_H_ +#define BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_MAC_H_ + +#include + +#include "bat/confirmations/internal/platform_helper.h" + +namespace confirmations { + +class PlatformHelperMac : public PlatformHelper { + public: + static PlatformHelperMac* GetInstanceImpl(); + + private: + PlatformHelperMac(); + ~PlatformHelperMac() override; + + // PlatformHelper impl + std::string GetPlatformName() const override; + + friend struct base::DefaultSingletonTraits; + DISALLOW_COPY_AND_ASSIGN(PlatformHelperMac); +}; + +} // namespace confirmations + +#endif // BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_MAC_H_ diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.mm b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.mm new file mode 100644 index 000000000000..c242f0a1dadb --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mac.mm @@ -0,0 +1,28 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "bat/confirmations/internal/platform_helper_mac.h" + +#import + +namespace confirmations { + +PlatformHelperMac::PlatformHelperMac() = default; + +PlatformHelperMac::~PlatformHelperMac() = default; + +std::string PlatformHelperMac::GetPlatformName() const { + return "macos"; +} + +PlatformHelperMac* PlatformHelperMac::GetInstanceImpl() { + return base::Singleton::get(); +} + +PlatformHelper* PlatformHelper::GetInstanceImpl() { + return PlatformHelperMac::GetInstanceImpl(); +} + +} // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mock.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mock.h new file mode 100644 index 000000000000..3876e54157c5 --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_mock.h @@ -0,0 +1,30 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_MOCK_H_ +#define BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_MOCK_H_ + +#include + +#include "testing/gmock/include/gmock/gmock.h" + +#include "bat/confirmations/internal/platform_helper.h" + +namespace confirmations { + +class PlatformHelperMock : public PlatformHelper { + public: + PlatformHelperMock(); + ~PlatformHelperMock() override; + + MOCK_CONST_METHOD0(GetPlatformName, std::string()); + + private: + DISALLOW_COPY_AND_ASSIGN(PlatformHelperMock); +}; + +} // namespace confirmations + +#endif // BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_MOCK_H_ diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.cc b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.cc new file mode 100644 index 000000000000..d80c25e397d6 --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.cc @@ -0,0 +1,26 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "bat/confirmations/internal/platform_helper_win.h" + +namespace confirmations { + +PlatformHelperWin::PlatformHelperWin() = default; + +PlatformHelperWin::~PlatformHelperWin() = default; + +std::string PlatformHelperWin::GetPlatformName() const { + return "windows"; +} + +PlatformHelperWin* PlatformHelperWin::GetInstanceImpl() { + return base::Singleton::get(); +} + +PlatformHelper* PlatformHelper::GetInstanceImpl() { + return PlatformHelperWin::GetInstanceImpl(); +} + +} // namespace confirmations diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.h new file mode 100644 index 000000000000..3c43a4aa03e3 --- /dev/null +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/platform_helper_win.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_WIN_H_ +#define BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_WIN_H_ + +#include + +#include "bat/confirmations/internal/platform_helper.h" + +namespace confirmations { + +class PlatformHelperWin : public PlatformHelper { + public: + static PlatformHelperWin* GetInstanceImpl(); + + private: + PlatformHelperWin(); + ~PlatformHelperWin() override; + + // PlatformHelper impl + std::string GetPlatformName() const override; + + friend struct base::DefaultSingletonTraits; + DISALLOW_COPY_AND_ASSIGN(PlatformHelperWin); +}; + +} // namespace confirmations + +#endif // BAT_CONFIRMATIONS_INTERNAL_PLATFORM_HELPER_WIN_H_ diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/redeem_token.cc b/vendor/bat-native-confirmations/src/bat/confirmations/internal/redeem_token.cc index ebd51df7f877..bccb9827f32d 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/redeem_token.cc +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/redeem_token.cc @@ -107,7 +107,7 @@ void RedeemToken::CreateConfirmation( BLOG(INFO) << "CreateConfirmation"; BLOG(INFO) << "POST /v1/confirmation/{confirmation_id}/{credential}"; - CreateConfirmationRequest request; + CreateConfirmationRequest request(confirmations_client_); BLOG(INFO) << "URL Request:"; @@ -150,6 +150,7 @@ void RedeemToken::CreateConfirmation( confirmation_info.creative_instance_id = ad_info.creative_instance_id; confirmation_info.type = confirmation_type; confirmation_info.token_info = token_info; + confirmation_info.country_code = ad_info.geo_target; auto payment_tokens = helper::Security::GenerateTokens(1); confirmation_info.payment_token = payment_tokens.front(); @@ -158,7 +159,7 @@ void RedeemToken::CreateConfirmation( auto blinded_payment_token = blinded_payment_tokens.front(); confirmation_info.blinded_payment_token = blinded_payment_token; - CreateConfirmationRequest request; + CreateConfirmationRequest request(confirmations_client_); auto payload = request.CreateConfirmationRequestDTO(confirmation_info); confirmation_info.credential = request.CreateCredential(token_info, payload); confirmation_info.timestamp_in_seconds = Time::NowInSeconds(); @@ -466,7 +467,7 @@ bool RedeemToken::Verify( auto signature = signature_value->GetString(); auto verification_signature = VerificationSignature::decode_base64(signature); - CreateConfirmationRequest request; + CreateConfirmationRequest request(confirmations_client_); auto payload = request.CreateConfirmationRequestDTO(info); auto unblinded_token = info.token_info.unblinded_token; diff --git a/vendor/bat-native-confirmations/src/bat/confirmations/internal/static_values.h b/vendor/bat-native-confirmations/src/bat/confirmations/internal/static_values.h index 86c0e677a35c..602cda209015 100644 --- a/vendor/bat-native-confirmations/src/bat/confirmations/internal/static_values.h +++ b/vendor/bat-native-confirmations/src/bat/confirmations/internal/static_values.h @@ -7,6 +7,8 @@ #define BAT_CONFIRMATIONS_INTERNAL_STATIC_VALUES_H_ #include +#include +#include #include "base/time/time.h" @@ -35,6 +37,80 @@ const uint64_t kDebugNextTokenRedemptionAfterSeconds = const uint64_t kRetryFailedConfirmationsAfterSeconds = 5 * base::Time::kSecondsPerMinute; +const std::map kLargeAnonymityCountryCodes = { + { "US", true }, // United States of America + { "CA", true }, // Canada + { "GB", true }, // United Kingdom (Great Britain and Northern Ireland) + { "DE", true }, // Germany + { "FR", true }, // France + { "AU", true }, // Australia + { "NZ", true }, // New Zealand + { "IE", true }, // Ireland + { "AR", true }, // Argentina + { "AT", true }, // Austria + { "BR", true }, // Brazil + { "CH", true }, // Switzerland + { "CL", true }, // Chile + { "CO", true }, // Colombia + { "DK", true }, // Denmark + { "EC", true }, // Ecuador + { "IL", true }, // Israel + { "IN", true }, // India + { "IT", true }, // Italy + { "JP", true }, // Japan + { "KR", true }, // Korea + { "MX", true }, // Mexico + { "NL", true }, // Netherlands + { "PE", true }, // Peru + { "PH", true }, // Philippines + { "PL", true }, // Poland + { "SE", true }, // Sweden + { "SG", true }, // Singapore + { "VE", true }, // Venezuela + { "ZA", true }, // South Africa + { "KY", false }, // Cayman Islands + { "AE", true }, // United Arab Emirates + { "AL", true }, // Albania + { "AZ", true }, // Azerbaijan + { "BD", true }, // Bangladesh + { "BE", true }, // Belgium + { "BG", true }, // Bulgaria + { "CN", true }, // China + { "CZ", true }, // Czechia + { "DZ", true }, // Algeria + { "EG", true }, // Egypt + { "ES", true }, // Spain + { "FI", true }, // Finland + { "GR", true }, // Greece + { "HK", true }, // Hong Kong + { "HR", true }, // Croatia + { "HU", true }, // Hungary + { "ID", true }, // Indonesia + { "IQ", true }, // Iraq + { "KH", true }, // Cambodia + { "LT", true }, // Lithuania + { "MA", true }, // Morocco + { "MY", true }, // Malaysia + { "NG", true }, // Nigeria + { "NO", true }, // Norway + { "PK", true }, // Pakistan + { "PT", true }, // Portugal + { "RO", true }, // Romania + { "RS", true }, // Serbia + { "RU", true }, // Russian Federation + { "SA", true }, // Saudi Arabia + { "SI", true }, // Slovenia + { "SK", true }, // Slovakia + { "TH", true }, // Thailand + { "TR", true }, // Turkey + { "TW", true }, // Taiwan + { "UA", true }, // Ukraine + { "VN", true } // Vietnam +}; + +const std::map kPrivacyCountryCodes = { +}; + } // namespace confirmations #endif // BAT_CONFIRMATIONS_INTERNAL_STATIC_VALUES_H_ diff --git a/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom b/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom index 225d548dc55d..1e7c82d4f4ff 100644 --- a/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom +++ b/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom @@ -399,6 +399,7 @@ enum OperatingSystem { struct ClientInfo { Platform platform; OperatingSystem os; + string channel; }; struct RecurringTip { diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc index cc7bd3b7e82a..399140fe7711 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc @@ -1246,6 +1246,7 @@ void LedgerImpl::ConfirmAd( confirmations_ad_info.creative_set_id = ad_info.creative_set_id; confirmations_ad_info.category = ad_info.category; confirmations_ad_info.target_url = ad_info.target_url; + confirmations_ad_info.geo_target = ad_info.geo_target; bat_confirmations_->ConfirmAd(confirmations_ad_info, confirmations::ConfirmationType(confirmation_type)); diff --git a/vendor/brave-ios/Ads/BATAdNotification.h b/vendor/brave-ios/Ads/BATAdNotification.h index 1a6c12578c40..aca50d7b7436 100644 --- a/vendor/brave-ios/Ads/BATAdNotification.h +++ b/vendor/brave-ios/Ads/BATAdNotification.h @@ -28,6 +28,7 @@ NS_SWIFT_NAME(AdsNotification) @property (nonatomic, readonly, copy) NSString *title; @property (nonatomic, readonly, copy) NSString *body; @property (nonatomic, readonly, copy) NSURL *targetURL; +@property (nonatomic, readonly, copy) NSString *geoTarget; @end @interface BATAdNotification (MyFirstAd) diff --git a/vendor/brave-ios/Ads/BATAdNotification.mm b/vendor/brave-ios/Ads/BATAdNotification.mm index 6ec9998a17d0..bf332aa918dd 100644 --- a/vendor/brave-ios/Ads/BATAdNotification.mm +++ b/vendor/brave-ios/Ads/BATAdNotification.mm @@ -15,6 +15,7 @@ @interface BATAdNotification () @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *body; @property (nonatomic, copy) NSURL *targetURL; +@property (nonatomic, copy) NSString *geoTarget; @end @implementation BATAdNotification @@ -30,6 +31,7 @@ - (instancetype)initWithNotificationInfo:(const ads::AdNotificationInfo&)info self.title = [NSString stringWithUTF8String:info.title.c_str()]; self.body = [NSString stringWithUTF8String:info.body.c_str()]; self.targetURL = [NSURL URLWithString:[NSString stringWithUTF8String:info.target_url.c_str()]]; + self.geoTarget = [NSString stringWithUTF8String:info.geo_target.c_str()]; } return self; }