feat: allow export all bookmarks keyboard shortcut
This commit is contained in:
@@ -108,6 +108,7 @@
|
||||
|
||||
// Bookmark commands.
|
||||
#define IDC_TOGGLE_ALL_BOOKMARKS_BUTTON_VISIBILITY 56300
|
||||
#define IDC_EXPORT_ALL_BOOKMARKS 56312
|
||||
|
||||
#define IDC_COMMANDER 56301
|
||||
|
||||
|
||||
@@ -311,6 +311,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.
|
||||
@@ -654,6 +655,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_));
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "brave/components/speedreader/common/buildflags/buildflags.h"
|
||||
#include "brave/components/tor/buildflags/buildflags.h"
|
||||
#include "brave/components/url_sanitizer/browser/url_sanitizer_service.h"
|
||||
#include "chrome/browser/bookmarks/bookmark_html_writer.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_manager.h"
|
||||
@@ -898,6 +899,15 @@ void ScrollTabToBottom(Browser* browser) {
|
||||
contents->ScrollToBottomOfDocument();
|
||||
}
|
||||
|
||||
void ExportAllBookmarks(Browser* browser) {
|
||||
Profile* profile = browser->profile();
|
||||
// @TODO: Get the path from the user, like we do when the user clicks the export bookmarks button manually.
|
||||
base::FilePath path("/home/hamir/Downloads/Brave browser bookmarks.html");
|
||||
BookmarksExportObserver* observer = nullptr;
|
||||
|
||||
bookmark_html_writer::WriteBookmarks(profile, path, observer);
|
||||
}
|
||||
|
||||
void ToggleAllBookmarksButtonVisibility(Browser* browser) {
|
||||
auto* prefs = browser->profile()->GetPrefs();
|
||||
prefs->SetBoolean(
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user