Skip to content

Commit

Permalink
Add DocumentInterfaceBroker mojom interface
Browse files Browse the repository at this point in the history
This change adds a new mojom interface DocumentInterfaceBroker and its
implementation in RenderFrameHostImpl. RenderFrameImpl and
LocalFrameClientImpl now store content and blink versions of
pointers to this new interface and add methods that make it available
to other classes.

Bug: 718652
Change-Id: Iad2030a51e7ee2ca6443723f3758d9e53d1f9e9a
Reviewed-on: https://chromium-review.googlesource.com/c/1285324
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#620490}
  • Loading branch information
Oksana Zhuravlova authored and Commit Bot committed Jan 7, 2019
1 parent cd7ff35 commit 8b88e57
Show file tree
Hide file tree
Showing 73 changed files with 1,317 additions and 305 deletions.
7 changes: 5 additions & 2 deletions components/plugins/renderer/webview_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "content/public/renderer/render_view.h"
#include "gin/converter.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/blink/public/mojom/frame/document_interface_broker.mojom.h"
#include "third_party/blink/public/platform/web_coalesced_input_event.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_url_response.h"
Expand Down Expand Up @@ -263,8 +264,10 @@ WebViewPlugin::WebViewHelper::WebViewHelper(WebViewPlugin* plugin,
// ApplyWebPreferences before making a WebLocalFrame so that the frame sees a
// consistent view of our preferences.
content::RenderView::ApplyWebPreferences(preferences, web_view_);
WebLocalFrame* web_frame =
WebLocalFrame::CreateMainFrame(web_view_, this, nullptr, nullptr);
blink::mojom::DocumentInterfaceBrokerPtrInfo document_interface_broker;
WebLocalFrame* web_frame = WebLocalFrame::CreateMainFrame(
web_view_, this, nullptr,
mojo::MakeRequest(&document_interface_broker).PassMessagePipe(), nullptr);
WebFrameWidget::CreateForMainFrame(this, web_frame);
}

Expand Down
11 changes: 8 additions & 3 deletions components/printing/renderer/print_render_frame_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "printing/units.h"
#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
#include "third_party/blink/public/common/frame/sandbox_flags.h"
#include "third_party/blink/public/mojom/frame/document_interface_broker.mojom.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_data.h"
#include "third_party/blink/public/platform/web_double_size.h"
Expand Down Expand Up @@ -684,8 +685,10 @@ void PrintRenderFrameHelper::PrintHeaderAndFooter(
};

HeaderAndFooterClient frame_client;
blink::mojom::DocumentInterfaceBrokerPtrInfo document_interface_broker;
blink::WebLocalFrame* frame = blink::WebLocalFrame::CreateMainFrame(
web_view, &frame_client, nullptr, nullptr);
web_view, &frame_client, nullptr,
mojo::MakeRequest(&document_interface_broker).PassMessagePipe(), nullptr);

blink::WebWidgetClient web_widget_client;
blink::WebFrameWidget::CreateForMainFrame(&web_widget_client, frame);
Expand Down Expand Up @@ -920,8 +923,10 @@ void PrepareFrameAndViewForPrint::CopySelection(
/*opener=*/nullptr);
owns_web_view_ = true;
content::RenderView::ApplyWebPreferences(prefs, web_view);
blink::WebLocalFrame* main_frame =
blink::WebLocalFrame::CreateMainFrame(web_view, this, nullptr, nullptr);
blink::mojom::DocumentInterfaceBrokerPtrInfo document_interface_broker;
blink::WebLocalFrame* main_frame = blink::WebLocalFrame::CreateMainFrame(
web_view, this, nullptr,
mojo::MakeRequest(&document_interface_broker).PassMessagePipe(), nullptr);
frame_.Reset(main_frame);
blink::WebFrameWidget::CreateForMainFrame(this, main_frame);
node_to_print_.Reset();
Expand Down
1 change: 1 addition & 0 deletions content/browser/bad_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ enum BadMessageReason {
RFH_CHILD_FRAME_NEEDS_OWNER_ELEMENT_TYPE = 208,
OBSOLETE_RFH_INVALID_WEB_REPORTING_CRASH_ID = 209,
RFH_DETACH_MAIN_FRAME = 210,
RFH_DOCUMENT_INTERFACE_BROKER_MISSING = 211,

// Please add new elements here. The naming convention is abbreviated class
// name (e.g. RenderFrameHost becomes RFH) plus a unique description of the
Expand Down
10 changes: 10 additions & 0 deletions content/browser/frame_host/frame_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ FrameTreeNode* FrameTree::AddFrame(
int process_id,
int new_routing_id,
service_manager::mojom::InterfaceProviderRequest interface_provider_request,
blink::mojom::DocumentInterfaceBrokerRequest
document_interface_broker_content_request,
blink::mojom::DocumentInterfaceBrokerRequest
document_interface_broker_blink_request,
blink::WebTreeScopeType scope,
const std::string& frame_name,
const std::string& frame_unique_name,
Expand Down Expand Up @@ -217,6 +221,12 @@ FrameTreeNode* FrameTree::AddFrame(
added_node->current_frame_host()->BindInterfaceProviderRequest(
std::move(interface_provider_request));

DCHECK(document_interface_broker_content_request.is_pending());
DCHECK(document_interface_broker_blink_request.is_pending());
added_node->current_frame_host()->BindDocumentInterfaceBrokerRequest(
std::move(document_interface_broker_content_request),
std::move(document_interface_broker_blink_request));

// The last committed NavigationEntry may have a FrameNavigationEntry with the
// same |frame_unique_name|, since we don't remove FrameNavigationEntries if
// their frames are deleted. If there is a stale one, remove it to avoid
Expand Down
4 changes: 4 additions & 0 deletions content/browser/frame_host/frame_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ class CONTENT_EXPORT FrameTree {
int new_routing_id,
service_manager::mojom::InterfaceProviderRequest
interface_provider_request,
blink::mojom::DocumentInterfaceBrokerRequest
document_interface_broker_content_request,
blink::mojom::DocumentInterfaceBrokerRequest
document_interface_broker_blink_request,
blink::WebTreeScopeType scope,
const std::string& frame_name,
const std::string& frame_unique_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class FrameTreeNodeBlameContextTest : public RenderViewHostImplTestHarness {
tree()->AddFrame(
node, process_id(), child_id,
TestRenderFrameHost::CreateStubInterfaceProviderRequest(),
TestRenderFrameHost::CreateStubDocumentInterfaceBrokerRequest(),
TestRenderFrameHost::CreateStubDocumentInterfaceBrokerRequest(),
blink::WebTreeScopeType::kDocument, std::string(),
base::StringPrintf("uniqueName%d", child_id), false,
base::UnguessableToken::Create(), blink::FramePolicy(),
Expand Down
Loading

0 comments on commit 8b88e57

Please sign in to comment.