#include "chrome/browser/ui/views/frame/browser_frame.h"
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/containers/fixed_flat_map.h"
#include "base/debug/leak_annotations.h"
#include "base/functional/bind.h"
#include "base/i18n/rtl.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/headless/headless_mode_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/custom_theme_supplier.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window_state.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_root_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/native_browser_frame.h"
#include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"
#include "chrome/browser/ui/views/frame/system_menu_model_builder.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "ui/base/hit_test.h"
#include "ui/base/mojom/themes.mojom.h"
#include "ui/color/color_provider_key.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/font_list.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/widget/native_widget.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chromeos/ui/base/window_properties.h"
#include "chromeos/ui/base/window_state_type.h"
#include "chromeos/ui/wm/desks/desks_helper.h"
#include "ui/aura/window.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h"
#include "components/user_manager/user_manager.h"
#endif
#if BUILDFLAG(IS_LINUX)
#include "ui/display/screen.h"
#include "ui/linux/linux_ui.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "chrome/browser/win/mica_titlebar.h"
#endif
namespace {
class ThemeChangedObserver : public views::WidgetObserver { … };
bool IsUsingLinuxSystemTheme(Profile* profile) { … }
ui::ColorProviderKey::SchemeVariant GetSchemeVariant(
ui::mojom::BrowserColorVariant color_variant) { … }
}
BrowserFrame::BrowserFrame(BrowserView* browser_view)
: … { … }
BrowserFrame::~BrowserFrame() { … }
void BrowserFrame::InitBrowserFrame() { … }
int BrowserFrame::GetMinimizeButtonOffset() const { … }
gfx::Rect BrowserFrame::GetBoundsForTabStripRegion(
const gfx::Size& tabstrip_minimum_size) const { … }
gfx::Rect BrowserFrame::GetBoundsForWebAppFrameToolbar(
const gfx::Size& toolbar_preferred_size) const { … }
void BrowserFrame::LayoutWebAppWindowTitle(
const gfx::Rect& available_space,
views::Label& window_title_label) const { … }
int BrowserFrame::GetTopInset() const { … }
void BrowserFrame::UpdateThrobber(bool running) { … }
BrowserNonClientFrameView* BrowserFrame::GetFrameView() const { … }
bool BrowserFrame::UseCustomFrame() const { … }
bool BrowserFrame::ShouldSaveWindowPlacement() const { … }
bool BrowserFrame::ShouldDrawFrameHeader() const { … }
void BrowserFrame::GetWindowPlacement(gfx::Rect* bounds,
ui::WindowShowState* show_state) const { … }
content::KeyboardEventProcessingResult BrowserFrame::PreHandleKeyboardEvent(
const input::NativeWebKeyboardEvent& event) { … }
bool BrowserFrame::HandleKeyboardEvent(
const input::NativeWebKeyboardEvent& event) { … }
void BrowserFrame::OnBrowserViewInitViewsComplete() { … }
void BrowserFrame::UserChangedTheme(BrowserThemeChangeType theme_change_type) { … }
views::internal::RootView* BrowserFrame::CreateRootView() { … }
std::unique_ptr<views::NonClientFrameView>
BrowserFrame::CreateNonClientFrameView() { … }
bool BrowserFrame::GetAccelerator(int command_id,
ui::Accelerator* accelerator) const { … }
const ui::ThemeProvider* BrowserFrame::GetThemeProvider() const { … }
ui::ColorProviderKey::ThemeInitializerSupplier* BrowserFrame::GetCustomTheme()
const { … }
void BrowserFrame::OnNativeWidgetWorkspaceChanged() { … }
void BrowserFrame::ShowContextMenuForViewImpl(views::View* source,
const gfx::Point& p,
ui::MenuSourceType source_type) { … }
bool BrowserFrame::IsMenuRunnerRunningForTesting() const { … }
ui::MenuModel* BrowserFrame::GetSystemMenuModel() { … }
void BrowserFrame::SetTabDragKind(TabDragKind tab_drag_kind) { … }
void BrowserFrame::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) { … }
ui::ColorProviderKey BrowserFrame::GetColorProviderKey() const { … }
void BrowserFrame::OnMenuClosed() { … }
void BrowserFrame::SelectNativeTheme() { … }
void BrowserFrame::OnTouchUiChanged() { … }
bool BrowserFrame::RegenerateFrameOnThemeChange(
BrowserThemeChangeType theme_change_type) { … }
bool BrowserFrame::IsIncognitoBrowser() const { … }