Remove explicit tracking of guest view frames

This is no longer required now that we have implicit exclusion
of certain frame types including guest view frames.

Rename GuestView to ExcludedView in the renderer process.
This commit is contained in:
Marshall Greenblatt
2024-04-24 17:23:47 -04:00
parent 65234a6830
commit 5065aba1b4
27 changed files with 166 additions and 374 deletions

View File

@ -16,6 +16,7 @@
#include "libcef/browser/browser_info_manager.h" #include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_platform_delegate.h" #include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h" #include "libcef/browser/context.h"
#include "libcef/browser/extensions/browser_extensions_util.h"
#include "libcef/browser/hang_monitor.h" #include "libcef/browser/hang_monitor.h"
#include "libcef/browser/media_access_query.h" #include "libcef/browser/media_access_query.h"
#include "libcef/browser/osr/osr_util.h" #include "libcef/browser/osr/osr_util.h"
@ -604,9 +605,8 @@ void AlloyBrowserHostImpl::CancelContextMenu() {
bool AlloyBrowserHostImpl::MaybeAllowNavigation( bool AlloyBrowserHostImpl::MaybeAllowNavigation(
content::RenderFrameHost* opener, content::RenderFrameHost* opener,
const content::OpenURLParams& params) { const content::OpenURLParams& params) {
bool is_guest_view = false; const bool is_guest_view = extensions::IsBrowserPluginGuest(
GetFrameForHost(opener, &is_guest_view); content::WebContents::FromRenderFrameHost(opener));
if (is_guest_view && !params.is_pdf && if (is_guest_view && !params.is_pdf &&
!params.url.SchemeIs(extensions::kExtensionScheme) && !params.url.SchemeIs(extensions::kExtensionScheme) &&
!params.url.SchemeIs(content::kChromeUIScheme)) { !params.url.SchemeIs(content::kChromeUIScheme)) {

View File

@ -94,8 +94,7 @@ void CefBrowserContentsDelegate::ObserveWebContents(
// Make sure MaybeCreateFrame is called at least one time. // Make sure MaybeCreateFrame is called at least one time.
// Create the frame representation before OnAfterCreated is called for a new // Create the frame representation before OnAfterCreated is called for a new
// browser. // browser.
browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame(), browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame());
false /* is_guest_view */);
// Make sure RenderWidgetCreated is called at least one time. This Observer // Make sure RenderWidgetCreated is called at least one time. This Observer
// is registered too late to catch the initial creation. // is registered too late to catch the initial creation.
@ -319,7 +318,7 @@ void CefBrowserContentsDelegate::DraggableRegionsChanged(
void CefBrowserContentsDelegate::RenderFrameCreated( void CefBrowserContentsDelegate::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */); browser_info_->MaybeCreateFrame(render_frame_host);
if (render_frame_host->GetParent() == nullptr) { if (render_frame_host->GetParent() == nullptr) {
auto render_view_host = render_frame_host->GetRenderViewHost(); auto render_view_host = render_frame_host->GetRenderViewHost();
auto base_background_color = platform_delegate()->GetBackgroundColor(); auto base_background_color = platform_delegate()->GetBackgroundColor();

View File

@ -283,8 +283,7 @@ std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
void CefBrowserContext::OnRenderFrameCreated( void CefBrowserContext::OnRenderFrameCreated(
CefRequestContextImpl* request_context, CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame) {
bool is_guest_view) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(global_id)); DCHECK(frame_util::IsValidGlobalId(global_id));
@ -302,8 +301,7 @@ void CefBrowserContext::OnRenderFrameCreated(
void CefBrowserContext::OnRenderFrameDeleted( void CefBrowserContext::OnRenderFrameDeleted(
CefRequestContextImpl* request_context, CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame) {
bool is_guest_view) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(frame_util::IsValidGlobalId(global_id)); DCHECK(frame_util::IsValidGlobalId(global_id));

View File

@ -132,14 +132,12 @@ class CefBrowserContext {
// Called from CefRequestContextImpl::OnRenderFrameCreated. // Called from CefRequestContextImpl::OnRenderFrameCreated.
void OnRenderFrameCreated(CefRequestContextImpl* request_context, void OnRenderFrameCreated(CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame);
bool is_guest_view);
// Called from CefRequestContextImpl::OnRenderFrameDeleted. // Called from CefRequestContextImpl::OnRenderFrameDeleted.
void OnRenderFrameDeleted(CefRequestContextImpl* request_context, void OnRenderFrameDeleted(CefRequestContextImpl* request_context,
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame);
bool is_guest_view);
// Returns the handler that matches the specified IDs. Pass -1 for unknown // Returns the handler that matches the specified IDs. Pass -1 for unknown
// values. If |require_frame_match| is true only exact matches will be // values. If |require_frame_match| is true only exact matches will be

View File

@ -59,10 +59,10 @@ void CefBrowserFrame::FrameAttached(
bool reattached) { bool reattached) {
// Always send to the newly created RFH, which may be speculative when // Always send to the newly created RFH, which may be speculative when
// navigating cross-origin. // navigating cross-origin.
bool excluded_type; bool is_excluded;
if (auto host = GetFrameHost(/*prefer_speculative=*/true, &excluded_type)) { if (auto host = GetFrameHost(/*prefer_speculative=*/true, &is_excluded)) {
host->FrameAttached(std::move(render_frame), reattached); host->FrameAttached(std::move(render_frame), reattached);
} else if (excluded_type) { } else if (is_excluded) {
VLOG(1) << "frame " VLOG(1) << "frame "
<< frame_util::GetFrameDebugString( << frame_util::GetFrameDebugString(
render_frame_host()->GetGlobalFrameToken()) render_frame_host()->GetGlobalFrameToken())
@ -82,8 +82,8 @@ void CefBrowserFrame::UpdateDraggableRegions(
CefRefPtr<CefFrameHostImpl> CefBrowserFrame::GetFrameHost( CefRefPtr<CefFrameHostImpl> CefBrowserFrame::GetFrameHost(
bool prefer_speculative, bool prefer_speculative,
bool* excluded_type) const { bool* is_excluded) const {
return CefBrowserInfoManager::GetFrameHost( return CefBrowserInfoManager::GetFrameHost(
render_frame_host(), prefer_speculative, render_frame_host(), prefer_speculative,
/*browser_info=*/nullptr, excluded_type); /*browser_info=*/nullptr, is_excluded);
} }

View File

@ -49,7 +49,7 @@ class CefBrowserFrame
bool ShouldCloseOnFinishNavigation() const override { return false; } bool ShouldCloseOnFinishNavigation() const override { return false; }
CefRefPtr<CefFrameHostImpl> GetFrameHost(bool prefer_speculative, CefRefPtr<CefFrameHostImpl> GetFrameHost(bool prefer_speculative,
bool* excluded_type = nullptr) const; bool* is_excluded = nullptr) const;
}; };
#endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_ #endif // CEF_LIBCEF_BROWSER_BROWSER_FRAME_H_

View File

@ -126,9 +126,9 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForContents(
return browser; return browser;
} }
// Try the owner WebContents if |contents| originates from a guest view such // Try the owner WebContents if |contents| originates from an excluded view
// as the PDF viewer or Print Preview. // such as the PDF viewer or Print Preview. This is safe to call even if Alloy
// This is safe to call even if Alloy extensions are disabled. // extensions are disabled.
if (auto* owner_contents = extensions::GetOwnerForGuestContents(contents)) { if (auto* owner_contents = extensions::GetOwnerForGuestContents(contents)) {
return WebContentsUserDataAdapter::Get(owner_contents); return WebContentsUserDataAdapter::Get(owner_contents);
} }
@ -153,8 +153,7 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalId(
return GetBrowserForHost(render_frame_host); return GetBrowserForHost(render_frame_host);
} else { } else {
// Use the thread-safe approach. // Use the thread-safe approach.
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_id, auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_id);
nullptr);
if (info) { if (info) {
auto browser = info->browser(); auto browser = info->browser();
if (!browser) { if (!browser) {
@ -185,8 +184,8 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForGlobalToken(
return GetBrowserForHost(render_frame_host); return GetBrowserForHost(render_frame_host);
} else { } else {
// Use the thread-safe approach. // Use the thread-safe approach.
auto info = CefBrowserInfoManager::GetInstance()->GetBrowserInfo( auto info =
global_token, nullptr); CefBrowserInfoManager::GetInstance()->GetBrowserInfo(global_token);
if (info) { if (info) {
auto browser = info->browser(); auto browser = info->browser();
if (!browser) { if (!browser) {
@ -1121,24 +1120,23 @@ void CefBrowserHostBase::OnWebContentsDestroyed(
content::WebContents* web_contents) {} content::WebContents* web_contents) {}
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost( CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost(
const content::RenderFrameHost* host, const content::RenderFrameHost* host) {
bool* is_guest_view) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (!host) { if (!host) {
return nullptr; return nullptr;
} }
return browser_info_->GetFrameForHost(host, is_guest_view); return browser_info_->GetFrameForHost(host);
} }
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalId( CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id) { const content::GlobalRenderFrameHostId& global_id) {
return browser_info_->GetFrameForGlobalId(global_id, nullptr); return browser_info_->GetFrameForGlobalId(global_id);
} }
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalToken( CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token) { const content::GlobalRenderFrameHostToken& global_token) {
return browser_info_->GetFrameForGlobalToken(global_token, nullptr); return browser_info_->GetFrameForGlobalToken(global_token);
} }
void CefBrowserHostBase::AddObserver(Observer* observer) { void CefBrowserHostBase::AddObserver(Observer* observer) {

View File

@ -286,12 +286,8 @@ class CefBrowserHostBase : public CefBrowserHost,
void OnWebContentsDestroyed(content::WebContents* web_contents) override; void OnWebContentsDestroyed(content::WebContents* web_contents) override;
// Returns the frame object matching the specified |host| or nullptr if no // Returns the frame object matching the specified |host| or nullptr if no
// match is found. Nullptr will also be returned if a guest view match is // match is found. Must be called on the UI thread.
// found because we don't create frame objects for guest views. If CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
// |is_guest_view| is non-nullptr it will be set to true in this case. Must be
// called on the UI thread.
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host,
bool* is_guest_view = nullptr);
// Returns the frame associated with the specified global ID/token. See // Returns the frame associated with the specified global ID/token. See
// documentation on RenderFrameHost::GetFrameTreeNodeId/Token() for why the // documentation on RenderFrameHost::GetFrameTreeNodeId/Token() for why the

View File

@ -95,8 +95,7 @@ void CefBrowserInfo::SetClosing() {
is_closing_ = true; is_closing_ = true;
} }
void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host, void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host) {
bool is_guest_view) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
if (CefBrowserInfoManager::IsExcludedFrameHost(host)) { if (CefBrowserInfoManager::IsExcludedFrameHost(host)) {
@ -129,11 +128,10 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly. // Check that the frame info hasn't changed unexpectedly.
DCHECK_EQ(info->global_id_, global_id); DCHECK_EQ(info->global_id_, global_id);
DCHECK_EQ(info->is_guest_view_, is_guest_view);
DCHECK_EQ(info->is_main_frame_, is_main_frame); DCHECK_EQ(info->is_main_frame_, is_main_frame);
#endif #endif
if (!info->is_guest_view_ && info->is_speculative_ && !is_speculative) { if (info->is_speculative_ && !is_speculative) {
// Upgrade the frame info from speculative to non-speculative. // Upgrade the frame info from speculative to non-speculative.
if (info->is_main_frame_) { if (info->is_main_frame_) {
// Set the main frame object. // Set the main frame object.
@ -147,28 +145,23 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
auto frame_info = new FrameInfo; auto frame_info = new FrameInfo;
frame_info->host_ = host; frame_info->host_ = host;
frame_info->global_id_ = global_id; frame_info->global_id_ = global_id;
frame_info->is_guest_view_ = is_guest_view;
frame_info->is_main_frame_ = is_main_frame; frame_info->is_main_frame_ = is_main_frame;
frame_info->is_speculative_ = is_speculative; frame_info->is_speculative_ = is_speculative;
// Guest views don't get their own CefBrowser or CefFrame objects. // Create a new frame object.
if (!is_guest_view) { frame_info->frame_ = new CefFrameHostImpl(this, host);
// Create a new frame object. MaybeNotifyFrameCreated(frame_info->frame_);
frame_info->frame_ = new CefFrameHostImpl(this, host); if (is_main_frame && !is_speculative) {
MaybeNotifyFrameCreated(frame_info->frame_); SetMainFrame(browser_, frame_info->frame_);
if (is_main_frame && !is_speculative) {
SetMainFrame(browser_, frame_info->frame_);
}
#if DCHECK_IS_ON()
// Check that the frame info hasn't changed unexpectedly.
DCHECK(host->GetGlobalFrameToken() == *frame_info->frame_->frame_token());
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
#endif
} }
browser_->request_context()->OnRenderFrameCreated(global_id, is_main_frame, #if DCHECK_IS_ON()
is_guest_view); // Check that the frame info hasn't changed unexpectedly.
DCHECK(host->GetGlobalFrameToken() == *frame_info->frame_->frame_token());
DCHECK_EQ(frame_info->is_main_frame_, frame_info->frame_->IsMain());
#endif
browser_->request_context()->OnRenderFrameCreated(global_id, is_main_frame);
// Populate the lookup maps. // Populate the lookup maps.
frame_id_map_.insert(std::make_pair(global_id, frame_info)); frame_id_map_.insert(std::make_pair(global_id, frame_info));
@ -238,8 +231,8 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
auto frame_info = it->second; auto frame_info = it->second;
browser_->request_context()->OnRenderFrameDeleted( browser_->request_context()->OnRenderFrameDeleted(global_id,
global_id, frame_info->is_main_frame_, frame_info->is_guest_view_); frame_info->is_main_frame_);
// Remove from the lookup maps. // Remove from the lookup maps.
frame_id_map_.erase(it); frame_id_map_.erase(it);
@ -290,29 +283,19 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::CreateTempSubFrame(
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost( CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForHost(
const content::RenderFrameHost* host, const content::RenderFrameHost* host,
bool* is_guest_view,
bool prefer_speculative) const { bool prefer_speculative) const {
if (is_guest_view) {
*is_guest_view = false;
}
if (!host) { if (!host) {
return nullptr; return nullptr;
} }
return GetFrameForGlobalId( return GetFrameForGlobalId(
const_cast<content::RenderFrameHost*>(host)->GetGlobalId(), is_guest_view, const_cast<content::RenderFrameHost*>(host)->GetGlobalId(),
prefer_speculative); prefer_speculative);
} }
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId( CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view,
bool prefer_speculative) const { bool prefer_speculative) const {
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalId(global_id)) { if (!frame_util::IsValidGlobalId(global_id)) {
return nullptr; return nullptr;
} }
@ -323,13 +306,6 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
if (it != frame_id_map_.end()) { if (it != frame_id_map_.end()) {
const auto info = it->second; const auto info = it->second;
if (info->is_guest_view_) {
if (is_guest_view) {
*is_guest_view = true;
}
return nullptr;
}
if (info->is_speculative_ && !prefer_speculative) { if (info->is_speculative_ && !prefer_speculative) {
if (info->is_main_frame_ && main_frame_) { if (info->is_main_frame_ && main_frame_) {
// Always prefer the non-speculative main frame. // Always prefer the non-speculative main frame.
@ -349,12 +325,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalId(
CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken( CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view,
bool prefer_speculative) const { bool prefer_speculative) const {
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalToken(global_token)) { if (!frame_util::IsValidGlobalToken(global_token)) {
return nullptr; return nullptr;
} }
@ -370,7 +341,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfo::GetFrameForGlobalToken(
global_id = it->second; global_id = it->second;
} }
return GetFrameForGlobalId(global_id, is_guest_view, prefer_speculative); return GetFrameForGlobalId(global_id, prefer_speculative);
} }
CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const { CefBrowserInfo::FrameHostList CefBrowserInfo::GetAllFrames() const {

View File

@ -67,10 +67,8 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
// Ensure that a frame record exists for |host|. Called for the main frame // Ensure that a frame record exists for |host|. Called for the main frame
// when the RenderView is created, or for a sub-frame when the associated // when the RenderView is created, or for a sub-frame when the associated
// RenderFrame is created in the renderer process. // RenderFrame is created in the renderer process.
// Called from CefBrowserContentsDelegate::RenderFrameCreated (is_guest_view = // Called from CefBrowserContentsDelegate::RenderFrameCreated.
// false) or CefMimeHandlerViewGuestDelegate::OnGuestAttached (is_guest_view = void MaybeCreateFrame(content::RenderFrameHost* host);
// true).
void MaybeCreateFrame(content::RenderFrameHost* host, bool is_guest_view);
// Used to track state changes such as entering/exiting the BackForwardCache. // Used to track state changes such as entering/exiting the BackForwardCache.
// Called from CefBrowserContentsDelegate::RenderFrameHostStateChanged. // Called from CefBrowserContentsDelegate::RenderFrameHostStateChanged.
@ -102,32 +100,22 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
const content::GlobalRenderFrameHostId& parent_global_id); const content::GlobalRenderFrameHostId& parent_global_id);
// Returns the frame object matching the specified host or nullptr if no match // Returns the frame object matching the specified host or nullptr if no match
// is found. Nullptr will also be returned if a guest view match is found // is found. Must be called on the UI thread.
// because we don't create frame objects for guest views. If |is_guest_view|
// is non-nullptr it will be set to true in this case. Must be called on the
// UI thread.
CefRefPtr<CefFrameHostImpl> GetFrameForHost( CefRefPtr<CefFrameHostImpl> GetFrameForHost(
const content::RenderFrameHost* host, const content::RenderFrameHost* host,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const; bool prefer_speculative = false) const;
// Returns the frame object matching the specified ID/token or nullptr if no // Returns the frame object matching the specified ID/token or nullptr if no
// match is found. Nullptr will also be returned if a guest view match is // match is found. Safe to call from any thread.
// found because we don't create frame objects for guest views. If
// |is_guest_view| is non-nullptr it will be set to true in this case. Safe to
// call from any thread.
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalId( CefRefPtr<CefFrameHostImpl> GetFrameForGlobalId(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const; bool prefer_speculative = false) const;
CefRefPtr<CefFrameHostImpl> GetFrameForGlobalToken( CefRefPtr<CefFrameHostImpl> GetFrameForGlobalToken(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token,
bool* is_guest_view = nullptr,
bool prefer_speculative = false) const; bool prefer_speculative = false) const;
// Returns all non-speculative frame objects that currently exist. Guest views // Returns all non-speculative frame objects that currently exist. Safe to
// will be excluded because they don't have a frame object. Safe to call from // call from any thread.
// any thread.
using FrameHostList = std::set<CefRefPtr<CefFrameHostImpl>>; using FrameHostList = std::set<CefRefPtr<CefFrameHostImpl>>;
FrameHostList GetAllFrames() const; FrameHostList GetAllFrames() const;
@ -184,7 +172,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
content::RenderFrameHost* host_; content::RenderFrameHost* host_;
content::GlobalRenderFrameHostId global_id_; content::GlobalRenderFrameHostId global_id_;
bool is_guest_view_;
bool is_main_frame_; bool is_main_frame_;
bool is_speculative_; bool is_speculative_;
bool is_in_bfcache_ = false; bool is_in_bfcache_ = false;

View File

@ -97,7 +97,7 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::CreatePopupBrowserInfo(
// Continue any pending NewBrowserInfo request. // Continue any pending NewBrowserInfo request.
ContinueNewBrowserInfo(frame_host->GetGlobalFrameToken(), browser_info, ContinueNewBrowserInfo(frame_host->GetGlobalFrameToken(), browser_info,
/*is_guest_view=*/false); /*is_excluded=*/false);
return browser_info; return browser_info;
} }
@ -307,15 +307,13 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
base::AutoLock lock_scope(browser_info_lock_); base::AutoLock lock_scope(browser_info_lock_);
bool is_guest_view = false;
scoped_refptr<CefBrowserInfo> browser_info = scoped_refptr<CefBrowserInfo> browser_info =
GetBrowserInfoInternal(global_token, &is_guest_view); GetBrowserInfoInternal(global_token);
if (browser_info) { if (browser_info) {
// Send the response immediately. // Send the response immediately.
SendNewBrowserInfoResponse(browser_info, is_guest_view, std::move(callback), SendNewBrowserInfoResponse(browser_info, /*is_excluded=*/false,
callback_runner); std::move(callback), callback_runner);
return; return;
} }
@ -347,7 +345,7 @@ void CefBrowserInfoManager::OnGetNewBrowserInfo(
kNewBrowserInfoResponseTimeoutMs); kNewBrowserInfoResponseTimeoutMs);
} }
// Check for PDF viewer or print preview frames. // Check for excluded content (PDF viewer or print preview).
CEF_POST_TASK( CEF_POST_TASK(
CEF_UIT, CEF_UIT,
base::BindOnce( base::BindOnce(
@ -369,29 +367,27 @@ void CefBrowserInfoManager::CheckExcludedNewBrowserInfoOnUIThread(
return; return;
} }
// PDF viewer and print preview create multiple renderer processes. Not all // PDF viewer and print preview create multiple renderer processes. These
// of those processes are currently tracked by CefBrowserInfo, so we also // excluded processes are not tracked by CefBrowserInfo.
// treat frames from untracked processes (like the print preview dialog) as
// guest views in the renderer process.
CefBrowserInfo* browser_info; CefBrowserInfo* browser_info;
bool excluded_type; bool is_excluded;
GetFrameHost(rfh, /*prefer_speculative=*/true, &browser_info, &excluded_type); GetFrameHost(rfh, /*prefer_speculative=*/true, &browser_info, &is_excluded);
if (browser_info && excluded_type) { if (browser_info && is_excluded) {
g_info_manager->ContinueNewBrowserInfo(global_token, browser_info, g_info_manager->ContinueNewBrowserInfo(global_token, browser_info,
/*is_guest_view=*/true); /*is_excluded=*/true);
} }
} }
void CefBrowserInfoManager::ContinueNewBrowserInfo( void CefBrowserInfoManager::ContinueNewBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token,
scoped_refptr<CefBrowserInfo> browser_info, scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view) { bool is_excluded) {
base::AutoLock lock_scope(browser_info_lock_); base::AutoLock lock_scope(browser_info_lock_);
// Continue any pending NewBrowserInfo request. // Continue any pending NewBrowserInfo request.
auto it = pending_new_browser_info_map_.find(global_token); auto it = pending_new_browser_info_map_.find(global_token);
if (it != pending_new_browser_info_map_.end()) { if (it != pending_new_browser_info_map_.end()) {
SendNewBrowserInfoResponse(browser_info, is_guest_view, SendNewBrowserInfoResponse(browser_info, is_excluded,
std::move(it->second->callback), std::move(it->second->callback),
it->second->callback_runner); it->second->callback_runner);
pending_new_browser_info_map_.erase(it); pending_new_browser_info_map_.erase(it);
@ -444,17 +440,15 @@ void CefBrowserInfoManager::DestroyAllBrowsers() {
} }
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo( scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id) {
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_); base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfoInternal(global_id, is_guest_view); return GetBrowserInfoInternal(global_id);
} }
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo( scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token) {
bool* is_guest_view) {
base::AutoLock lock_scope(browser_info_lock_); base::AutoLock lock_scope(browser_info_lock_);
return GetBrowserInfoInternal(global_token, is_guest_view); return GetBrowserInfoInternal(global_token);
} }
bool CefBrowserInfoManager::MaybeAllowNavigation( bool CefBrowserInfoManager::MaybeAllowNavigation(
@ -496,7 +490,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfoManager::GetFrameHost(
content::RenderFrameHost* rfh, content::RenderFrameHost* rfh,
bool prefer_speculative, bool prefer_speculative,
CefBrowserInfo** browser_info, CefBrowserInfo** browser_info,
bool* excluded_type) { bool* is_excluded) {
CEF_REQUIRE_UIT(); CEF_REQUIRE_UIT();
DCHECK(rfh); DCHECK(rfh);
@ -510,28 +504,22 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfoManager::GetFrameHost(
bool excluded = bool excluded =
is_pdf_process || is_browser_process_guest || is_print_preview_dialog; is_pdf_process || is_browser_process_guest || is_print_preview_dialog;
bool guest_view = false;
CefRefPtr<CefFrameHostImpl> frame; CefRefPtr<CefFrameHostImpl> frame;
// A BrowserHost may match an excluded RFH type. Some associations are // A BrowserHost may match an excluded RFH type. Some associations are
// registered directly via CefBrowserInfo::MaybeCreateFrame and some are // registered directly via CefBrowserInfo::MaybeCreateFrame and some are
// discovered indirectly via extensions::GetOwnerForGuestContents. // discovered indirectly via extensions::GetOwnerForGuestContents.
auto browser = CefBrowserHostBase::GetBrowserForHost(rfh); auto browser = CefBrowserHostBase::GetBrowserForHost(rfh);
if (browser) { if (browser && !excluded) {
frame = browser->browser_info()->GetFrameForHost(rfh, &guest_view, frame = browser->browser_info()->GetFrameForHost(rfh, prefer_speculative);
prefer_speculative);
excluded |= guest_view;
// A FrameHost should never exist for an excluded type.
DCHECK(!frame || !excluded);
} }
if (browser_info) { if (browser_info) {
*browser_info = browser ? browser->browser_info().get() : nullptr; *browser_info = browser ? browser->browser_info().get() : nullptr;
} }
if (excluded_type) { if (is_excluded) {
*excluded_type = excluded; *is_excluded = excluded;
} }
if (VLOG_IS_ON(1)) { if (VLOG_IS_ON(1)) {
@ -539,9 +527,7 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfoManager::GetFrameHost(
frame_util::GetFrameDebugString(rfh->GetGlobalFrameToken()); frame_util::GetFrameDebugString(rfh->GetGlobalFrameToken());
const bool is_main = rfh->GetParent() == nullptr; const bool is_main = rfh->GetParent() == nullptr;
VLOG(1) << "frame " << debug_string VLOG(1) << "frame " << debug_string << ", pdf_process=" << is_pdf_process
<< " registered_guest_view=" << guest_view
<< ", pdf_process=" << is_pdf_process
<< ", browser_process_guest=" << is_browser_process_guest << ", browser_process_guest=" << is_browser_process_guest
<< ", print_preview_dialog=" << is_print_preview_dialog << ", print_preview_dialog=" << is_print_preview_dialog
<< ", main=" << is_main << (browser ? "" : ", has no BrowserHost") << ", main=" << is_main << (browser ? "" : ", has no BrowserHost")
@ -686,26 +672,16 @@ CefBrowserInfoManager::PopPendingPopup(PendingPopup::Step previous_step_alloy,
} }
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal( scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id) {
bool* is_guest_view) {
browser_info_lock_.AssertAcquired(); browser_info_lock_.AssertAcquired();
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalId(global_id)) { if (!frame_util::IsValidGlobalId(global_id)) {
return nullptr; return nullptr;
} }
for (const auto& browser_info : browser_info_list_) { for (const auto& browser_info : browser_info_list_) {
bool is_guest_view_tmp; auto frame = browser_info->GetFrameForGlobalId(global_id);
auto frame = if (frame) {
browser_info->GetFrameForGlobalId(global_id, &is_guest_view_tmp);
if (frame || is_guest_view_tmp) {
if (is_guest_view) {
*is_guest_view = is_guest_view_tmp;
}
return browser_info; return browser_info;
} }
} }
@ -714,26 +690,16 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
} }
scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal( scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token) {
bool* is_guest_view) {
browser_info_lock_.AssertAcquired(); browser_info_lock_.AssertAcquired();
if (is_guest_view) {
*is_guest_view = false;
}
if (!frame_util::IsValidGlobalToken(global_token)) { if (!frame_util::IsValidGlobalToken(global_token)) {
return nullptr; return nullptr;
} }
for (const auto& browser_info : browser_info_list_) { for (const auto& browser_info : browser_info_list_) {
bool is_guest_view_tmp; auto frame = browser_info->GetFrameForGlobalToken(global_token);
auto frame = if (frame) {
browser_info->GetFrameForGlobalToken(global_token, &is_guest_view_tmp);
if (frame || is_guest_view_tmp) {
if (is_guest_view) {
*is_guest_view = is_guest_view_tmp;
}
return browser_info; return browser_info;
} }
} }
@ -744,20 +710,20 @@ scoped_refptr<CefBrowserInfo> CefBrowserInfoManager::GetBrowserInfoInternal(
// static // static
void CefBrowserInfoManager::SendNewBrowserInfoResponse( void CefBrowserInfoManager::SendNewBrowserInfoResponse(
scoped_refptr<CefBrowserInfo> browser_info, scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view, bool is_excluded,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback, cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner) { scoped_refptr<base::SequencedTaskRunner> callback_runner) {
if (!callback_runner->RunsTasksInCurrentSequence()) { if (!callback_runner->RunsTasksInCurrentSequence()) {
callback_runner->PostTask( callback_runner->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&CefBrowserInfoManager::SendNewBrowserInfoResponse, base::BindOnce(&CefBrowserInfoManager::SendNewBrowserInfoResponse,
browser_info, is_guest_view, std::move(callback), browser_info, is_excluded, std::move(callback),
callback_runner)); callback_runner));
return; return;
} }
auto params = cef::mojom::NewBrowserInfo::New(); auto params = cef::mojom::NewBrowserInfo::New();
params->is_guest_view = is_guest_view; params->is_excluded = is_excluded;
if (browser_info) { if (browser_info) {
params->browser_id = browser_info->browser_id(); params->browser_id = browser_info->browser_id();
@ -783,7 +749,7 @@ void CefBrowserInfoManager::SendNewBrowserInfoResponse(
// static // static
void CefBrowserInfoManager::CancelNewBrowserInfoResponse( void CefBrowserInfoManager::CancelNewBrowserInfoResponse(
PendingNewBrowserInfo* pending_info) { PendingNewBrowserInfo* pending_info) {
SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_guest_view=*/false, SendNewBrowserInfoResponse(/*browser_info=*/nullptr, /*is_excluded=*/false,
std::move(pending_info->callback), std::move(pending_info->callback),
pending_info->callback_runner); pending_info->callback_runner);
} }

View File

@ -110,9 +110,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// browser info to the renderer process. If the browser info already exists // browser info to the renderer process. If the browser info already exists
// the response will be sent immediately. Otherwise, the response will be sent // the response will be sent immediately. Otherwise, the response will be sent
// when CreatePopupBrowserInfo creates the browser info. The info will already // when CreatePopupBrowserInfo creates the browser info. The info will already
// exist for explicitly created browsers and guest views. It may sometimes // exist for explicitly created browsers. It may sometimes already exist for
// already exist for traditional popup browsers depending on timing. See // traditional popup browsers depending on timing. See comments on
// comments on PendingPopup for more information. // PendingPopup for more information.
void OnGetNewBrowserInfo( void OnGetNewBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback); cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback);
@ -127,15 +127,10 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Returns the CefBrowserInfo matching the specified ID/token or nullptr if no // Returns the CefBrowserInfo matching the specified ID/token or nullptr if no
// match is found. It is allowed to add new callers of this method but // match is found. It is allowed to add new callers of this method but
// consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() instead. // consider using CefBrowserHostBase::GetBrowserForGlobalId/Token() instead.
// If |is_guest_view| is non-nullptr it will be set to true if the ID/token
// matches a guest view associated with the returned browser info instead of
// the browser itself.
scoped_refptr<CefBrowserInfo> GetBrowserInfo( scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id);
bool* is_guest_view = nullptr);
scoped_refptr<CefBrowserInfo> GetBrowserInfo( scoped_refptr<CefBrowserInfo> GetBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token);
bool* is_guest_view = nullptr);
// Returns all existing CefBrowserInfo objects. // Returns all existing CefBrowserInfo objects.
using BrowserInfoList = std::list<scoped_refptr<CefBrowserInfo>>; using BrowserInfoList = std::list<scoped_refptr<CefBrowserInfo>>;
@ -152,13 +147,13 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
bool use_default_browser_creation); bool use_default_browser_creation);
// Returns the FrameHost associated with |rfh|, if any. |browser_info| and // Returns the FrameHost associated with |rfh|, if any. |browser_info| and
// |excluded_type| will be populated if non-nullptr. An excluded type will not // |is_excluded| will be populated if non-nullptr. An excluded type will not
// have a FrameHost but |browser_info| may still be populated if the // have a FrameHost but |browser_info| may still be populated if the
// association is known. // association is known.
static CefRefPtr<CefFrameHostImpl> GetFrameHost(content::RenderFrameHost* rfh, static CefRefPtr<CefFrameHostImpl> GetFrameHost(content::RenderFrameHost* rfh,
bool prefer_speculative, bool prefer_speculative,
CefBrowserInfo** browser_info, CefBrowserInfo** browser_info,
bool* excluded_type); bool* is_excluded);
// Returns true if |rfh| should be excluded (no FrameHost created). // Returns true if |rfh| should be excluded (no FrameHost created).
static bool IsExcludedFrameHost(content::RenderFrameHost* rfh); static bool IsExcludedFrameHost(content::RenderFrameHost* rfh);
@ -171,7 +166,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// - CanCreateWindow (UIT): // - CanCreateWindow (UIT):
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and // Provides an opportunity to cancel the popup (calls OnBeforePopup) and
// creates the new platform delegate for the popup. If the popup owner is // creates the new platform delegate for the popup. If the popup owner is
// an extension guest view then the popup is canceled and // an extension guest view (PDF viewer) then the popup is canceled and
// WebContentsDelegate::OpenURLFromTab is called via the // WebContentsDelegate::OpenURLFromTab is called via the
// CefBrowserHostBase::MaybeAllowNavigation implementation. // CefBrowserHostBase::MaybeAllowNavigation implementation.
// And then the following calls may occur at the same time: // And then the following calls may occur at the same time:
@ -237,11 +232,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Retrieves the BrowserInfo matching the specified ID/token. // Retrieves the BrowserInfo matching the specified ID/token.
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal( scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id);
bool* is_guest_view);
scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal( scoped_refptr<CefBrowserInfo> GetBrowserInfoInternal(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token);
bool* is_guest_view);
// Check for excluded frames that can be responded to immediately. // Check for excluded frames that can be responded to immediately.
static void CheckExcludedNewBrowserInfoOnUIThread( static void CheckExcludedNewBrowserInfoOnUIThread(
@ -250,12 +243,12 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
void ContinueNewBrowserInfo( void ContinueNewBrowserInfo(
const content::GlobalRenderFrameHostToken& global_token, const content::GlobalRenderFrameHostToken& global_token,
scoped_refptr<CefBrowserInfo> browser_info, scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view); bool is_excluded);
// Send the response for a pending OnGetNewBrowserInfo request. // Send the response for a pending OnGetNewBrowserInfo request.
static void SendNewBrowserInfoResponse( static void SendNewBrowserInfoResponse(
scoped_refptr<CefBrowserInfo> browser_info, scoped_refptr<CefBrowserInfo> browser_info,
bool is_guest_view, bool is_excluded,
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback, cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_runner); scoped_refptr<base::SequencedTaskRunner> callback_runner);

View File

@ -256,7 +256,7 @@ class CefContextMenuObserver : public RenderViewContextMenuObserver,
// May return nullptr if the frame is destroyed while the menu is pending. // May return nullptr if the frame is destroyed while the menu is pending.
auto* rfh = context_menu_->GetRenderFrameHost(); auto* rfh = context_menu_->GetRenderFrameHost();
if (rfh) { if (rfh) {
// May return nullptr for guest views. // May return nullptr for excluded views.
frame = browser_->GetFrameForHost(rfh); frame = browser_->GetFrameForHost(rfh);
} }
if (!frame) { if (!frame) {

View File

@ -6,7 +6,6 @@
#include "libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h" #include "libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h"
#include "libcef/browser/browser_host_base.h" #include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/chrome/chrome_context_menu_handler.h" #include "libcef/browser/chrome/chrome_context_menu_handler.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h" #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
@ -15,37 +14,11 @@ namespace extensions {
ChromeMimeHandlerViewGuestDelegateCef::ChromeMimeHandlerViewGuestDelegateCef( ChromeMimeHandlerViewGuestDelegateCef::ChromeMimeHandlerViewGuestDelegateCef(
MimeHandlerViewGuest* guest) MimeHandlerViewGuest* guest)
: guest_(guest), owner_web_contents_(guest_->owner_web_contents()) {} : owner_web_contents_(guest->owner_web_contents()) {}
ChromeMimeHandlerViewGuestDelegateCef:: ChromeMimeHandlerViewGuestDelegateCef::
~ChromeMimeHandlerViewGuestDelegateCef() = default; ~ChromeMimeHandlerViewGuestDelegateCef() = default;
void ChromeMimeHandlerViewGuestDelegateCef::OnGuestAttached() {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
auto owner_browser =
CefBrowserHostBase::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
// Associate guest state information with the owner browser.
owner_browser->browser_info()->MaybeCreateFrame(
web_contents->GetPrimaryMainFrame(), true /* is_guest_view */);
}
void ChromeMimeHandlerViewGuestDelegateCef::OnGuestDetached() {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
auto owner_browser =
CefBrowserHostBase::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
// Disassociate guest state information with the owner browser.
owner_browser->browser_info()->RemoveFrame(
web_contents->GetPrimaryMainFrame());
}
bool ChromeMimeHandlerViewGuestDelegateCef::HandleContextMenu( bool ChromeMimeHandlerViewGuestDelegateCef::HandleContextMenu(
content::RenderFrameHost& render_frame_host, content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) { const content::ContextMenuParams& params) {

View File

@ -7,10 +7,11 @@
#define CEF_LIBCEF_BROWSER_CHROME_EXTENSIONS_CHROME_MIME_HANDLER_VIEW_GUEST_DELEGATE_CEF_H_ #define CEF_LIBCEF_BROWSER_CHROME_EXTENSIONS_CHROME_MIME_HANDLER_VIEW_GUEST_DELEGATE_CEF_H_
#include "chrome/browser/guest_view/mime_handler_view/chrome_mime_handler_view_guest_delegate.h" #include "chrome/browser/guest_view/mime_handler_view/chrome_mime_handler_view_guest_delegate.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
namespace extensions { namespace extensions {
class MimeHandlerViewGuest;
class ChromeMimeHandlerViewGuestDelegateCef class ChromeMimeHandlerViewGuestDelegateCef
: public ChromeMimeHandlerViewGuestDelegate { : public ChromeMimeHandlerViewGuestDelegate {
public: public:
@ -24,13 +25,10 @@ class ChromeMimeHandlerViewGuestDelegateCef
~ChromeMimeHandlerViewGuestDelegateCef() override; ~ChromeMimeHandlerViewGuestDelegateCef() override;
// MimeHandlerViewGuestDelegate methods. // MimeHandlerViewGuestDelegate methods.
void OnGuestAttached() override;
void OnGuestDetached() override;
bool HandleContextMenu(content::RenderFrameHost& render_frame_host, bool HandleContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override; const content::ContextMenuParams& params) override;
private: private:
MimeHandlerViewGuest* guest_; // Owns us.
content::WebContents* owner_web_contents_; content::WebContents* owner_web_contents_;
}; };

View File

@ -209,8 +209,8 @@ void CefExtensionSystem::Init() {
// MimeHandlerViewGuest and CefMimeHandlerViewGuestDelegate in the browser // MimeHandlerViewGuest and CefMimeHandlerViewGuestDelegate in the browser
// process. // process.
// 11.MimeHandlerViewGuest::CreateWebContents creates a new guest WebContents // 11.MimeHandlerViewGuest::CreateWebContents creates a new guest WebContents
// (is_guest_view=true) to host the PDF extension and the PDF resource // to host the PDF extension and the PDF resource stream is retrieved via
// stream is retrieved via MimeHandlerStreamManager::ReleaseStream. // MimeHandlerStreamManager::ReleaseStream.
// 12.MimeHandlerViewGuest::DidAttachToEmbedder calls // 12.MimeHandlerViewGuest::DidAttachToEmbedder calls
// CefMimeHandlerViewGuestDelegate::OnGuestAttached to associate the guest // CefMimeHandlerViewGuestDelegate::OnGuestAttached to associate the guest
// WebContents routing IDs with the owner CefBrowser. MimeHandlerViewGuest // WebContents routing IDs with the owner CefBrowser. MimeHandlerViewGuest

View File

@ -6,9 +6,6 @@
#include "libcef/browser/extensions/mime_handler_view_guest_delegate.h" #include "libcef/browser/extensions/mime_handler_view_guest_delegate.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h" #include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/browser/browser_context.h"
#include "libcef/browser/browser_info.h"
#include "libcef/browser/osr/web_contents_view_osr.h" #include "libcef/browser/osr/web_contents_view_osr.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h" #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
@ -17,7 +14,7 @@ namespace extensions {
CefMimeHandlerViewGuestDelegate::CefMimeHandlerViewGuestDelegate( CefMimeHandlerViewGuestDelegate::CefMimeHandlerViewGuestDelegate(
MimeHandlerViewGuest* guest) MimeHandlerViewGuest* guest)
: guest_(guest), owner_web_contents_(guest_->owner_web_contents()) {} : owner_web_contents_(guest->owner_web_contents()) {}
CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() = default; CefMimeHandlerViewGuestDelegate::~CefMimeHandlerViewGuestDelegate() = default;
@ -37,32 +34,6 @@ void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
} }
} }
void CefMimeHandlerViewGuestDelegate::OnGuestAttached() {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
// Associate guest state information with the owner browser.
owner_browser->browser_info()->MaybeCreateFrame(
web_contents->GetPrimaryMainFrame(), true /* is_guest_view */);
}
void CefMimeHandlerViewGuestDelegate::OnGuestDetached() {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
CefRefPtr<AlloyBrowserHostImpl> owner_browser =
AlloyBrowserHostImpl::GetBrowserForContents(owner_web_contents_);
DCHECK(owner_browser);
// Disassociate guest state information with the owner browser.
owner_browser->browser_info()->RemoveFrame(
web_contents->GetPrimaryMainFrame());
}
bool CefMimeHandlerViewGuestDelegate::HandleContextMenu( bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(
content::RenderFrameHost& render_frame_host, content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) { const content::ContextMenuParams& params) {

View File

@ -6,7 +6,6 @@
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_MIME_HANDLER_VIEW_GUEST_DELEGATE_H_ #ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_MIME_HANDLER_VIEW_GUEST_DELEGATE_H_
#define CEF_LIBCEF_BROWSER_EXTENSIONS_MIME_HANDLER_VIEW_GUEST_DELEGATE_H_ #define CEF_LIBCEF_BROWSER_EXTENSIONS_MIME_HANDLER_VIEW_GUEST_DELEGATE_H_
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h" #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h"
namespace content { namespace content {
@ -15,6 +14,8 @@ struct ContextMenuParams;
namespace extensions { namespace extensions {
class MimeHandlerViewGuest;
class CefMimeHandlerViewGuestDelegate : public MimeHandlerViewGuestDelegate { class CefMimeHandlerViewGuestDelegate : public MimeHandlerViewGuestDelegate {
public: public:
explicit CefMimeHandlerViewGuestDelegate(MimeHandlerViewGuest* guest); explicit CefMimeHandlerViewGuestDelegate(MimeHandlerViewGuest* guest);
@ -29,13 +30,10 @@ class CefMimeHandlerViewGuestDelegate : public MimeHandlerViewGuestDelegate {
// MimeHandlerViewGuestDelegate methods. // MimeHandlerViewGuestDelegate methods.
void OverrideWebContentsCreateParams( void OverrideWebContentsCreateParams(
content::WebContents::CreateParams* params) override; content::WebContents::CreateParams* params) override;
void OnGuestAttached() override;
void OnGuestDetached() override;
bool HandleContextMenu(content::RenderFrameHost& render_frame_host, bool HandleContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override; const content::ContextMenuParams& params) override;
private: private:
MimeHandlerViewGuest* guest_; // Owns us.
content::WebContents* owner_web_contents_; content::WebContents* owner_web_contents_;
}; };

View File

@ -69,9 +69,9 @@ javascript_dialogs::TabModalDialogManager* GetTabModalDialogManager(
return manager; return manager;
} }
// Try the owner WebContents if the dialog originates from a guest view such // Try the owner WebContents if the dialog originates from an excluded view
// as the PDF viewer or Print Preview. // such as the PDF viewer or Print Preview. This is safe to call even if Alloy
// This is safe to call even if Alloy extensions are disabled. // extensions are disabled.
if (auto* owner_contents = if (auto* owner_contents =
extensions::GetOwnerForGuestContents(web_contents)) { extensions::GetOwnerForGuestContents(web_contents)) {
return javascript_dialogs::TabModalDialogManager::FromWebContents( return javascript_dialogs::TabModalDialogManager::FromWebContents(

View File

@ -1336,7 +1336,7 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
if (frame) { if (frame) {
browserPtr = CefBrowserHostBase::GetBrowserForHost(frame); browserPtr = CefBrowserHostBase::GetBrowserForHost(frame);
if (browserPtr) { if (browserPtr) {
// May return nullptr for guest view requests. // May return nullptr for excluded view requests.
framePtr = browserPtr->GetFrameForHost(frame); framePtr = browserPtr->GetFrameForHost(frame);
if (!framePtr) { if (!framePtr) {
framePtr = browserPtr->GetMainFrame(); framePtr = browserPtr->GetMainFrame();
@ -1407,7 +1407,7 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
browserPtr = CefBrowserHostBase::GetBrowserForHost(frame); browserPtr = CefBrowserHostBase::GetBrowserForHost(frame);
if (browserPtr) { if (browserPtr) {
// May return nullptr for guest view requests. // May return nullptr for excluded view requests.
framePtr = browserPtr->GetFrameForHost(frame); framePtr = browserPtr->GetFrameForHost(frame);
if (!framePtr) { if (!framePtr) {
framePtr = browserPtr->GetMainFrame(); framePtr = browserPtr->GetMainFrame();

View File

@ -702,18 +702,14 @@ cef_color_variant_t CefRequestContextImpl::GetChromeColorSchemeVariant() {
void CefRequestContextImpl::OnRenderFrameCreated( void CefRequestContextImpl::OnRenderFrameCreated(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame) {
bool is_guest_view) { browser_context_->OnRenderFrameCreated(this, global_id, is_main_frame);
browser_context_->OnRenderFrameCreated(this, global_id, is_main_frame,
is_guest_view);
} }
void CefRequestContextImpl::OnRenderFrameDeleted( void CefRequestContextImpl::OnRenderFrameDeleted(
const content::GlobalRenderFrameHostId& global_id, const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame) {
bool is_guest_view) { browser_context_->OnRenderFrameDeleted(this, global_id, is_main_frame);
browser_context_->OnRenderFrameDeleted(this, global_id, is_main_frame,
is_guest_view);
} }
// static // static

View File

@ -139,19 +139,15 @@ class CefRequestContextImpl : public CefRequestContext {
const CefRequestContextSettings& settings() const { return config_.settings; } const CefRequestContextSettings& settings() const { return config_.settings; }
// Called from CefBrowserContentsDelegate::RenderFrameCreated or // Called from CefBrowserContentsDelegate::RenderFrameCreated when a render
// CefMimeHandlerViewGuestDelegate::OnGuestAttached when a render frame is // frame is created.
// created.
void OnRenderFrameCreated(const content::GlobalRenderFrameHostId& global_id, void OnRenderFrameCreated(const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame);
bool is_guest_view);
// Called from CefBrowserContentsDelegate::RenderFrameDeleted or // Called from CefBrowserContentsDelegate::RenderFrameDeleted when a render
// CefMimeHandlerViewGuestDelegate::OnGuestDetached when a render frame is // frame is deleted.
// deleted.
void OnRenderFrameDeleted(const content::GlobalRenderFrameHostId& global_id, void OnRenderFrameDeleted(const content::GlobalRenderFrameHostId& global_id,
bool is_main_frame, bool is_main_frame);
bool is_guest_view);
private: private:
friend class CefRequestContext; friend class CefRequestContext;

View File

@ -119,7 +119,7 @@ struct NewBrowserInfo {
bool? is_popup; bool? is_popup;
bool? is_windowless; bool? is_windowless;
bool? print_preview_enabled; bool? print_preview_enabled;
bool is_guest_view; bool is_excluded;
mojo_base.mojom.DictionaryValue? extra_info; mojo_base.mojom.DictionaryValue? extra_info;
}; };

View File

@ -52,13 +52,13 @@ CefRenderManager* g_manager = nullptr;
} // namespace } // namespace
// Placeholder object for guest views. // Placeholder object for excluded views.
class CefGuestView : public blink::WebViewObserver { class CefExcludedView : public blink::WebViewObserver {
public: public:
CefGuestView(CefRenderManager* manager, CefExcludedView(CefRenderManager* manager,
blink::WebView* web_view, blink::WebView* web_view,
std::optional<bool> is_windowless, std::optional<bool> is_windowless,
std::optional<bool> print_preview_enabled) std::optional<bool> print_preview_enabled)
: blink::WebViewObserver(web_view), : blink::WebViewObserver(web_view),
manager_(manager), manager_(manager),
is_windowless_(is_windowless), is_windowless_(is_windowless),
@ -71,7 +71,7 @@ class CefGuestView : public blink::WebViewObserver {
private: private:
// RenderViewObserver methods. // RenderViewObserver methods.
void OnDestruct() override { manager_->OnGuestViewDestroyed(this); } void OnDestruct() override { manager_->OnExcludedViewDestroyed(this); }
CefRenderManager* const manager_; CefRenderManager* const manager_;
const std::optional<bool> is_windowless_; const std::optional<bool> is_windowless_;
@ -306,8 +306,8 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
return nullptr; return nullptr;
} }
// Don't create another browser or guest view object if one already exists for // Don't create another browser or excluded view object if one already exists
// the view. // for the view.
auto browser = GetBrowserForView(web_view); auto browser = GetBrowserForView(web_view);
if (browser) { if (browser) {
if (is_windowless) { if (is_windowless) {
@ -319,13 +319,13 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
return browser; return browser;
} }
auto guest_view = GetGuestViewForView(web_view); auto excluded_view = GetExcludedViewForView(web_view);
if (guest_view) { if (excluded_view) {
if (is_windowless) { if (is_windowless) {
*is_windowless = guest_view->is_windowless(); *is_windowless = excluded_view->is_windowless();
} }
if (print_preview_enabled) { if (print_preview_enabled) {
*print_preview_enabled = guest_view->print_preview_enabled(); *print_preview_enabled = excluded_view->print_preview_enabled();
} }
return nullptr; return nullptr;
} }
@ -346,14 +346,14 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
*print_preview_enabled = params->print_preview_enabled; *print_preview_enabled = params->print_preview_enabled;
} }
if (params->is_guest_view || params->browser_id < 0) { if (params->is_excluded || params->browser_id < 0) {
// Don't create a CefBrowser for a guest view (PDF renderer, PDF extension // Don't create a CefBrowser for excluded content (PDF renderer, PDF
// or print preview dialog), or if the new browser info response has timed // extension or print preview dialog), or if the new browser info response
// out. // has timed out.
guest_views_.insert(std::make_pair( excluded_views_.insert(std::make_pair(
web_view, web_view,
std::make_unique<CefGuestView>(this, web_view, params->is_windowless, std::make_unique<CefExcludedView>(this, web_view, params->is_windowless,
params->print_preview_enabled))); params->print_preview_enabled)));
return nullptr; return nullptr;
} }
@ -398,26 +398,27 @@ void CefRenderManager::OnBrowserDestroyed(CefBrowserImpl* browser) {
DCHECK(false); DCHECK(false);
} }
CefGuestView* CefRenderManager::GetGuestViewForView(blink::WebView* view) { CefExcludedView* CefRenderManager::GetExcludedViewForView(
blink::WebView* view) {
CEF_REQUIRE_RT_RETURN(nullptr); CEF_REQUIRE_RT_RETURN(nullptr);
GuestViewMap::const_iterator it = guest_views_.find(view); ExcludedViewMap::const_iterator it = excluded_views_.find(view);
if (it != guest_views_.end()) { if (it != excluded_views_.end()) {
return it->second.get(); return it->second.get();
} }
return nullptr; return nullptr;
} }
void CefRenderManager::OnGuestViewDestroyed(CefGuestView* guest_view) { void CefRenderManager::OnExcludedViewDestroyed(CefExcludedView* excluded_view) {
GuestViewMap::iterator it = guest_views_.begin(); ExcludedViewMap::iterator it = excluded_views_.begin();
for (; it != guest_views_.end(); ++it) { for (; it != excluded_views_.end(); ++it) {
if (it->second.get() == guest_view) { if (it->second.get() == excluded_view) {
guest_views_.erase(it); excluded_views_.erase(it);
return; return;
} }
} }
// No guest view was found in the map. // No excluded view was found in the map.
DCHECK(false); DCHECK(false);
} }

View File

@ -31,7 +31,7 @@ class BinderMap;
} // namespace mojo } // namespace mojo
class CefBrowserImpl; class CefBrowserImpl;
class CefGuestView; class CefExcludedView;
class CefRenderFrameObserver; class CefRenderFrameObserver;
// Singleton object for managing BrowserImpl instances. Only accessed on the // Singleton object for managing BrowserImpl instances. Only accessed on the
@ -77,7 +77,7 @@ class CefRenderManager : public cef::mojom::RenderManager {
private: private:
friend class CefBrowserImpl; friend class CefBrowserImpl;
friend class CefGuestView; friend class CefExcludedView;
// Binds receivers for the RenderManager interface. // Binds receivers for the RenderManager interface.
void BindReceiver(mojo::PendingReceiver<cef::mojom::RenderManager> receiver); void BindReceiver(mojo::PendingReceiver<cef::mojom::RenderManager> receiver);
@ -91,7 +91,7 @@ class CefRenderManager : public cef::mojom::RenderManager {
void WebKitInitialized(); void WebKitInitialized();
// Maybe create a new browser object, return the existing one, or return // Maybe create a new browser object, return the existing one, or return
// nullptr for guest views. // nullptr for excluded views.
CefRefPtr<CefBrowserImpl> MaybeCreateBrowser( CefRefPtr<CefBrowserImpl> MaybeCreateBrowser(
blink::WebView* web_view, blink::WebView* web_view,
content::RenderFrame* render_frame, content::RenderFrame* render_frame,
@ -102,19 +102,20 @@ class CefRenderManager : public cef::mojom::RenderManager {
// Called from CefBrowserImpl::OnDestruct(). // Called from CefBrowserImpl::OnDestruct().
void OnBrowserDestroyed(CefBrowserImpl* browser); void OnBrowserDestroyed(CefBrowserImpl* browser);
// Returns the guest view associated with the specified RenderView if any. // Returns the excluded view associated with the specified RenderView if any.
CefGuestView* GetGuestViewForView(blink::WebView* view); CefExcludedView* GetExcludedViewForView(blink::WebView* view);
// Called from CefGuestView::OnDestruct(). // Called from CefExcludedView::OnDestruct().
void OnGuestViewDestroyed(CefGuestView* guest_view); void OnExcludedViewDestroyed(CefExcludedView* excluded_view);
// Map of RenderView pointers to CefBrowserImpl references. // Map of RenderView pointers to CefBrowserImpl references.
using BrowserMap = std::map<blink::WebView*, CefRefPtr<CefBrowserImpl>>; using BrowserMap = std::map<blink::WebView*, CefRefPtr<CefBrowserImpl>>;
BrowserMap browsers_; BrowserMap browsers_;
// Map of RenderView poiners to CefGuestView implementations. // Map of RenderView poiners to CefExcludedView implementations.
using GuestViewMap = std::map<blink::WebView*, std::unique_ptr<CefGuestView>>; using ExcludedViewMap =
GuestViewMap guest_views_; std::map<blink::WebView*, std::unique_ptr<CefExcludedView>>;
ExcludedViewMap excluded_views_;
// Cross-origin white list entries that need to be registered with WebKit. // Cross-origin white list entries that need to be registered with WebKit.
std::vector<cef::mojom::CrossOriginWhiteListEntryPtr> std::vector<cef::mojom::CrossOriginWhiteListEntryPtr>

View File

@ -150,8 +150,7 @@ patches = [
'name': 'web_contents_1257_1565', 'name': 'web_contents_1257_1565',
}, },
{ {
# Support custom RenderWidgetHostViewOSR for MimeHandlerViewGuest and # Support custom RenderWidgetHostViewOSR for MimeHandlerViewGuest.
# expose OnGuestAttached/Detached notifications.
# https://github.com/chromiumembedded/cef/issues/1565 # https://github.com/chromiumembedded/cef/issues/1565
# https://github.com/chromiumembedded/cef/issues/2727 # https://github.com/chromiumembedded/cef/issues/2727
'name': 'mime_handler_view_guest_1565_2727', 'name': 'mime_handler_view_guest_1565_2727',

View File

@ -12,7 +12,7 @@ index 285dc38950991..326646bb585da 100644
virtual ~WebContentsView() = default; virtual ~WebContentsView() = default;
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
index bd8b5ddfd8659..0f1e6e2ed9ea2 100644 index bd8b5ddfd8659..767c0ec89ef7a 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc --- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc +++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
@@ -205,6 +205,8 @@ void MimeHandlerViewGuest::CreateWebContents( @@ -205,6 +205,8 @@ void MimeHandlerViewGuest::CreateWebContents(
@ -24,51 +24,8 @@ index bd8b5ddfd8659..0f1e6e2ed9ea2 100644
std::move(callback).Run(std::move(owned_this), std::move(callback).Run(std::move(owned_this),
WebContents::CreateWithSessionStorage( WebContents::CreateWithSessionStorage(
params, owner_web_contents() params, owner_web_contents()
@@ -213,6 +215,10 @@ void MimeHandlerViewGuest::CreateWebContents(
}
void MimeHandlerViewGuest::DidAttachToEmbedder() {
+ is_guest_attached_ = true;
+ if (delegate_)
+ delegate_->OnGuestAttached();
+
DCHECK(stream_->handler_url().SchemeIs(extensions::kExtensionScheme));
GetController().LoadURL(stream_->handler_url(), content::Referrer(),
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
@@ -489,6 +495,14 @@ void MimeHandlerViewGuest::DidFinishNavigation(
}
}
+void MimeHandlerViewGuest::WebContentsDestroyed() {
+ if (is_guest_attached_ && delegate_)
+ delegate_->OnGuestDetached();
+
+ // May delete |this|.
+ GuestView<MimeHandlerViewGuest>::WebContentsDestroyed();
+}
+
void MimeHandlerViewGuest::FuseBeforeUnloadControl(
mojo::PendingReceiver<mime_handler::BeforeUnloadControl> receiver) {
if (!pending_before_unload_control_)
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
index f0b71aba6dfb4..a8b4b6dc27fa7 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
@@ -198,10 +198,12 @@ class MimeHandlerViewGuest
void ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) final;
void DidFinishNavigation(content::NavigationHandle* navigation_handle) final;
+ void WebContentsDestroyed() override;
std::unique_ptr<MimeHandlerViewGuestDelegate> delegate_;
std::unique_ptr<StreamContainer> stream_;
+ bool is_guest_attached_ = false;
bool is_guest_fullscreen_ = false;
bool is_embedder_fullscreen_ = false;
bool plugin_can_save_ = false;
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
index 7f59e7925084e..777b8a3cf103a 100644 index 7f59e7925084e..e3e69dc6d3a43 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h --- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h +++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
@@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
@ -80,17 +37,13 @@ index 7f59e7925084e..777b8a3cf103a 100644
namespace content { namespace content {
class RenderFrameHost; class RenderFrameHost;
struct ContextMenuParams; struct ContextMenuParams;
@@ -25,6 +27,14 @@ class MimeHandlerViewGuestDelegate { @@ -25,6 +27,10 @@ class MimeHandlerViewGuestDelegate {
virtual ~MimeHandlerViewGuestDelegate() {} virtual ~MimeHandlerViewGuestDelegate() {}
+ // Provides an opportunity to supply a custom view implementation. + // Provides an opportunity to supply a custom view implementation.
+ virtual void OverrideWebContentsCreateParams( + virtual void OverrideWebContentsCreateParams(
+ content::WebContents::CreateParams* params) {} + content::WebContents::CreateParams* params) {}
+
+ // Called when a guest is attached or detached.
+ virtual void OnGuestAttached() {}
+ virtual void OnGuestDetached() {}
+ +
// Handles context menu, or returns false if unhandled. // Handles context menu, or returns false if unhandled.
// //