#include "components/guest_view/browser/guest_view_base.h"
#include <memory>
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "components/guest_view/browser/guest_view_event.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/guest_view/common/guest_view_constants.h"
#include "components/zoom/zoom_controller.h"
#include "content/public/browser/file_select_listener.h"
#include "content/public/browser/isolated_web_apps_policy.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/permission_result.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/page/page_zoom.h"
WebContents;
namespace guest_view {
namespace {
void DestroyGuestIfUnattached(GuestViewBase* guest) { … }
}
SetSizeParams::SetSizeParams() = default;
SetSizeParams::~SetSizeParams() = default;
class GuestViewBase::OwnerContentsObserver : public WebContentsObserver { … };
class GuestViewBase::OpenerLifetimeObserver : public WebContentsObserver { … };
GuestViewBase::GuestViewBase(content::RenderFrameHost* owner_rfh)
: … { … }
GuestViewBase::~GuestViewBase() { … }
void GuestViewBase::Init(std::unique_ptr<GuestViewBase> owned_this,
const base::Value::Dict& create_params,
GuestCreatedCallback callback) { … }
void GuestViewBase::InitWithWebContents(const base::Value::Dict& create_params,
WebContents* guest_web_contents) { … }
const std::optional<
std::pair<base::Value::Dict, content::WebContents::CreateParams>>&
GuestViewBase::GetCreateParams() const { … }
void GuestViewBase::SetCreateParams(
const base::Value::Dict& create_params,
const content::WebContents::CreateParams& web_contents_create_params) { … }
void GuestViewBase::DispatchOnResizeEvent(const gfx::Size& old_size,
const gfx::Size& new_size) { … }
gfx::Size GuestViewBase::GetDefaultSize() const { … }
void GuestViewBase::SetSize(const SetSizeParams& params) { … }
GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { … }
GuestViewBase* GuestViewBase::FromRenderFrameHost(
content::RenderFrameHost* rfh) { … }
GuestViewBase* GuestViewBase::FromRenderFrameHostId(
const content::GlobalRenderFrameHostId& rfh_id) { … }
GuestViewBase* GuestViewBase::FromInstanceID(int owner_process_id,
int guest_instance_id) { … }
WebContents* GuestViewBase::GetTopLevelWebContents(WebContents* web_contents) { … }
bool GuestViewBase::IsGuest(WebContents* web_contents) { … }
bool GuestViewBase::IsGuest(content::RenderFrameHost* rfh) { … }
bool GuestViewBase::IsGuest(const content::GlobalRenderFrameHostId& rfh_id) { … }
bool GuestViewBase::IsAutoSizeSupported() const { … }
bool GuestViewBase::IsPreferredSizeModeEnabled() const { … }
bool GuestViewBase::ZoomPropagatesFromEmbedderToGuest() const { … }
content::NavigationController& GuestViewBase::GetController() { … }
GuestViewManager* GuestViewBase::GetGuestViewManager() const { … }
std::unique_ptr<WebContents> GuestViewBase::CreateNewGuestWindow(
const WebContents::CreateParams& create_params) { … }
void GuestViewBase::DidAttach() { … }
WebContents* GuestViewBase::GetOwnerWebContents() { … }
content::RenderFrameHost* GuestViewBase::GetProspectiveOuterDocument() { … }
const GURL& GuestViewBase::GetOwnerLastCommittedURL() const { … }
const GURL& GuestViewBase::GetOwnerSiteURL() const { … }
void GuestViewBase::SetAttachParams(const base::Value::Dict& params) { … }
void GuestViewBase::SetOpener(GuestViewBase* guest) { … }
void GuestViewBase::AttachToOuterWebContentsFrame(
std::unique_ptr<GuestViewBase> owned_this,
content::RenderFrameHost* outer_contents_frame,
int element_instance_id,
bool is_full_page_plugin,
GuestViewMessageHandler::AttachToEmbedderFrameCallback
attachment_callback) { … }
void GuestViewBase::OnOwnerAudioMutedStateUpdated(bool muted) { … }
void GuestViewBase::SignalWhenReady(base::OnceClosure callback) { … }
int GuestViewBase::LogicalPixelsToPhysicalPixels(double logical_pixels) const { … }
double GuestViewBase::PhysicalPixelsToLogicalPixels(int physical_pixels) const { … }
void GuestViewBase::DidStopLoading() { … }
void GuestViewBase::WebContentsDestroyed() { … }
void GuestViewBase::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
void GuestViewBase::ActivateContents(WebContents* web_contents) { … }
void GuestViewBase::ContentsMouseEvent(WebContents* source,
const ui::Event& event) { … }
void GuestViewBase::ContentsZoomChange(bool zoom_in) { … }
bool GuestViewBase::HandleKeyboardEvent(
WebContents* source,
const input::NativeWebKeyboardEvent& event) { … }
void GuestViewBase::LoadingStateChanged(WebContents* source,
bool should_show_loading_ui) { … }
void GuestViewBase::ResizeDueToAutoResize(WebContents* web_contents,
const gfx::Size& new_size) { … }
void GuestViewBase::RunFileChooser(
content::RenderFrameHost* render_frame_host,
scoped_refptr<content::FileSelectListener> listener,
const blink::mojom::FileChooserParams& params) { … }
bool GuestViewBase::ShouldFocusPageAfterCrash(content::WebContents* source) { … }
bool GuestViewBase::PreHandleGestureEvent(WebContents* source,
const blink::WebGestureEvent& event) { … }
void GuestViewBase::UpdatePreferredSize(WebContents* target_web_contents,
const gfx::Size& pref_size) { … }
void GuestViewBase::UpdateTargetURL(WebContents* source, const GURL& url) { … }
void GuestViewBase::OnZoomControllerDestroyed(zoom::ZoomController* source) { … }
void GuestViewBase::OnZoomChanged(
const zoom::ZoomController::ZoomChangedEventData& data) { … }
void GuestViewBase::DispatchEventToGuestProxy(
std::unique_ptr<GuestViewEvent> event) { … }
void GuestViewBase::DispatchEventToView(std::unique_ptr<GuestViewEvent> event) { … }
void GuestViewBase::SendQueuedEvents() { … }
void GuestViewBase::CompleteInit(
base::Value::Dict create_params,
GuestCreatedCallback callback,
std::unique_ptr<GuestViewBase> owned_this,
std::unique_ptr<content::WebContents> guest_web_contents) { … }
void GuestViewBase::TakeGuestContentsOwnership(
std::unique_ptr<WebContents> guest_web_contents) { … }
void GuestViewBase::ClearOwnedGuestContents() { … }
void GuestViewBase::UpdateWebContentsForNewOwner(
content::RenderFrameHost* new_owner_rfh) { … }
double GuestViewBase::GetEmbedderZoomFactor() const { … }
void GuestViewBase::SetUpSizing(const base::Value::Dict& params) { … }
void GuestViewBase::SetGuestZoomLevelToMatchEmbedder() { … }
void GuestViewBase::StartTrackingEmbedderZoomLevel() { … }
void GuestViewBase::StopTrackingEmbedderZoomLevel() { … }
void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size,
bool due_to_auto_resize) { … }
bool GuestViewBase::IsOwnedByExtension() const { … }
bool GuestViewBase::IsOwnedByWebUI() const { … }
bool GuestViewBase::IsOwnedByControlledFrameEmbedder() const { … }
void GuestViewBase::SetOwnerHost() { … }
bool GuestViewBase::CanBeEmbeddedInsideCrossProcessFrames() const { … }
bool GuestViewBase::RequiresSslInterstitials() const { … }
bool GuestViewBase::IsPermissionRequestable(ContentSettingsType type) const { … }
std::optional<content::PermissionResult>
GuestViewBase::OverridePermissionResult(ContentSettingsType type) const { … }
content::RenderFrameHost* GuestViewBase::GetGuestMainFrame() const { … }
base::WeakPtr<content::BrowserPluginGuestDelegate>
GuestViewBase::GetGuestDelegateWeakPtr() { … }
}