#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "base/auto_reset.h"
#include "base/check.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/ui/blocked_content/popunder_preventer.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_within_tab_helper.h"
#include "chrome/browser/ui/status_bubble.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_types.h"
#include "components/safe_browsing/core/browser/db/database_manager.h"
#include "content/public/browser/fullscreen_types.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "extensions/common/extension.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/display/types/display_constants.h"
#if !BUILDFLAG(IS_MAC)
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#endif
WebContents;
namespace {
constexpr char kHistogramFullscreenWebsiteStateAtApiRequest[] = …;
enum class WebsiteStateAtFullscreenRequest { … };
bool IsAnotherScreen(const WebContents& web_contents,
const int64_t display_id) { … }
void RecordWebsiteStateAtApiRequest(history::HistoryLastVisitResult result,
std::optional<bool> on_allowlist) { … }
void CheckUrlForAllowlistAndRecordMetric(
const GURL& url,
history::HistoryLastVisitResult result) { … }
}
FullscreenController::FullscreenController(ExclusiveAccessManager* manager)
: … { … }
FullscreenController::~FullscreenController() = default;
void FullscreenController::AddObserver(FullscreenObserver* observer) { … }
void FullscreenController::RemoveObserver(FullscreenObserver* observer) { … }
int64_t FullscreenController::GetDisplayId(const WebContents& web_contents) { … }
bool FullscreenController::IsFullscreenForBrowser() const { … }
void FullscreenController::ToggleBrowserFullscreenMode() { … }
void FullscreenController::ToggleBrowserFullscreenModeWithExtension(
const GURL& extension_url) { … }
bool FullscreenController::IsWindowFullscreenForTabOrPending() const { … }
bool FullscreenController::IsExtensionFullscreenOrPending() const { … }
bool FullscreenController::IsControllerInitiatedFullscreen() const { … }
bool FullscreenController::IsTabFullscreen() const { … }
content::FullscreenState FullscreenController::GetFullscreenState(
const content::WebContents* web_contents) const { … }
bool FullscreenController::IsFullscreenCausedByTab() const { … }
bool FullscreenController::CanEnterFullscreenModeForTab(
content::RenderFrameHost* requesting_frame) { … }
void FullscreenController::EnterFullscreenModeForTab(
content::RenderFrameHost* requesting_frame,
const int64_t display_id) { … }
void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) { … }
void FullscreenController::FullscreenTabOpeningPopup(
content::WebContents* opener,
content::WebContents* popup) { … }
void FullscreenController::OnTabDeactivated(
content::WebContents* web_contents) { … }
void FullscreenController::OnTabDetachedFromView(WebContents* old_contents) { … }
void FullscreenController::OnTabClosing(WebContents* web_contents) { … }
void FullscreenController::WindowFullscreenStateChanged() { … }
void FullscreenController::FullscreenTransitionCompleted() { … }
void FullscreenController::RunOrDeferUntilTransitionIsComplete(
base::OnceClosure callback) { … }
bool FullscreenController::HandleUserPressedEscape() { … }
void FullscreenController::HandleUserHeldEscape() { … }
void FullscreenController::HandleUserReleasedEscapeEarly() { … }
bool FullscreenController::RequiresPressAndHoldEscToExit() const { … }
void FullscreenController::ExitExclusiveAccessToPreviousState() { … }
GURL FullscreenController::GetURLForExclusiveAccessBubble() const { … }
void FullscreenController::ExitExclusiveAccessIfNecessary() { … }
void FullscreenController::PostFullscreenChangeNotification() { … }
void FullscreenController::NotifyFullscreenChange() { … }
void FullscreenController::NotifyTabExclusiveAccessLost() { … }
void FullscreenController::ToggleFullscreenModeInternal(
FullscreenInternalOption option,
content::RenderFrameHost* requesting_frame,
const int64_t display_id) { … }
void FullscreenController::EnterFullscreenModeInternal(
FullscreenInternalOption option,
content::RenderFrameHost* requesting_frame,
int64_t display_id) { … }
void FullscreenController::ExitFullscreenModeInternal() { … }
bool FullscreenController::MaybeToggleFullscreenWithinTab(
WebContents* web_contents,
bool enter_fullscreen) { … }
bool FullscreenController::IsFullscreenWithinTab(
const WebContents* web_contents) const { … }
GURL FullscreenController::GetRequestingOrigin() const { … }
GURL FullscreenController::GetEmbeddingOrigin() const { … }
void FullscreenController::RecordMetricsOnFullscreenApiRequested(
content::RenderFrameHost* requesting_frame) { … }
void FullscreenController::RecordMetricsOnEnteringFullscreen() { … }