"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/bat-native-ads/src/bat/ads/internal/account/account.cc" between
brave-core-1.30.89.tar.gz and brave-core-1.31.87.tar.gz

About: brave-core is the core engine for Brave, a "next generation" Chromium-based web browser. It tries to block ads and website trackers but displays optionally privacy-respecting advertisements to earn BAT tokens which can be spent to preferred publishers. Release channel.

account.cc  (brave-core-1.30.89):account.cc  (brave-core-1.31.87)
/* Copyright (c) 2020 The Brave Authors. All rights reserved. /* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public * 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, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "bat/ads/internal/account/account.h" #include "bat/ads/internal/account/account.h"
#include "base/check.h"
#include "bat/ads/ads_client.h"
#include "bat/ads/internal/account/ad_rewards/ad_rewards.h" #include "bat/ads/internal/account/ad_rewards/ad_rewards.h"
#include "bat/ads/internal/account/ad_rewards/ad_rewards_util.h" #include "bat/ads/internal/account/ad_rewards/ad_rewards_util.h"
#include "bat/ads/internal/account/confirmations/confirmation_info.h" #include "bat/ads/internal/account/confirmations/confirmation_info.h"
#include "bat/ads/internal/account/confirmations/confirmations.h" #include "bat/ads/internal/account/confirmations/confirmations.h"
#include "bat/ads/internal/account/confirmations/confirmations_state.h"
#include "bat/ads/internal/account/statement/statement.h" #include "bat/ads/internal/account/statement/statement.h"
#include "bat/ads/internal/account/transactions/transactions.h" #include "bat/ads/internal/account/transactions/transactions.h"
#include "bat/ads/internal/account/wallet/wallet.h" #include "bat/ads/internal/account/wallet/wallet.h"
#include "bat/ads/internal/account/wallet/wallet_info.h" #include "bat/ads/internal/account/wallet/wallet_info.h"
#include "bat/ads/internal/ads_client_helper.h"
#include "bat/ads/internal/logging.h" #include "bat/ads/internal/logging.h"
#include "bat/ads/internal/privacy/tokens/token_generator_interface.h" #include "bat/ads/internal/privacy/tokens/token_generator_interface.h"
#include "bat/ads/internal/privacy/unblinded_tokens/unblinded_tokens.h" #include "bat/ads/internal/privacy/unblinded_tokens/unblinded_tokens.h"
#include "bat/ads/internal/tokens/redeem_unblinded_payment_tokens/redeem_unblind ed_payment_tokens.h" #include "bat/ads/internal/tokens/redeem_unblinded_payment_tokens/redeem_unblind ed_payment_tokens.h"
#include "bat/ads/internal/tokens/refill_unblinded_tokens/refill_unblinded_token s.h" #include "bat/ads/internal/tokens/refill_unblinded_tokens/refill_unblinded_token s.h"
#include "bat/ads/statement_info.h"
namespace ads { namespace ads {
Account::Account(privacy::TokenGeneratorInterface* token_generator) Account::Account(privacy::TokenGeneratorInterface* token_generator)
: token_generator_(token_generator), : ad_rewards_(std::make_unique<AdRewards>()),
ad_rewards_(std::make_unique<AdRewards>()),
confirmations_( confirmations_(
std::make_unique<Confirmations>(token_generator, ad_rewards_.get())), std::make_unique<Confirmations>(token_generator, ad_rewards_.get())),
redeem_unblinded_payment_tokens_( redeem_unblinded_payment_tokens_(
std::make_unique<RedeemUnblindedPaymentTokens>()), std::make_unique<RedeemUnblindedPaymentTokens>()),
refill_unblinded_tokens_( refill_unblinded_tokens_(
std::make_unique<RefillUnblindedTokens>(token_generator)), std::make_unique<RefillUnblindedTokens>(token_generator)),
statement_(std::make_unique<Statement>(ad_rewards_.get())), statement_(std::make_unique<Statement>(ad_rewards_.get())),
wallet_(std::make_unique<Wallet>()) { wallet_(std::make_unique<Wallet>()) {
DCHECK(token_generator_);
confirmations_->AddObserver(this); confirmations_->AddObserver(this);
ad_rewards_->set_delegate(this); ad_rewards_->set_delegate(this);
redeem_unblinded_payment_tokens_->set_delegate(this); redeem_unblinded_payment_tokens_->set_delegate(this);
refill_unblinded_tokens_->set_delegate(this);
} }
Account::~Account() { Account::~Account() {
confirmations_->RemoveObserver(this); confirmations_->RemoveObserver(this);
ad_rewards_->set_delegate(nullptr);
redeem_unblinded_payment_tokens_->set_delegate(nullptr);
} }
void Account::AddObserver(AccountObserver* observer) { void Account::AddObserver(AccountObserver* observer) {
DCHECK(observer); DCHECK(observer);
observers_.AddObserver(observer); observers_.AddObserver(observer);
} }
void Account::RemoveObserver(AccountObserver* observer) { void Account::RemoveObserver(AccountObserver* observer) {
DCHECK(observer); DCHECK(observer);
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
skipping to change at line 91 skipping to change at line 92
return wallet_->Get(); return wallet_->Get();
} }
void Account::SetCatalogIssuers(const CatalogIssuersInfo& catalog_issuers) { void Account::SetCatalogIssuers(const CatalogIssuersInfo& catalog_issuers) {
confirmations_->SetCatalogIssuers(catalog_issuers); confirmations_->SetCatalogIssuers(catalog_issuers);
NotifyCatalogIssuersDidChange(catalog_issuers); NotifyCatalogIssuersDidChange(catalog_issuers);
} }
void Account::Deposit(const std::string& creative_instance_id, void Account::Deposit(const std::string& creative_instance_id,
const ConfirmationType& confirmation_type) { const ConfirmationType& confirmation_type) {
confirmations_->ConfirmAd(creative_instance_id, confirmation_type); confirmations_->Confirm(creative_instance_id, confirmation_type);
} }
StatementInfo Account::GetStatement(const int64_t from_timestamp, StatementInfo Account::GetStatement(const int64_t from_timestamp,
const int64_t to_timestamp) const { const int64_t to_timestamp) const {
DCHECK(to_timestamp >= from_timestamp); DCHECK(to_timestamp >= from_timestamp);
return statement_->Get(from_timestamp, to_timestamp); return statement_->Get(from_timestamp, to_timestamp);
} }
void Account::Reconcile() { void Account::Reconcile() {
if (!ShouldRewardUser()) { if (!ShouldRewardUser()) {
skipping to change at line 166 skipping to change at line 167
observer.OnCatalogIssuersDidChange(catalog_issuers); observer.OnCatalogIssuersDidChange(catalog_issuers);
} }
} }
void Account::NotifyStatementOfAccountsDidChange() const { void Account::NotifyStatementOfAccountsDidChange() const {
for (AccountObserver& observer : observers_) { for (AccountObserver& observer : observers_) {
observer.OnStatementOfAccountsDidChange(); observer.OnStatementOfAccountsDidChange();
} }
} }
void Account::OnConfirmAd(const double estimated_redemption_value, void Account::OnDidConfirm(const double estimated_redemption_value,
const ConfirmationInfo& confirmation) { const ConfirmationInfo& confirmation) {
transactions::Add(estimated_redemption_value, confirmation); transactions::Add(estimated_redemption_value, confirmation);
NotifyStatementOfAccountsDidChange(); NotifyStatementOfAccountsDidChange();
TopUpUnblindedTokens(); TopUpUnblindedTokens();
} }
void Account::OnConfirmAdFailed(const ConfirmationInfo& confirmation) { void Account::OnFailedToConfirm(const ConfirmationInfo& confirmation) {
TopUpUnblindedTokens(); TopUpUnblindedTokens();
confirmations_->RetryAfterDelay(); confirmations_->RetryAfterDelay();
} }
void Account::OnDidReconcileAdRewards() { void Account::OnDidReconcileAdRewards() {
NotifyStatementOfAccountsDidChange(); NotifyStatementOfAccountsDidChange();
} }
void Account::OnDidRedeemUnblindedPaymentTokens( void Account::OnDidRedeemUnblindedPaymentTokens(
skipping to change at line 202 skipping to change at line 203
} }
void Account::OnFailedToRedeemUnblindedPaymentTokens() { void Account::OnFailedToRedeemUnblindedPaymentTokens() {
BLOG(1, "Failed to redeem unblinded payment tokens"); BLOG(1, "Failed to redeem unblinded payment tokens");
} }
void Account::OnDidRetryRedeemingUnblindedPaymentTokens() { void Account::OnDidRetryRedeemingUnblindedPaymentTokens() {
BLOG(1, "Retry redeeming unblinded payment tokens"); BLOG(1, "Retry redeeming unblinded payment tokens");
} }
void Account::OnDidRefillUnblindedTokens() {
BLOG(1, "Successfully refilled unblinded tokens");
AdsClientHelper::Get()->ClearScheduledCaptcha();
}
void Account::OnCaptchaRequiredToRefillUnblindedTokens(
const std::string& captcha_id) {
BLOG(1, "Captcha required to refill unblinded tokens");
const WalletInfo wallet = GetWallet();
AdsClientHelper::Get()->ShowScheduledCaptchaNotification(wallet.id,
captcha_id);
}
} // namespace ads } // namespace ads
 End of changes. 12 change blocks. 
10 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)