#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include <string_view>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/strings/escape.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/browser_theme_pack.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/browser_window_state.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/tabs/tab_menu_model_factory.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_render_frame.mojom.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/themes/autogenerated_theme_util.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/security_state/content/security_state_tab_helper.h"
#include "components/security_state/core/security_state.h"
#include "components/url_formatter/url_formatter.h"
#include "components/webapps/browser/installable/installable_evaluator.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/page.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
#include "third_party/blink/public/mojom/page/draggable_region.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/color/color_recipe.h"
#include "ui/color/color_transform.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/resize_utils.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/native_theme/native_theme.h"
#include "url/gurl.h"
#include "url/origin.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/apps/icon_standardizer.h"
#include "chrome/browser/ash/system_web_apps/types/system_web_app_delegate.h"
#include "chromeos/ui/base/chromeos_ui_constants.h"
#endif
namespace {
SkColor GetAltColor(SkColor color) { … }
void SetWebContentsCanAcceptLoadDrops(content::WebContents* contents,
bool can_accept) { … }
}
namespace web_app {
bool AppBrowserController::IsWebApp(const Browser* browser) { … }
bool AppBrowserController::IsForWebApp(const Browser* browser,
const webapps::AppId& app_id) { … }
Browser* AppBrowserController::FindForWebApp(const Profile& profile,
const webapps::AppId& app_id) { … }
std::u16string AppBrowserController::FormatUrlOrigin(
const GURL& url,
url_formatter::FormatUrlTypes format_types) { … }
const ui::ThemeProvider* AppBrowserController::GetThemeProvider() const { … }
AppBrowserController::AppBrowserController(Browser* browser,
webapps::AppId app_id,
bool has_tab_strip)
: … { … }
AppBrowserController::AppBrowserController(Browser* browser,
webapps::AppId app_id)
: … { … }
void AppBrowserController::Init() { … }
AppBrowserController::~AppBrowserController() { … }
bool AppBrowserController::ShouldShowCustomTabBar() const { … }
bool AppBrowserController::has_tab_strip() const { … }
bool AppBrowserController::HasTitlebarMenuButton() const { … }
bool AppBrowserController::HasTitlebarAppOriginText() const { … }
bool AppBrowserController::HasTitlebarContentSettings() const { … }
std::vector<PageActionIconType> AppBrowserController::GetTitleBarPageActions()
const { … }
bool AppBrowserController::IsInstalled() const { … }
std::unique_ptr<TabMenuModelFactory>
AppBrowserController::GetTabMenuModelFactory() const { … }
bool AppBrowserController::AppUsesWindowControlsOverlay() const { … }
bool AppBrowserController::AppUsesBorderlessMode() const { … }
bool AppBrowserController::AppUsesTabbed() const { … }
bool AppBrowserController::IsIsolatedWebApp() const { … }
void AppBrowserController::SetIsolatedWebAppTrueForTesting() { … }
bool AppBrowserController::IsWindowControlsOverlayEnabled() const { … }
void AppBrowserController::ToggleWindowControlsOverlayEnabled(
base::OnceClosure on_complete) { … }
gfx::Rect AppBrowserController::GetDefaultBounds() const { … }
bool AppBrowserController::HasReloadButton() const { … }
bool AppBrowserController::IsPreventCloseEnabled() const { … }
#if !BUILDFLAG(IS_CHROMEOS)
bool AppBrowserController::HasProfileMenuButton() const { … }
bool AppBrowserController::IsProfileMenuButtonVisible() const { … }
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
const ash::SystemWebAppDelegate* AppBrowserController::system_app() const {
return nullptr;
}
#endif
std::u16string AppBrowserController::GetLaunchFlashText() const { … }
bool AppBrowserController::IsHostedApp() const { … }
WebAppBrowserController* AppBrowserController::AsWebAppBrowserController() { … }
bool AppBrowserController::CanUserUninstall() const { … }
void AppBrowserController::Uninstall(
webapps::WebappUninstallSource webapp_uninstall_source) { … }
void AppBrowserController::UpdateCustomTabBarVisibility(bool animate) const { … }
void AppBrowserController::DidStartNavigation(
content::NavigationHandle* navigation_handle) { … }
void AppBrowserController::DOMContentLoaded(
content::RenderFrameHost* render_frame_host) { … }
void AppBrowserController::DidChangeThemeColor() { … }
void AppBrowserController::OnBackgroundColorChanged() { … }
void AppBrowserController::PrimaryPageChanged(content::Page& page) { … }
std::optional<SkColor> AppBrowserController::GetThemeColor() const { … }
std::optional<SkColor> AppBrowserController::GetBackgroundColor() const { … }
std::u16string AppBrowserController::GetTitle() const { … }
std::string AppBrowserController::GetTitleForMediaControls() const { … }
GURL AppBrowserController::GetAppNewTabUrl() const { … }
bool AppBrowserController::ShouldHideNewTabButton() const { … }
bool AppBrowserController::IsUrlInHomeTabScope(const GURL& url) const { … }
bool AppBrowserController::ShouldShowAppIconOnTab(int index) const { … }
#if BUILDFLAG(IS_MAC)
bool AppBrowserController::AlwaysShowToolbarInFullscreen() const {
return true;
}
void AppBrowserController::ToggleAlwaysShowToolbarInFullscreen() {}
#endif
void AppBrowserController::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) { … }
CustomThemeSupplier* AppBrowserController::GetThemeSupplier() const { … }
bool AppBrowserController::ShouldUseCustomFrame() const { … }
void AppBrowserController::AddColorMixers(
ui::ColorProvider* provider,
const ui::ColorProviderKey& key) const { … }
void AppBrowserController::OnReceivedInitialURL() { … }
void AppBrowserController::OnTabInserted(content::WebContents* contents) { … }
void AppBrowserController::OnTabRemoved(content::WebContents* contents) { … }
ui::ImageModel AppBrowserController::GetFallbackAppIcon() const { … }
void AppBrowserController::DraggableRegionsChanged(
const std::vector<blink::mojom::DraggableRegionPtr>& regions,
content::WebContents* contents) { … }
void AppBrowserController::SetOnUpdateDraggableRegionForTesting(
base::OnceClosure done) { … }
void AppBrowserController::MaybeSetInitialUrlOnReparentTab() { … }
void AppBrowserController::UpdateThemePack() { … }
void AppBrowserController::SetInitialURL(const GURL& initial_url) { … }
void AppBrowserController::UpdateSupportsDraggableRegions(
bool supports_draggable_regions,
content::RenderFrameHost* host) { … }
}