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

Move Vertical tab settings to brave://settings #18146

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 0 additions & 18 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -898,15 +898,6 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
<message name="IDS_TAB_CXMENU_BOOKMARK_ALL_TABS" desc="The label of the tab context menu item for creating a bookmark folder containing an entry for each open tab.">
Bookmark all tabs...
</message>
<message name="IDS_TAB_CXMENU_SHOW_VERTICAL_TABS" desc="The label of the tab context menu item for showing tabs vertically">
Use vertical tabs
</message>
<message name="IDS_TAB_CXMENU_SHOW_TITLE_BAR" desc="The label of the tab context menu item for showing window title when vertical tab strip is enabled.">
Show title bar
</message>
<message name="IDS_TAB_CXMENU_USE_FLOATING_VERTICAL_TABS" desc="The label of the tab context menu item for enabling floating mode for vertical tab strip">
Float on mouseover
</message>
<message name="IDS_TAB_CXMENU_SOUND_MUTE_TAB" desc="The label of the tab context menu item for muting one or more tabs. NOTE: If having no explicit # makes the phrasing awkward, feel free to add a # as necessary. [ICU Syntax]">
{NUM_TABS, plural, =1 {Mute tab} other {Mute tabs}}
</message>
Expand All @@ -924,15 +915,6 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
<message name="IDS_TAB_CXMENU_BOOKMARK_ALL_TABS" desc="In Title Case: The label of the tab context menu item for creating a bookmark folder containing an entry for each open tab.">
Bookmark All Tabs...
</message>
<message name="IDS_TAB_CXMENU_SHOW_VERTICAL_TABS" desc="The label of the tab context menu item for showing tabs vertically">
Use Vertical Tabs
</message>
<message name="IDS_TAB_CXMENU_SHOW_TITLE_BAR" desc="The label of the tab context menu item for showing window title when vertical tab strip is enabled.">
Show Title Bar
</message>
<message name="IDS_TAB_CXMENU_USE_FLOATING_VERTICAL_TABS" desc="The label of the tab context menu item for enabling floating mode for vertical tab strip">
Float on Mouseover
</message>
<message name="IDS_TAB_CXMENU_SOUND_MUTE_TAB" desc="The label of the tab context menu item for muting one or more tabs. NOTE: If having no explicit # makes the phrasing awkward, feel free to add a # as necessary. [ICU Syntax]">
{NUM_TABS, plural, =1 {Mute Tab} other {Mute Tabs}}
</message>
Expand Down
12 changes: 12 additions & 0 deletions app/brave_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
<message name="IDS_SETTINGS_APPEARANCE_SETTINGS_BRAVE_DEFAULT_IMAGES_OPTION_LABEL" desc="The label for choosing default images over super referral">
Brave default images
</message>
<message name="IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_SECTION" desc="The label for section containing settings related to tabs">
Tabs
</message>
<message name="IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_SHOW_VERTICAL_TABS" desc="The label for showing tabs vertically">
Use vertical tabs
</message>
<message name="IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_SHOW_TITLE_BAR" desc="The label for showing window title when vertical tab strip is enabled.">
Show title bar
</message>
<message name="IDS_SETTINGS_APPEARANCE_SETTINGS_TABS_USE_FLOATING_VERTICAL_TABS" desc="The label for enabling floating mode for vertical tab strip">
Float on mouseover
</message>
<message name="IDS_SETTINGS_APPEARANCE_SETTINGS_BRAVE_TAB_HOVER_MODE" desc="The label for the settings select controlling what happens when a user hovers over a tab.">
Tab hover mode
</message>
Expand Down
14 changes: 14 additions & 0 deletions browser/extensions/api/settings_private/brave_prefs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double checking we need the TOOLKIT_VIEWS check here - this file is in extensions, so it might only exist on desktop 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not sure about it. @simonhong , what do you think about this? kSidebarShowOption is guarded with TOOLKIT_VIEWS too, though it seems to be replacement of ENABLE_SIDEBAR.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm.. I picked TOOLKIT_VIEWS to mark sidebar is desktop UI feature.
Previously, ENABLE_SIDEBAR was used but realized that both are defined with same condition.
So, redundant ENABLE_SIDEBAR is removed and all things outside of views is replaced with TOOLKIT_VIEWS.

Actually, removing this will work but I want to use it here because this file brave_prefs_util.cc is not guarded by toolkit_views in the gn file. If this file is guarded by toolkit_views in gn, I think we don't need to use this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, unless we have assert(tookit_views) in browser/extensions/BUILD.gn, it'd be safer to have TOOLKIT_VIEWS in sources like this. FYI, the BUILD.gn also has conditional with toolkit_views.

  if (toolkit_views) {
    deps += [ "//brave/components/sidebar" ]
  }

So, we might want to check if assert(toolkit_views) is better, but I think we can deal with it in a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filed an issue for it : brave/brave-browser#29918

// 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;
}

Expand Down
67 changes: 67 additions & 0 deletions browser/resources/settings/brave_appearance_page/tabs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!-- This file will be converted into tabs.html.js using //tools/grit/preprocess_if_expr -->
<style include="settings-shared iron-flex">
.border {
border-top: var(--cr-separator-line);
border-bottom: var(--cr-separator-line);
}

.settings-box {
padding: 0
}
</style>

<div class="cr-row">$i18n{appearanceSettingsTabsSection}</div>
<div class="list-frame">
<!-- Vertical Tab strip -->
<template is="dom-if" if="[[isVerticalTabStripFeatureEnabled()]]">
<settings-toggle-button
class="cr-row list-item"
pref="{{prefs.brave.tabs.vertical_tabs_enabled}}"
label="$i18n{appearanceSettingsTabsUseVerticalTabs}">
</settings-toggle-button>
<template
is="dom-if"
if="[[prefs.brave.tabs.vertical_tabs_enabled.value]]">
<div class="cr-row">
<settings-checkbox
class="cr-row list-item"
pref="{{prefs.brave.tabs.vertical_tabs_show_title_on_window}}"
label="$i18n{appearanceSettingsTabsShowWindowTitle}">
</settings-checkbox>
</div>
<div class="cr-row">
<settings-checkbox
class="cr-row list-item"
pref="{{prefs.brave.tabs.vertical_tabs_floating_enabled}}"
label="$i18n{appearanceSettingsTabsFloatOnMouseOver}">
</settings-checkbox>
</div>
</template> <!-- vertical_tabs_enabled.value -->
</template> <!-- isVerticalTabStripFeatureEnabled()-->

<!-- Tab search button visibility -->
<settings-toggle-button
pref="{{prefs.brave.tabs_search_show}}"
class="cr-row list-item"
label="$i18n{showSearchTabsBtn}">
</settings-toggle-button>

<!-- Tab speaker icons function -->
<settings-toggle-button
pref="{{prefs.brave.tabs.mute_indicator_not_clickable}}"
class="cr-row list-item"
label="$i18n{braveDisableClickableMuteIndicators}">
</settings-toggle-button>

<!-- Tab hover mode -->
<div class="cr-row list-item settings-box">
<div class="flex">
<div class="label">$i18n{appearanceSettingsTabHoverMode}</div>
</div>
<settings-dropdown-menu
pref="{{prefs.brave.tabs.hover_mode}}"
menu-options="[[tabTooltipModes_]]">
</settings-dropdown-menu>
</div>
</div> <!-- .list-frame -->

42 changes: 42 additions & 0 deletions browser/resources/settings/brave_appearance_page/tabs.ts
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 1 addition & 19 deletions browser/resources/settings/brave_appearance_page/toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</div>
</template>
<if expr="toolkit_views">
<settings-brave-appearance-tabs prefs="{{prefs}}""></settings-brave-appearance-tabs>
<settings-brave-appearance-sidebar prefs="{{prefs}}"></settings-brave-appearance-sidebar>
</if>
<if expr="enable_brave_vpn">
Expand All @@ -59,22 +60,3 @@
</settings-toggle-button>
</template>
</if>
<settings-toggle-button
pref="{{prefs.brave.tabs_search_show}}"
class="cr-row"
label="$i18n{showSearchTabsBtn}">
</settings-toggle-button>
<settings-toggle-button
pref="{{prefs.brave.tabs.mute_indicator_not_clickable}}"
class="cr-row"
label="$i18n{braveDisableClickableMuteIndicators}">
</settings-toggle-button>
<div class="settings-box">
<div class="flex">
<div class="label">$i18n{appearanceSettingsTabHoverMode}</div>
</div>
<settings-dropdown-menu
pref="{{prefs.brave.tabs.hover_mode}}"
menu-options="[[tabTooltipModes_]]">
</settings-dropdown-menu>
</div>
10 changes: 1 addition & 9 deletions browser/resources/settings/brave_appearance_page/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
}
Expand Down
7 changes: 5 additions & 2 deletions browser/resources/settings/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
9 changes: 0 additions & 9 deletions browser/ui/tabs/brave_tab_menu_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 0 additions & 3 deletions browser/ui/tabs/brave_tab_menu_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class BraveTabMenuModel : public TabMenuModel {
CommandStart = TabStripModel::CommandLast,
CommandRestoreTab,
CommandBookmarkAllTabs,
CommandShowVerticalTabs,
CommandShowTitleBar,
CommandUseFloatingVerticalTabStrip,
CommandToggleTabMuted,
CommandLast,
};
Expand Down
51 changes: 0 additions & 51 deletions browser/ui/views/tabs/brave_tab_context_menu_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -91,21 +73,6 @@ bool BraveTabContextMenuContents::IsCommandIdEnabled(int command_id) const {
static_cast<TabStripModel::ContextMenuCommand>(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 {
Expand Down Expand Up @@ -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<BraveTabStripModel*>(controller_->model());
for (const auto& index : model->GetTabIndicesForCommandAt(tab_index_)) {
Expand All @@ -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<BraveTabStripModel*>(controller_->model());
auto indices = model->GetTabIndicesForCommandAt(tab_index_);
Expand Down
2 changes: 0 additions & 2 deletions browser/ui/views/tabs/brave_tab_context_menu_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading