#include "content/public/browser/web_contents_delegate.h"
#include <memory>
#include <utility>
#include "base/compiler_specific.h"
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "content/public/browser/audio_stream_broker.h"
#include "content/public/browser/color_chooser.h"
#include "content/public/browser/file_select_listener.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/url_constants.h"
#include "third_party/blink/public/common/security/protocol_handler_security_level.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/geometry/rect.h"
namespace content {
WebContentsDelegate::WebContentsDelegate() = default;
WebContents* WebContentsDelegate::OpenURLFromTab(
WebContents* source,
const OpenURLParams& params,
base::OnceCallback<void(NavigationHandle&)> navigation_handle_callback) { … }
bool WebContentsDelegate::ShouldAllowRendererInitiatedCrossProcessNavigation(
bool is_outermost_main_frame_navigation) { … }
WebContents* WebContentsDelegate::AddNewContents(
WebContents* source,
std::unique_ptr<WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& window_features,
bool user_gesture,
bool* was_blocked) { … }
bool WebContentsDelegate::CanOverscrollContent() { … }
bool WebContentsDelegate::ShouldSuppressDialogs(WebContents* source) { … }
bool WebContentsDelegate::ShouldPreserveAbortedURLs(WebContents* source) { … }
bool WebContentsDelegate::DidAddMessageToConsole(
WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
int32_t line_no,
const std::u16string& source_id) { … }
void WebContentsDelegate::BeforeUnloadFired(WebContents* web_contents,
bool proceed,
bool* proceed_to_fire_unload) { … }
bool WebContentsDelegate::ShouldFocusLocationBarByDefault(WebContents* source) { … }
bool WebContentsDelegate::ShouldFocusPageAfterCrash(WebContents* source) { … }
bool WebContentsDelegate::ShouldResumeRequestsForCreatedWindow() { … }
bool WebContentsDelegate::TakeFocus(WebContents* source, bool reverse) { … }
void WebContentsDelegate::CanDownload(const GURL& url,
const std::string& request_method,
base::OnceCallback<void(bool)> callback) { … }
bool WebContentsDelegate::HandleContextMenu(RenderFrameHost& render_frame_host,
const ContextMenuParams& params) { … }
KeyboardEventProcessingResult WebContentsDelegate::PreHandleKeyboardEvent(
WebContents* source,
const input::NativeWebKeyboardEvent& event) { … }
bool WebContentsDelegate::HandleKeyboardEvent(
WebContents* source,
const input::NativeWebKeyboardEvent& event) { … }
bool WebContentsDelegate::PreHandleGestureEvent(
WebContents* source,
const blink::WebGestureEvent& event) { … }
bool WebContentsDelegate::CanDragEnter(
WebContents* source,
const DropData& data,
blink::DragOperationsMask operations_allowed) { … }
bool WebContentsDelegate::OnGoToEntryOffset(int offset) { … }
bool WebContentsDelegate::IsWebContentsCreationOverridden(
SiteInstance* source_site_instance,
mojom::WindowContainerType window_container_type,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url) { … }
WebContents* WebContentsDelegate::CreateCustomWebContents(
RenderFrameHost* opener,
SiteInstance* source_site_instance,
bool is_new_browsing_instance,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url,
const StoragePartitionConfig& partition_config,
SessionStorageNamespace* session_storage_namespace) { … }
JavaScriptDialogManager* WebContentsDelegate::GetJavaScriptDialogManager(
WebContents* source) { … }
void WebContentsDelegate::CreateSmsPrompt(
RenderFrameHost* host,
const std::vector<url::Origin>& origin_list,
const std::string& one_time_code,
base::OnceCallback<void()> on_confirm,
base::OnceCallback<void()> on_cancel) { … }
bool WebContentsDelegate::CanUseWindowingControls(
RenderFrameHost* requesting_frame) { … }
bool WebContentsDelegate::GetCanResize() { … }
ui::WindowShowState WebContentsDelegate::GetWindowShowState() const { … }
bool WebContentsDelegate::IsFullscreenForTabOrPending(
const WebContents* web_contents) { … }
FullscreenState WebContentsDelegate::GetFullscreenState(
const WebContents* web_contents) const { … }
bool WebContentsDelegate::CanEnterFullscreenModeForTab(
RenderFrameHost* requesting_frame) { … }
blink::mojom::DisplayMode WebContentsDelegate::GetDisplayMode(
const WebContents* web_contents) { … }
blink::ProtocolHandlerSecurityLevel
WebContentsDelegate::GetProtocolHandlerSecurityLevel(RenderFrameHost*) { … }
void WebContentsDelegate::RequestPointerLock(WebContents* web_contents,
bool user_gesture,
bool last_unlocked_by_target) { … }
void WebContentsDelegate::RequestKeyboardLock(WebContents* web_contents,
bool esc_key_locked) { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
std::unique_ptr<ColorChooser> WebContentsDelegate::OpenColorChooser(
WebContents* web_contents,
SkColor color,
const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions) {
return nullptr;
}
#endif
std::unique_ptr<EyeDropper> WebContentsDelegate::OpenEyeDropper(
RenderFrameHost* frame,
EyeDropperListener* listener) { … }
void WebContentsDelegate::RunFileChooser(
RenderFrameHost* render_frame_host,
scoped_refptr<FileSelectListener> listener,
const blink::mojom::FileChooserParams& params) { … }
void WebContentsDelegate::EnumerateDirectory(
WebContents* web_contents,
scoped_refptr<FileSelectListener> listener,
const base::FilePath& path) { … }
void WebContentsDelegate::RequestMediaAccessPermission(
WebContents* web_contents,
const MediaStreamRequest& request,
MediaResponseCallback callback) { … }
bool WebContentsDelegate::CheckMediaAccessPermission(
RenderFrameHost* render_frame_host,
const url::Origin& security_origin,
blink::mojom::MediaStreamType type) { … }
std::string WebContentsDelegate::GetTitleForMediaControls(
WebContents* web_contents) { … }
std::unique_ptr<AudioStreamBrokerFactory>
WebContentsDelegate::CreateAudioStreamBrokerFactory(WebContents* web_contents) { … }
#if BUILDFLAG(IS_ANDROID)
bool WebContentsDelegate::ShouldBlockMediaRequest(const GURL& url) {
return false;
}
#endif
WebContentsDelegate::~WebContentsDelegate() { … }
void WebContentsDelegate::Attach(WebContents* web_contents) { … }
void WebContentsDelegate::Detach(WebContents* web_contents) { … }
gfx::Size WebContentsDelegate::GetSizeForNewRenderView(
WebContents* web_contents) { … }
bool WebContentsDelegate::IsNeverComposited(WebContents* web_contents) { … }
bool WebContentsDelegate::GuestSaveFrame(WebContents* guest_web_contents) { … }
bool WebContentsDelegate::SaveFrame(const GURL& url,
const Referrer& referrer,
RenderFrameHost* rfh) { … }
bool WebContentsDelegate::ShouldAllowRunningInsecureContent(
WebContents* web_contents,
bool allowed_per_prefs,
const url::Origin& origin,
const GURL& resource_url) { … }
int WebContentsDelegate::GetTopControlsHeight() { … }
int WebContentsDelegate::GetTopControlsMinHeight() { … }
int WebContentsDelegate::GetBottomControlsHeight() { … }
int WebContentsDelegate::GetBottomControlsMinHeight() { … }
bool WebContentsDelegate::ShouldAnimateBrowserControlsHeightChanges() { … }
bool WebContentsDelegate::DoBrowserControlsShrinkRendererSize(
WebContents* web_contents) { … }
int WebContentsDelegate::GetVirtualKeyboardHeight(WebContents* web_contents) { … }
bool WebContentsDelegate::OnlyExpandTopControlsAtPageTop() { … }
PictureInPictureResult WebContentsDelegate::EnterPictureInPicture(
WebContents* web_contents) { … }
bool WebContentsDelegate::ShouldAllowLazyLoad() { … }
bool WebContentsDelegate::IsBackForwardCacheSupported(
WebContents& web_contents) { … }
PreloadingEligibility WebContentsDelegate::IsPrerender2Supported(
WebContents& web_contents) { … }
NavigationController::UserAgentOverrideOption
WebContentsDelegate::ShouldOverrideUserAgentForPrerender2() { … }
bool WebContentsDelegate::ShouldAllowPartialParamMismatchOfPrerender2(
NavigationHandle& navigation_handle) { … }
bool WebContentsDelegate::ShouldShowStaleContentOnEviction(
WebContents* source) { … }
device::mojom::GeolocationContext*
WebContentsDelegate::GetInstalledWebappGeolocationContext() { … }
bool WebContentsDelegate::IsPrivileged() { … }
#if !BUILDFLAG(IS_ANDROID)
bool WebContentsDelegate::ShouldUseInstancedSystemMediaControls() const { … }
#endif
bool WebContentsDelegate::MaybeCopyContentAreaAsBitmap(
base::OnceCallback<void(const SkBitmap&)> callback) { … }
#if BUILDFLAG(IS_ANDROID)
SkBitmap WebContentsDelegate::MaybeCopyContentAreaAsBitmapSync() {
return SkBitmap();
}
BackForwardTransitionAnimationManager::FallbackUXConfig
WebContentsDelegate::GetBackForwardTransitionFallbackUXConfig() {
return BackForwardTransitionAnimationManager::FallbackUXConfig();
}
#endif
}