Skip to content

Commit

Permalink
Merge pull request #1013 from brave/revert-957-monthly-amount-dropdown
Browse files Browse the repository at this point in the history
Revert "Adds functionality to monthly contribution dropdown (Panel)"
  • Loading branch information
bbondy committed Dec 4, 2018
2 parents 78b0533 + 13e54e6 commit f77acbe
Show file tree
Hide file tree
Showing 22 changed files with 18 additions and 344 deletions.
39 changes: 0 additions & 39 deletions browser/extensions/api/brave_rewards_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,44 +138,5 @@ ExtensionFunction::ResponseAction BraveRewardsGetGrantFunction::Run() {
return RespondNow(NoArguments());
}

BraveRewardsSaveRecurringDonationFunction::~BraveRewardsSaveRecurringDonationFunction() {
}

ExtensionFunction::ResponseAction
BraveRewardsSaveRecurringDonationFunction::Run() {

std::unique_ptr<brave_rewards::SaveRecurringDonation::Params> params(
brave_rewards::SaveRecurringDonation::Params::Create(*args_));

Profile* profile = Profile::FromBrowserContext(browser_context());
RewardsService* rewards_service_ = RewardsServiceFactory::GetForProfile(profile);

if (rewards_service_) {
rewards_service_->AddRecurringPayment(params->publisher_key, params->new_amount);
}

return RespondNow(NoArguments());
}

BraveRewardsRemoveRecurringDonationFunction::~BraveRewardsRemoveRecurringDonationFunction() {
}

ExtensionFunction::ResponseAction
BraveRewardsRemoveRecurringDonationFunction::Run() {

std::unique_ptr<brave_rewards::RemoveRecurringDonation::Params> params(
brave_rewards::RemoveRecurringDonation::Params::Create(*args_));

Profile* profile = Profile::FromBrowserContext(browser_context());
RewardsService* rewards_service_ = RewardsServiceFactory::GetForProfile(profile);

if (rewards_service_) {
rewards_service_->RemoveRecurring(params->publisher_key);
}

return RespondNow(NoArguments());
}


} // namespace api
} // namespace extensions
20 changes: 0 additions & 20 deletions browser/extensions/api/brave_rewards_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,6 @@ class BraveRewardsGetGrantFunction : public UIThreadExtensionFunction {
ResponseAction Run() override;
};

class BraveRewardsSaveRecurringDonationFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveRewards.saveRecurringDonation", UNKNOWN)

protected:
~BraveRewardsSaveRecurringDonationFunction() override;

ResponseAction Run() override;
};

class BraveRewardsRemoveRecurringDonationFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveRewards.removeRecurringDonation", UNKNOWN)

protected:
~BraveRewardsRemoveRecurringDonationFunction() override;

ResponseAction Run() override;
};

} // namespace api
} // namespace extensions

Expand Down
37 changes: 0 additions & 37 deletions common/extensions/api/brave_rewards.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,6 @@
}
}
]
},
{
"name": "onRecurringDonations",
"type": "function",
"description": "",
"parameters": [
{
"name": "result",
"type": "any"
}
]
}
],
"functions": [
Expand Down Expand Up @@ -267,32 +256,6 @@
"type": "function",
"description": "Retrieves grant when panel is mounted",
"parameters": []
},
{
"name": "saveRecurringDonation",
"type": "function",
"description": "Updates recurring donation amount for rewards panel",
"parameters": [
{
"name": "publisher_key",
"type": "string"
},
{
"name": "new_amount",
"type": "integer"
}
]
},
{
"name": "removeRecurringDonation",
"type": "function",
"description": "Removes recurring donation for rewards panel",
"parameters": [
{
"name": "publisher_key",
"type": "string"
}
]
}
]
}
Expand Down
2 changes: 0 additions & 2 deletions components/brave_rewards/browser/content_site.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace brave_rewards {
percentage(0),
verified(false),
excluded(0),
weight(0),
reconcile_stamp(0) {
}

Expand All @@ -27,7 +26,6 @@ namespace brave_rewards {
url = properties.url;
provider = properties.provider;
id = properties.id;
weight = properties.weight;
reconcile_stamp = properties.reconcile_stamp;
}

Expand Down
1 change: 0 additions & 1 deletion components/brave_rewards/browser/content_site.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct ContentSite {
std::string favicon_url;
std::string url;
std::string provider;
double weight;
uint64_t reconcile_stamp;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/components/brave_rewards/browser/extension_rewards_service_observer.h"

#include "brave/common/extensions/api/brave_rewards.h"
#include "brave/components/brave_rewards/browser/rewards_service.h"
#include "chrome/browser/profiles/profile.h"
Expand Down Expand Up @@ -139,37 +140,4 @@ void ExtensionRewardsServiceObserver::OnGetPublisherActivityFromUrl(
event_router->BroadcastEvent(std::move(event));
}

void ExtensionRewardsServiceObserver::OnRecurringDonations(
RewardsService* rewards_service,
brave_rewards::ContentSiteList list) {
extensions::EventRouter* event_router = extensions::EventRouter::Get(profile_);
if (!event_router) {
return;
}

base::DictionaryValue result;
auto recurringDonations = std::make_unique<base::ListValue>();

if (!list.empty()) {
for (auto const& item: list) {
auto recurringDonation = std::make_unique<base::DictionaryValue>();
recurringDonation->SetString("publisherKey", item.id);
recurringDonation->SetInteger("amount", item.weight);
recurringDonations->Append(std::move(recurringDonation));
}
}

result.SetList("recurringDonations", std::move(recurringDonations));

std::unique_ptr<base::ListValue> args(
extensions::api::brave_rewards::OnRecurringDonations::Create(result)
.release());

std::unique_ptr<extensions::Event> event(new extensions::Event(
extensions::events::BRAVE_START,
extensions::api::brave_rewards::OnRecurringDonations::kEventName,
std::move(args)));
event_router->BroadcastEvent(std::move(event));
}

} // namespace brave_rewards
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "base/macros.h"
#include "brave/components/brave_rewards/browser/rewards_service_observer.h"
#include "brave/components/brave_rewards/browser/content_site.h"
#include "brave/components/brave_rewards/browser/rewards_service_private_observer.h"

class Profile;
Expand Down Expand Up @@ -41,8 +40,6 @@ class ExtensionRewardsServiceObserver : public RewardsServiceObserver,
std::unique_ptr<ledger::PublisherInfo> info,
uint64_t windowId) override;

void OnRecurringDonations(RewardsService* rewards_service,
brave_rewards::ContentSiteList) override;
private:
Profile* profile_;

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion components/brave_rewards/browser/rewards_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class RewardsService : public KeyedService {
virtual void OnDonate(const std::string& publisher_key, int amount,
bool recurring, std::unique_ptr<brave_rewards::ContentSite> site) = 0;
virtual void RemoveRecurring(const std::string& publisher_key) = 0;
virtual void AddRecurringPayment(const std::string& publisher_key, double new_amount) = 0;
virtual void UpdateRecurringDonationsList() = 0;
virtual void UpdateTipsList() = 0;
virtual void SetContributionAutoInclude(
Expand Down
18 changes: 0 additions & 18 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ ContentSite PublisherInfoToContentSite(
content_site.provider = publisher_info.provider;
content_site.favicon_url = publisher_info.favicon_url;
content_site.id = publisher_info.id;
content_site.weight = publisher_info.weight;
content_site.reconcile_stamp = publisher_info.reconcile_stamp;
return content_site;
}
Expand Down Expand Up @@ -1521,19 +1520,6 @@ ledger::PublisherInfoList GetRecurringDonationsOnFileTaskRunner(PublisherInfoDat
void RewardsServiceImpl::OnRecurringDonationsData(const ledger::PublisherInfoListCallback callback,
const ledger::PublisherInfoList list) {
callback(list, 0);

// Incoming ledger::PublisherInfoList needs to be converted to brave_rewards::ContentSiteList
brave_rewards::ContentSiteList site_list;
for (auto& info : list) {
site_list.push_back(PublisherInfoToContentSite(info));
}

TriggerOnRecurringDonations(site_list);
}

void RewardsServiceImpl::TriggerOnRecurringDonations(brave_rewards::ContentSiteList list) {
for (auto& observer : observers_)
observer.OnRecurringDonations(this, list);
}

void RewardsServiceImpl::GetRecurringDonations(ledger::PublisherInfoListCallback callback) {
Expand Down Expand Up @@ -1594,10 +1580,6 @@ void RewardsServiceImpl::OnTipsUpdatedData(const ledger::PublisherInfoList list)
}
}

void RewardsServiceImpl::AddRecurringPayment(const std::string& publisher_key, double new_amount) {
SaveRecurringDonation(publisher_key, new_amount);
}

void RewardsServiceImpl::RemoveRecurring(const std::string& publisher_key) {
ledger_->RemoveRecurring(publisher_key);
}
Expand Down
2 changes: 0 additions & 2 deletions components/brave_rewards/browser/rewards_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class RewardsServiceImpl : public RewardsService,
void RemoveRecurring(const std::string& publisher_key) override;
void UpdateRecurringDonationsList() override;
void UpdateTipsList() override;
void AddRecurringPayment(const std::string& publisher_key, double new_amount) override;
void SetContributionAutoInclude(
std::string publisher_key, bool excluded, uint64_t windowId) override;
RewardsNotificationService* GetNotificationService() const override;
Expand Down Expand Up @@ -198,7 +197,6 @@ class RewardsServiceImpl : public RewardsService,
ledger::Result result,
std::unique_ptr<ledger::PublisherInfo> info,
uint64_t windowId);
void TriggerOnRecurringDonations(brave_rewards::ContentSiteList);

// ledger::LedgerClient
std::string GenerateGUID() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class MockRewardsServiceObserver : public RewardsServiceObserver {
MOCK_METHOD2(OnCurrentTips, void(RewardsService*, brave_rewards::ContentSiteList));
MOCK_METHOD2(OnPublisherBanner, void(RewardsService*, const brave_rewards::PublisherBanner));
MOCK_METHOD4(OnGetPublisherActivityFromUrl, void(RewardsService*, int, ledger::PublisherInfo*, uint64_t));
MOCK_METHOD2(OnRecurringDonations, void(brave_rewards::RewardsService*, const ledger::PublisherInfoList*));
};

class RewardsServiceTest : public testing::Test {
Expand Down
3 changes: 0 additions & 3 deletions components/brave_rewards/browser/rewards_service_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ class RewardsServiceObserver : public base::CheckedObserver {
brave_rewards::ContentSiteList) {};
virtual void OnPublisherBanner(brave_rewards::RewardsService* rewards_service,
const brave_rewards::PublisherBanner banner) {};
virtual void OnRecurringDonations(
brave_rewards::RewardsService* rewards_service,
brave_rewards::ContentSiteList) {};
};

} // namespace brave_rewards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,3 @@ export const includeInAutoContribution = (publisherKey: string, excluded: boolea
})

export const getGrant = () => action(types.GET_GRANT, {})

export const saveRecurringDonation = (publisherKey: string, newAmount: number) => action(types.SAVE_RECURRING_DONATION, {
publisherKey,
newAmount
})

export const removeRecurringContribution = (publisherKey: string) => action(types.REMOVE_RECURRING_DONATION, {
publisherKey
})

export const getRecurringDonations = () => action(types.GET_RECURRING_DONATIONS)

export const onRecurringDonations = (result: RewardsExtension.RecurringDonation) => action(types.ON_RECURRING_DONATIONS, {
result
})
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ chrome.rewardsNotifications.onNotificationAdded.addListener((id: string, type: n
chrome.rewardsNotifications.onNotificationDeleted.addListener((id: string, type: number, timestamp: number) => {
rewardsPanelActions.onNotificationDeleted(id, type, timestamp)
})

chrome.braveRewards.onRecurringDonations.addListener((result: RewardsExtension.RecurringDonation) => {
rewardsPanelActions.onRecurringDonations(result)
})
Loading

0 comments on commit f77acbe

Please sign in to comment.