File tree 2 files changed +54
-0
lines changed
vendor/bat-native-ads/src/bat/ads/internal
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,11 @@ std::unique_ptr<BundleState> Bundle::GenerateFromCatalog(
136
136
ad_info.notification_url = creative.payload .target_url ;
137
137
ad_info.uuid = creative.creative_instance_id ;
138
138
139
+ // OSes
140
+ if (!DoesOsSupportCreativeSet (creative_set)) {
141
+ continue ;
142
+ }
143
+
139
144
// Segments
140
145
for (const auto & segment : creative_set.segments ) {
141
146
auto segment_name = base::ToLowerASCII (segment.name );
@@ -188,6 +193,50 @@ std::unique_ptr<BundleState> Bundle::GenerateFromCatalog(
188
193
return state;
189
194
}
190
195
196
+ bool Bundle::DoesOsSupportCreativeSet (
197
+ const CreativeSetInfo& creative_set) {
198
+ if (creative_set.oses .empty ()) {
199
+ // Creative set supports all OSes
200
+ return true ;
201
+ }
202
+
203
+ const std::string client_os = GetClientOS ();
204
+ for (const auto & os : creative_set.oses ) {
205
+ if (os.name == client_os) {
206
+ return true ;
207
+ }
208
+ }
209
+
210
+ return false ;
211
+ }
212
+
213
+ std::string Bundle::GetClientOS () {
214
+ ClientInfo client_info;
215
+ ads_client_->GetClientInfo (&client_info);
216
+
217
+ switch (client_info.platform ) {
218
+ case UNKNOWN: {
219
+ NOTREACHED ();
220
+ return " " ;
221
+ }
222
+ case WINDOWS: {
223
+ return " windows" ;
224
+ }
225
+ case MACOS: {
226
+ return " macos" ;
227
+ }
228
+ case IOS: {
229
+ return " ios" ;
230
+ }
231
+ case ANDROID_OS: {
232
+ return " android" ;
233
+ }
234
+ case LINUX: {
235
+ return " linux" ;
236
+ }
237
+ }
238
+ }
239
+
191
240
void Bundle::OnStateSaved (
192
241
const std::string& catalog_id,
193
242
const uint64_t & catalog_version,
Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ class Bundle {
38
38
private:
39
39
std::unique_ptr<BundleState> GenerateFromCatalog (const Catalog& catalog);
40
40
41
+ bool DoesOsSupportCreativeSet (
42
+ const CreativeSetInfo& creative_set);
43
+
44
+ std::string GetClientOS ();
45
+
41
46
void SaveState ();
42
47
void OnStateSaved (
43
48
const std::string& catalog_id,
You can’t perform that action at this time.
0 commit comments