Commit 7dadbe81 authored by Darwin Huang's avatar Darwin Huang Committed by Commit Bot

Clipboard: Use GlobalFrameRoutingId for mojo host.

This simplifies the interface a bit, and allows us to avoid any
potential issues with argument ordering in RenderFrameHostImpl::FromID,
or otherwise.

Change-Id: I0c9d9fe921a5b0ca8765e9d7c8ae6196dc329e5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419663Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Darwin Huang <huangdarwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813028}
parent 102f1058
......@@ -88,13 +88,16 @@ ClipboardHostImpl::ClipboardHostImpl(
clipboard_(ui::Clipboard::GetForCurrentThread()) {
// |render_frame_host| may be null in unit tests.
if (render_frame_host) {
render_frame_routing_id_ = render_frame_host->GetRoutingID();
render_process_id_ = render_frame_host->GetProcess()->GetID();
render_frame_routing_id_ =
GlobalFrameRoutingId(render_frame_host->GetProcess()->GetID(),
render_frame_host->GetRoutingID());
clipboard_writer_ = std::make_unique<ui::ScopedClipboardWriter>(
ui::ClipboardBuffer::kCopyPaste,
std::make_unique<ui::ClipboardDataEndpoint>(
render_frame_host->GetLastCommittedOrigin()));
} else {
render_frame_routing_id_ = GlobalFrameRoutingId(
ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE);
clipboard_writer_ = std::make_unique<ui::ScopedClipboardWriter>(
ui::ClipboardBuffer::kCopyPaste);
}
......@@ -384,7 +387,7 @@ void ClipboardHostImpl::StartIsPasteAllowedRequest(
std::string data) {
// May not have a RenderFrameHost in tests.
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(render_process_id_, render_frame_routing_id_);
RenderFrameHostImpl::FromID(render_frame_routing_id_);
if (render_frame_host) {
render_frame_host->IsClipboardPasteAllowed(
data_type, data,
......@@ -416,7 +419,7 @@ void ClipboardHostImpl::CleanupObsoleteRequests() {
std::unique_ptr<ui::ClipboardDataEndpoint>
ClipboardHostImpl::CreateDataEndpoint() {
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(render_process_id_, render_frame_routing_id_);
RenderFrameHostImpl::FromID(render_frame_routing_id_);
if (render_frame_host) {
return std::make_unique<ui::ClipboardDataEndpoint>(
render_frame_host->GetLastCommittedOrigin());
......
......@@ -182,8 +182,7 @@ class CONTENT_EXPORT ClipboardHostImpl : public blink::mojom::ClipboardHost {
mojo::Receiver<blink::mojom::ClipboardHost> receiver_;
ui::Clipboard* const clipboard_; // Not owned
int render_frame_routing_id_ = MSG_ROUTING_NONE;
int render_process_id_ = ChildProcessHost::kInvalidUniqueID;
GlobalFrameRoutingId render_frame_routing_id_;
std::unique_ptr<ui::ScopedClipboardWriter> clipboard_writer_;
// Outstanding is allowed requests per clipboard contents. Maps a clipboard
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment