Skip to content

Commit

Permalink
feat: keyboard shortcut to export all bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
hamirmahal committed Oct 4, 2024
1 parent 94ec4f5 commit 2db2f06
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/brave_command_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@

// Bookmark commands.
#define IDC_TOGGLE_ALL_BOOKMARKS_BUTTON_VISIBILITY 56300
#define IDC_EXPORT_ALL_BOOKMARKS 56312

#define IDC_COMMANDER 56301

Expand Down
4 changes: 4 additions & 0 deletions browser/ui/brave_browser_command_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ void BraveBrowserCommandController::InitBraveCommandState() {
UpdateCommandsForPin();

UpdateCommandEnabled(IDC_TOGGLE_ALL_BOOKMARKS_BUTTON_VISIBILITY, true);
UpdateCommandEnabled(IDC_EXPORT_ALL_BOOKMARKS, true);

if (browser_->is_type_normal()) {
// Delete these when upstream enables by default.
Expand Down Expand Up @@ -656,6 +657,9 @@ bool BraveBrowserCommandController::ExecuteBraveCommandWithDisposition(
case IDC_TOGGLE_ALL_BOOKMARKS_BUTTON_VISIBILITY:
brave::ToggleAllBookmarksButtonVisibility(base::to_address(browser_));
break;
case IDC_EXPORT_ALL_BOOKMARKS:
brave::ExportAllBookmarks(&*browser_);
break;
case IDC_COMMANDER:
#if BUILDFLAG(ENABLE_COMMANDER)
brave::ToggleCommander(base::to_address(browser_));
Expand Down
6 changes: 6 additions & 0 deletions browser/ui/browser_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,12 @@ void ScrollTabToBottom(Browser* browser) {
contents->ScrollToBottomOfDocument();
}

void ExportAllBookmarks(Browser* browser) {
auto* profile = browser->profile();
DCHECK(profile);
chrome::ExportBookmarks(profile, /*export_path=*/base::FilePath());
}

void ToggleAllBookmarksButtonVisibility(Browser* browser) {
auto* prefs = browser->profile()->GetPrefs();
prefs->SetBoolean(
Expand Down
1 change: 1 addition & 0 deletions browser/ui/browser_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void UnmuteAllTabs(Browser* browser);
void ScrollTabToTop(Browser* browser);
void ScrollTabToBottom(Browser* browser);

void ExportAllBookmarks(Browser* browser);
void ToggleAllBookmarksButtonVisibility(Browser* browser);

// In case |tab| is not provided, the active tab will be used.
Expand Down
3 changes: 3 additions & 0 deletions components/resources/commands.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@
<message name="IDS_IDC_BRAVE_BOOKMARK_BAR_NEVER">
Hide bookmark bar
</message>
<message name="IDS_IDC_EXPORT_ALL_BOOKMARKS">
Export all bookmarks
</message>
<message name="IDS_IDC_TOGGLE_ALL_BOOKMARKS_BUTTON_VISIBILITY">
Toggle All bookmarks button visibility
</message>
Expand Down

0 comments on commit 2db2f06

Please sign in to comment.