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

CI run for contributor PR #25484 #25691

Merged
11 commits merged into from
Nov 27, 2024
Merged
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
51 changes: 0 additions & 51 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,32 @@
#include <optional>
#include <string>

#include "base/base_switches.h"
#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "brave/browser/brave_content_browser_client.h"
#include "brave/common/resource_bundle_helper.h"
#include "brave/components/brave_component_updater/browser/features.h"
#include "brave/components/brave_component_updater/browser/switches.h"
#include "brave/components/brave_sync/buildflags.h"
#include "brave/components/constants/brave_switches.h"
#include "brave/components/speedreader/common/buildflags/buildflags.h"
#include "brave/components/update_client/buildflags.h"
#include "brave/components/variations/command_line_utils.h"
#include "brave/renderer/brave_content_renderer_client.h"
#include "brave/utility/brave_content_utility_client.h"
#include "build/build_config.h"
#include "chrome/app/chrome_main_delegate.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
#include "components/component_updater/component_updater_switches.h"
#include "components/dom_distiller/core/dom_distiller_switches.h"
#include "components/embedder_support/switches.h"
#include "components/sync/base/command_line_switches.h"
#include "google_apis/gaia/gaia_switches.h"

#if BUILDFLAG(IS_LINUX)
#include "base/linux_util.h"
#endif

#if BUILDFLAG(IS_ANDROID)
#include "base/android/jni_android.h"
#include "brave/build/android/jni_headers/BraveQAPreferences_jni.h"
#include "components/signin/public/base/account_consistency_method.h"
#endif
namespace {

constexpr char kBraveOriginTrialsPublicKey[] =
Expand All @@ -65,34 +54,6 @@ std::string GetUpdateURLHost() {
return BUILDFLAG(UPDATER_DEV_ENDPOINT);
}

#if BUILDFLAG(IS_ANDROID)
// staging "https://sync-v2.bravesoftware.com/v2" can be overriden by
// syncer::kSyncServiceURL manually
constexpr char kBraveSyncServiceStagingURL[] =
"https://sync-v2.bravesoftware.com/v2";

void AdjustSyncServiceUrlForAndroid(std::string* brave_sync_service_url) {
DCHECK_NE(brave_sync_service_url, nullptr);
static constexpr char kProcessTypeSwitchName[] = "type";

// On Android we can detect data dir only on host process, and we cannot
// for example on renderer or gpu-process, because JNI is not initialized
// And no sense to override sync service url for them in anyway
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
kProcessTypeSwitchName)) {
// This is something other than browser process
return;
}

JNIEnv* env = base::android::AttachCurrentThread();
bool b_use_staging_sync_server =
Java_BraveQAPreferences_isSyncStagingUsed(env);
if (b_use_staging_sync_server) {
*brave_sync_service_url = kBraveSyncServiceStagingURL;
}
}
#endif // BUILDFLAG(IS_ANDROID)

} // namespace

#if !defined(CHROME_MULTIPLE_DLL_BROWSER)
Expand Down Expand Up @@ -157,19 +118,7 @@ void BraveMainDelegate::AppendCommandLineOptions() {
kBraveOriginTrialsPublicKey);
}

std::string brave_sync_service_url = BUILDFLAG(BRAVE_SYNC_ENDPOINT);
#if BUILDFLAG(IS_ANDROID)
AdjustSyncServiceUrlForAndroid(&brave_sync_service_url);
#endif // BUILDFLAG(IS_ANDROID)

command_line->AppendSwitchASCII(switches::kLsoUrl, kDummyUrl);

// Brave's sync protocol does not use the sync service url
if (!command_line->HasSwitch(syncer::kSyncServiceURL)) {
command_line->AppendSwitchASCII(syncer::kSyncServiceURL,
brave_sync_service_url.c_str());
}

variations::AppendBraveCommandLineOptions(*command_line);
}

Expand Down
3 changes: 0 additions & 3 deletions app/brave_main_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ TEST(BraveMainDelegateUnitTest, DefaultCommandLineOverrides) {
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
BraveMainDelegate::AppendCommandLineOptions();

ASSERT_STREQ(
BUILDFLAG(BRAVE_SYNC_ENDPOINT),
command_line.GetSwitchValueASCII(syncer::kSyncServiceURL).c_str());
ASSERT_STREQ(
kBraveOriginTrialsPublicKey,
command_line.GetSwitchValueASCII(embedder_support::kOriginTrialPublicKey)
Expand Down
9 changes: 9 additions & 0 deletions app/brave_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,15 @@
<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_TITLE" desc="Title for custom sync url">
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_POLICY_INDICATOR" desc="Tooltip text for policy indicator(building) icon">
This setting is managed by your organization
</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/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ source_set("extensions") {
"//brave/components/brave_rewards/common",
"//brave/components/brave_rewards/common/mojom",
"//brave/components/brave_shields/core/common",
"//brave/components/brave_sync:prefs",
"//brave/components/brave_vpn/common/buildflags",
"//brave/components/brave_wallet/browser:pref_names",
"//brave/components/brave_wallet/browser:utils",
Expand Down
6 changes: 6 additions & 0 deletions browser/extensions/api/settings_private/brave_prefs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "brave/components/brave_news/common/pref_names.h"
#include "brave/components/brave_rewards/common/pref_names.h"
#include "brave/components/brave_shields/core/common/pref_names.h"
#include "brave/components/brave_sync/brave_sync_prefs.h"
#include "brave/components/brave_vpn/common/buildflags/buildflags.h"
#include "brave/components/brave_wallet/browser/pref_names.h"
#include "brave/components/brave_wayback_machine/buildflags/buildflags.h"
Expand Down Expand Up @@ -211,6 +212,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)[brave_sync::kCustomSyncServiceUrl] =
settings_api::PrefType::kUrl;

// WebTorrent pref
(*s_brave_allowlist)[kWebTorrentEnabled] = settings_api::PrefType::kBoolean;
#if BUILDFLAG(ENABLE_BRAVE_WAYBACK_MACHINE)
Expand Down
4 changes: 3 additions & 1 deletion browser/resources/settings/brave_overrides/basic_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ RegisterPolymerTemplateModifications({
'braveSync',
'braveSync',
'settings-brave-sync-page',
{}
{
prefs: '{{prefs}}'
}
))
const sectionShields = document.createElement('template')
sectionShields.setAttribute('is', 'dom-if')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// 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 {SyncStatus} from '/shared/settings/people_page/sync_browser_proxy.js';
import {sendWithPromise} from 'chrome://resources/js/cr.js';
import { sendWithPromise } from 'chrome://resources/js/cr.js';
import { loadTimeData } from '../i18n_setup.js';
import { SyncStatus } from '/shared/settings/people_page/sync_browser_proxy.js';

export type BraveDeviceInfo = {
name: string
Expand Down Expand Up @@ -50,15 +51,24 @@ export class BraveSyncBrowserProxy {
getSyncStatus(): Promise<BraveSyncStatus> {
return sendWithPromise('SyncSetupGetSyncStatus');
}
permanentlyDeleteSyncAccount(): Promise<boolean> {
permanentlyDeleteSyncAccount(): Promise<boolean> {
return sendWithPromise('SyncPermanentlyDeleteAccount');
}
getWordsCount(syncCode: string): Promise<number> {
return sendWithPromise('SyncGetWordsCount', syncCode);
}

getCustomSyncUrlAtStartup(): string {
return loadTimeData.getString('customSyncUrlAtStartup');
}

validateCustomSyncUrl(url: string) {
return sendWithPromise('validateCustomSyncUrl', url);
}

static getInstance() {
return instance || (instance = new BraveSyncBrowserProxy())
}
}

let instance: BraveSyncBrowserProxy|null = null
let instance: BraveSyncBrowserProxy | null = null
39 changes: 29 additions & 10 deletions browser/resources/settings/brave_sync_page/brave_sync_page.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
<style include="settings-shared iron-flex">
</style>
<settings-animated-pages id="pages" section="braveSync">
<style include="settings-shared iron-flex"></style>
<settings-animated-pages
id="pages"
section="braveSync"
>
<div route-path="default">
<cr-link-row id="brave-sync-setup"
<cr-link-row
id="brave-sync-setup"
label$="[[syncLabel_]]"
on-click="onSyncTap_"
role-description="$i18n{subpageArrowRoleDescription}">
role-description="$i18n{subpageArrowRoleDescription}"
>
</cr-link-row>

<template
is="dom-if"
if="[[shouldShowCustomSyncInput_]]"
>
<div class="hr"></div>
<sync-url-input
id="customSyncUrl"
pref="{{prefs.brave_sync.sync_service_url}}"
disabled="[[shouldDisableCustomSyncInput_]]"
>
</sync-url-input>
</template>
</div>

<template is="dom-if" route-path="/braveSync/setup">
<template
is="dom-if"
route-path="/braveSync/setup"
>
<settings-subpage
associated-control="[[$$('#brave-sync-setup')]]"
page-title="[[syncLabel_]]">
<settings-brave-sync-subpage
sync-status="[[syncStatus_]]">
page-title="[[syncLabel_]]"
>
<settings-brave-sync-subpage sync-status="[[syncStatus_]]">
</settings-brave-sync-subpage>
</settings-subpage>

</template>
</settings-animated-pages>
64 changes: 45 additions & 19 deletions browser/resources/settings/brave_sync_page/brave_sync_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ import '../settings_page/settings_subpage.js';
import '../settings_shared.css.js';
import '../settings_vars.css.js';
import './brave_sync_subpage.js';
import './sync_url_input.js';
import '/shared/settings/prefs/prefs.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 } from 'chrome://resources/cr_elements/i18n_mixin.js';
import { WebUiListenerMixin } 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 } 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,9 +33,8 @@ import {getTemplate} from './brave_sync_page.html.js'
*/

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

export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBase {
static get is() {
Expand All @@ -57,6 +60,14 @@ export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBa
type: String,
computed: 'computeSyncLabel_(syncStatus_)'
},
shouldShowCustomSyncInput_: {
type: Boolean,
computed: 'computeShouldShowCustomSyncInput_(syncStatus_)'
},
shouldDisableCustomSyncInput_: {
type: Boolean,
computed: 'computeShouldDisableCustomSyncInput_(syncStatus_)'
},
};
}

Expand All @@ -69,20 +80,34 @@ export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBa

computeSyncLabel_() {
if (this.syncStatus_ !== undefined &&
this.syncStatus_.hasSyncWordsDecryptionError) {
return this.i18n('braveSyncCouldNotSyncActionLabel');
this.syncStatus_.hasSyncWordsDecryptionError) {
return this.i18n('braveSyncCouldNotSyncActionLabel');
}
const isAlreadySetup = this.syncStatus_ !== undefined &&
!this.syncStatus_.firstSetupInProgress;
!this.syncStatus_.firstSetupInProgress;
const key = isAlreadySetup ? 'braveSyncManageActionLabel' : 'braveSyncSetupActionLabel';
return this.i18n(key);
}

computeShouldShowCustomSyncInput_() {
const isAlreadySetup =
this.syncStatus_ !== undefined && !this.syncStatus_.firstSetupInProgress

return !(
isAlreadySetup &&
this.braveBrowserProxy_.getCustomSyncUrlAtStartup() === ''
)
}

computeShouldDisableCustomSyncInput_() {
return this.syncStatus_ !== undefined && !this.syncStatus_.firstSetupInProgress
}

override connectedCallback() {
super.connectedCallback()
const onSyncStatus = this.handleSyncStatus_.bind(this)
this.braveBrowserProxy_.getSyncStatus().then(
(status: BraveSyncStatus) => onSyncStatus(status));
(status: BraveSyncStatus) => onSyncStatus(status));
this.addWebUiListener(
'sync-prefs-changed', this.handleSyncPrefsChanged_.bind(this));
this.addWebUiListener('sync-status-changed', onSyncStatus);
Expand All @@ -91,7 +116,8 @@ export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBa
onSyncTap_() {
// Users can go to sync subpage regardless of sync status.
const router = Router.getInstance();
router.navigateTo((router.getRoutes() as {BRAVE_SYNC_SETUP: Route}).BRAVE_SYNC_SETUP);
router.navigateTo((router.getRoutes() as
{ BRAVE_SYNC_SETUP: Route }).BRAVE_SYNC_SETUP);
}

/**
Expand All @@ -111,9 +137,9 @@ export class SettingsBraveSyncPageElement extends SettingsBraveSyncPageElementBa
await this.browserProxy_.setDecryptionPassphrase(pureSyncCode);
} else if (!this.isEncryptionSet_) {
this.browserProxy_.setEncryptionPassphrase(pureSyncCode)
.then(successfullySet => {
this.isEncryptionSet_ = successfullySet
})
.then(successfullySet => {
this.isEncryptionSet_ = successfullySet
})
}
}
}
Expand Down
Loading
Loading