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

WIP: Rewards data can now be cleared #1187

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 37 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,43 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_SETTINGS_BRAVE_ON_EXIT" desc="Clear Browsing Data dialog On exit tab label">
On exit
</message>
<!-- Clear Rewards Browsing Data -->
<message name="IDS_CLEAR_REWARDS_AUTO_CONTRIBUTE" desc="Clear Brave Rewards Auto-Contribute Label.">
Brave Rewards Auto-Contribute Data
</message>
<message name="IDS_CLEAR_REWARDS_ALL" desc="Clear All Brave Rewards Label.">
All Brave Rewards Data
</message>
<message name="IDS_CLEAR_REWARDS_ALL_DESCRIPTION" desc="Clear All Brave Rewards Description.">
Clears All Brave Rewards Data
</message>
<message name="IDS_REWARDS_CONTRIBUTION_IN_PROGRESS" desc="The subtext used for autocontribute when a contribution is in progress">
A contribution is in progress. Rewards data cannot be cleared at this time.
</message>
<message name="IDS_DEL_REWARDS_COUNTER" desc="A counter showing how many sites is in current autocontribute list.">
{COUNT, plural,
=0 {None }
=1 {1 site }
other {# sites }}
</message>
<message name="IDS_DEL_REWARDS_COUNTER_LAST_DATE_TEXT" desc="Text to follow after number of sites.">
since your last contribution on <ph name="DATE">$1<ex>1/22/1111</ex></ph>
</message>
<message name="IDS_CLEAR_ALL_REWARDS_WARNING" desc="Warning message shown in modal when user selects Clear All Rewards to warn of the permanent loss of data">
This action cannot be undone. All transaction history and reports will no longer be available. Please note that Brave does not store a copy of your data on our servers, so deleting this data from your browser is final.
</message>
<message name="IDS_CLEAR_REWARDS_DATA" desc="Warning message shown in modal when user selects Clear All Rewards to warn of the permanent loss of data">
Clear Brave Rewards data
</message>
<message name="IDS_CLEAR_REWARDS_DATA_DESCRIPTION" desc="Warning message shown in modal when user selects Clear All Rewards to warn of the permanent loss of data">
Clear Auto-Contribute history or clear all Rewards data.
</message>
<message name="IDS_CLEAR_REWARDS_DATA_SECONDARY" desc="Warning message shown in modal when user selects Clear All Rewards to warn of the permanent loss of data">
secondary
</message>
<message name="IDS_CLEAR_REWARDS_CONTRIBUTION_IN_PROGRESS" desc="Message that displays on the Clear Rewards dialog when a contribution is in progress">
A Brave Rewards contribution is currently in progress. Rewards data cannot be cleared at this time.
</message>
</messages>
<includes>
<include name="IDR_BRAVE_TAG_SERVICES_POLYFILL" file="resources/js/tag_services_polyfill.js" type="BINDATA" />
Expand Down
5 changes: 5 additions & 0 deletions browser/extensions/api/settings_private/brave_prefs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "brave/browser/extensions/api/settings_private/brave_prefs_util.h"

#include "brave/common/pref_names.h"
#include "brave/components/brave_rewards/common/pref_names.h"
#include "chrome/browser/extensions/api/settings_private/prefs_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/extensions/api/settings_private.h"
Expand Down Expand Up @@ -78,6 +79,10 @@ const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetWhitelistedKeys() {
// Hangouts pref
(*s_brave_whitelist)[kHangoutsEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_brave_whitelist)[brave_rewards::prefs::kRewardsAutoContributeSites] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_brave_whitelist)[brave_rewards::prefs::kRewardsAllData] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
return *s_brave_whitelist;
}

Expand Down
7 changes: 4 additions & 3 deletions browser/profiles/brave_profile_manager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* 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 http://mozilla.org/MPL/2.0/. */
// Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/.

#ifndef BRAVE_BROWSER_PROFILES_BRAVE_PROFILE_MANAGER_H_
#define BRAVE_BROWSER_PROFILES_BRAVE_PROFILE_MANAGER_H_
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
jasonrsadler marked this conversation as resolved.
Show resolved Hide resolved
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="brave_clear_rewards_data_dialog_browser_proxy.html">
<link rel="import" href="../controls/settings_checkbox.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="../settings_vars_css.html">

<dom-module id="settings-brave-clear-rewards-data-dialog">
<template>
<style include="settings-shared">
:host {
--body-container-height: 122px;
/* origin CBD height is 322px */
}

#clearRewardsDataDialog {
--cr-dialog-top-container-min-height: 42px;
--cr-dialog-title: {
padding-bottom: 8px;
};
--cr-dialog-body-container: {
border-top: 1px solid var(--paper-grey-300);
height: var(--body-container-height);
};
}

#clearRewardsDataDialog [slot=body] {
padding-top: 8px;
}

.row {
align-items: center;
display: flex;
min-height: 40px;
}

paper-spinner-lite {
margin-bottom: auto;
margin-inline-end: 16px;
margin-top: auto;
}

settings-checkbox {
--settings-row-two-line-min-height: 48px;
--settings-checkbox-label: {
line-height: 1.25rem;
}
}

[slot=title] .secondary {
font-size: calc(13 / 15 * 100%);
padding-top: 8px;
}

.divider {
border-top: var(--settings-separator-line);
margin: 0 16px;
}
</style>
<cr-dialog id="confirmClearRewardsDataDialog"
close-text="$i18n{close}" ignore-popstate>
<div slot="title">
<div>Clear Rewards Data</div>
</div>
<div slot="body">
$i18n{clearAllRewardsWarning}
</div>
<div slot="button-container">
<paper-button class="cancel-button"
on-click="onCancelTap_">$i18n{cancel}
</paper-button>
<paper-button id="clearRewardsDataConfirm"
class="warn action-button" on-click="clearRewardsData_">
$i18n{clearData}
</paper-button>
</div>
</cr-dialog>
<cr-dialog id="clearRewardsDataDialog"
close-text="$i18n{close}" ignore-popstate>
<div slot="title">
<div>$i18n{rewardsPageTitle}</div>
</div>
<div slot="body">
<div id="rewardsData">
<settings-checkbox id="rewardsAutoContribute"
pref="{{prefs.brave.clear_data.rewards_autocontribute}}"
label="$i18n{clearRewardsAutoContribute}"
sub-label="[[counters_.rewards_autocontribute]]"
disabled="[[autoContributeDisabled_]]">
</settings-checkbox>
<settings-checkbox id="rewardsAllData"
pref="{{prefs.brave.clear_data.rewards_all_data}}"
label="$i18n{clearAllRewardsData}"
sub-label="$i18n{clearAllRewardsDataDescription}"
disabled="[[clearingInProgress_]]">
</settings-checkbox>
</div>
</div>
<div slot="button-container">
<paper-spinner-lite active="[[showSpinner_]]">
</paper-spinner-lite>
jasonrsadler marked this conversation as resolved.
Show resolved Hide resolved
<paper-button class="cancel-button" disabled="[[cancelButtonDisabled_]]"
on-click="onCancelTap_">$i18n{cancel}</paper-button>
<paper-button id="clearRewardsDataConfirm"
class="action-button" on-click="clearRewardsData_"
disabled="[[isClearButtonDisabled_(clearingInProgress_,
clearButtonDisabled_)]]">
$i18n{clearData}
</paper-button>
</div>
<div slot="footer"
hidden="[[!shouldShowFooter_]]">
<div id="footer-description">
<span id="contribution-in-progress" hidden="[[!shouldShowFooter_]]">
$i18nRaw{rewardsContributionInProgress}
</span>
</div>
</div>
</cr-dialog>
</template>
<script src="brave_clear_rewards_data_dialog.js"></script>
</dom-module>
Loading