Skip to content

Commit

Permalink
Remove GuestViewHostMsg_AttachGuest
Browse files Browse the repository at this point in the history
GuestViewAttachRequest class is never constructed. This means that
GuestViewHostMsg_AttachGuest can be removed as well.

BUG=1143268

Change-Id: I5631a5aacb68a426ec1f5d101aea28cd180b86ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587373
Reviewed-by: Lucas Gadani <lfg@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836836}
  • Loading branch information
dtapuska authored and Chromium LUCI CQ committed Dec 14, 2020
1 parent bd43598 commit f16e07c
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 106 deletions.
21 changes: 0 additions & 21 deletions components/guest_view/browser/guest_view_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void GuestViewMessageFilter::OnDestruct() const {
bool GuestViewMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(GuestViewMessageFilter, message)
IPC_MESSAGE_HANDLER(GuestViewHostMsg_AttachGuest, OnAttachGuest)
IPC_MESSAGE_HANDLER(GuestViewHostMsg_AttachToEmbedderFrame,
OnAttachToEmbedderFrame)
IPC_MESSAGE_HANDLER(GuestViewHostMsg_ViewCreated, OnViewCreated)
Expand Down Expand Up @@ -139,26 +138,6 @@ void GuestViewMessageFilter::OnViewGarbageCollected(int view_instance_id) {
view_instance_id);
}

void GuestViewMessageFilter::OnAttachGuest(
int element_instance_id,
int guest_instance_id,
const base::DictionaryValue& params) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!browser_context_)
return;

// We should have a GuestViewManager at this point. If we don't then the
// embedder is misbehaving.
auto* manager = GetGuestViewManagerOrKill();
if (!manager)
return;

manager->AttachGuest(render_process_id_,
element_instance_id,
guest_instance_id,
params);
}

void GuestViewMessageFilter::OnAttachToEmbedderFrame(
int embedder_local_render_frame_id,
int element_instance_id,
Expand Down
3 changes: 0 additions & 3 deletions components/guest_view/browser/guest_view_message_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ class GuestViewMessageFilter : public content::BrowserMessageFilter {
friend class base::DeleteHelper<GuestViewMessageFilter>;

// Message handlers on the UI thread.
void OnAttachGuest(int element_instance_id,
int guest_instance_id,
const base::DictionaryValue& attach_params);
void OnAttachToEmbedderFrame(int embedder_local_render_frame_id,
int element_instance_id,
int guest_instance_id,
Expand Down
7 changes: 0 additions & 7 deletions components/guest_view/common/guest_view_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ IPC_MESSAGE_CONTROL2(GuestViewMsg_GuestAttached,

// Messages sent from the renderer to the browser.

// Sent by the renderer to set initialization parameters of a Browser Plugin
// that is identified by |element_instance_id|.
IPC_MESSAGE_CONTROL3(GuestViewHostMsg_AttachGuest,
int /* element_instance_id */,
int /* guest_instance_id */,
base::DictionaryValue /* attach_params */)

// We have a RenderFrame with routing id of |embedder_local_frame_routing_id|.
// We want this local frame to be replaced with a remote frame that points
// to a GuestView. This message will attach the local frame to the guest.
Expand Down
52 changes: 0 additions & 52 deletions components/guest_view/renderer/guest_view_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,56 +49,4 @@ void GuestViewRequest::ExecuteCallbackIfAvailable(
.FromMaybe(v8::Local<v8::Value>());
}

GuestViewAttachRequest::GuestViewAttachRequest(
GuestViewContainer* container,
int guest_instance_id,
std::unique_ptr<base::DictionaryValue> params,
v8::Local<v8::Function> callback,
v8::Isolate* isolate)
: GuestViewRequest(container, callback, isolate),
guest_instance_id_(guest_instance_id),
params_(std::move(params)) {}

GuestViewAttachRequest::~GuestViewAttachRequest() {
}

void GuestViewAttachRequest::PerformRequest() {
if (!container()->render_frame())
return;

// TODO(wjmaclean): Can this next chunk be removed?
// Step 1, send the attach params to guest_view/.
container()->render_frame()->Send(
new GuestViewHostMsg_AttachGuest(container()->element_instance_id(),
guest_instance_id_,
*params_));
}

void GuestViewAttachRequest::HandleResponse(const IPC::Message& message) {
// TODO(fsamuel): Rename this message so that it's apparent that this is a
// response to GuestViewHostMsg_AttachGuest. Perhaps
// GuestViewMsg_AttachGuest_ACK?
GuestViewMsg_GuestAttached::Param param;
if (!GuestViewMsg_GuestAttached::Read(&message, &param))
return;

content::RenderView* guest_proxy_render_view =
content::RenderView::FromRoutingID(std::get<1>(param));
// TODO(fsamuel): Should we be reporting an error to JavaScript or DCHECKing?
if (!guest_proxy_render_view)
return;

v8::HandleScope handle_scope(isolate());
blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->MainFrame();
v8::Local<v8::Value> window = frame->GlobalProxy();

const int argc = 1;
std::unique_ptr<v8::Local<v8::Value>[]> argv(new v8::Local<v8::Value>[argc]);
argv[0] = window;

// Call the AttachGuest API's callback with the guest proxy as the first
// parameter.
ExecuteCallbackIfAvailable(argc, std::move(argv));
}

} // namespace guest_view
23 changes: 0 additions & 23 deletions components/guest_view/renderer/guest_view_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,6 @@ class GuestViewRequest {
DISALLOW_COPY_AND_ASSIGN(GuestViewRequest);
};

// This class represents an AttachGuest request from Javascript. It includes
// the input parameters and the callback function. The Attach operation may
// not execute immediately, if the container is not ready or if there are
// other GuestViewRequests in flight.
class GuestViewAttachRequest : public GuestViewRequest {
public:
GuestViewAttachRequest(GuestViewContainer* container,
int guest_instance_id,
std::unique_ptr<base::DictionaryValue> params,
v8::Local<v8::Function> callback,
v8::Isolate* isolate);
~GuestViewAttachRequest() override;

void PerformRequest() override;
void HandleResponse(const IPC::Message& message) override;

private:
const int guest_instance_id_;
std::unique_ptr<base::DictionaryValue> params_;

DISALLOW_COPY_AND_ASSIGN(GuestViewAttachRequest);
};

} // namespace guest_view

#endif // COMPONENTS_GUEST_VIEW_RENDERER_GUEST_VIEW_CONTAINER_H_

0 comments on commit f16e07c

Please sign in to comment.