diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index 0a5863232caf..967cecb8c981 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -898,15 +898,6 @@ Or change later at $2brave://settings/ext Bookmark all tabs... - - Use vertical tabs - - - Show title bar - - - Float on mouseover - {NUM_TABS, plural, =1 {Mute tab} other {Mute tabs}} @@ -924,15 +915,6 @@ Or change later at $2brave://settings/ext Bookmark All Tabs... - - Use Vertical Tabs - - - Show Title Bar - - - Float on Mouseover - {NUM_TABS, plural, =1 {Mute Tab} other {Mute Tabs}} diff --git a/app/brave_settings_strings.grdp b/app/brave_settings_strings.grdp index 0d936cd4e982..1a2b59229c33 100644 --- a/app/brave_settings_strings.grdp +++ b/app/brave_settings_strings.grdp @@ -59,6 +59,18 @@ Brave default images + + Tabs + + + Use vertical tabs + + + Show title bar + + + Float on mouseover + Tab hover mode diff --git a/browser/extensions/api/settings_private/brave_prefs_util.cc b/browser/extensions/api/settings_private/brave_prefs_util.cc index 0e1dc9f50e39..1dbe06332e5d 100644 --- a/browser/extensions/api/settings_private/brave_prefs_util.cc +++ b/browser/extensions/api/settings_private/brave_prefs_util.cc @@ -5,8 +5,10 @@ #include "brave/browser/extensions/api/settings_private/brave_prefs_util.h" +#include "base/feature_list.h" #include "brave/browser/ethereum_remote_client/buildflags/buildflags.h" #include "brave/browser/ui/tabs/brave_tab_prefs.h" +#include "brave/browser/ui/tabs/features.h" #include "brave/components/brave_ads/common/pref_names.h" #include "brave/components/brave_news/common/pref_names.h" #include "brave/components/brave_rewards/common/pref_names.h" @@ -315,6 +317,18 @@ const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetAllowlistedKeys() { // NFT pinning pref (*s_brave_allowlist)[kAutoPinEnabled] = settings_api::PrefType::PREF_TYPE_BOOLEAN; + +#if defined(TOOLKIT_VIEWS) + // Vertical tab strip prefs + if (base::FeatureList::IsEnabled(tabs::features::kBraveVerticalTabs)) { + (*s_brave_allowlist)[brave_tabs::kVerticalTabsEnabled] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_allowlist)[brave_tabs::kVerticalTabsFloatingEnabled] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + (*s_brave_allowlist)[brave_tabs::kVerticalTabsShowTitleOnWindow] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; + } +#endif return *s_brave_allowlist; } diff --git a/browser/resources/settings/brave_appearance_page/tabs.html b/browser/resources/settings/brave_appearance_page/tabs.html new file mode 100644 index 000000000000..e35d13b38e7c --- /dev/null +++ b/browser/resources/settings/brave_appearance_page/tabs.html @@ -0,0 +1,67 @@ + + + +
$i18n{appearanceSettingsTabsSection}
+
+ + + + + + + + + + + + +
+
+
$i18n{appearanceSettingsTabHoverMode}
+
+ + +
+
+ diff --git a/browser/resources/settings/brave_appearance_page/tabs.ts b/browser/resources/settings/brave_appearance_page/tabs.ts new file mode 100644 index 000000000000..72e4560afd80 --- /dev/null +++ b/browser/resources/settings/brave_appearance_page/tabs.ts @@ -0,0 +1,42 @@ +// Copyright (c) 2023 The Brave Authors. All rights reserved. +// 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 https://mozilla.org/MPL/2.0/. + +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import {I18nMixin, I18nMixinInterface} from 'chrome://resources/cr_elements/i18n_mixin.js' +import {PrefsMixin, PrefsMixinInterface} from '../prefs/prefs_mixin.js' +import '../settings_shared.css.js' +import '../settings_vars.css.js' +import {getTemplate} from './tabs.html.js' +import { loadTimeData } from '../i18n_setup.js' + +const SettingsBraveAppearanceTabsElementBase = PrefsMixin(I18nMixin(PolymerElement)) as { + new (): PolymerElement & I18nMixinInterface & PrefsMixinInterface +} + +export class SettingsBraveAppearanceTabsElement extends SettingsBraveAppearanceTabsElementBase { + static get is() { + return 'settings-brave-appearance-tabs' + } + + static get template() { + return getTemplate() + } + + private isVerticalTabStripFeatureEnabled() { + return loadTimeData.getBoolean('verticalTabStripFeatureEnabled') + } + + private tabTooltipModes_ = [ + { value: 1, name: this.i18n('appearanceSettingsTabHoverModeCard') }, + { + value: 2, + name: this.i18n('appearanceSettingsTabHoverModeCardWithPreview') + }, + { value: 0, name: this.i18n('appearanceSettingsTabHoverModeTooltip') } + ] + +} + +customElements.define(SettingsBraveAppearanceTabsElement.is, SettingsBraveAppearanceTabsElement) diff --git a/browser/resources/settings/brave_appearance_page/toolbar.html b/browser/resources/settings/brave_appearance_page/toolbar.html index 1ac13b955f39..17607432bb61 100644 --- a/browser/resources/settings/brave_appearance_page/toolbar.html +++ b/browser/resources/settings/brave_appearance_page/toolbar.html @@ -47,6 +47,7 @@ + @@ -59,22 +60,3 @@ - - - - -
-
-
$i18n{appearanceSettingsTabHoverMode}
-
- - -
diff --git a/browser/resources/settings/brave_appearance_page/toolbar.ts b/browser/resources/settings/brave_appearance_page/toolbar.ts index 7ec33dbb2668..b249384ba768 100644 --- a/browser/resources/settings/brave_appearance_page/toolbar.ts +++ b/browser/resources/settings/brave_appearance_page/toolbar.ts @@ -11,6 +11,7 @@ import {getTemplate} from './toolbar.html.js' import '../settings_shared.css.js' import '../settings_vars.css.js' import './sidebar.js' +import './tabs.js' const SettingsBraveAppearanceToolbarElementBase = I18nMixin(PolymerElement) as { new (): PolymerElement & I18nMixinInterface @@ -48,15 +49,6 @@ class SettingsBraveAppearanceToolbarElement extends SettingsBraveAppearanceToolb // } // } - private tabTooltipModes_ = [ - { value: 1, name: this.i18n('appearanceSettingsTabHoverModeCard') }, - { - value: 2, - name: this.i18n('appearanceSettingsTabHoverModeCardWithPreview') - }, - { value: 0, name: this.i18n('appearanceSettingsTabHoverModeTooltip') } - ] - private showBraveVPNOption_() { return loadTimeData.getBoolean('isBraveVPNEnabled') } diff --git a/browser/resources/settings/sources.gni b/browser/resources/settings/sources.gni index 5d71feecb138..79bb165ae26c 100644 --- a/browser/resources/settings/sources.gni +++ b/browser/resources/settings/sources.gni @@ -11,11 +11,13 @@ import("//brave/browser/shell_integrations/buildflags/buildflags.gni") # webui build pipeline. brave_settings_preprocess_deps = [ "//brave/browser/resources/settings:preprocess" ] + brave_settings_web_component_files = [ + "brave_appearance_page/bookmark_bar.ts", "brave_appearance_page/brave_theme.ts", "brave_appearance_page/sidebar.ts", - "brave_appearance_page/bookmark_bar.ts", "brave_appearance_page/super_referral.ts", + "brave_appearance_page/tabs.ts", "brave_appearance_page/toolbar.ts", "brave_clear_browsing_data_dialog/brave_clear_browsing_data_on_exit_page.ts", "brave_default_extensions_page/brave_default_extensions_page.ts", @@ -32,12 +34,12 @@ brave_settings_web_component_files = [ "brave_privacy_page/brave_personalization_options.ts", "brave_rewards_page/brave_rewards_page.ts", "brave_search_engines_page/brave_search_engines_page.ts", + "brave_site_settings/brave_site_data_details_subpage.ts", "brave_sync_page/brave_sync_code_dialog.ts", "brave_sync_page/brave_sync_configure.ts", "brave_sync_page/brave_sync_delete_account_dialog.ts", "brave_sync_page/brave_sync_page.ts", "brave_sync_page/brave_sync_setup.ts", - "brave_site_settings/brave_site_data_details_subpage.ts", "brave_sync_page/brave_sync_subpage.ts", "brave_system_page/brave_performance_page.ts", "brave_tor_page/brave_tor_bridges_dialog.ts", @@ -55,6 +57,7 @@ brave_settings_web_component_files = [ "getting_started_page/getting_started.ts", "social_blocking_page/social_blocking_page.ts", ] + brave_settings_non_web_component_files = [ "brave_appearance_page/brave_appearance_browser_proxy.ts", "brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.ts", diff --git a/browser/ui/tabs/brave_tab_menu_model.cc b/browser/ui/tabs/brave_tab_menu_model.cc index 22562b0806c5..5fef195a0fdf 100644 --- a/browser/ui/tabs/brave_tab_menu_model.cc +++ b/browser/ui/tabs/brave_tab_menu_model.cc @@ -97,13 +97,4 @@ void BraveTabMenuModel::Build(int selected_tab_count) { AddItemWithStringId(CommandRestoreTab, GetRestoreTabCommandStringId()); AddItemWithStringId(CommandBookmarkAllTabs, IDS_TAB_CXMENU_BOOKMARK_ALL_TABS); - - if (!base::FeatureList::IsEnabled(tabs::features::kBraveVerticalTabs)) - return; - - AddCheckItemWithStringId(CommandShowVerticalTabs, - IDS_TAB_CXMENU_SHOW_VERTICAL_TABS); - AddCheckItemWithStringId(CommandShowTitleBar, IDS_TAB_CXMENU_SHOW_TITLE_BAR); - AddCheckItemWithStringId(CommandUseFloatingVerticalTabStrip, - IDS_TAB_CXMENU_USE_FLOATING_VERTICAL_TABS); } diff --git a/browser/ui/tabs/brave_tab_menu_model.h b/browser/ui/tabs/brave_tab_menu_model.h index 2e3014afd094..ee7a47bd491b 100644 --- a/browser/ui/tabs/brave_tab_menu_model.h +++ b/browser/ui/tabs/brave_tab_menu_model.h @@ -24,9 +24,6 @@ class BraveTabMenuModel : public TabMenuModel { CommandStart = TabStripModel::CommandLast, CommandRestoreTab, CommandBookmarkAllTabs, - CommandShowVerticalTabs, - CommandShowTitleBar, - CommandUseFloatingVerticalTabStrip, CommandToggleTabMuted, CommandLast, }; diff --git a/browser/ui/views/tabs/brave_tab_context_menu_contents.cc b/browser/ui/views/tabs/brave_tab_context_menu_contents.cc index 1e84e1a5f3d8..00021a6edfa4 100644 --- a/browser/ui/views/tabs/brave_tab_context_menu_contents.cc +++ b/browser/ui/views/tabs/brave_tab_context_menu_contents.cc @@ -65,24 +65,6 @@ void BraveTabContextMenuContents::RunMenuAt(const gfx::Point& point, views::MenuAnchorPosition::kTopLeft, source_type); } -bool BraveTabContextMenuContents::IsCommandIdChecked(int command_id) const { - if (!base::FeatureList::IsEnabled(tabs::features::kBraveVerticalTabs)) - return ui::SimpleMenuModel::Delegate::IsCommandIdChecked(command_id); - - if (command_id == BraveTabMenuModel::CommandShowVerticalTabs) - return tabs::utils::ShouldShowVerticalTabs(browser_); - - if (command_id == BraveTabMenuModel::CommandShowTitleBar) { - return tabs::utils::ShouldShowWindowTitleForVerticalTabs(browser_); - } - - if (command_id == BraveTabMenuModel::CommandUseFloatingVerticalTabStrip) { - return tabs::utils::IsFloatingVerticalTabsEnabled(browser_); - } - - return ui::SimpleMenuModel::Delegate::IsCommandIdChecked(command_id); -} - bool BraveTabContextMenuContents::IsCommandIdEnabled(int command_id) const { if (IsBraveCommandId(command_id)) return IsBraveCommandIdEnabled(command_id); @@ -91,21 +73,6 @@ bool BraveTabContextMenuContents::IsCommandIdEnabled(int command_id) const { static_cast(command_id), tab_); } -bool BraveTabContextMenuContents::IsCommandIdVisible(int command_id) const { - if (!base::FeatureList::IsEnabled(tabs::features::kBraveVerticalTabs)) - return ui::SimpleMenuModel::Delegate::IsCommandIdVisible(command_id); - - if (command_id == BraveTabMenuModel::CommandShowVerticalTabs) - return tabs::utils::SupportsVerticalTabs(browser_); - - if (command_id == BraveTabMenuModel::CommandShowTitleBar || - command_id == BraveTabMenuModel::CommandUseFloatingVerticalTabStrip) { - return tabs::utils::ShouldShowVerticalTabs(browser_); - } - - return ui::SimpleMenuModel::Delegate::IsCommandIdVisible(command_id); -} - bool BraveTabContextMenuContents::GetAcceleratorForCommandId( int command_id, ui::Accelerator* accelerator) const { @@ -143,10 +110,6 @@ bool BraveTabContextMenuContents::IsBraveCommandIdEnabled( chrome::CanBookmarkAllTabs(browser_); } break; - case BraveTabMenuModel::CommandShowTitleBar: - case BraveTabMenuModel::CommandShowVerticalTabs: - case BraveTabMenuModel::CommandUseFloatingVerticalTabStrip: - return true; case BraveTabMenuModel::CommandToggleTabMuted: { auto* model = static_cast(controller_->model()); for (const auto& index : model->GetTabIndicesForCommandAt(tab_index_)) { @@ -171,20 +134,6 @@ void BraveTabContextMenuContents::ExecuteBraveCommand(int command_id) { case BraveTabMenuModel::CommandBookmarkAllTabs: chrome::BookmarkAllTabs(browser_); return; - case BraveTabMenuModel::CommandShowVerticalTabs: { - brave::ToggleVerticalTabStrip(browser_); - BrowserView::GetBrowserViewForBrowser(browser_)->InvalidateLayout(); - return; - } - case BraveTabMenuModel::CommandShowTitleBar: { - brave::ToggleWindowTitleVisibilityForVerticalTabs(browser_); - BrowserView::GetBrowserViewForBrowser(browser_)->InvalidateLayout(); - return; - } - case BraveTabMenuModel::CommandUseFloatingVerticalTabStrip: { - brave::ToggleVerticalTabStripFloatingMode(browser_); - return; - } case BraveTabMenuModel::CommandToggleTabMuted: { auto* model = static_cast(controller_->model()); auto indices = model->GetTabIndicesForCommandAt(tab_index_); diff --git a/browser/ui/views/tabs/brave_tab_context_menu_contents.h b/browser/ui/views/tabs/brave_tab_context_menu_contents.h index e8927cefa6c5..9b7652dc91d1 100644 --- a/browser/ui/views/tabs/brave_tab_context_menu_contents.h +++ b/browser/ui/views/tabs/brave_tab_context_menu_contents.h @@ -44,9 +44,7 @@ class BraveTabContextMenuContents : public ui::SimpleMenuModel::Delegate { void RunMenuAt(const gfx::Point& point, ui::MenuSourceType source_type); // ui::SimpleMenuModel::Delegate overrides: - bool IsCommandIdChecked(int command_id) const override; bool IsCommandIdEnabled(int command_id) const override; - bool IsCommandIdVisible(int command_id) const override; bool GetAcceleratorForCommandId(int command_id, ui::Accelerator* accelerator) const override; void ExecuteCommand(int command_id, int event_flags) override; diff --git a/browser/ui/webui/brave_settings_ui.cc b/browser/ui/webui/brave_settings_ui.cc index 1c6e13863ebd..a63e2a4922fd 100644 --- a/browser/ui/webui/brave_settings_ui.cc +++ b/browser/ui/webui/brave_settings_ui.cc @@ -15,6 +15,7 @@ #include "brave/browser/resources/settings/grit/brave_settings_resources.h" #include "brave/browser/resources/settings/grit/brave_settings_resources_map.h" #include "brave/browser/shell_integrations/buildflags/buildflags.h" +#include "brave/browser/ui/tabs/features.h" #include "brave/browser/ui/webui/navigation_bar_data_provider.h" #include "brave/browser/ui/webui/settings/brave_adblock_handler.h" #include "brave/browser/ui/webui/settings/brave_appearance_handler.h" @@ -141,6 +142,11 @@ void BraveSettingsUI::AddResources(content::WebUIDataSource* html_source, html_source->AddBoolean("extensionsManifestV2Feature", base::FeatureList::IsEnabled(kExtensionsManifestV2)); +#if defined(TOOLKIT_VIEWS) + html_source->AddBoolean( + "verticalTabStripFeatureEnabled", + base::FeatureList::IsEnabled(tabs::features::kBraveVerticalTabs)); +#endif } // static diff --git a/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc b/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc index b5433aa3d0f1..ce66e572663d 100644 --- a/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc +++ b/browser/ui/webui/settings/brave_settings_localized_strings_provider.cc @@ -140,6 +140,15 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_APPEARANCE_SETTINGS_GET_MORE_THEMES}, {"appearanceBraveDefaultImagesOptionLabel", IDS_SETTINGS_APPEARANCE_SETTINGS_BRAVE_DEFAULT_IMAGES_OPTION_LABEL}, +#if defined(TOOLKIT_VIEWS) + {"appearanceSettingsTabsSection", + IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_SECTION}, + {"appearanceSettingsTabsUseVerticalTabs", + IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_SHOW_VERTICAL_TABS}, + {"appearanceSettingsTabsShowWindowTitle", + IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_SHOW_TITLE_BAR}, + {"appearanceSettingsTabsFloatOnMouseOver", + IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_USE_FLOATING_VERTICAL_TABS}, {"appearanceSettingsTabHoverMode", IDS_SETTINGS_APPEARANCE_SETTINGS_BRAVE_TAB_HOVER_MODE}, {"appearanceSettingsTabHoverModeCard", @@ -148,7 +157,6 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_APPEARANCE_SETTINGS_BRAVE_TAB_HOVER_MODE_CARD_WITH_PREVIEW}, {"appearanceSettingsTabHoverModeTooltip", IDS_SETTINGS_APPEARANCE_SETTINGS_BRAVE_TAB_HOVER_MODE_TOOLTIP}, -#if defined(TOOLKIT_VIEWS) {"sideBar", IDS_SETTINGS_APPEARNCE_SETTINGS_SIDEBAR_PART_TITLE}, {"appearanceSettingsShowOptionTitle", IDS_SETTINGS_SIDEBAR_SHOW_OPTION_TITLE}, @@ -162,7 +170,7 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_APPEARANCE_SETTINGS_SIDEBAR_ENABLED_DESC}, {"appearanceSettingsSidebarDisabledDesc", IDS_SETTINGS_APPEARANCE_SETTINGS_SIDEBAR_DISABLED_DESC}, -#endif +#endif // defined(TOOLKIT_VIEWS) #if BUILDFLAG(ENABLE_BRAVE_VPN) {"showBraveVPNButton", IDS_SETTINGS_SHOW_VPN_BUTTON}, {"showBraveVPNButtonSubLabel", IDS_SETTINGS_SHOW_VPN_BUTTON_SUB_LABEL},