mirror of
https://github.com/imputnet/helium.git
synced 2026-08-20 00:57:32 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a0b0a49f8 | |||
| 83d3523887 | |||
| 46537de4b9 | |||
| 179d1b0ae8 | |||
| f6054174ed | |||
| 098ada2d58 | |||
| 5f57fd4d68 | |||
| 60225cdd75 |
@@ -1 +1 @@
|
||||
146.0.7680.71
|
||||
146.0.7680.75
|
||||
|
||||
@@ -0,0 +1,470 @@
|
||||
--- /dev/null
|
||||
+++ b/chrome/utility/importer/arc_sidebar_importer.cc
|
||||
@@ -0,0 +1,349 @@
|
||||
+// Copyright 2026 The Helium Authors
|
||||
+// You can use, redistribute, and/or modify this source code under
|
||||
+// the terms of the GPL-3.0 license that can be found in the LICENSE file.
|
||||
+
|
||||
+#include "chrome/utility/importer/arc_sidebar_importer.h"
|
||||
+
|
||||
+#include <map>
|
||||
+#include <optional>
|
||||
+#include <string>
|
||||
+#include <vector>
|
||||
+
|
||||
+#include "base/files/file_util.h"
|
||||
+#include "base/json/json_reader.h"
|
||||
+#include "base/logging.h"
|
||||
+#include "base/strings/utf_string_conversions.h"
|
||||
+#include "base/time/time.h"
|
||||
+#include "base/values.h"
|
||||
+#include "chrome/common/importer/importer_bridge.h"
|
||||
+#include "chrome/grit/generated_resources.h"
|
||||
+#include "components/user_data_importer/common/imported_bookmark_entry.h"
|
||||
+#include "components/user_data_importer/common/importer_data_types.h"
|
||||
+#include "ui/base/l10n/l10n_util.h"
|
||||
+#include "url/gurl.h"
|
||||
+
|
||||
+namespace {
|
||||
+
|
||||
+// macOS CFAbsoluteTime epoch: 2001-01-01 00:00:00 UTC
|
||||
+// Unix epoch offset: 978307200 seconds between 1970-01-01 and 2001-01-01.
|
||||
+constexpr double kCFAbsoluteTimeToUnixOffset = 978307200.0;
|
||||
+
|
||||
+base::Time CFAbsoluteTimeToBaseTime(double cf_time) {
|
||||
+ return base::Time::FromSecondsSinceUnixEpoch(cf_time +
|
||||
+ kCFAbsoluteTimeToUnixOffset);
|
||||
+}
|
||||
+
|
||||
+// Represents a parsed sidebar item from StorableSidebar.json.
|
||||
+struct ArcSidebarItem {
|
||||
+ std::string id;
|
||||
+ std::string title;
|
||||
+ std::string saved_url;
|
||||
+ std::string saved_title;
|
||||
+ double created_at = 0;
|
||||
+ std::vector<std::string> children_ids;
|
||||
+ bool is_container = false;
|
||||
+};
|
||||
+
|
||||
+// Parse the flat item list from the sidebar JSON into a map of id -> item.
|
||||
+// The items array alternates between id strings and item objects:
|
||||
+// ["id1", {item1}, "id2", {item2}, ...]
|
||||
+std::map<std::string, ArcSidebarItem> ParseItems(
|
||||
+ const base::ListValue& items_list) {
|
||||
+ std::map<std::string, ArcSidebarItem> items;
|
||||
+
|
||||
+ for (size_t i = 0; i + 1 < items_list.size(); i += 2) {
|
||||
+ const auto* id_str = items_list[i].GetIfString();
|
||||
+ const auto* dict = items_list[i + 1].GetIfDict();
|
||||
+ if (!id_str || !dict) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ ArcSidebarItem item;
|
||||
+ item.id = *id_str;
|
||||
+
|
||||
+ if (const auto* title = dict->FindString("title")) {
|
||||
+ item.title = *title;
|
||||
+ }
|
||||
+
|
||||
+ if (auto created = dict->FindDouble("createdAt")) {
|
||||
+ item.created_at = *created;
|
||||
+ }
|
||||
+
|
||||
+ if (const auto* children = dict->FindList("childrenIds")) {
|
||||
+ for (const auto& child : *children) {
|
||||
+ if (const auto* child_str = child.GetIfString()) {
|
||||
+ item.children_ids.push_back(*child_str);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Check if this is a tab (has URL) or a container.
|
||||
+ const auto* data = dict->FindDict("data");
|
||||
+ const auto* tab = data ? data->FindDict("tab") : nullptr;
|
||||
+ const auto* container = data ? data->FindDict("itemContainer") : nullptr;
|
||||
+
|
||||
+ if (tab) {
|
||||
+ if (const auto* url = tab->FindString("savedURL")) {
|
||||
+ item.saved_url = *url;
|
||||
+ }
|
||||
+
|
||||
+ if (const auto* title = tab->FindString("savedTitle")) {
|
||||
+ item.saved_title = *title;
|
||||
+ }
|
||||
+ } else if (container) {
|
||||
+ item.is_container = true;
|
||||
+ }
|
||||
+
|
||||
+ items[item.id] = std::move(item);
|
||||
+ }
|
||||
+ return items;
|
||||
+}
|
||||
+
|
||||
+void WalkItem(const std::string& item_id,
|
||||
+ const std::map<std::string, ArcSidebarItem>& items,
|
||||
+ const std::vector<std::u16string>& path,
|
||||
+ bool in_toolbar,
|
||||
+ std::vector<user_data_importer::ImportedBookmarkEntry>* bookmarks,
|
||||
+ std::unordered_set<std::string>& visited) {
|
||||
+ if (!visited.insert(item_id).second) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ auto it = items.find(item_id);
|
||||
+ if (it == items.end()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ const ArcSidebarItem& item = it->second;
|
||||
+ if (item.saved_url.starts_with("arc://")) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ bool is_folder = item.saved_url.empty() && !item.children_ids.empty() &&
|
||||
+ !item.is_container;
|
||||
+
|
||||
+ if (!item.saved_url.empty()) {
|
||||
+ user_data_importer::ImportedBookmarkEntry entry;
|
||||
+ entry.in_toolbar = in_toolbar;
|
||||
+ entry.is_folder = false;
|
||||
+ entry.url = GURL(item.saved_url);
|
||||
+ entry.path = path;
|
||||
+ entry.title =
|
||||
+ base::UTF8ToUTF16(!item.title.empty() ? item.title : item.saved_title);
|
||||
+ if (item.created_at > 0) {
|
||||
+ entry.creation_time = CFAbsoluteTimeToBaseTime(item.created_at);
|
||||
+ }
|
||||
+ bookmarks->push_back(std::move(entry));
|
||||
+ } else if (is_folder) {
|
||||
+ std::string folder_name = item.title;
|
||||
+ if (folder_name.empty()) {
|
||||
+ folder_name = item.saved_title;
|
||||
+ }
|
||||
+ if (folder_name.empty()) {
|
||||
+ folder_name = "Folder";
|
||||
+ }
|
||||
+
|
||||
+ std::vector<std::u16string> child_path = path;
|
||||
+ child_path.push_back(base::UTF8ToUTF16(folder_name));
|
||||
+ for (const auto& child_id : item.children_ids) {
|
||||
+ WalkItem(child_id, items, child_path, in_toolbar, bookmarks, visited);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // For containers, just recurse into children.
|
||||
+ if (item.is_container) {
|
||||
+ for (const auto& child_id : item.children_ids) {
|
||||
+ WalkItem(child_id, items, path, in_toolbar, bookmarks, visited);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+struct SpaceInfo {
|
||||
+ std::string id;
|
||||
+ std::string pinned_container_id;
|
||||
+};
|
||||
+
|
||||
+// Parse the spaces list from the sidebar data container.
|
||||
+// Spaces alternate: ["spaceId", {spaceObj}, ...] and each space has
|
||||
+// containerIDs: ["pinned", "<id>", "unpinned", "<id>"].
|
||||
+std::vector<SpaceInfo> ParseSpaces(const base::ListValue* spaces_list) {
|
||||
+ std::vector<SpaceInfo> spaces;
|
||||
+ if (!spaces_list) {
|
||||
+ return spaces;
|
||||
+ }
|
||||
+
|
||||
+ for (size_t i = 0; i + 1 < spaces_list->size(); i += 2) {
|
||||
+ const auto* space_id = (*spaces_list)[i].GetIfString();
|
||||
+ const auto* space_dict = (*spaces_list)[i + 1].GetIfDict();
|
||||
+ if (!space_id || !space_dict) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ SpaceInfo space;
|
||||
+ space.id = *space_id;
|
||||
+
|
||||
+ const auto* container_ids = space_dict->FindList("containerIDs");
|
||||
+ if (container_ids) {
|
||||
+ for (size_t j = 0; j + 1 < container_ids->size(); j += 2) {
|
||||
+ const auto* label = (*container_ids)[j].GetIfString();
|
||||
+ const auto* cid = (*container_ids)[j + 1].GetIfString();
|
||||
+ if (!label || !cid) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (*label == "pinned") {
|
||||
+ space.pinned_container_id = *cid;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ spaces.push_back(std::move(space));
|
||||
+ }
|
||||
+ return spaces;
|
||||
+}
|
||||
+
|
||||
+} // namespace
|
||||
+
|
||||
+ArcSidebarImporter::ArcSidebarImporter() = default;
|
||||
+
|
||||
+ArcSidebarImporter::~ArcSidebarImporter() = default;
|
||||
+
|
||||
+constexpr const base::FilePath::StringViewType kStorableSidebarFilename =
|
||||
+ FILE_PATH_LITERAL("StorableSidebar.json");
|
||||
+
|
||||
+base::FilePath ArcSidebarImporter::GetStorableSidebarPath() const {
|
||||
+ const std::array<base::FilePath, 3> sidebar_paths = {
|
||||
+ source_path_.DirName().DirName().Append(kStorableSidebarFilename),
|
||||
+ source_path_.DirName().Append(kStorableSidebarFilename),
|
||||
+ source_path_.Append(kStorableSidebarFilename),
|
||||
+ };
|
||||
+
|
||||
+ for (const auto& path : sidebar_paths) {
|
||||
+ if (base::PathExists(path)) {
|
||||
+ return path;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return {};
|
||||
+}
|
||||
+
|
||||
+std::optional<base::DictValue> ArcSidebarImporter::LoadSidebarData(
|
||||
+ base::FilePath path) const {
|
||||
+ std::string sidebar_content;
|
||||
+ if (!base::ReadFileToString(path, &sidebar_content)) {
|
||||
+ LOG(WARNING) << "failed to read arc data";
|
||||
+ return std::nullopt;
|
||||
+ }
|
||||
+
|
||||
+ std::optional<base::DictValue> root = base::JSONReader::ReadDict(
|
||||
+ sidebar_content, base::JSON_PARSE_CHROMIUM_EXTENSIONS);
|
||||
+ if (!root) {
|
||||
+ LOG(WARNING) << "failed to parse arc data";
|
||||
+ return std::nullopt;
|
||||
+ }
|
||||
+
|
||||
+ if (!root->FindDict("sidebar")) {
|
||||
+ return std::nullopt;
|
||||
+ }
|
||||
+
|
||||
+ return root;
|
||||
+}
|
||||
+
|
||||
+void ArcSidebarImporter::ImportBookmarksImpl() {
|
||||
+ base::FilePath path = GetStorableSidebarPath();
|
||||
+ if (path.empty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ auto root = LoadSidebarData(path);
|
||||
+ if (!root) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ const auto* sidebar = root->FindDict("sidebar");
|
||||
+ const auto* containers = sidebar->FindList("containers");
|
||||
+ if (!containers || containers->size() < 2) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ const auto* data_container = (*containers)[1].GetIfDict();
|
||||
+ if (!data_container) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ const auto* items_list = data_container->FindList("items");
|
||||
+ if (!items_list) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ auto items = ParseItems(*items_list);
|
||||
+ if (items.empty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ auto spaces = ParseSpaces(data_container->FindList("spaces"));
|
||||
+ std::unordered_set<std::string> visited_ids;
|
||||
+ std::vector<user_data_importer::ImportedBookmarkEntry> bookmarks;
|
||||
+ const auto* top_apps_ids = data_container->FindList("topAppsContainerIDs");
|
||||
+ if (top_apps_ids) {
|
||||
+ for (size_t i = 0; i + 1 < top_apps_ids->size(); i += 2) {
|
||||
+ const auto* id = (*top_apps_ids)[i + 1].GetIfString();
|
||||
+ if (!id) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ auto it = items.find(*id);
|
||||
+ if (it != items.end()) {
|
||||
+ std::vector<std::u16string> path_parts;
|
||||
+ for (const auto& child_id : it->second.children_ids) {
|
||||
+ WalkItem(child_id, items, path_parts, /*in_toolbar=*/true, &bookmarks,
|
||||
+ visited_ids);
|
||||
+ }
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ bool multiple_spaces = spaces.size() > 1;
|
||||
+
|
||||
+ for (const auto& space : spaces) {
|
||||
+ if (space.pinned_container_id.empty()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ auto it = items.find(space.pinned_container_id);
|
||||
+ if (it == items.end() || it->second.children_ids.empty()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ std::vector<std::u16string> path_parts;
|
||||
+ if (multiple_spaces) {
|
||||
+ std::string space_name = space.id;
|
||||
+ if (space_name.contains("defaultPersonalSpaceID")) {
|
||||
+ space_name = "Personal";
|
||||
+ }
|
||||
+ path_parts.push_back(base::UTF8ToUTF16(space_name));
|
||||
+ }
|
||||
+
|
||||
+ for (const auto& child_id : it->second.children_ids) {
|
||||
+ WalkItem(child_id, items, path_parts, /*in_toolbar=*/false, &bookmarks,
|
||||
+ visited_ids);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!bookmarks.empty() && !cancelled()) {
|
||||
+ bridge_->AddBookmarks(
|
||||
+ bookmarks, l10n_util::GetStringFUTF16(IDS_IMPORTED_FROM_BOOKMARK_FOLDER,
|
||||
+ importer_name_));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void ArcSidebarImporter::ImportBookmarks() {
|
||||
+ // Only call the base class if the Chromium Bookmarks file exists — Arc
|
||||
+ // typically doesn't have one, and ScopedCopyFile DCHECKs on missing files.
|
||||
+ base::FilePath bookmarks_path = source_path_.Append(
|
||||
+ base::FilePath::StringType(FILE_PATH_LITERAL("Bookmarks")));
|
||||
+ if (base::PathExists(bookmarks_path)) {
|
||||
+ ChromeImporter::ImportBookmarks();
|
||||
+ }
|
||||
+ ImportBookmarksImpl();
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/chrome/utility/importer/arc_sidebar_importer.h
|
||||
@@ -0,0 +1,34 @@
|
||||
+// Copyright 2026 The Helium Authors
|
||||
+// You can use, redistribute, and/or modify this source code under
|
||||
+// the terms of the GPL-3.0 license that can be found in the LICENSE file.
|
||||
+
|
||||
+#ifndef CHROME_UTILITY_IMPORTER_ARC_SIDEBAR_IMPORTER_H_
|
||||
+#define CHROME_UTILITY_IMPORTER_ARC_SIDEBAR_IMPORTER_H_
|
||||
+
|
||||
+#include <string>
|
||||
+#include <vector>
|
||||
+
|
||||
+#include "chrome/utility/importer/chrome_importer.h"
|
||||
+
|
||||
+namespace user_data_importer {
|
||||
+struct ImportedBookmarkEntry;
|
||||
+} // namespace user_data_importer
|
||||
+
|
||||
+class ArcSidebarImporter : public ChromeImporter {
|
||||
+ public:
|
||||
+ ArcSidebarImporter();
|
||||
+ ArcSidebarImporter(const ArcSidebarImporter&) = delete;
|
||||
+ ArcSidebarImporter& operator=(const ArcSidebarImporter&) = delete;
|
||||
+
|
||||
+ protected:
|
||||
+ ~ArcSidebarImporter() override;
|
||||
+
|
||||
+ void ImportBookmarks() override;
|
||||
+
|
||||
+ private:
|
||||
+ base::FilePath GetStorableSidebarPath() const;
|
||||
+ void ImportBookmarksImpl();
|
||||
+ std::optional<base::DictValue> LoadSidebarData(base::FilePath path) const;
|
||||
+};
|
||||
+
|
||||
+#endif // CHROME_UTILITY_IMPORTER_ARC_SIDEBAR_IMPORTER_H_
|
||||
--- a/chrome/common/importer/chrome_importer_utils.cc
|
||||
+++ b/chrome/common/importer/chrome_importer_utils.cc
|
||||
@@ -206,6 +206,16 @@ bool ChromeImporterCanImport(const base:
|
||||
*services_supported |= user_data_importer::FAVORITES;
|
||||
}
|
||||
|
||||
+ // Arc stores sidebar items (pinned tabs, top apps, folders) in
|
||||
+ // StorableSidebar.json at the Arc root, two levels above the profile dir.
|
||||
+ if (type == user_data_importer::TYPE_ARC) {
|
||||
+ base::FilePath sidebar = profile.DirName().DirName().Append(
|
||||
+ base::FilePath::StringType(FILE_PATH_LITERAL("StorableSidebar.json")));
|
||||
+ if (base::PathExists(sidebar)) {
|
||||
+ *services_supported |= user_data_importer::FAVORITES;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
base::FilePath history =
|
||||
profile.Append(base::FilePath::StringType(FILE_PATH_LITERAL("History")));
|
||||
if (base::PathExists(history)) {
|
||||
--- a/chrome/utility/BUILD.gn
|
||||
+++ b/chrome/utility/BUILD.gn
|
||||
@@ -97,6 +97,8 @@ static_library("utility") {
|
||||
"importer/brave_external_process_importer_bridge.h",
|
||||
"importer/brave_profile_import_impl.cc",
|
||||
"importer/brave_profile_import_impl.h",
|
||||
+ "importer/arc_sidebar_importer.cc",
|
||||
+ "importer/arc_sidebar_importer.h",
|
||||
"importer/chrome_importer.cc",
|
||||
"importer/chrome_importer.h",
|
||||
"importer/external_process_importer_bridge.cc",
|
||||
--- a/chrome/utility/importer/brave_profile_import_impl.cc
|
||||
+++ b/chrome/utility/importer/brave_profile_import_impl.cc
|
||||
@@ -16,10 +16,11 @@
|
||||
#include "base/notreached.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "base/threading/thread.h"
|
||||
-#include "chrome/utility/importer/brave_external_process_importer_bridge.h"
|
||||
-#include "chrome/utility/importer/chrome_importer.h"
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/common/importer/profile_import.mojom.h"
|
||||
+#include "chrome/utility/importer/arc_sidebar_importer.h"
|
||||
+#include "chrome/utility/importer/brave_external_process_importer_bridge.h"
|
||||
+#include "chrome/utility/importer/chrome_importer.h"
|
||||
#include "chrome/utility/importer/external_process_importer_bridge.h"
|
||||
#include "chrome/utility/importer/importer.h"
|
||||
#include "components/user_data_importer/common/importer_type.h"
|
||||
@@ -45,7 +46,7 @@ scoped_refptr<Importer> CreateImporterBy
|
||||
case user_data_importer::TYPE_WHALE:
|
||||
return new ChromeImporter();
|
||||
case user_data_importer::TYPE_ARC:
|
||||
- return new ChromeImporter();
|
||||
+ return new ArcSidebarImporter();
|
||||
case user_data_importer::TYPE_DIA:
|
||||
return new ChromeImporter();
|
||||
case user_data_importer::TYPE_PERPLEXITY_COMET:
|
||||
--- a/chrome/utility/importer/chrome_importer.h
|
||||
+++ b/chrome/utility/importer/chrome_importer.h
|
||||
@@ -43,12 +43,13 @@ class ChromeImporter : public Importer {
|
||||
protected:
|
||||
~ChromeImporter() override;
|
||||
|
||||
- void ImportBookmarks();
|
||||
+ virtual void ImportBookmarks();
|
||||
void ImportHistory();
|
||||
|
||||
double chromeTimeToDouble(int64_t time);
|
||||
|
||||
base::FilePath source_path_;
|
||||
+ std::u16string importer_name_;
|
||||
|
||||
private:
|
||||
// Multiple URLs can share the same favicon; this is a map
|
||||
@@ -69,8 +70,6 @@ class ChromeImporter : public Importer {
|
||||
const std::vector<std::u16string>& parent_path,
|
||||
bool is_in_toolbar,
|
||||
std::vector<user_data_importer::ImportedBookmarkEntry>* bookmarks);
|
||||
-
|
||||
- std::u16string importer_name_;
|
||||
};
|
||||
|
||||
#endif // BRAVE_UTILITY_IMPORTER_CHROME_IMPORTER_H_
|
||||
@@ -40,7 +40,18 @@
|
||||
registry->RegisterBooleanPref(policy::policy_prefs::kHideWebStoreIcon, false);
|
||||
--- a/chrome/browser/ui/browser_command_controller.cc
|
||||
+++ b/chrome/browser/ui/browser_command_controller.cc
|
||||
@@ -413,7 +413,9 @@ bool BrowserCommandController::IsReserve
|
||||
@@ -282,6 +282,10 @@ BrowserCommandController::BrowserCommand
|
||||
base::Unretained(this)));
|
||||
#endif // BUILDFLAG(ENABLE_PRINTING)
|
||||
profile_pref_registrar_.Add(
|
||||
+ prefs::kCopyPageUrlShortcut,
|
||||
+ base::BindRepeating(&BrowserCommandController::UpdateCommandsForDevTools,
|
||||
+ base::Unretained(this)));
|
||||
+ profile_pref_registrar_.Add(
|
||||
policy::policy_prefs::kDownloadRestrictions,
|
||||
base::BindRepeating(&BrowserCommandController::UpdateSaveAsState,
|
||||
base::Unretained(this)));
|
||||
@@ -413,7 +417,9 @@ bool BrowserCommandController::IsReserve
|
||||
command_id == IDC_NEW_INCOGNITO_WINDOW || command_id == IDC_NEW_TAB ||
|
||||
command_id == IDC_NEW_WINDOW || command_id == IDC_RESTORE_TAB ||
|
||||
command_id == IDC_SELECT_NEXT_TAB ||
|
||||
@@ -51,7 +62,7 @@
|
||||
}
|
||||
|
||||
void BrowserCommandController::TabStateChanged() {
|
||||
@@ -1232,6 +1234,14 @@ bool BrowserCommandController::ExecuteCo
|
||||
@@ -1232,6 +1238,14 @@ bool BrowserCommandController::ExecuteCo
|
||||
case IDC_DUPLICATE_TARGET_TAB:
|
||||
DuplicateKeyboardFocusedTab(browser_);
|
||||
break;
|
||||
@@ -66,7 +77,7 @@
|
||||
// Hosted App commands
|
||||
case IDC_COPY_URL:
|
||||
CopyURL(browser_, browser_->tab_strip_model()->GetActiveWebContents());
|
||||
@@ -2019,6 +2029,12 @@ void BrowserCommandController::UpdateCom
|
||||
@@ -2019,6 +2033,12 @@ void BrowserCommandController::UpdateCom
|
||||
|
||||
bool dev_tools_enabled = DevToolsWindow::AllowDevToolsFor(
|
||||
profile(), browser_->tab_strip_model()->GetActiveWebContents());
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
+ Compact
|
||||
+ </message>
|
||||
+ <message name="IDS_BROWSER_LAYOUT_VERTICAL" desc="In Title Case: Option for vertical layout.">
|
||||
+ Vertical (Experimental)
|
||||
+ Vertical
|
||||
+ </message>
|
||||
+ <message name="IDS_BROWSER_LAYOUT_VERTICAL_RIGHT" desc="In Title Case: Option to move vertical tabs to the right side.">
|
||||
+ Tabs on Right Side
|
||||
@@ -57,7 +57,7 @@
|
||||
+ Compact
|
||||
+ </message>
|
||||
+ <message name="IDS_BROWSER_LAYOUT_VERTICAL" desc="Option for vertical layout.">
|
||||
+ Vertical (experimental)
|
||||
+ Vertical
|
||||
+ </message>
|
||||
+ <message name="IDS_BROWSER_LAYOUT_VERTICAL_RIGHT" desc="Option to move vertical tabs to the right side.">
|
||||
+ Tabs on right side
|
||||
@@ -124,7 +124,7 @@
|
||||
tab_search::mojom::TabSearchSection::kOrganize,
|
||||
--- a/chrome/browser/ui/browser_command_controller.cc
|
||||
+++ b/chrome/browser/ui/browser_command_controller.cc
|
||||
@@ -693,6 +693,18 @@ bool BrowserCommandController::ExecuteCo
|
||||
@@ -697,6 +697,18 @@ bool BrowserCommandController::ExecuteCo
|
||||
case IDC_NAME_WINDOW:
|
||||
PromptToNameWindow(browser_);
|
||||
break;
|
||||
@@ -143,7 +143,7 @@
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
case IDC_TAKE_SCREENSHOT:
|
||||
@@ -1510,6 +1522,14 @@ void BrowserCommandController::InitComma
|
||||
@@ -1514,6 +1526,14 @@ void BrowserCommandController::InitComma
|
||||
command_updater_.UpdateCommandEnabled(IDC_SHOW_SEARCH_TOOLS, true);
|
||||
command_updater_.UpdateCommandEnabled(IDC_SHOW_AI_MODE_OMNIBOX_BUTTON, true);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
+ Compact
|
||||
+ </message>
|
||||
+ <message name="IDS_SETTINGS_BROWSER_LAYOUT_VERTICAL" desc="Vertical option in the browser layout dropdown.">
|
||||
+ Vertical (experimental)
|
||||
+ Vertical
|
||||
+ </message>
|
||||
+ <message name="IDS_SETTINGS_TAB_STRIP_RIGHT_ALIGN" desc="Label for the toggle that displays vertical tabs on the right side of the browser window.">
|
||||
+ Show vertical tabs on right side
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
--- a/chrome/common/pref_names.h
|
||||
+++ b/chrome/common/pref_names.h
|
||||
@@ -1554,6 +1554,11 @@ inline constexpr char kPrefersDefaultScr
|
||||
inline constexpr char kCopyPageUrlShortcut[] =
|
||||
"helium.settings.a11y.copy_page_url_shortcut";
|
||||
|
||||
+// Boolean that indicates whether the user has enabled the keyboard shortcut
|
||||
+// for toggling vertical tabs in vertical layout.
|
||||
+inline constexpr char kVerticalCollapseShortcut[] =
|
||||
+ "helium.settings.behavior.vertical_collapse_shortcut";
|
||||
+
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// Boolean that indicates whether the application should show the info bar
|
||||
// asking the user to set up automatic updates when Keystone promotion is
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -167,6 +167,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
base::ListValue());
|
||||
|
||||
registry->RegisterBooleanPref(prefs::kCopyPageUrlShortcut, true);
|
||||
+ registry->RegisterBooleanPref(prefs::kVerticalCollapseShortcut, true);
|
||||
|
||||
// We need to register the type of these preferences in order to query
|
||||
// them even though they're only typically controlled via policy.
|
||||
--- a/chrome/app/chrome_command_ids.h
|
||||
+++ b/chrome/app/chrome_command_ids.h
|
||||
@@ -100,6 +100,7 @@
|
||||
#define IDC_BROWSER_LAYOUT_COMPACT 34083
|
||||
#define IDC_BROWSER_LAYOUT_VERTICAL 34084
|
||||
#define IDC_BROWSER_LAYOUT_VERTICAL_RIGHT 34085
|
||||
+#define IDC_CTRL_S_SHORTCUT 34086
|
||||
|
||||
// Tab group Commands
|
||||
#define IDC_ADD_NEW_TAB_TO_GROUP 34100
|
||||
--- a/chrome/browser/ui/browser_command_controller.cc
|
||||
+++ b/chrome/browser/ui/browser_command_controller.cc
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "chrome/browser/ui/chrome_pages.h"
|
||||
#include "chrome/browser/ui/customize_chrome/side_panel_controller.h"
|
||||
#include "chrome/browser/ui/dialogs/browser_dialogs.h"
|
||||
+#include "chrome/browser/ui/helium/helium_layout_state_controller.h"
|
||||
#include "chrome/browser/ui/lens/lens_overlay_controller.h"
|
||||
#include "chrome/browser/ui/managed_ui.h"
|
||||
#include "chrome/browser/ui/page_info/page_info_dialog.h"
|
||||
@@ -71,6 +72,7 @@
|
||||
#include "chrome/browser/ui/tabs/tab_model.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_user_gesture_details.h"
|
||||
+#include "chrome/browser/ui/tabs/vertical_tab_strip_state_controller.h"
|
||||
#include "chrome/browser/ui/toolbar/chrome_labs/chrome_labs_utils.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/browser/ui/views/frame/browser_view.h"
|
||||
@@ -222,6 +224,13 @@ void InvokeAction(actions::ActionId id,
|
||||
actions::ActionManager::Get().FindAction(id, scope)->InvokeAction();
|
||||
}
|
||||
|
||||
+bool ShouldToggleVerticalCollapse(PrefService* prefs) {
|
||||
+ return tabs::IsVerticalTabsFeatureEnabled() &&
|
||||
+ prefs->GetBoolean(prefs::kVerticalCollapseShortcut) &&
|
||||
+ prefs->GetInteger(prefs::kHeliumLayout) ==
|
||||
+ std::to_underlying(HeliumLayoutType::kVertical);
|
||||
+}
|
||||
+
|
||||
} // namespace
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -275,6 +284,10 @@ BrowserCommandController::BrowserCommand
|
||||
base::BindRepeating(
|
||||
&BrowserCommandController::UpdateCommandsForIncognitoAvailability,
|
||||
base::Unretained(this)));
|
||||
+ profile_pref_registrar_.AddMultiple(
|
||||
+ {prefs::kHeliumLayout, prefs::kVerticalCollapseShortcut},
|
||||
+ base::BindRepeating(&BrowserCommandController::UpdateSaveAsState,
|
||||
+ base::Unretained(this)));
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
profile_pref_registrar_.Add(
|
||||
prefs::kPrintingEnabled,
|
||||
@@ -1258,6 +1271,20 @@ bool BrowserCommandController::ExecuteCo
|
||||
copy ? IDC_COPY_URL : IDC_DEV_TOOLS_INSPECT,
|
||||
disposition, time_stamp);
|
||||
}
|
||||
+ case IDC_CTRL_S_SHORTCUT: {
|
||||
+ PrefService* prefs = profile()->GetPrefs();
|
||||
+ if (ShouldToggleVerticalCollapse(prefs)) {
|
||||
+ auto* controller =
|
||||
+ tabs::VerticalTabStripStateController::From(browser_);
|
||||
+ if (controller) {
|
||||
+ controller->SetCollapsed(!controller->IsCollapsed());
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ExecuteCommandWithDisposition(IDC_SAVE_PAGE, disposition,
|
||||
+ time_stamp);
|
||||
+ }
|
||||
// Hosted App commands
|
||||
case IDC_COPY_URL:
|
||||
CopyURL(browser_, browser_->tab_strip_model()->GetActiveWebContents());
|
||||
@@ -2296,7 +2323,10 @@ void BrowserCommandController::UpdateSav
|
||||
return;
|
||||
}
|
||||
|
||||
- command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, CanSavePage(browser_));
|
||||
+ const bool can_save_page = CanSavePage(browser_);
|
||||
+ command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, can_save_page);
|
||||
+ command_updater_.UpdateCommandEnabled(IDC_CTRL_S_SHORTCUT,
|
||||
+ can_save_page || ShouldToggleVerticalCollapse(profile()->GetPrefs()));
|
||||
}
|
||||
|
||||
void BrowserCommandController::UpdateReloadStopState(bool is_loading,
|
||||
--- a/chrome/browser/ui/accelerator_table.cc
|
||||
+++ b/chrome/browser/ui/accelerator_table.cc
|
||||
@@ -70,7 +70,7 @@ const AcceleratorMapping kAcceleratorMap
|
||||
{ui::VKEY_R, ui::EF_PLATFORM_ACCELERATOR, IDC_RELOAD},
|
||||
{ui::VKEY_R, ui::EF_SHIFT_DOWN | ui::EF_PLATFORM_ACCELERATOR,
|
||||
IDC_RELOAD_BYPASSING_CACHE},
|
||||
- {ui::VKEY_S, ui::EF_PLATFORM_ACCELERATOR, IDC_SAVE_PAGE},
|
||||
+ {ui::VKEY_S, ui::EF_PLATFORM_ACCELERATOR, IDC_CTRL_S_SHORTCUT},
|
||||
{ui::VKEY_9, ui::EF_PLATFORM_ACCELERATOR, IDC_SELECT_LAST_TAB},
|
||||
{ui::VKEY_NUMPAD9, ui::EF_PLATFORM_ACCELERATOR, IDC_SELECT_LAST_TAB},
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
--- a/chrome/browser/global_keyboard_shortcuts_mac.mm
|
||||
+++ b/chrome/browser/global_keyboard_shortcuts_mac.mm
|
||||
@@ -143,6 +143,8 @@ const std::vector<KeyboardShortcutData>&
|
||||
{true, false, false, false, kVK_ANSI_9, IDC_SELECT_LAST_TAB},
|
||||
{true, false, false, false, kVK_ANSI_Keypad9, IDC_SELECT_LAST_TAB},
|
||||
|
||||
+ {true, false, false, false, kVK_ANSI_S, IDC_CTRL_S_SHORTCUT},
|
||||
+
|
||||
{true, true, false, false, kVK_ANSI_M, IDC_SHOW_AVATAR_MENU},
|
||||
{true, false, false, true, kVK_ANSI_L, IDC_SHOW_DOWNLOADS},
|
||||
{true, true, false, false, kVK_ANSI_I, IDC_DEV_TOOLS},
|
||||
--- a/chrome/browser/ui/cocoa/accelerators_cocoa.mm
|
||||
+++ b/chrome/browser/ui/cocoa/accelerators_cocoa.mm
|
||||
@@ -48,7 +48,7 @@ const struct AcceleratorMapping {
|
||||
{IDC_PASTE, ui::EF_COMMAND_DOWN, ui::VKEY_V},
|
||||
{IDC_PRINT, ui::EF_COMMAND_DOWN, ui::VKEY_P},
|
||||
{IDC_RESTORE_TAB, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN, ui::VKEY_T},
|
||||
- {IDC_SAVE_PAGE, ui::EF_COMMAND_DOWN, ui::VKEY_S},
|
||||
+ {IDC_CTRL_S_SHORTCUT, ui::EF_COMMAND_DOWN, ui::VKEY_S},
|
||||
{IDC_SHOW_BOOKMARK_BAR, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN,
|
||||
ui::VKEY_B},
|
||||
{IDC_SHOW_BOOKMARK_MANAGER, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN,
|
||||
--- a/chrome/browser/ui/views/frame/browser_native_widget_mac.mm
|
||||
+++ b/chrome/browser/ui/views/frame/browser_native_widget_mac.mm
|
||||
@@ -264,6 +264,7 @@ void BrowserNativeWidgetMac::ValidateUse
|
||||
case IDC_PIN_TARGET_TAB:
|
||||
case IDC_PRINT:
|
||||
case IDC_RELOAD:
|
||||
+ case IDC_CTRL_S_SHORTCUT:
|
||||
case IDC_SAVE_PAGE:
|
||||
case IDC_SELECT_NEXT_TAB:
|
||||
case IDC_SELECT_PREVIOUS_TAB:
|
||||
--- a/chrome/app/chrome_dll.rc
|
||||
+++ b/chrome/app/chrome_dll.rc
|
||||
@@ -84,7 +84,7 @@ BEGIN
|
||||
VK_F5, IDC_RELOAD_BYPASSING_CACHE, VIRTKEY, CONTROL
|
||||
VK_F5, IDC_RELOAD_BYPASSING_CACHE, VIRTKEY, SHIFT
|
||||
"T", IDC_RESTORE_TAB, VIRTKEY, CONTROL, SHIFT
|
||||
- "S", IDC_SAVE_PAGE, VIRTKEY, CONTROL
|
||||
+ "S", IDC_CTRL_S_SHORTCUT, VIRTKEY, CONTROL
|
||||
"9", IDC_SELECT_LAST_TAB, VIRTKEY, CONTROL
|
||||
VK_NUMPAD9, IDC_SELECT_LAST_TAB, VIRTKEY, CONTROL
|
||||
VK_NEXT, IDC_MOVE_TAB_NEXT, VIRTKEY, CONTROL, SHIFT
|
||||
--- a/chrome/app/settings_strings.grdp
|
||||
+++ b/chrome/app/settings_strings.grdp
|
||||
@@ -200,6 +200,16 @@
|
||||
Enable quick page link copying with Ctrl+Shift+C
|
||||
</message>
|
||||
</if>
|
||||
+ <if expr="is_macosx">
|
||||
+ <message name="IDS_SETTINGS_VERTICAL_COLLAPSE_SHORTCUT" desc="Toggle in settings that allows you to enable the keyboard shortcut that toggles vertical tabs in the Vertical layout. It's enabled by default.">
|
||||
+ Use ⌘+S to toggle vertical tabs in Vertical layout
|
||||
+ </message>
|
||||
+ </if>
|
||||
+ <if expr="not is_macosx">
|
||||
+ <message name="IDS_SETTINGS_VERTICAL_COLLAPSE_SHORTCUT" desc="Toggle in settings that allows you to enable the keyboard shortcut that toggles vertical tabs in the Vertical layout. It's enabled by default.">
|
||||
+ Use Ctrl+S to toggle vertical tabs in Vertical layout
|
||||
+ </message>
|
||||
+ </if>
|
||||
|
||||
<!-- Appearance Page -->
|
||||
<message name="IDS_SETTINGS_APPEARANCE" desc="Name of the settings page which displays appearance preferences.">
|
||||
--- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
|
||||
+++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
|
||||
@@ -511,6 +511,7 @@ void AddAppearanceStrings(content::WebUI
|
||||
{"browserLayoutCompact", IDS_SETTINGS_BROWSER_LAYOUT_COMPACT},
|
||||
{"browserLayoutVertical", IDS_SETTINGS_BROWSER_LAYOUT_VERTICAL},
|
||||
{"tabStripRightAlign", IDS_SETTINGS_TAB_STRIP_RIGHT_ALIGN},
|
||||
+ {"verticalCollapseShortcut", IDS_SETTINGS_VERTICAL_COLLAPSE_SHORTCUT},
|
||||
{"showHomeButton", IDS_SETTINGS_SHOW_HOME_BUTTON},
|
||||
{"showBookmarksBar", IDS_SETTINGS_SHOW_BOOKMARKS_BAR},
|
||||
{"tabStripPosition", IDS_SETTINGS_TAB_STRIP_POSITION},
|
||||
--- a/chrome/browser/extensions/api/settings_private/prefs_util.cc
|
||||
+++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc
|
||||
@@ -638,6 +638,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil
|
||||
settings_api::PrefType::kBoolean;
|
||||
(*s_allowlist)[::prefs::kCopyPageUrlShortcut] =
|
||||
settings_api::PrefType::kBoolean;
|
||||
+ (*s_allowlist)[::prefs::kVerticalCollapseShortcut] =
|
||||
+ settings_api::PrefType::kBoolean;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
// Accounts / Users / People.
|
||||
--- a/chrome/browser/resources/settings/appearance_page/appearance_behavior_page.html
|
||||
+++ b/chrome/browser/resources/settings/appearance_page/appearance_behavior_page.html
|
||||
@@ -16,6 +16,11 @@
|
||||
label="$i18n{copyPageUrlShortcut}">
|
||||
</settings-toggle-button>
|
||||
|
||||
+ <settings-toggle-button class="hr" id="verticalCollapseShortcut"
|
||||
+ pref="{{prefs.helium.settings.behavior.vertical_collapse_shortcut}}"
|
||||
+ label="$i18n{verticalCollapseShortcut}">
|
||||
+ </settings-toggle-button>
|
||||
+
|
||||
<settings-toggle-button class="hr" id="autoPinNewTabGroups"
|
||||
pref="{{prefs.auto_pin_new_tab_groups}}"
|
||||
label="$i18n{autoPinNewTabGroups}">
|
||||
@@ -102,6 +102,7 @@ brave/fix-component-content-settings-store.patch
|
||||
brave/tab-cycling-mru-impl.patch
|
||||
|
||||
helium/core/add-zen-importer.patch
|
||||
helium/core/add-arc-importer.patch
|
||||
helium/core/disable-unsupported-importers.patch
|
||||
helium/core/fix-building-without-safebrowsing.patch
|
||||
helium/core/services-prefs.patch
|
||||
@@ -273,6 +274,7 @@ helium/ui/remove-zoom-action.patch
|
||||
helium/ui/layout/core.patch
|
||||
helium/ui/layout/settings.patch
|
||||
helium/ui/layout/context-menu.patch
|
||||
helium/ui/layout/shortcuts.patch
|
||||
helium/ui/layout/compact.patch
|
||||
helium/ui/layout/vertical.patch
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2
|
||||
3
|
||||
|
||||
Reference in New Issue
Block a user