-
Notifications
You must be signed in to change notification settings - Fork 908
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
1,937 additions
and
1,098 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...nents/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_event_type_util.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/components/brave_ads/core/public/ad_units/new_tab_page_ad/new_tab_page_ad_event_type_util.h" | ||
|
||
#include "base/containers/fixed_flat_map.h" | ||
#include "brave/components/brave_ads/core/mojom/brave_ads.mojom.h" | ||
|
||
namespace brave_ads { | ||
|
||
namespace { | ||
|
||
constexpr char kServedImpressionType[] = "served"; | ||
constexpr char kViewedImpressionType[] = "view"; | ||
constexpr char kClickedType[] = "click"; | ||
constexpr char kInteractionType[] = "interaction"; | ||
constexpr char kMediaPlayType[] = "media_play"; | ||
constexpr char kMedia25Type[] = "media_25"; | ||
constexpr char kMedia50Type[] = "media_50"; | ||
constexpr char kMedia75Type[] = "media_75"; | ||
constexpr char kMedia100Type[] = "media_100"; | ||
|
||
constexpr auto kNewTabPageAdEventTypeMap = | ||
base::MakeFixedFlatMap<std::string, mojom::NewTabPageAdEventType>({ | ||
{kServedImpressionType, | ||
mojom::NewTabPageAdEventType::kServedImpression}, | ||
{kViewedImpressionType, | ||
mojom::NewTabPageAdEventType::kViewedImpression}, | ||
{kClickedType, mojom::NewTabPageAdEventType::kClicked}, | ||
{kInteractionType, mojom::NewTabPageAdEventType::kInteraction}, | ||
{kMediaPlayType, mojom::NewTabPageAdEventType::kMediaPlay}, | ||
{kMedia25Type, mojom::NewTabPageAdEventType::kMedia25}, | ||
{kMedia50Type, mojom::NewTabPageAdEventType::kMedia50}, | ||
{kMedia75Type, mojom::NewTabPageAdEventType::kMedia75}, | ||
{kMedia100Type, brave_ads::mojom::NewTabPageAdEventType::kMedia100}, | ||
}); | ||
|
||
} // namespace | ||
|
||
std::optional<brave_ads::mojom::NewTabPageAdEventType> | ||
ToMojomNewTabPageAdEventType(const std::string& event_type) { | ||
const auto iter = kNewTabPageAdEventTypeMap.find(event_type); | ||
if (iter == kNewTabPageAdEventTypeMap.cend()) { | ||
return std::nullopt; | ||
} | ||
|
||
return iter->second; | ||
} | ||
|
||
std::string FromMojomNewTabPageAdEventType( | ||
const brave_ads::mojom::NewTabPageAdEventType& event_type) { | ||
switch (event_type) { | ||
case brave_ads::mojom::NewTabPageAdEventType::kServedImpression: | ||
return kServedImpressionType; | ||
case brave_ads::mojom::NewTabPageAdEventType::kViewedImpression: | ||
return kViewedImpressionType; | ||
case brave_ads::mojom::NewTabPageAdEventType::kClicked: | ||
return kClickedType; | ||
case brave_ads::mojom::NewTabPageAdEventType::kInteraction: | ||
return kInteractionType; | ||
case brave_ads::mojom::NewTabPageAdEventType::kMediaPlay: | ||
return kMediaPlayType; | ||
case brave_ads::mojom::NewTabPageAdEventType::kMedia25: | ||
return kMedia25Type; | ||
case brave_ads::mojom::NewTabPageAdEventType::kMedia50: | ||
return kMedia50Type; | ||
case brave_ads::mojom::NewTabPageAdEventType::kMedia75: | ||
return kMedia75Type; | ||
case brave_ads::mojom::NewTabPageAdEventType::kMedia100: | ||
return kMedia100Type; | ||
} | ||
} | ||
|
||
} // namespace brave_ads |
Oops, something went wrong.