+
+
-
+
-
+
-
-
- $i18n{restart}
-
-
-
-
-
-
+
diff --git a/browser/resources/settings/brave_sync_page/brave_sync_page.ts b/browser/resources/settings/brave_sync_page/brave_sync_page.ts
index 072e130da19a..2f3110b4e7a6 100644
--- a/browser/resources/settings/brave_sync_page/brave_sync_page.ts
+++ b/browser/resources/settings/brave_sync_page/brave_sync_page.ts
@@ -21,7 +21,6 @@ import { SyncBrowserProxy, SyncBrowserProxyImpl, SyncPrefs } from '/shared/setti
import { PrefsMixin } from '/shared/settings/prefs/prefs_mixin.js';
import { BaseMixin } from '../base_mixin.js';
-import { RelaunchMixin, RestartType } from '../relaunch_mixin.js';
import { Route, Router } from '../router.js';
import { BraveSyncBrowserProxy, BraveSyncStatus } from './brave_sync_browser_proxy.js';
@@ -34,8 +33,8 @@ import { getTemplate } from './brave_sync_page.html.js';
*/
const SettingsBraveSyncPageElementBase =
- RelaunchMixin(PrefsMixin(I18nMixin(
- WebUiListenerMixin((BaseMixin(PolymerElement))))));
+ PrefsMixin(I18nMixin(
+ WebUiListenerMixin((BaseMixin(PolymerElement)))));
export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBase {
static get is() {
@@ -122,19 +121,6 @@ export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBa
}
}
}
-
- private shouldShowRestart_(enabled: boolean, url: string): boolean {
- const proxy = BraveSyncBrowserProxy.getInstance();
- return enabled !== proxy.wasCustomSyncUrlEnabledAtStartup() ||
- proxy.getCustomSyncUrlAtStartup() !== url;
- }
-
- private onRestartClick_(e: Event) {
- // Prevent event from bubbling up to the toggle button.
- e.stopPropagation();
- this.performRestart(RestartType.RESTART);
- }
-
}
customElements.define(
diff --git a/browser/resources/settings/brave_sync_page/sync_url_input.html b/browser/resources/settings/brave_sync_page/sync_url_input.html
index e9b565e9a4ff..b6823bc3062a 100644
--- a/browser/resources/settings/brave_sync_page/sync_url_input.html
+++ b/browser/resources/settings/brave_sync_page/sync_url_input.html
@@ -1,28 +1,63 @@
-
-
+
diff --git a/browser/resources/settings/brave_sync_page/sync_url_input.ts b/browser/resources/settings/brave_sync_page/sync_url_input.ts
index 7d874db90989..f337b83632e3 100644
--- a/browser/resources/settings/brave_sync_page/sync_url_input.ts
+++ b/browser/resources/settings/brave_sync_page/sync_url_input.ts
@@ -3,42 +3,51 @@
* 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/. */
-
/**
- * @fileoverview `sync-url-input` is a single-line text field that is used
- * for setting up custom sync server url. It is based on
+ * @fileoverview `sync-url-input` is a single-line text field with title
+ * that is used for setting up custom sync server url. It is based on
* `home-url-input`.
*/
-import 'chrome://resources/cr_elements/cr_textarea/cr_textarea.js';
-import '/shared/settings/prefs/prefs.js';
+import 'chrome://resources/cr_elements/cr_textarea/cr_textarea.js'
+import '/shared/settings/prefs/prefs.js'
+
+import type { CrInputElement } from 'chrome://resources/cr_elements/cr_input/cr_input.js'
+import type { CrPolicyPrefMixinInterface } from '/shared/settings/controls/cr_policy_pref_mixin.js'
-import type { CrInputElement } from 'chrome://resources/cr_elements/cr_input/cr_input.js';
-import { assert } from 'chrome://resources/js/assert.js';
-import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
-import { PrefControlMixin } from '/shared/settings/controls/pref_control_mixin.js';
-import { PrefsMixin, PrefsMixinInterface } from '/shared/settings/prefs/prefs_mixin.js';
+import { assert } from 'chrome://resources/js/assert.js'
+import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'
+import { PrefControlMixin } from '/shared/settings/controls/pref_control_mixin.js'
+import { PrefsMixin } from '/shared/settings/prefs/prefs_mixin.js'
+import { CrPolicyPrefMixin } from '/shared/settings/controls/cr_policy_pref_mixin.js'
+import {
+ RelaunchMixin,
+ RelaunchMixinInterface,
+ RestartType
+} from '../relaunch_mixin.js'
-import { BraveSyncBrowserProxy } from './brave_sync_browser_proxy.js';
+import { BraveSyncBrowserProxy } from './brave_sync_browser_proxy.js'
-import { getTemplate } from './sync_url_input.html.js';
+import { getTemplate } from './sync_url_input.html.js'
export interface SyncUrlInputElement {
$: {
- input: CrInputElement,
- };
+ input: CrInputElement
+ }
}
-const SyncUrlInputElementBase =
- PrefsMixin(PrefControlMixin(PolymerElement)) as
- { new(): PolymerElement & PrefsMixinInterface };
+const SyncUrlInputElementBase = RelaunchMixin(
+ PrefsMixin(PrefControlMixin(CrPolicyPrefMixin(PolymerElement)))
+) as {
+ new (): PolymerElement & CrPolicyPrefMixinInterface & RelaunchMixinInterface
+}
export class SyncUrlInputElement extends SyncUrlInputElementBase {
static get is() {
- return 'sync-url-input';
+ return 'sync-url-input'
}
static get template() {
- return getTemplate();
+ return getTemplate()
}
static get properties() {
@@ -53,37 +62,35 @@ export class SyncUrlInputElement extends SyncUrlInputElementBase {
*/
pref: { observer: 'prefChanged_' },
-
/**
* Indicates whether the input is invalid.s
*/
- invalid: {type: Boolean, value: false},
- };
- }
+ invalid: { type: Boolean, value: false },
- value: string;
- pref: chrome.settingsPrivate.PrefObject | undefined;
- invalid: boolean;
-
- private browserProxy_: BraveSyncBrowserProxy =
- BraveSyncBrowserProxy.getInstance();
-
- private onKeyPress_(e: KeyboardEvent) {
- if (e.key === 'Enter' && !e.shiftKey) {
- e.preventDefault();
- this.validate_();
+ /**
+ * Whether the control is disabled, for example due to an extension
+ * managing the preference.
+ */
+ disabled: {
+ type: Boolean,
+ value: false
+ }
}
}
- private validate_() {
- if (this.value === '') {
- this.invalid = false;
- return;
- }
+ value: string
+ pref: chrome.settingsPrivate.PrefObject | undefined
+ invalid: boolean
+ disabled: boolean
- this.browserProxy_.validateCustomSyncUrl(this.value).then(isValid => {
- this.invalid = !isValid;
- });
+ private browserProxy_: BraveSyncBrowserProxy =
+ BraveSyncBrowserProxy.getInstance()
+
+ /**
+ * Focus the custom input field.
+ */
+ override focus() {
+ this.$.input.focusInput()
}
/**
@@ -91,45 +98,83 @@ export class SyncUrlInputElement extends SyncUrlInputElementBase {
*/
private prefChanged_() {
if (!this.pref) {
- return;
+ return
}
- this.setInputValueFromPref_();
+ this.setInputValueFromPref_()
+ }
+
+ private onRestartClick_(e: Event) {
+ // Prevent event from bubbling up to the toggle button.
+ e.stopPropagation()
+ this.performRestart(RestartType.RESTART)
+ }
+
+ private validate_() {
+ if (this.value === '') {
+ this.invalid = false
+ return
+ }
+
+ this.browserProxy_.validateCustomSyncUrl(this.value).then((isValid) => {
+ this.invalid = !isValid
+ })
}
private setInputValueFromPref_() {
- assert(this.pref!.type === chrome.settingsPrivate.PrefType.URL);
- this.value = this.pref!.value;
+ assert(this.pref!.type === chrome.settingsPrivate.PrefType.URL)
+ this.value = this.pref!.value
}
private onChange_() {
if (this.invalid) {
- this.resetValue_();
- return;
+ this.resetValue_()
+ return
}
- assert(this.pref!.type === chrome.settingsPrivate.PrefType.URL);
- this.set('pref.value', this.value);
+ assert(this.pref!.type === chrome.settingsPrivate.PrefType.URL)
+ this.set('pref.value', this.value)
}
private resetValue_() {
- this.invalid = false;
- this.setInputValueFromPref_();
- this.$.input.blur();
+ this.invalid = false
+ this.setInputValueFromPref_()
+ this.$.input.blur()
}
- /**
- * Focus the custom input field.
- */
- override focus() {
- this.$.input.focusInput();
+ private onKeyPress_(e: KeyboardEvent) {
+ if (e.key === 'Enter' && !e.shiftKey) {
+ e.preventDefault()
+ this.validate_()
+ this.onChange_()
+ }
+ }
+
+ private isPrefEnforced_(): boolean {
+ return (
+ !!this.pref &&
+ this.pref.enforcement === chrome.settingsPrivate.Enforcement.ENFORCED
+ )
+ }
+
+ private shouldShowRestart_(): boolean {
+ const proxy = BraveSyncBrowserProxy.getInstance()
+ return !!this.pref && proxy.getCustomSyncUrlAtStartup() !== this.pref.value
+ }
+
+ private controlDisabled_(): boolean {
+ return (
+ this.disabled ||
+ this.isPrefEnforced_() ||
+ !!(this.pref && this.pref.userControlDisabled)
+ )
}
}
declare global {
interface HTMLElementTagNameMap {
- 'sync-url-input': SyncUrlInputElement;
+ 'sync-url-input': SyncUrlInputElement
}
}
-customElements.define(SyncUrlInputElement.is, SyncUrlInputElement);
+customElements.define(SyncUrlInputElement.is, SyncUrlInputElement)
diff --git a/browser/ui/webui/brave_settings_ui.cc b/browser/ui/webui/brave_settings_ui.cc
index 8af11b9f8970..d89ca580d69b 100644
--- a/browser/ui/webui/brave_settings_ui.cc
+++ b/browser/ui/webui/brave_settings_ui.cc
@@ -28,6 +28,7 @@
#include "brave/browser/ui/webui/settings/brave_wallet_handler.h"
#include "brave/browser/ui/webui/settings/default_brave_shields_handler.h"
#include "brave/components/ai_chat/core/common/buildflags/buildflags.h"
+#include "brave/components/brave_sync/brave_sync_prefs.h"
#include "brave/components/brave_vpn/common/buildflags/buildflags.h"
#include "brave/components/brave_vpn/common/features.h"
#include "brave/components/brave_wallet/common/features.h"
@@ -217,13 +218,9 @@ void BraveSettingsUI::AddResources(content::WebUIDataSource* html_source,
html_source->AddBoolean(
"isSharedPinnedTabsEnabled",
base::FeatureList::IsEnabled(tabs::features::kBraveSharedPinnedTabs));
-
- html_source->AddBoolean(
- "customSyncUrlEnabledAtStartup",
- g_browser_process->local_state()->GetBoolean(kBraveCustomSyncUrlEnabled));
html_source->AddString(
"customSyncUrlAtStartup",
- g_browser_process->local_state()->GetString(kBraveCustomSyncUrl));
+ profile->GetPrefs()->GetString(brave_sync::kCustomSyncServiceUrl));
}
// static
diff --git a/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc b/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc
index e54cf8fa82e5..f650db218ef1 100644
--- a/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc
+++ b/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc
@@ -319,8 +319,7 @@ 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},
+ {"braveCustomSyncUrlTitle", IDS_SETTINGS_BRAVE_CUSTOM_SYNC_URL_TITLE},
{"enterCustomSyncUrl", IDS_SETTINGS_ENTER_CUSTOM_SYNC_URL},
{"braveSyncWordCount", IDS_SETTINGS_BRAVE_SYNC_WORD_COUNT},
{"braveSyncCopied", IDS_SETTINGS_BRAVE_SYNC_COPIED_TEXT},
diff --git a/components/constants/pref_names.h b/components/constants/pref_names.h
index b18469bda540..051eee42df44 100644
--- a/components/constants/pref_names.h
+++ b/components/constants/pref_names.h
@@ -162,8 +162,4 @@ inline constexpr char kBraveSuggestedSiteSuggestionsEnabled[] =
"brave.brave_suggested_site_suggestions_enabled";
#endif
-inline constexpr char kBraveCustomSyncUrlEnabled[] =
- "brave.custom_sync_url_enabled";
-inline constexpr char kBraveCustomSyncUrl[] = "brave.custom_sync_url";
-
#endif // BRAVE_COMPONENTS_CONSTANTS_PREF_NAMES_H_