Skip to content
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

Ad matching for ads that are not categorized #3158

Merged
merged 5 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/brave_ads/browser/ads_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class AdsService : public KeyedService {
// ads::Ads proxy
virtual void SetConfirmationsIsReady(const bool is_ready) = 0;
virtual void ChangeLocale(const std::string& locale) = 0;
virtual void ClassifyPage(
virtual void OnPageLoaded(
const std::string& url,
const std::string& page) = 0;
const std::string& html) = 0;
virtual void OnMediaStart(SessionID tab_id) = 0;
virtual void OnMediaStop(SessionID tab_id) = 0;
virtual void OnTabUpdated(
Expand Down
10 changes: 6 additions & 4 deletions components/brave_ads/browser/ads_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1360,12 +1360,14 @@ void AdsServiceImpl::ChangeLocale(const std::string& locale) {
bat_ads_->ChangeLocale(locale);
}

void AdsServiceImpl::ClassifyPage(const std::string& url,
const std::string& page) {
if (!connected())
void AdsServiceImpl::OnPageLoaded(
const std::string& url,
const std::string& html) {
if (!connected()) {
return;
}

bat_ads_->ClassifyPage(url, page);
bat_ads_->OnPageLoaded(url, html);
}

int AdsServiceImpl::GetIdleThreshold() {
Expand Down
2 changes: 1 addition & 1 deletion components/brave_ads/browser/ads_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AdsServiceImpl : public AdsService,

void SetConfirmationsIsReady(const bool is_ready) override;
void ChangeLocale(const std::string& locale) override;
void ClassifyPage(const std::string& url, const std::string& page) override;
void OnPageLoaded(const std::string& url, const std::string& html) override;
void OnMediaStart(SessionID tab_id) override;
void OnMediaStop(SessionID tab_id) override;
void OnTabUpdated(
Expand Down
2 changes: 1 addition & 1 deletion components/brave_ads/browser/ads_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void AdsTabHelper::OnWebContentsDistillationDone(
distiller_result->has_distilled_content() &&
distiller_result->has_markup_info() &&
distiller_result->distilled_content().has_html()) {
ads_service_->ClassifyPage(url.spec(),
ads_service_->OnPageLoaded(url.spec(),
distiller_result->distilled_content().html());
} else {
// TODO(bridiver) - fall back to web_contents()->GenerateMHTML or ignore?
Expand Down
6 changes: 3 additions & 3 deletions components/services/bat_ads/bat_ads_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ void BatAdsImpl::ChangeLocale(const std::string& locale) {
ads_->ChangeLocale(locale);
}

void BatAdsImpl::ClassifyPage(
void BatAdsImpl::OnPageLoaded(
const std::string& url,
const std::string& page) {
ads_->ClassifyPage(url, page);
const std::string& html) {
ads_->OnPageLoaded(url, html);
}

void BatAdsImpl::ServeSampleAd() {
Expand Down
2 changes: 1 addition & 1 deletion components/services/bat_ads/bat_ads_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BatAdsImpl :
void Shutdown(ShutdownCallback callback) override;
void SetConfirmationsIsReady(const bool is_ready) override;
void ChangeLocale(const std::string& locale) override;
void ClassifyPage(const std::string& url, const std::string& page) override;
void OnPageLoaded(const std::string& url, const std::string& html) override;
void ServeSampleAd() override;
void OnTimer(const uint32_t timer_id) override;
void OnUnIdle() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ interface BatAds {
Shutdown() => (int32 result);
SetConfirmationsIsReady(bool is_ready);
ChangeLocale(string locale);
ClassifyPage(string url, string page);
OnPageLoaded(string url, string html);
ServeSampleAd();
OnTimer(uint32 timer_id);
OnUnIdle();
Expand Down
4 changes: 2 additions & 2 deletions vendor/bat-native-ads/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ void ChangeLocale(
const std::string& locale)
```

`ClassifyPage` should be called when a page has loaded in the current browser tab, and the HTML is available for analysis
`OnPageLoaded` should be called when a page has loaded in the current browser tab, and the HTML is available for analysis
```
void ClassifyPage(
void OnPageLoaded(
const std::string& url,
const std::string& html)
```
Expand Down
2 changes: 1 addition & 1 deletion vendor/bat-native-ads/include/bat/ads/ads.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ADS_EXPORT Ads {

// Should be called when a page has loaded in the current browser tab, and the
// HTML is available for analysis
virtual void ClassifyPage(
virtual void OnPageLoaded(
const std::string& url,
const std::string& html) = 0;

Expand Down
19 changes: 5 additions & 14 deletions vendor/bat-native-ads/src/bat/ads/ads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "bat/ads/internal/ads_impl.h"
#include "bat/ads/internal/locale_helper.h"
#include "bat/ads/internal/static_values.h"

namespace ads {

Expand All @@ -25,20 +26,10 @@ Ads* Ads::CreateInstance(AdsClient* ads_client) {
}

bool Ads::IsSupportedRegion(const std::string& locale) {
auto region = helper::Locale::GetCountryCode(locale);

std::vector<std::string> regions = {
"US", // United States of America
"CA", // Canada
"GB", // United Kingdom (Great Britain and Northern Ireland)
"DE", // Germany
"FR", // France
"AU", // Australia
"NZ", // New Zealand
"IE" // Ireland
};

if (std::find(regions.begin(), regions.end(), region) == regions.end()) {
auto region = GetRegion(locale);

auto it = kSupportedRegions.find(region);
if (it == kSupportedRegions.end()) {
return false;
}

Expand Down
Loading