#include "chrome/browser/media/offscreen_tab.h"
#include <algorithm>
#include <utility>
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_destroyer.h"
#include "components/media_router/browser/presentation/presentation_navigation_policy.h"
#include "components/media_router/browser/presentation/receiver_presentation_service_delegate_impl.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/presentation_receiver_flags.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#if defined(USE_AURA)
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#endif
WebContents;
namespace {
constexpr base::TimeDelta kMaxWaitForCapture = …;
constexpr base::TimeDelta kPollInterval = …;
}
#if defined(USE_AURA)
class OffscreenTab::WindowAdoptionAgent final : protected aura::WindowObserver { … };
#endif
OffscreenTab::OffscreenTab(Owner* owner, content::BrowserContext* context)
: … { … }
OffscreenTab::~OffscreenTab() { … }
void OffscreenTab::Start(const GURL& start_url,
const gfx::Size& initial_size,
const std::string& optional_presentation_id) { … }
void OffscreenTab::Close() { … }
void OffscreenTab::CloseContents(WebContents* source) { … }
bool OffscreenTab::ShouldSuppressDialogs(WebContents* source) { … }
bool OffscreenTab::ShouldFocusLocationBarByDefault(WebContents* source) { … }
bool OffscreenTab::ShouldFocusPageAfterCrash(content::WebContents* source) { … }
void OffscreenTab::CanDownload(const GURL& url,
const std::string& request_method,
base::OnceCallback<void(bool)> callback) { … }
bool OffscreenTab::HandleContextMenu(
content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) { … }
content::KeyboardEventProcessingResult OffscreenTab::PreHandleKeyboardEvent(
WebContents* source,
const input::NativeWebKeyboardEvent& event) { … }
bool OffscreenTab::PreHandleGestureEvent(WebContents* source,
const blink::WebGestureEvent& event) { … }
bool OffscreenTab::CanDragEnter(WebContents* source,
const content::DropData& data,
blink::DragOperationsMask operations_allowed) { … }
bool OffscreenTab::IsWebContentsCreationOverridden(
content::SiteInstance* source_site_instance,
content::mojom::WindowContainerType window_container_type,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url) { … }
void OffscreenTab::EnterFullscreenModeForTab(
content::RenderFrameHost* requesting_frame,
const blink::mojom::FullscreenOptions& options) { … }
void OffscreenTab::ExitFullscreenModeForTab(WebContents* contents) { … }
bool OffscreenTab::IsFullscreenForTabOrPending(const WebContents* contents) { … }
blink::mojom::DisplayMode OffscreenTab::GetDisplayMode(
const WebContents* contents) { … }
void OffscreenTab::RequestMediaAccessPermission(
WebContents* contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) { … }
bool OffscreenTab::CheckMediaAccessPermission(
content::RenderFrameHost* render_frame_host,
const url::Origin& security_origin,
blink::mojom::MediaStreamType type) { … }
void OffscreenTab::DidStartNavigation(
content::NavigationHandle* navigation_handle) { … }
void OffscreenTab::DieIfContentCaptureEnded() { … }
void OffscreenTab::OnProfileWillBeDestroyed(Profile* profile) { … }