mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for MimeHandlerViewInCrossProcessFrame (fixes issue #2727)
The PDF loading documentation in extension_system.cc has be updated to describe the new code paths. To support delivery of input events to the mime handler renderer process it is now necessary to route events via the correct RWHV interface. For Aura-based platforms (Windows/Linux) this means RWHVAura::On*Event and for macOS this means RWHVMac::RouteOrProcess*Event. Since Aura uses UI event types these have become the source of truth on Aura-based platforms with conversion to Web event types when needed (primarily for OSR). This change also adds a timeout for CefProcessHostMsg_GetNewBrowserInfo to avoid a hung renderer process if the guest WebContents route is not registered via CefMimeHandlerViewGuestDelegate::OnGuestDetached as expected prior to CefBrowserInfoManager::OnGetNewBrowserInfo being called. This timeout can be disabled for testing purposes by passing the `--disable-new-browser-info-timeout` command-line flag. The `--disable-features=MimeHandlerViewInCrossProcessFrame` command-line flag can be used for a limited time to restore the previous implementation based on BrowserPlugin. That implementation will be deleted starting with the 3897 branch update. Known issues: - ExecuteJavaScript calls on the frame hosting the PDF extension will not be routed to the mime handler renderer process. - The PDF extension will not load successfully if blocked by ChromePluginPlaceholder and then manually continued via the "Run this plugin" context menu option (see https://crbug.com/533069#c41).
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "third_party/blink/renderer/core/dom/node.h"
|
||||
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
|
||||
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
|
||||
#include "third_party/blink/renderer/core/frame/frame_owner.h"
|
||||
#include "third_party/blink/renderer/core/frame/local_frame.h"
|
||||
#include "third_party/blink/renderer/core/frame/settings.h"
|
||||
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
|
||||
@@ -245,4 +246,9 @@ bool ResponseWasCached(const blink::WebURLResponse& response) {
|
||||
return response.ToResourceResponse().WasCached();
|
||||
}
|
||||
|
||||
bool HasPluginFrameOwner(blink::WebLocalFrame* frame) {
|
||||
blink::Frame* core_frame = blink::WebFrame::ToCoreFrame(*frame);
|
||||
return core_frame->Owner() && core_frame->Owner()->IsPlugin();
|
||||
}
|
||||
|
||||
} // namespace blink_glue
|
||||
|
@@ -87,6 +87,9 @@ class BLINK_EXPORT CefScriptForbiddenScope final {
|
||||
|
||||
BLINK_EXPORT bool ResponseWasCached(const blink::WebURLResponse& response);
|
||||
|
||||
// Returns true if the frame owner is a plugin.
|
||||
BLINK_EXPORT bool HasPluginFrameOwner(blink::WebLocalFrame* frame);
|
||||
|
||||
} // namespace blink_glue
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_BLINK_GLUE_H_
|
||||
|
@@ -81,6 +81,7 @@
|
||||
#include "content/public/renderer/render_view_visitor.h"
|
||||
#include "content/renderer/render_widget.h"
|
||||
#include "extensions/common/switches.h"
|
||||
#include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container_manager.h"
|
||||
#include "extensions/renderer/renderer_extension_registry.h"
|
||||
#include "ipc/ipc_sync_channel.h"
|
||||
#include "media/base/media.h"
|
||||
@@ -90,6 +91,7 @@
|
||||
#include "services/service_manager/public/cpp/connector.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
||||
#include "third_party/blink/public/platform/platform.h"
|
||||
#include "third_party/blink/public/platform/scheduler/web_renderer_process_type.h"
|
||||
#include "third_party/blink/public/platform/url_conversion.h"
|
||||
@@ -480,9 +482,16 @@ void CefContentRendererClient::RenderFrameCreated(
|
||||
|
||||
new PepperHelper(render_frame);
|
||||
|
||||
if (extensions::ExtensionsEnabled())
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
extensions_renderer_client_->RenderFrameCreated(render_frame, registry);
|
||||
|
||||
blink::AssociatedInterfaceRegistry* associated_interfaces =
|
||||
render_frame_observer->associated_interfaces();
|
||||
associated_interfaces->AddInterface(base::BindRepeating(
|
||||
&extensions::MimeHandlerViewContainerManager::BindReceiver,
|
||||
render_frame->GetRoutingID()));
|
||||
}
|
||||
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
|
||||
@@ -747,8 +756,9 @@ CefRefPtr<CefBrowserImpl> CefContentRendererClient::MaybeCreateBrowser(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (params.is_guest_view) {
|
||||
// Don't create a CefBrowser for guest views.
|
||||
if (params.is_guest_view || params.browser_id < 0) {
|
||||
// Don't create a CefBrowser for guest views, or if the new browser info
|
||||
// response has timed out.
|
||||
guest_views_.insert(std::make_pair(
|
||||
render_view,
|
||||
std::make_unique<CefGuestView>(render_view, params.is_windowless)));
|
||||
|
@@ -315,6 +315,11 @@ bool CefFrameImpl::OnMessageReceived(const IPC::Message& message) {
|
||||
}
|
||||
|
||||
void CefFrameImpl::OnDidFinishLoad() {
|
||||
// Ignore notifications from the embedded frame hosting a mime-type plugin.
|
||||
// We'll eventually receive a notification from the owner frame.
|
||||
if (blink_glue::HasPluginFrameOwner(frame_))
|
||||
return;
|
||||
|
||||
blink::WebDocumentLoader* dl = frame_->GetDocumentLoader();
|
||||
const int http_status_code = dl->GetResponse().HttpStatusCode();
|
||||
Send(new CefHostMsg_DidFinishLoad(MSG_ROUTING_NONE, dl->GetUrl(),
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
||||
#include "third_party/blink/public/web/blink.h"
|
||||
#include "third_party/blink/public/web/web_document.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
@@ -42,6 +44,12 @@ void CefRenderFrameObserver::OnInterfaceRequestForFrame(
|
||||
registry_.TryBindInterface(interface_name, interface_pipe);
|
||||
}
|
||||
|
||||
bool CefRenderFrameObserver::OnAssociatedInterfaceRequestForFrame(
|
||||
const std::string& interface_name,
|
||||
mojo::ScopedInterfaceEndpointHandle* handle) {
|
||||
return associated_interfaces_.TryBindInterface(interface_name, handle);
|
||||
}
|
||||
|
||||
void CefRenderFrameObserver::DidCommitProvisionalLoad(
|
||||
bool is_same_document_navigation,
|
||||
ui::PageTransition transition) {
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "content/public/renderer/render_frame_observer.h"
|
||||
#include "services/service_manager/public/cpp/binder_registry.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
||||
|
||||
namespace content {
|
||||
class RenderFrame;
|
||||
@@ -24,6 +25,9 @@ class CefRenderFrameObserver : public content::RenderFrameObserver {
|
||||
void OnInterfaceRequestForFrame(
|
||||
const std::string& interface_name,
|
||||
mojo::ScopedMessagePipeHandle* interface_pipe) override;
|
||||
bool OnAssociatedInterfaceRequestForFrame(
|
||||
const std::string& interface_name,
|
||||
mojo::ScopedInterfaceEndpointHandle* handle) override;
|
||||
void DidCommitProvisionalLoad(bool is_same_document_navigation,
|
||||
ui::PageTransition transition) override;
|
||||
void DidFailProvisionalLoad() override;
|
||||
@@ -40,6 +44,9 @@ class CefRenderFrameObserver : public content::RenderFrameObserver {
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
|
||||
service_manager::BinderRegistry* registry() { return ®istry_; }
|
||||
blink::AssociatedInterfaceRegistry* associated_interfaces() {
|
||||
return &associated_interfaces_;
|
||||
}
|
||||
|
||||
void AttachFrame(CefFrameImpl* frame);
|
||||
|
||||
@@ -48,6 +55,7 @@ class CefRenderFrameObserver : public content::RenderFrameObserver {
|
||||
void OnLoadError();
|
||||
|
||||
service_manager::BinderRegistry registry_;
|
||||
blink::AssociatedInterfaceRegistry associated_interfaces_;
|
||||
CefFrameImpl* frame_ = nullptr;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefRenderFrameObserver);
|
||||
|
Reference in New Issue
Block a user