Skip to content

Commit

Permalink
[Sync] Add an option in setting page to Enable/Enter Custom Sync Url.
Browse files Browse the repository at this point in the history
  • Loading branch information
jagadeshjai committed Sep 7, 2024
1 parent 29a2752 commit cd1714c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 11 deletions.
6 changes: 6 additions & 0 deletions app/brave_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@
<message name="IDS_SETTINGS_BRAVE_SYNC_COULD_NOT_SYNC_ACTION_LABEL" desc="Could not sync devices action label. It is displayed in the case when Brave Sync could not decrypt code words and start work">
Could not sync Brave on your devices
</message>
<message name="IDS_SETTINGS_BRAVE_CUSTOM_SYNC_URL_ENABLE_LABEL" desc="Label for setting to en/disable Custom sync url feature">
Enable custom sync url
</message>
<message name="IDS_SETTINGS_ENTER_CUSTOM_SYNC_URL" desc="Input label for a custom sync url">
Enter custom sync url
</message>
<message name="IDS_SETTINGS_BRAVE_SYNC_MANAGER_TITLE" desc="Brave Sync manager title">
Sync Manager
</message>
Expand Down
1 change: 1 addition & 0 deletions browser/brave_profile_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(kTabMuteIndicatorNotClickable, false);

brave_sync::Prefs::RegisterProfilePrefs(registry);
registry->RegisterBooleanPref(kBraveCustomSyncUrlEnabled, false);

brave_shields::RegisterShieldsP3AProfilePrefs(registry);

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 @@ -225,6 +225,11 @@ const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetAllowlistedKeys() {
(*s_brave_allowlist)[kAlwaysShowBookmarkBarOnNTP] =
settings_api::PrefType::kBoolean;
(*s_brave_allowlist)[kMRUCyclingEnabled] = settings_api::PrefType::kBoolean;

// Sync prefs
(*s_brave_allowlist)[kBraveCustomSyncUrlEnabled] =
settings_api::PrefType::kBoolean;

// WebTorrent pref
(*s_brave_allowlist)[kWebTorrentEnabled] = settings_api::PrefType::kBoolean;
#if BUILDFLAG(ENABLE_BRAVE_WAYBACK_MACHINE)
Expand Down
21 changes: 20 additions & 1 deletion browser/resources/settings/brave_sync_page/brave_sync_page.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<style include="settings-shared iron-flex">
cr-input {
width: 100%;
--cr-input-width: 50%;
margin-top: 10px;
margin-left: 20px;
}

cr-input::part(row-container) {
justify-content: normal;
}
</style>
<settings-animated-pages id="pages" section="braveSync">
<div route-path="default">
Expand All @@ -17,6 +27,15 @@
sync-status="[[syncStatus_]]">
</settings-brave-sync-subpage>
</settings-subpage>

</template>
</settings-animated-pages>


<settings-toggle-button id="customSyncUrlEnabled"
class="hr"
pref="{{prefs.brave.custom_sync_url_enabled}}"
label="$i18n{braveCustomSyncUrlEnableLabel}">
</settings-toggle-button>
<template is="dom-if" if="[[prefs.brave.custom_sync_url_enabled.value]]">
<cr-input id="customSyncUrl" value="{{customSyncUrl_}}" placeholder="$i18n{enterCustomSyncUrl}" spellcheck="false"></cr-input>
</template>
25 changes: 15 additions & 10 deletions browser/resources/settings/brave_sync_page/brave_sync_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
* You can obtain one at https://mozilla.org/MPL/2.0/. */

import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.js';
import '/shared/settings/prefs/prefs.js';
import 'chrome://resources/cr_elements/icons.html.js';
import '../settings_page/settings_animated_pages.js';
import '../settings_page/settings_subpage.js';
import '../settings_shared.css.js';
import '../settings_vars.css.js';
import './brave_sync_subpage.js';
import 'chrome://resources/cr_elements/cr_input/cr_input.js';

import {SyncBrowserProxy, SyncBrowserProxyImpl, SyncPrefs} from '/shared/settings/people_page/sync_browser_proxy.js';
import {I18nMixin, I18nMixinInterface} from 'chrome://resources/cr_elements/i18n_mixin.js'
import {WebUiListenerMixin, WebUiListenerMixinInterface} from 'chrome://resources/cr_elements/web_ui_listener_mixin.js';
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {BaseMixin} from '../base_mixin.js'
import {Route, Router} from '../router.js';
import { I18nMixin, I18nMixinInterface } from 'chrome://resources/cr_elements/i18n_mixin.js';
import { WebUiListenerMixin, WebUiListenerMixinInterface } from 'chrome://resources/cr_elements/web_ui_listener_mixin.js';
import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import { SyncBrowserProxy, SyncBrowserProxyImpl, SyncPrefs } from '/shared/settings/people_page/sync_browser_proxy.js';
import { PrefsMixin, PrefsMixinInterface } from '/shared/settings/prefs/prefs_mixin.js';

import {BraveSyncBrowserProxy, BraveSyncStatus} from './brave_sync_browser_proxy.js';
import {getTemplate} from './brave_sync_page.html.js'
import { BaseMixin } from '../base_mixin.js';
import { Route, Router } from '../router.js';

import { BraveSyncBrowserProxy, BraveSyncStatus } from './brave_sync_browser_proxy.js';
import { getTemplate } from './brave_sync_page.html.js';

/**
* @fileoverview
Expand All @@ -29,8 +33,8 @@ import {getTemplate} from './brave_sync_page.html.js'
*/

const SettingsBraveSyncPageElementBase =
I18nMixin(WebUiListenerMixin(BaseMixin(PolymerElement))) as {
new(): PolymerElement & WebUiListenerMixinInterface & I18nMixinInterface
I18nMixin(WebUiListenerMixin(PrefsMixin(BaseMixin(PolymerElement)))) as {
new(): PolymerElement & PrefsMixinInterface & WebUiListenerMixinInterface & I18nMixinInterface
}

export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBase {
Expand All @@ -57,6 +61,7 @@ export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBa
type: String,
computed: 'computeSyncLabel_(syncStatus_)'
},
customSyncUrl_: String,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_BRAVE_SYNC_MANAGE_ACTION_LABEL},
{"braveSyncCouldNotSyncActionLabel",
IDS_SETTINGS_BRAVE_SYNC_COULD_NOT_SYNC_ACTION_LABEL},
{"braveCustomSyncUrlEnableLabel",
IDS_SETTINGS_BRAVE_CUSTOM_SYNC_URL_ENABLE_LABEL},
{"enterCustomSyncUrl", IDS_SETTINGS_ENTER_CUSTOM_SYNC_URL},
{"enterCustomSyncUrl", IDS_SETTINGS_ENTER_CUSTOM_SYNC_URL},
{"braveSyncWordCount", IDS_SETTINGS_BRAVE_SYNC_WORD_COUNT},
{"braveSyncCopied", IDS_SETTINGS_BRAVE_SYNC_COPIED_TEXT},
{"braveSyncQRCodeAlt", IDS_SETTINGS_BRAVE_SYNC_QR_IMAGE_ALT},
Expand Down
3 changes: 3 additions & 0 deletions components/constants/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@ inline constexpr char kBraveSuggestedSiteSuggestionsEnabled[] =
"brave.brave_suggested_site_suggestions_enabled";
#endif

inline constexpr char kBraveCustomSyncUrlEnabled[] =
"brave.custom_sync_url_enabled";

#endif // BRAVE_COMPONENTS_CONSTANTS_PREF_NAMES_H_

0 comments on commit cd1714c

Please sign in to comment.