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

Sync #226

Merged
merged 97 commits into from
Nov 1, 2018
Merged

Sync #226

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
5f72a3e
WIP branch. Rebasing Brave-sync to Chromium69
AlexeyBarabash Jul 25, 2018
8587c52
add sync extension to typescript exclusion list
cezaraugusto Sep 27, 2018
42c69ca
set sync to be locale-ready
cezaraugusto Sep 24, 2018
5b2e4db
Pass base bookmark order when id == -1
darkdh Sep 28, 2018
a8461a0
can send created bookmarks with order after sync initialization when …
AlexeyBarabash Sep 30, 2018
4732630
Propagate parentFolderID correctly when
darkdh Oct 2, 2018
fd9df0c
Make sure each bookmark is processed and save to object id map before
darkdh Oct 3, 2018
aeea601
removed some not actual TODOs
AlexeyBarabash Oct 3, 2018
e229cbd
Cleanup
darkdh Oct 3, 2018
50f549e
Pass weakptr for same sequence post task in ControllerImpl
darkdh Oct 4, 2018
4f0689e
modified brave-crypto DEPS '0.1.0'->'0.2.0'
AlexeyBarabash Oct 4, 2018
bd568a9
Fix BookmarkNodeRemoved for folder deletion
darkdh Oct 4, 2018
10b5157
controller -> brave_sync_service
bridiver Oct 4, 2018
f4e72bb
more service, dep and thread cleanup
bridiver Oct 5, 2018
43b904b
fix device not being removed
cezaraugusto Oct 5, 2018
2e20c79
properly initialize BraveSyncClientFactory
bridiver Oct 5, 2018
c47615c
make sure all leveldb operations happen on the same thread
bridiver Oct 5, 2018
454037e
sync_client -> brave_sync_client to match actual class name
bridiver Oct 5, 2018
e18a8b5
fixes according to codereview notices
AlexeyBarabash Oct 5, 2018
a122377
not synced records re-send support
AlexeyBarabash Oct 5, 2018
44adf0c
removed testing constant parameter
AlexeyBarabash Oct 5, 2018
07cd6a5
improve generateQRCodeImageSource
cezaraugusto Oct 5, 2018
c4d346e
set `sync this device` and all sync data to return if input is undefined
cezaraugusto Oct 5, 2018
3f4d621
cleaned logging on extension background page
AlexeyBarabash Oct 8, 2018
465da0c
fixed delete operation with unsynced items
AlexeyBarabash Oct 8, 2018
879144e
Load/Unload sync extension based on the value of kSyncThisDeviceEnabled
darkdh Oct 8, 2018
11b9f2f
workaround to use C++ sync words => bytes conversion
AlexeyBarabash Oct 9, 2018
fb830cc
fixed send remove device record
AlexeyBarabash Oct 10, 2018
3a3a6b9
reset sync by device itself if deleted from other
AlexeyBarabash Oct 10, 2018
05a2ff5
updated DEPS to the latest brave/sync lib
AlexeyBarabash Oct 11, 2018
9ea0ab2
convert to bookmark meta info
bridiver Oct 10, 2018
d93864b
use sync_timestamp to identify unsynced bookmarks
bridiver Oct 11, 2018
297f025
fix shutdown destruction for sync_object_map_
bridiver Oct 11, 2018
6758726
get device resolving and fetch on latest record timestamp back
AlexeyBarabash Oct 11, 2018
2254893
Save seed only from SAVE_INIT_DATA also remove temp storage
darkdh Oct 11, 2018
95d54f5
Init SyncService in DoFinalInitForServices when sync is configured
darkdh Oct 11, 2018
c879d42
set sync_timestamp in resolve
bridiver Oct 12, 2018
7254c74
1. Fix next_node calculation when node is the last item, GetChild(ind…
darkdh Oct 12, 2018
4b00aeb
fix typo and resulting DCHECK error
bridiver Oct 12, 2018
9db1086
Start/stop loop by extension reday/unloaded
darkdh Oct 12, 2018
3717e4f
add parent_order for calculating get order api
bridiver Oct 12, 2018
fe40545
parentOrder parameter for get/save bookmark order in background page
AlexeyBarabash Oct 12, 2018
b96b6eb
add parentNode to callback
bridiver Oct 12, 2018
8c4a7c7
Send sync records at the end of bookmarks iterating
darkdh Oct 13, 2018
e87c5a6
fix weakptr sequence checker crash
bridiver Oct 13, 2018
b860a91
stop the loop on shutdown
bridiver Oct 15, 2018
7cc9f96
Monitor kSyncThisDeviceEnabled change by PrefChangeRegistrar
darkdh Oct 15, 2018
4a45763
lint and other cleanup
bridiver Oct 15, 2018
29c212c
Fix unsynchronized data between prefs and webui settings
darkdh Oct 15, 2018
2cff586
more lint and cleanup
bridiver Oct 15, 2018
10f1b29
cleanup pref names
bridiver Oct 15, 2018
fe4b7d9
use prefs for devices
bridiver Oct 16, 2018
f561314
temporarily set sync_version back to 0
bridiver Oct 16, 2018
bf9eead
devices -> sync_devices to match class name
bridiver Oct 16, 2018
e7d158e
these aren't necessary anymore, we only need checks on public method …
bridiver Oct 16, 2018
5b66731
clear out history stuff for now because we want to look at a differen…
bridiver Oct 16, 2018
cb88944
add missing sync_devices
bridiver Oct 16, 2018
d2a69e1
sync_client shouldn't be a keyed service
bridiver Oct 16, 2018
1059ad9
don't need weak ptr anymore
bridiver Oct 16, 2018
41773b2
cleanup deps
bridiver Oct 16, 2018
05c7003
refactor bookmarks into BookmarkChangeProcessor
bridiver Oct 16, 2018
10e6176
add change processor interface to start bringing things in line with …
bridiver Oct 16, 2018
d8547c6
updated DEPS for brave-sync lib to its main branch after merge branch PR
AlexeyBarabash Oct 16, 2018
355896c
Implement FETCH_SYNC_DEVICES so that when "sync site setting" toggle …
darkdh Oct 16, 2018
9a49882
Prevent users from turning on history, site settings until they are
darkdh Oct 16, 2018
6ab5f74
NotifySyncStateChanged cleanup
darkdh Oct 16, 2018
5c94f4a
wip sync unit test; can run test 1
AlexeyBarabash Oct 16, 2018
0dd5cf2
refactor classes to cleanup test setup code
bridiver Oct 17, 2018
3641710
add some missing assertions
bridiver Oct 17, 2018
8de0f46
fix rebase issues
bridiver Oct 17, 2018
3d5e794
updated brave sync lib DEPS
AlexeyBarabash Oct 18, 2018
5995298
pausing observer while applying changes from sync
AlexeyBarabash Oct 18, 2018
68b7355
fix finding of parent when updating
bridiver Oct 18, 2018
50e139a
we're skipping the observer method so these bookmarks should already …
bridiver Oct 18, 2018
ac2db42
pause the sync loop when waiting for an order response so new records…
bridiver Oct 18, 2018
95d310b
try to avoid overwriting remote sync data with unchanged local data
bridiver Oct 19, 2018
2f348a5
this seems more reliable
bridiver Oct 19, 2018
c144627
cleanup
bridiver Oct 19, 2018
14063af
Don't put changes records from sync model to unsync lists
darkdh Oct 22, 2018
3682708
bookmark_change_processor_unittest; matcher for send record; sync cli…
AlexeyBarabash Oct 23, 2018
cdf4306
cleanup
AlexeyBarabash Oct 23, 2018
6480555
don't keep static vars for per-profile attributes
bridiver Oct 23, 2018
28062ef
fixing tests
AlexeyBarabash Oct 23, 2018
a4f6851
Obtain order when "SEND_SYNC_RECORDS" and "RESOLVE_SYNC_RECORDS" to s…
darkdh Oct 24, 2018
fa33db2
cleaned some unused code
AlexeyBarabash Oct 25, 2018
b7d740f
more bookmark_change_processor tests
AlexeyBarabash Oct 25, 2018
c1f5e79
clearing order for shifted nodes when moving
darkdh Oct 26, 2018
03a2a79
Fix syncTimestamp propagation
darkdh Oct 30, 2018
1f1aff4
added new and adapted existing test to new resolve records way
AlexeyBarabash Oct 30, 2018
33af016
GetTaskRunnerForThread removal (C71 upgrade)
darkdh Oct 30, 2018
753b75b
more BraveSyncService tests
AlexeyBarabash Oct 31, 2018
d7823ab
command line key to enable use of sync, disabled by default
AlexeyBarabash Oct 31, 2018
cf5f057
Address review comments
darkdh Oct 31, 2018
045518d
ts lint
darkdh Nov 1, 2018
eb93cac
removed BraveSyncServiceObserver::OnLogMessage because it just sends …
AlexeyBarabash Nov 1, 2018
30cd566
Fix build on Windows
darkdh Nov 1, 2018
c5853d8
fix of incorrect sync initialization with wrong code words
AlexeyBarabash Nov 1, 2018
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/browser/resources/brave_extension/
/components/brave_webtorrent/extension/out/
/components/brave_rewards/resources/extension/brave_rewards/out/
/components/brave_sync/extension/brave-crypto/
/components/brave_sync/extension/brave-sync/
/dist/
/out/
/vendor
Expand Down
14 changes: 14 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ deps = {
"vendor/bip39wally-core-native": "https://github.com/brave-intl/bip39wally-core-native.git@9b119931c702d55be994117eb505d56310720b1d",
"vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@adeff3254bb90ccdc9699040d5a4e1cd6b8393b7",
"vendor/bat-native-tweetnacl": "https://github.com/brave-intl/bat-native-tweetnacl.git@1b4362968c8f22720bfb75af6f506d4ecc0f3116",
"components/brave_sync/extension/brave-sync": "https://github.com/brave/sync.git@ff9c7f3bdea37e8cc1cb08eff48123fd9add6da9",
"components/brave_sync/extension/brave-crypto": "https://github.com/brave/crypto@c07866c3b9c8264195756a81112bb74b8fa90858",
}

hooks = [
Expand All @@ -37,5 +39,17 @@ hooks = [
'condition': 'not checkout_android',
'pattern': '.',
'action': ['python', 'src/brave/script/init-brave-extension.py'],
},
{
# Build brave-sync
'name': 'build_brave_sync',
'pattern': '.',
'action': ['python', 'src/brave/script/build-simple-js-bundle.py', '--repo_dir_path', 'src/brave/components/brave_sync/extension/brave-sync'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we combine these scripts with init-brave-extension.py in a follow-up?

},
{
# Build brave-crypto
'name': 'build_brave_crypto',
'pattern': '.',
'action': ['python', 'src/brave/script/build-simple-js-bundle.py', '--repo_dir_path', 'src/brave/components/brave_sync/extension/brave-crypto'],
}
]
1 change: 1 addition & 0 deletions app/brave_command_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define IDC_NEW_TOR_IDENTITY 56002
#define IDC_NEW_OFFTHERECORD_WINDOW_TOR 56003
#define IDC_CONTENT_CONTEXT_OPENLINKTOR 56004
#define IDC_SHOW_BRAVE_SYNC 56005

#define IDC_BRAVE_COMMANDS_LAST 57000

Expand Down
3 changes: 3 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<message name="IDS_SHOW_BRAVE_ADBLOCK" desc="The show Brave Ad Block menu in the app menu">
Brave Ad Block
</message>
<message name="IDS_SHOW_BRAVE_SYNC" desc="The show brave sync menu in the app menu">
Brave Sync
</message>
<message name="IDS_EXTENSION_CANT_INSTALL_ON_BRAVE" desc="Error message when user tries to install an extension that is not allowed in Brave.">
<ph name="EXTENSION_NAME">$1</ph> (extension ID "<ph name="EXTENSION_ID">$2<ex>abacabadabacabaeabacabadabacabaf</ex></ph>") is not allowed in Brave.
</message>
Expand Down
4 changes: 3 additions & 1 deletion brave_paks.gni
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ template("brave_extra_paks") {
"$root_gen_dir/brave/components/brave_rewards/resources/extension/brave_rewards_extension_resources.pak",
"$target_gen_dir/browser/resources/brave_extension.pak",
"$target_gen_dir/components/brave_webtorrent/brave_webtorrent_resources.pak",
"$target_gen_dir/components/brave_sync/brave_sync_resources.pak",
]

deps = [
Expand All @@ -75,7 +76,8 @@ template("brave_extra_paks") {
"//brave/components/resources:strings",
"//brave/browser/resources:brave_extension_grit",
"//brave/browser/resources:brave_settings_resources",
"//brave/common/extensions/api"
"//brave/common/extensions/api",
"//brave/components/brave_sync:resources",
]

if (defined(invoker.deps)) {
Expand Down
4 changes: 4 additions & 0 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ source_set("browser_process") {
"autocomplete/brave_autocomplete_provider_client.h",
"autocomplete/brave_autocomplete_scheme_classifier.cc",
"autocomplete/brave_autocomplete_scheme_classifier.h",
"bookmarks/brave_bookmark_client.cc",
"bookmarks/brave_bookmark_client.h",
"brave_browser_main_extra_parts.cc",
"brave_browser_main_extra_parts.h",
"brave_browser_main_parts_mac.mm",
Expand Down Expand Up @@ -60,6 +62,8 @@ source_set("browser_process") {
"//brave/common",
"//brave/components/brave_rewards/browser",
"//brave/components/brave_shields/browser:brave_shields",
"//brave/components/brave_sync",
"//brave/components/content_settings/core/browser",
"//chrome/common",
"//components/component_updater",
"//components/prefs",
Expand Down
31 changes: 31 additions & 0 deletions browser/bookmarks/brave_bookmark_client.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* 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/. */

#include "brave/browser/bookmarks/brave_bookmark_client.h"

#include "brave/components/brave_sync/brave_sync_service.h"
#include "chrome/browser/profiles/profile.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/managed/managed_bookmark_service.h"
#include "components/sync_bookmarks/bookmark_sync_service.h"

BraveBookmarkClient::BraveBookmarkClient(
Profile* profile,
bookmarks::ManagedBookmarkService* managed_bookmark_service,
sync_bookmarks::BookmarkSyncService* bookmark_sync_service)
: ChromeBookmarkClient(profile,
managed_bookmark_service,
bookmark_sync_service) {}

bookmarks::LoadExtraCallback BraveBookmarkClient::GetLoadExtraNodesCallback() {
return base::BindOnce(&brave_sync::LoadExtraNodes,
ChromeBookmarkClient::GetLoadExtraNodesCallback());
}

bool BraveBookmarkClient::IsPermanentNodeVisible(
const bookmarks::BookmarkPermanentNode* node) {
if (brave_sync::IsSyncManagedNode(node))
return false; // don't display sync managed nodes
return ChromeBookmarkClient::IsPermanentNodeVisible(node);
}
25 changes: 25 additions & 0 deletions browser/bookmarks/brave_bookmark_client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* 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_BOOKMARKS_BRAVE_BOOKMARK_CLIENT_H_
#define BRAVE_BROWSER_BOOKMARKS_BRAVE_BOOKMARK_CLIENT_H_

#include "chrome/browser/bookmarks/chrome_bookmark_client.h"

class BraveBookmarkClient : public ChromeBookmarkClient {
public:
BraveBookmarkClient(
Profile* profile,
bookmarks::ManagedBookmarkService* managed_bookmark_service,
sync_bookmarks::BookmarkSyncService* bookmark_sync_service);

bookmarks::LoadExtraCallback GetLoadExtraNodesCallback() override;
bool IsPermanentNodeVisible(
const bookmarks::BookmarkPermanentNode* node) override;

private:
DISALLOW_COPY_AND_ASSIGN(BraveBookmarkClient);
};

#endif // BRAVE_BROWSER_BOOKMARKS_BRAVE_BOOKMARK_CLIENT_H_
2 changes: 2 additions & 0 deletions browser/browser_context_keyed_service_factories.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

#include "brave/browser/tor/tor_profile_service_factory.h"
#include "brave/components/brave_rewards/browser/rewards_service_factory.h"
#include "brave/components/brave_sync/brave_sync_service_factory.h"

namespace brave {

void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
brave_rewards::RewardsServiceFactory::GetInstance();
brave_sync::BraveSyncServiceFactory::GetInstance();
TorProfileServiceFactory::GetInstance();
}

Expand Down
1 change: 1 addition & 0 deletions browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ source_set("extensions") {
"//brave/browser/resources:brave_extension_grit",
"//brave/common/extensions/api",
"//brave/components/brave_rewards/resources/extension:resources",
"//brave/components/brave_sync:resources",
"//brave/components/brave_webtorrent:resources",
"//chrome/browser",
"//content/public/browser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "brave/browser/resources/grit/brave_extension_resources_map.h"
#include "brave/components/brave_rewards/resources/extension/grit/brave_rewards_extension_resources_map.h"
#include "brave/components/brave_sync/grit/brave_sync_resources_map.h"
#include "brave/components/brave_webtorrent/grit/brave_webtorrent_resources_map.h"

namespace extensions {
Expand All @@ -20,6 +21,10 @@ BraveComponentExtensionResourceManager() {
kBraveRewardsExtensionResources,
kBraveRewardsExtensionResourcesSize);

AddComponentResourceEntries(
kBraveSyncResources,
kBraveSyncResourcesSize);

AddComponentResourceEntries(
kBraveWebtorrentResources,
kBraveWebtorrentResourcesSize);
Expand Down
6 changes: 4 additions & 2 deletions browser/extensions/brave_extension_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bool BraveExtensionProvider::IsVetted(const Extension* extension) {
static std::vector<std::string> vetted_extensions({
brave_extension_id,
brave_rewards_extension_id,
brave_sync_extension_id,
brave_webtorrent_extension_id,
pdfjs_extension_id,
// 1Password
Expand Down Expand Up @@ -96,7 +97,7 @@ bool BraveExtensionProvider::IsVetted(const Extension* extension) {
// Test ID: Brave HTTPS Everywhere Updater
"bhlmpjhncoojbkemjkeppfahkglffilp",
// Test ID: Brave Tor Client Updater
"ngicbhhaldfdgmjhilmnleppfpmkgbbk"
"ngicbhhaldfdgmjhilmnleppfpmkgbbk",
});
return std::find(vetted_extensions.begin(), vetted_extensions.end(),
extension->id()) != vetted_extensions.end();
Expand Down Expand Up @@ -138,7 +139,8 @@ bool BraveExtensionProvider::MustRemainInstalled(const Extension* extension,
base::string16* error) const {
return extension->id() == brave_extension_id ||
extension->id() == brave_rewards_extension_id ||
extension->id() == brave_webtorrent_extension_id;
extension->id() == brave_webtorrent_extension_id ||
extension->id() == brave_sync_extension_id;
}

} // namespace extensions
1 change: 1 addition & 0 deletions browser/profiles/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ source_set("profiles") {
"//brave/browser/extensions",
"//brave/browser/tor",
"//brave/common/tor",
"//brave/components/brave_sync",
"//ui/base",
]
}
9 changes: 9 additions & 0 deletions browser/profiles/brave_profile_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "brave/browser/tor/tor_profile_service_factory.h"
#include "brave/common/tor/pref_names.h"
#include "brave/common/tor/tor_constants.h"
#include "brave/components/brave_sync/brave_sync_service_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
Expand Down Expand Up @@ -89,6 +90,14 @@ BraveProfileManager::CreateProfileAsyncHelper(const base::FilePath& path,
return profile;
}

void BraveProfileManager::DoFinalInitForServices(Profile* profile,
bool go_off_the_record) {
ProfileManager::DoFinalInitForServices(profile, go_off_the_record);
// BraveSyncService need to be created when profile initialized, otherwise
// it will only be constructed only when we open chrome://bravesync
brave_sync::BraveSyncServiceFactory::GetForProfile(profile);
darkdh marked this conversation as resolved.
Show resolved Hide resolved
}

void BraveProfileManager::LaunchTorProcess(Profile* profile) {
tor::TorProfileService* tor_profile_service =
TorProfileServiceFactory::GetForProfile(profile);
Expand Down
2 changes: 2 additions & 0 deletions browser/profiles/brave_profile_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class BraveProfileManager : public ProfileManager {
Profile* CreateProfileHelper(const base::FilePath& path) override;
Profile* CreateProfileAsyncHelper(const base::FilePath& path,
Delegate* delegate) override;
void DoFinalInitForServices(Profile* profile,
bool go_off_the_record) override;
private:
void LaunchTorProcess(Profile* profile);

Expand Down
3 changes: 3 additions & 0 deletions browser/resources/resource_ids
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"brave/app/theme/brave_unscaled_resources.grd": {
"includes": [36500],
},
"brave/components/brave_sync/resources.grd": {
"includes": [37000]
},
# brave webtorrent 37500
"brave/components/brave_rewards/resources/extension/extension_resources.grd": {
"includes": [38000]
Expand Down
5 changes: 5 additions & 0 deletions browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ source_set("ui") {
"webui/settings/brave_privacy_handler.h",
"webui/settings/default_brave_shields_handler.cc",
"webui/settings/default_brave_shields_handler.h",
"webui/sync/sync_ui.cc",
bridiver marked this conversation as resolved.
Show resolved Hide resolved
"webui/sync/sync_ui.h",
]

if (enable_widevine_cdm_component) {
Expand Down Expand Up @@ -110,7 +112,10 @@ source_set("ui") {
"//brave/app/theme:brave_unscaled_resources",
"//brave/app/theme:brave_theme_resources",
"//brave/app/vector_icons:vector_icons",
"//brave/common",
"//brave/components/brave_rewards/browser",
"//brave/components/brave_sync",
"//brave/components/brave_sync:resources",
"//brave/browser/tor",
"//brave/browser/resources:brave_settings_resources",
"//brave/components/resources",
Expand Down
12 changes: 12 additions & 0 deletions browser/ui/brave_browser_command_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "brave/app/brave_command_ids.h"
#include "brave/browser/ui/brave_pages.h"
#include "brave/components/brave_rewards/browser/buildflags/buildflags.h"
#include "brave/components/brave_sync/brave_sync_service.h"
#include "brave/browser/ui/browser_commands.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"

Expand Down Expand Up @@ -78,6 +80,9 @@ void BraveBrowserCommandController::InitBraveCommandState() {
#endif
UpdateCommandForBraveAdblock();
UpdateCommandForTor();
if (brave_sync::BraveSyncService::is_enabled() &&
!browser_->profile()->IsOffTheRecord())
UpdateCommandForBraveSync();
darkdh marked this conversation as resolved.
Show resolved Hide resolved
}

void BraveBrowserCommandController::UpdateCommandForBraveRewards() {
Expand All @@ -93,6 +98,10 @@ void BraveBrowserCommandController::UpdateCommandForTor() {
UpdateCommandEnabled(IDC_NEW_OFFTHERECORD_WINDOW_TOR, true);
}

void BraveBrowserCommandController::UpdateCommandForBraveSync() {
UpdateCommandEnabled(IDC_SHOW_BRAVE_SYNC, true);
}

bool BraveBrowserCommandController::ExecuteBraveCommandWithDisposition(
int id, WindowOpenDisposition disposition) {
if (!SupportsCommand(id) || !IsCommandEnabled(id))
Expand All @@ -117,6 +126,9 @@ bool BraveBrowserCommandController::ExecuteBraveCommandWithDisposition(
case IDC_NEW_TOR_IDENTITY:
brave::NewTorIdentity(browser_);
break;
case IDC_SHOW_BRAVE_SYNC:
brave::ShowBraveSync(browser_);
break;

default:
LOG(WARNING) << "Received Unimplemented Command: " << id;
Expand Down
1 change: 1 addition & 0 deletions browser/ui/brave_browser_command_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BraveBrowserCommandController : public chrome::BrowserCommandController {
void UpdateCommandForBraveRewards();
void UpdateCommandForBraveAdblock();
void UpdateCommandForTor();
void UpdateCommandForBraveSync();

bool ExecuteBraveCommandWithDisposition(int id,
WindowOpenDisposition disposition);
Expand Down
6 changes: 6 additions & 0 deletions browser/ui/brave_pages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ void ShowBraveAdblock(Browser* browser) {
GetSingletonTabNavigateParams(browser, GURL(kBraveUIAdblockURL)));
}

void ShowBraveSync(Browser* browser) {
ShowSingletonTabOverwritingNTP(
browser,
GetSingletonTabNavigateParams(browser, GURL(kBraveUISyncURL)));
}

} // namespace brave
1 change: 1 addition & 0 deletions browser/ui/brave_pages.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace brave {

void ShowBraveAdblock(Browser* browser);
void ShowBraveRewards(Browser* browser);
void ShowBraveSync(Browser* browser);

} // namespace brave

Expand Down
7 changes: 7 additions & 0 deletions browser/ui/toolbar/brave_app_menu_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "brave/browser/ui/toolbar/brave_app_menu_model.h"

#include "brave/app/brave_command_ids.h"
#include "brave/components/brave_sync/brave_sync_service.h"
#include "brave/grit/brave_generated_resources.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/profiles/profile.h"
Expand Down Expand Up @@ -43,4 +44,10 @@ void BraveAppMenuModel::InsertBraveMenuItems() {
IDC_NEW_OFFTHERECORD_WINDOW_TOR,
IDS_NEW_OFFTHERECORD_WINDOW_TOR);
}
if (brave_sync::BraveSyncService::is_enabled() &&
!browser_->profile()->IsOffTheRecord())
InsertItemWithStringIdAt(
GetIndexOfCommandId(IDC_SHOW_BRAVE_REWARDS),
IDC_SHOW_BRAVE_SYNC,
IDS_SHOW_BRAVE_SYNC);
}
Loading