#include "components/guest_view/browser/guest_view_manager.h"
#include <tuple>
#include <utility>
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/crash/core/common/crash_key.h"
#include "components/guest_view/browser/bad_message.h"
#include "components/guest_view/browser/guest_view_base.h"
#include "components/guest_view/browser/guest_view_manager_delegate.h"
#include "components/guest_view/browser/guest_view_manager_factory.h"
#include "components/guest_view/common/guest_view_constants.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/child_process_host.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_process_host_observer.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents_observer.h"
BrowserContext;
RenderProcessHost;
SiteInstance;
WebContents;
namespace guest_view {
namespace {
GuestViewManagerFactory* g_factory;
}
class GuestViewManager::EmbedderRenderProcessHostObserver
: public content::RenderProcessHostObserver { … };
GuestViewManager::GuestViewManager(
content::BrowserContext* context,
std::unique_ptr<GuestViewManagerDelegate> delegate)
: … { … }
GuestViewManager::~GuestViewManager() { … }
GuestViewManager* GuestViewManager::CreateWithDelegate(
BrowserContext* context,
std::unique_ptr<GuestViewManagerDelegate> delegate) { … }
GuestViewManager* GuestViewManager::FromBrowserContext(
BrowserContext* context) { … }
void GuestViewManager::set_factory_for_testing(
GuestViewManagerFactory* factory) { … }
GuestViewBase* GuestViewManager::GetGuestByInstanceIDSafely(
int guest_instance_id,
int embedder_render_process_id) { … }
void GuestViewManager::AttachGuest(int embedder_process_id,
int element_instance_id,
int guest_instance_id,
const base::Value::Dict& attach_params) { … }
bool GuestViewManager::IsOwnedByExtension(const GuestViewBase* guest) { … }
bool GuestViewManager::IsOwnedByControlledFrameEmbedder(
const GuestViewBase* guest) { … }
int GuestViewManager::GetNextInstanceID() { … }
base::WeakPtr<GuestViewManager> GuestViewManager::AsWeakPtr() { … }
void GuestViewManager::CreateGuest(const std::string& view_type,
content::RenderFrameHost* owner_rfh,
const base::Value::Dict& create_params,
UnownedGuestCreatedCallback callback) { … }
void GuestViewManager::CreateGuestAndTransferOwnership(
const std::string& view_type,
content::RenderFrameHost* owner_rfh,
const base::Value::Dict& create_params,
OwnedGuestCreatedCallback callback) { … }
std::unique_ptr<GuestViewBase> GuestViewManager::TransferOwnership(
GuestViewBase* guest) { … }
void GuestViewManager::ManageOwnership(std::unique_ptr<GuestViewBase> guest) { … }
std::unique_ptr<content::WebContents>
GuestViewManager::CreateGuestWithWebContentsParams(
const std::string& view_type,
content::RenderFrameHost* owner_rfh,
const content::WebContents::CreateParams& create_params) { … }
SiteInstance* GuestViewManager::GetGuestSiteInstance(
const content::StoragePartitionConfig& storage_partition_config) { … }
void GuestViewManager::ForEachUnattachedGuest(
content::WebContents* owner_web_contents,
base::FunctionRef<void(content::WebContents*)> fn) { … }
bool GuestViewManager::ForEachGuest(
WebContents* owner_web_contents,
base::FunctionRef<bool(content::WebContents*)> fn) { … }
WebContents* GuestViewManager::GetFullPageGuest(
WebContents* embedder_web_contents) { … }
void GuestViewManager::AddGuest(GuestViewBase* guest) { … }
void GuestViewManager::RemoveGuest(GuestViewBase* guest, bool invalidate_id) { … }
GuestViewBase* GuestViewManager::GetGuestFromWebContents(
content::WebContents* web_contents) { … }
void GuestViewManager::EmbedderProcessDestroyed(int embedder_process_id) { … }
void GuestViewManager::ViewCreated(int embedder_process_id,
int view_instance_id,
const std::string& view_type) { … }
void GuestViewManager::ViewGarbageCollected(int embedder_process_id,
int view_instance_id) { … }
void GuestViewManager::CallViewDestructionCallbacks(int embedder_process_id,
int view_instance_id) { … }
void GuestViewManager::CallViewDestructionCallbacks(int embedder_process_id) { … }
std::unique_ptr<GuestViewBase> GuestViewManager::CreateGuestInternal(
content::RenderFrameHost* owner_rfh,
const std::string& view_type) { … }
void GuestViewManager::RegisterGuestViewTypes() { … }
void GuestViewManager::RegisterGuestViewType(
const std::string& type,
GuestViewCreateFunction create_function,
GuestViewCleanUpFunction cleanup_function) { … }
void GuestViewManager::RegisterViewDestructionCallback(
int embedder_process_id,
int view_instance_id,
base::OnceClosure callback) { … }
void GuestViewManager::ObserveEmbedderLifetime(
RenderProcessHost* embedder_process) { … }
bool GuestViewManager::IsGuestAvailableToContext(GuestViewBase* guest) { … }
void GuestViewManager::DispatchEvent(const std::string& event_name,
base::Value::Dict args,
GuestViewBase* guest,
int instance_id) { … }
GuestViewBase* GuestViewManager::GetGuestByInstanceID(int guest_instance_id) { … }
bool GuestViewManager::CanEmbedderAccessInstanceIDMaybeKill(
int embedder_render_process_id,
int guest_instance_id) { … }
bool GuestViewManager::CanUseGuestInstanceID(int guest_instance_id) { … }
bool GuestViewManager::CanEmbedderAccessInstanceID(
int embedder_render_process_id,
int guest_instance_id) { … }
GuestViewManager::ElementInstanceKey::ElementInstanceKey()
: … { … }
GuestViewManager::ElementInstanceKey::ElementInstanceKey(
int embedder_process_id,
int element_instance_id)
: … { … }
bool GuestViewManager::ElementInstanceKey::operator<(
const GuestViewManager::ElementInstanceKey& other) const { … }
GuestViewManager::GuestViewData::GuestViewData(
const GuestViewCreateFunction& create_function,
const GuestViewCleanUpFunction& cleanup_function)
: … { … }
GuestViewManager::GuestViewData::GuestViewData(const GuestViewData& other) =
default;
GuestViewManager::GuestViewData::~GuestViewData() = default;
}