diff --git a/browser/importer/brave_profile_writer.cc b/browser/importer/brave_profile_writer.cc index 8eb13580c3af..e193588c2745 100644 --- a/browser/importer/brave_profile_writer.cc +++ b/browser/importer/brave_profile_writer.cc @@ -90,8 +90,14 @@ void BraveProfileWriter::UpdateLedger(const BraveLedger& ledger) { return; } - // TODO: set the values that were read in the importer - // ... + // Set the preferences read from session-store-1 + auto* payments = &ledger.settings.payments; + rewards_service->SetPublisherAllowVideos(payments->allow_media_publishers); + rewards_service->SetPublisherAllowNonVerified(payments->allow_non_verified); + rewards_service->SetAutoContribute(payments->enabled); + rewards_service->SetContributionAmount(payments->contribution_amount); + rewards_service->SetPublisherMinVisitTime(payments->min_visit_time); + rewards_service->SetPublisherMinVisits(payments->min_visits); // TODO: register observer which can handle the work // that needs to happen AFTER RecoverWallet (StuffThatHappensAfterRecover) diff --git a/common/importer/brave_ledger.h b/common/importer/brave_ledger.h index 8753a5af2686..55faa84ffb97 100644 --- a/common/importer/brave_ledger.h +++ b/common/importer/brave_ledger.h @@ -24,8 +24,8 @@ struct BraveLedger { bool allow_media_publishers; bool allow_non_verified; bool enabled; - uint64_t min_publisher_duration; - unsigned int contribution_amount; + double contribution_amount; + uint64_t min_visit_time; unsigned int min_visits; } payments; } settings; diff --git a/utility/importer/brave_importer.cc b/utility/importer/brave_importer.cc index 6a14ae748b9b..7df429c320a9 100644 --- a/utility/importer/brave_importer.cc +++ b/utility/importer/brave_importer.cc @@ -403,6 +403,14 @@ bool ParsePaymentsPreferences(BraveLedger& ledger, const base::Value& session_st TryFindBoolKey(settings, "payments.allow-non-verified-publishers", payments->allow_non_verified); TryFindBoolKey(settings, "payments.allow-media-publishers", payments->allow_media_publishers); + std::string contribution_amount = ""; + TryFindStringKey(settings, "payments.contribution-amount", contribution_amount); + if (!contribution_amount.empty()) { + if (!base::StringToDouble(contribution_amount, &payments->contribution_amount)) { + LOG(ERROR) << "StringToDouble failed when converting \"settings.payments.contribution-amount\"; unable to convert value \"" << contribution_amount << "\"; defaulting value."; + } + } + std::string minimum_visits = ""; TryFindStringKey(settings, "payments.minimum-visits", minimum_visits); if (!minimum_visits.empty()) { @@ -422,42 +430,25 @@ bool ParsePaymentsPreferences(BraveLedger& ledger, const base::Value& session_st } std::string minumum_visit_time = ""; - TryFindStringKey(settings, "payments.minimum-visit-time",minumum_visit_time); + TryFindStringKey(settings, "payments.minimum-visit-time", minumum_visit_time); if (!minumum_visit_time.empty()) { - if (!base::StringToUint64(minumum_visit_time, &payments->min_publisher_duration)) { + if (!base::StringToUint64(minumum_visit_time, &payments->min_visit_time)) { LOG(ERROR) << "StringToUint64 failed when converting \"settings.payments.minimum-visit-time\"; unable to convert value \"" << minumum_visit_time << "\"; defaulting value."; } } - switch (payments->min_publisher_duration) { + switch (payments->min_visit_time) { // allowed values - case 5000: - case 8000: - case 60000: - break; + case 5000: payments->min_visit_time = 5; break; + case 8000: payments->min_visit_time = 8; break; + case 60000: payments->min_visit_time = 60; break; default: - payments->min_publisher_duration = braveledger_ledger::_default_min_publisher_duration; - } - - std::string contribution_amount = ""; - TryFindStringKey(settings, "payments.contribution-amount", contribution_amount); - if (!contribution_amount.empty()) { - if (!base::StringToUint(contribution_amount, &payments->contribution_amount)) { - LOG(ERROR) << "StringToUint failed when converting \"settings.payments.contribution-amount\"; unable to convert value \"" << contribution_amount << "\"; defaulting value."; - } + payments->min_visit_time = braveledger_ledger::_default_min_publisher_duration; } // TODO: read in excluded sites // ... - LOG(ERROR) << "BSC]] " - << "\npayments->allow_media_publishers=" << payments->allow_media_publishers - << "\npayments->allow_non_verified=" << payments->allow_non_verified - << "\npayments->enabled=" << payments->enabled - << "\npayments->min_publisher_duration=" << payments->min_publisher_duration - << "\npayments->contribution_amount=" << payments->contribution_amount - << "\npayments->min_visits=" << payments->min_visits; - return true; }