#include "chrome/browser/ui/views/location_bar/custom_tab_bar_view.h"
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/grit/generated_resources.h"
#include "components/security_interstitials/content/security_interstitial_tab_helper.h"
#include "components/url_formatter/url_formatter.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/text_constants.h"
#include "ui/native_theme/native_theme.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#include "ui/views/view_class_properties.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ui/base/chromeos_ui_constants.h"
#endif
namespace {
bool ShouldDisplayUrl(content::WebContents* contents) { … }
bool IsInitialUrlInAppScope(web_app::AppBrowserController* app_controller) { … }
bool IsUrlInAppScope(web_app::AppBrowserController* app_controller, GURL url) { … }
ui::ColorId GetSecurityChipColorId(
security_state::SecurityLevel security_level) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
class CustomTabBarAppMenuButton : public WebAppMenuButton {
METADATA_HEADER(CustomTabBarAppMenuButton, WebAppMenuButton)
public:
using WebAppMenuButton::WebAppMenuButton;
protected:
SkColor GetForegroundColor(ButtonState state) const override {
return GetColorProvider()->GetColor(kColorPwaMenuButtonIcon);
}
};
BEGIN_METADATA(CustomTabBarAppMenuButton)
END_METADATA
#endif
}
class CustomTabBarTitleOriginView : public views::View { … };
BEGIN_METADATA(…)
CustomTabBarView::CustomTabBarView(BrowserView* browser_view,
LocationBarView::Delegate* delegate)
: … { … }
CustomTabBarView::~CustomTabBarView() { … }
gfx::Rect CustomTabBarView::GetAnchorBoundsInScreen() const { … }
void CustomTabBarView::SetVisible(bool visible) { … }
gfx::Size CustomTabBarView::CalculatePreferredSize(
const views::SizeBounds& available_size) const { … }
void CustomTabBarView::OnPaintBackground(gfx::Canvas* canvas) { … }
void CustomTabBarView::ChildPreferredSizeChanged(views::View* child) { … }
void CustomTabBarView::OnThemeChanged() { … }
void CustomTabBarView::TabChangedAt(content::WebContents* contents,
int index,
TabChangeType change_type) { … }
void CustomTabBarView::UpdateContents() { … }
SkColor CustomTabBarView::GetIconLabelBubbleSurroundingForegroundColor() const { … }
SkColor CustomTabBarView::GetIconLabelBubbleBackgroundColor() const { … }
std::optional<ui::ColorId>
CustomTabBarView::GetLocationIconBackgroundColorOverride() const { … }
content::WebContents* CustomTabBarView::GetWebContents() { … }
bool CustomTabBarView::IsEditingOrEmpty() const { … }
void CustomTabBarView::OnLocationIconPressed(const ui::MouseEvent& event) { … }
void CustomTabBarView::OnLocationIconDragged(const ui::MouseEvent& event) { … }
SkColor CustomTabBarView::GetSecurityChipColor(
security_state::SecurityLevel security_level) const { … }
bool CustomTabBarView::ShowPageInfoDialog() { … }
const LocationBarModel* CustomTabBarView::GetLocationBarModel() const { … }
ui::ImageModel CustomTabBarView::GetLocationIcon(
LocationIconView::Delegate::IconFetchedCallback on_icon_fetched) const { … }
void CustomTabBarView::GoBackToAppForTesting() { … }
bool CustomTabBarView::IsShowingOriginForTesting() const { … }
bool CustomTabBarView::IsShowingCloseButtonForTesting() const { … }
void CustomTabBarView::GoBackToApp() { … }
void CustomTabBarView::AppInfoClosedCallback(
views::Widget::ClosedReason closed_reason,
bool reload_prompt) { … }
void CustomTabBarView::ExecuteCommand(int command_id, int event_flags) { … }
void CustomTabBarView::ShowContextMenuForViewImpl(
views::View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) { … }
bool CustomTabBarView::GetShowTitle() const { … }
BEGIN_METADATA(…)