Files
Brian R. Bondy fe1a9add88 Add enable_playlist buildflag gated on is_brave_origin_branded (#35732)
Introduces enable_playlist (defaults to !is_brave_origin_branded),
following the same pattern as enable_brave_wallet and enable_ai_chat,
to gate all Playlist code from compilation on origin-branded desktop
builds. enable_playlist_webui now chains through enable_playlist.

Changes are scoped to desktop: iOS and Android don't support
is_brave_origin_branded=true (enforced by asserts in
//brave/components/brave_origin/buildflags/buildflags.gni), so they
have no guards.
2026-04-23 08:23:26 -04:00

97 lines
2.8 KiB
C++

/* Copyright (c) 2021 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/. */
#ifndef BRAVE_COMPONENTS_SIDEBAR_BROWSER_SIDEBAR_ITEM_H_
#define BRAVE_COMPONENTS_SIDEBAR_BROWSER_SIDEBAR_ITEM_H_
#include "brave/components/ai_chat/core/common/buildflags/buildflags.h"
#include "brave/components/brave_talk/buildflags/buildflags.h"
#include "brave/components/playlist/core/common/buildflags/buildflags.h"
#include "brave/components/sidebar/common/features.h"
#include "url/gurl.h"
namespace sidebar {
struct SidebarItem {
enum class Type {
kTypeBuiltIn,
kTypeWeb,
};
// Underlying values are used as id of items. Use explicit values so
// conditionally compiled items don't shift others.
enum class BuiltInItemType {
kNone = 0,
#if BUILDFLAG(ENABLE_BRAVE_TALK)
kBraveTalk = 1,
#endif
kWallet = 2,
kBookmarks = 3,
kReadingList = 4,
kHistory = 5,
#if BUILDFLAG(ENABLE_PLAYLIST)
kPlaylist = 6,
#endif
#if BUILDFLAG(ENABLE_AI_CHAT)
kChatUI = 7,
#endif
};
// Count of built-in items based on enabled features.
static constexpr size_t kBuiltInItemsCount =
4 // kWallet, kBookmarks, kReadingList, kHistory
#if BUILDFLAG(ENABLE_PLAYLIST)
+ 1 // kPlaylist
#endif
#if BUILDFLAG(ENABLE_AI_CHAT)
+ 1 // kChatUI
#endif
#if BUILDFLAG(ENABLE_BRAVE_TALK)
+ 1 // kBraveTalk
#endif
;
static SidebarItem Create(const std::u16string& title,
Type type,
BuiltInItemType built_in_item_type,
bool open_in_panel);
static SidebarItem Create(const GURL& url,
const std::u16string& title,
Type type,
BuiltInItemType built_in_item_type,
bool open_in_panel);
SidebarItem();
SidebarItem(const SidebarItem&);
SidebarItem& operator=(const SidebarItem&);
SidebarItem(SidebarItem&&);
SidebarItem& operator=(SidebarItem&&);
~SidebarItem();
bool is_built_in_type() const {
return type == SidebarItem::Type::kTypeBuiltIn;
}
bool is_web_type() const { return type == SidebarItem::Type::kTypeWeb; }
bool is_web_panel_type() const {
return base::FeatureList::IsEnabled(features::kSidebarWebPanel) &&
type == SidebarItem::Type::kTypeWeb && open_in_panel;
}
bool IsValidItem() const;
bool operator==(const SidebarItem& item) const;
GURL url;
Type type = Type::kTypeBuiltIn;
BuiltInItemType built_in_item_type = BuiltInItemType::kNone;
std::u16string title;
// Set false to open this item in new tab.
bool open_in_panel = false;
};
} // namespace sidebar
#endif // BRAVE_COMPONENTS_SIDEBAR_BROWSER_SIDEBAR_ITEM_H_