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

Email aliases implementation #27127

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions app/brave_command_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@

#define IDC_SHOW_APPS_PAGE 56352

#define IDC_SHOW_EMAIL_ALIASES 56353
#define IDC_NEW_EMAIL_ALIAS 56354

#define IDC_BRAVE_COMMANDS_LAST 57000

#endif // BRAVE_APP_BRAVE_COMMAND_IDS_H_
8 changes: 8 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
<message name="IDS_BRAVE_PERMISSIONS_BUBBLE_PROMPT" desc="The label that is used to introduce permission request details to the user in a popup.">
<ph name="SITE_NAME">$1<ex>google.com</ex></ph> is asking you to
</message>
<message name="IDS_SHOW_EMAIL_ALIASES" desc="The show Email Aliases menu in the app menu">
Email Aliases
</message>

<!-- Autoplay -->
<message name="IDS_BLOCKED_AUTOPLAY_TITLE" desc="Tooltip and bubble info header text when a page is not allowed to autoplay media.">
Expand Down Expand Up @@ -351,6 +354,11 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
Block elements
</message>

<!-- Adblock contenxt menu -->
<message name="IDS_NEW_EMAIL_ALIAS" desc="Message for context menu that enables the Email Alias generator UI for the page">
New Email Alias
</message>

<message name="IDS_LOCATION_BAR_ONION_AVAILABLE" desc="Button in location bar to indicate onion available site to open a new tab in tor window.">
.onion
</message>
Expand Down
104 changes: 104 additions & 0 deletions app/brave_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,117 @@
</if>

<!-- Settings / Autofill -->
<message name="IDS_SETTINGS_EMAIL_ALIASES_LABEL" desc="The label to show the Email Aliases page">
Email Aliases
</message>
<message name="IDS_SETTINGS_BRAVE_AUTOFILL_PRIVATE_WINDOWS_LABEL" desc="The label to enable autofill in private profiles">
Allow auto-fill in private windows
</message>
<message name="IDS_SETTINGS_BRAVE_AUTOFILL_PRIVATE_WINDOWS_DESC" desc="The description for the label to enable autofill in private profiles">
Info from regular windows can be read/auto-filled in private windows
</message>

<!-- Settings / Email Aliases -->
<message name="IDS_SETTINGS_EMAIL_ALIASES_SHORT_DESCRIPTION" desc="The short description for the Email Aliases page">
Keep your personal email address private
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_DESCRIPTION" desc="The description for the Email Aliases page">
Create unique, random addresses that forward to your Brave account email and can be deleted at any time. Keep your actual email address from being disclosed or used by advertisers.
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_LEARN_MORE" desc="The label for the learn more link">
Learn more
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_SIGN_OUT" desc="The label for the sign out link">
Sign out
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_SIGN_OUT_TITLE" desc="The title for the sign out link">
Sign out of Email Aliases
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CONNECTING_TO_BRAVE_ACCOUNT" desc="The label for the connecting to Brave Account">
Connecting to Brave Account...
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_BRAVE_ACCOUNT" desc="The label for the Brave Account">
Brave Account
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_COPIED_TO_CLIPBOARD" desc="The label for the copied to clipboard">
Copied to clipboard
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CLICK_TO_COPY_ALIAS" desc="The label for the click to copy alias">
Click to copy alias
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_USED_BY" desc="The label for the used by">
Used by <ph name="DOMAINS">$1<ex>example.com, example.org</ex></ph>
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_EDIT" desc="The label for the edit link">
Edit
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_DELETE" desc="The label for the delete link">
Delete
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CREATE_DESCRIPTION" desc="The description for the create email alias">
Create up to 5 free email aliases to protect your real email address.
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_LIST_TITLE" desc="The title for the email alias list">
Your email aliases
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CREATE_ALIAS_TITLE" desc="The title for the create alias">
Create a new alias email
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CREATE_ALIAS_LABEL" desc="The label for the create alias">
New alias
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_REFRESH_BUTTON_TITLE" desc="The title for the refresh button">
Suggest another email alias
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_NOTE_LABEL" desc="The label for the note">
Note
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_EDIT_NOTE_PLACEHOLDER" desc="The placeholder for the edit note">
Enter a note for your address (optional)
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CANCEL_BUTTON" desc="The label for the cancel button">
Cancel
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_ALIAS_LABEL" desc="The label for the alias">
Email alias
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_EMAILS_WILL_BE_FORWARDED_TO" desc="The label explaining where emails will be forwarded">
Emails will be forwarded to <ph name="MAIN_EMAIL">$1<ex>[email protected]</ex></ph>
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_EDIT_ALIAS_TITLE" desc="The title for the edit alias">
Edit email alias
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CREATE_ALIAS_BUTTON" desc="The label for the create alias button">
Create
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_SAVE_ALIAS_BUTTON" desc="The label for the save alias button">
Save
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_SIGN_IN_OR_CREATE_ACCOUNT" desc="The label for the sign in or create account">
To get started, sign in or create a Brave account
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_ENTER_EMAIL_TO_GET_LOGIN_LINK" desc="The label for the enter email to get login link">
Enter your email address to get a secure login link sent to your email. Clicking this link will either create or access a Brave Account and let you use the free Email Aliases service.
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_GET_LOGIN_LINK_BUTTON" desc="The label for the get login link button">
Get login link
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_EMAIL_ADDRESS_PLACEHOLDER" desc="The placeholder for the email address">
Email address
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_LOGIN_EMAIL_ON_THE_WAY" desc="The label for the login email on the way">
A login email is on the way to <ph name="MAIN_EMAIL">$1<ex>[email protected]</ex></ph>
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_CLICK_ON_SECURE_LOGIN" desc="The label for the click on secure login">
Click on the secure login link in the email to access your account.
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_DONT_SEE_EMAIL" desc="The label for the don't see email">
Don't see the email? Check your spam folder or
</message>
<message name="IDS_SETTINGS_EMAIL_ALIASES_TRY_AGAIN" desc="The label for the try again">
try again.
</message>

<!-- Settings / New tab page -->
<message name="IDS_SETTINGS_NEW_TAB" desc="The text label for the New Tab settings page">
New Tab Page
Expand Down
1 change: 1 addition & 0 deletions app/generate_command_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
"IDC_NEW_TOR_CONNECTION_FOR_SITE": "IDS_NEW_TOR_CONNECTION_FOR_SITE",
"IDC_NEW_OFFTHERECORD_WINDOW_TOR": "IDS_NEW_OFFTHERECORD_WINDOW_TOR",
"IDC_SHOW_BRAVE_SYNC": "IDS_SHOW_BRAVE_SYNC",
"IDC_SHOW_EMAIL_ALIASES": "IDS_SHOW_EMAIL_ALIASES",
"IDC_SHOW_BRAVE_WALLET": "IDS_SHOW_BRAVE_WALLET",
"IDC_SHOW_BRAVE_WEBCOMPAT_REPORTER": "IDS_SHOW_BRAVE_WEBCOMPAT_REPORTER",
"IDC_WINDOW_CLOSE_TABS_TO_LEFT": "IDS_TAB_CXMENU_CLOSETABSTOLEFT",
Expand Down
8 changes: 8 additions & 0 deletions browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,14 @@
"corners, padding, and a drop shadow", \
kOsWin | kOsLinux | kOsMac, \
FEATURE_VALUE_TYPE(features::kBraveWebViewRoundedCorners), \
}, \
{ \
"brave-email-aliases", \
"Enable Email Aliases", \
"Enables the Email Aliases feature, which allows you to hide your " \
"real email address behind an alias email address.", \
kOsWin | kOsLinux | kOsMac, \
FEATURE_VALUE_TYPE(features::kBraveEmailAliases), \
}) \
BRAVE_NATIVE_WALLET_FEATURE_ENTRIES \
BRAVE_NEWS_FEATURE_ENTRIES \
Expand Down
4 changes: 4 additions & 0 deletions browser/brave_browser_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ BASE_FEATURE(kNewAndroidOnboarding,
base::FEATURE_DISABLED_BY_DEFAULT);
#endif // BUILDFLAG(IS_ANDROID)

BASE_FEATURE(kBraveEmailAliases,
"BraveEmailAliases",
base::FEATURE_DISABLED_BY_DEFAULT);

// The variant of the "day zero" experiment. i.e. A, B, C, D, etc.
const base::FeatureParam<std::string> kBraveDayZeroExperimentVariant{
&kBraveDayZeroExperiment,
Expand Down
1 change: 1 addition & 0 deletions browser/brave_browser_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ BASE_DECLARE_FEATURE(kBraveDayZeroExperiment);
#if BUILDFLAG(IS_ANDROID)
BASE_DECLARE_FEATURE(kNewAndroidOnboarding);
#endif // BUILDFLAG(IS_ANDROID)
BASE_DECLARE_FEATURE(kBraveEmailAliases);

extern const base::FeatureParam<std::string> kBraveDayZeroExperimentVariant;

Expand Down
1 change: 1 addition & 0 deletions browser/brave_local_state_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "brave/components/brave_wallet/browser/brave_wallet_prefs.h"
#include "brave/components/constants/pref_names.h"
#include "brave/components/decentralized_dns/core/utils.h"
#include "brave/components/email_aliases/browser/email_aliases_prefs.h"
#include "brave/components/l10n/common/prefs.h"
#include "brave/components/misc_metrics/general_browser_usage.h"
#include "brave/components/misc_metrics/page_metrics.h"
Expand Down
3 changes: 3 additions & 0 deletions browser/brave_profile_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "brave/components/constants/pref_names.h"
#include "brave/components/de_amp/common/pref_names.h"
#include "brave/components/debounce/core/browser/debounce_service.h"
#include "brave/components/email_aliases/browser/email_aliases_prefs.h"
#include "brave/components/ipfs/ipfs_prefs.h"
#include "brave/components/ntp_background_images/browser/view_counter_service.h"
#include "brave/components/ntp_background_images/buildflags/buildflags.h"
Expand Down Expand Up @@ -493,6 +494,8 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
base::Value(false));

webcompat_reporter::prefs::RegisterProfilePrefs(registry);

email_aliases::RegisterProfilePrefs(registry);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the use of these prefs here for? I'm curious if you think it would be useful to integrity protect them to prevent filesystem tampering here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

} // namespace brave
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ export class BraveSettingsAutofillPageElement extends RouteObserverMixin(BaseEle
override currentRouteChanged(newRoute: Route) {
this.isAutofillPage_ = newRoute == Router.getInstance().getRoutes().AUTOFILL
}

private onEmailAliasesClicked_() {
const router = Router.getInstance()
router.navigateTo((router.getRoutes() as any).EMAIL_ALIASES)
}
}
39 changes: 35 additions & 4 deletions browser/resources/settings/brave_overrides/autofill_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

import {html, RegisterPolymerTemplateModifications, RegisterPolymerComponentReplacement} from 'chrome://resources/brave/polymer_overriding.js'
import {BraveSettingsAutofillPageElement} from '../brave_autofill_page/brave_autofill_page.js'
import {loadTimeData} from '../i18n_setup.js'
import {
html,
RegisterPolymerTemplateModifications,
RegisterPolymerComponentReplacement,
} from 'chrome://resources/brave/polymer_overriding.js'
import { BraveSettingsAutofillPageElement } from '../brave_autofill_page/brave_autofill_page.js'
import { loadTimeData } from '../i18n_setup.js'

import '../email_aliases_page/email_aliases_page.js'

RegisterPolymerComponentReplacement(
'settings-autofill-page', BraveSettingsAutofillPageElement
)


RegisterPolymerTemplateModifications({
'settings-autofill-page': (templateContent) => {
const isEmailAliasesFeatureEnabled = loadTimeData.getBoolean('isEmailAliasesFeatureEnabled')
if (isEmailAliasesFeatureEnabled) {
const parentManagerButton = templateContent.getElementById('paymentManagerButton')
parentManagerButton.parentNode.insertBefore(html`
<cr-link-row id="emailAliasesButton"
start-icon="email-shield"
label="${loadTimeData.getString('emailAliasesLabel')}"
on-click="onEmailAliasesClicked_"
role-description="$i18n{subpageArrowRoleDescription}"></cr-link-row>
`, parentManagerButton)
}
templateContent.appendChild(html`
<settings-toggle-button
class="hr"
Expand All @@ -23,6 +41,19 @@ RegisterPolymerTemplateModifications({
hidden=[[!isAutofillPage_]]
</settings-toggle-button>
`)
if (isEmailAliasesFeatureEnabled) {
const pages = templateContent.getElementById('pages')
pages.appendChild(html`
<template is="dom-if" route-path="/email-aliases">
<settings-subpage
associated-control="[[$$('#paymentManagerButton')]]"
page-title="${loadTimeData.getString('emailAliasesLabel')}"
learn-more-url="$i18n{addressesAndPaymentMethodsLearnMoreURL}">
<settings-email-aliases-page id="emailAliasesSection" prefs="{{prefs}}" />
</settings-subpage>
</template>
`)
}
}
},
}
)
14 changes: 14 additions & 0 deletions browser/resources/settings/brave_overrides/site_settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,20 @@ RegisterPolymerComponentReplacement(
}
lists_.permissionsAdvanced.splice(currentIndex, 0, solanaItem)
}
const isEmailAliasesEnabled = loadTimeData.getBoolean('isEmailAliasesFeatureEnabled')
if (isEmailAliasesEnabled) {
currentIndex++
const emailAliasesItem = {
route: routes.EMAIL_ALIASES,
id: 'braveEmailAliases',
label: 'siteSettingsEmailAliases',
icon: 'product-email-aliases',
enabledLabel: 'siteSettingsEmailAliasesAsk',
disabledLabel: 'siteSettingsEmailAliasesBlock'
}
lists_.permissionsAdvanced.splice(currentIndex, 0,
emailAliasesItem)
}
}
}
lists_.shieldsBasic = [
Expand Down
6 changes: 6 additions & 0 deletions browser/resources/settings/brave_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export default function addBraveRoutes(r: Partial<SettingsRoutes>) {
} else if (!isGuest) {
console.error('[Brave Settings Overrides] Could not move autofill route to advanced route', r)
}

const isEmailAliasesFeatureEnabled = loadTimeData.getBoolean('isEmailAliasesFeatureEnabled')
if (isEmailAliasesFeatureEnabled) {
r.EMAIL_ALIASES = r.AUTOFILL.createChild('/email-aliases')
}

// Delete performance menu - system menu includes it instead.
if (r.PERFORMANCE) {
delete r.PERFORMANCE
Expand Down
22 changes: 22 additions & 0 deletions browser/resources/settings/email_aliases_page/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2025 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 https://mozilla.org/MPL/2.0/.

import("//brave/components/common/typescript.gni")

transpile_web_ui("email_aliases_ui") {
entry_points = [ [
"email_aliases",
rebase_path("email_aliases.tsx"),
] ]

resource_name = "email_aliases"
}

pack_web_resources("generated_resources") {
resource_name = "email_aliases"
output_dir =
"$root_gen_dir/brave/browser/resources/settings/email_aliases_page"
deps = [ ":email_aliases_ui" ]
}
Loading
Loading