From 99e26b83189038d07fb58d361752935458cbb722 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 1 Jan 2018 22:54:02 +0530 Subject: [PATCH] fix: draggable region ipc should be frame based --- atom/browser/native_window.cc | 8 +++++--- atom/browser/native_window.h | 4 +++- atom/browser/native_window_mac.h | 1 + atom/browser/native_window_mac.mm | 3 ++- atom/common/api/api_messages.h | 2 +- atom/renderer/atom_render_frame_observer.cc | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 1b4111eabce9..34778fb64347 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -688,10 +688,11 @@ void NativeWindow::DidFirstVisuallyNonEmptyPaint() { base::Bind(&NativeWindow::NotifyReadyToShow, GetWeakPtr())); } -bool NativeWindow::OnMessageReceived(const IPC::Message& message) { +bool NativeWindow::OnMessageReceived(const IPC::Message& message, + content::RenderFrameHost* rfh) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP(NativeWindow, message) - IPC_MESSAGE_HANDLER(AtomViewHostMsg_UpdateDraggableRegions, + IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, rfh) + IPC_MESSAGE_HANDLER(AtomFrameHostMsg_UpdateDraggableRegions, UpdateDraggableRegions) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -700,6 +701,7 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) { } void NativeWindow::UpdateDraggableRegions( + content::RenderFrameHost* rfh, const std::vector& regions) { // Draggable region is not supported for non-frameless window. if (has_frame_) diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 09780be079f1..e63d0e3be91d 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -313,13 +313,15 @@ class NativeWindow : public base::SupportsUserData, // Called when the window needs to update its draggable region. virtual void UpdateDraggableRegions( + content::RenderFrameHost* rfh, const std::vector& regions); // content::WebContentsObserver: void RenderViewCreated(content::RenderViewHost* render_view_host) override; void BeforeUnloadDialogCancelled() override; void DidFirstVisuallyNonEmptyPaint() override; - bool OnMessageReceived(const IPC::Message& message) override; + bool OnMessageReceived(const IPC::Message& message, + content::RenderFrameHost* rfh) override; private: // Schedule a notification unresponsive event. diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 24d9a0aab878..b52b5fe67b1b 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -159,6 +159,7 @@ class NativeWindowMac : public NativeWindow, gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const; gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const; void UpdateDraggableRegions( + content::RenderFrameHost* rfh, const std::vector& regions) override; void InternalSetParentWindow(NativeWindow* parent, bool attach); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 59301fc7a982..7b01a7929749 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -1814,8 +1814,9 @@ gfx::Rect NativeWindowMac::WindowBoundsToContentBounds( } void NativeWindowMac::UpdateDraggableRegions( + content::RenderFrameHost* rfh, const std::vector& regions) { - NativeWindow::UpdateDraggableRegions(regions); + NativeWindow::UpdateDraggableRegions(rfh, regions); draggable_regions_ = regions; UpdateDraggableRegionViews(regions); } diff --git a/atom/common/api/api_messages.h b/atom/common/api/api_messages.h index cb8f19090333..ad8c1d49bbc0 100644 --- a/atom/common/api/api_messages.h +++ b/atom/common/api/api_messages.h @@ -49,7 +49,7 @@ IPC_MESSAGE_ROUTED1(AtomAutofillFrameMsg_AcceptSuggestion, base::string16 /* suggestion */) // Sent by the renderer when the draggable regions are updated. -IPC_MESSAGE_ROUTED1(AtomViewHostMsg_UpdateDraggableRegions, +IPC_MESSAGE_ROUTED1(AtomFrameHostMsg_UpdateDraggableRegions, std::vector /* regions */) // Update renderer process preferences. diff --git a/atom/renderer/atom_render_frame_observer.cc b/atom/renderer/atom_render_frame_observer.cc index d64588a17c80..1971a26c1c5d 100644 --- a/atom/renderer/atom_render_frame_observer.cc +++ b/atom/renderer/atom_render_frame_observer.cc @@ -52,7 +52,7 @@ void AtomRenderFrameObserver::DraggableRegionsChanged() { region.draggable = webregion.draggable; regions.push_back(region); } - Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions)); + Send(new AtomFrameHostMsg_UpdateDraggableRegions(routing_id(), regions)); } void AtomRenderFrameObserver::WillReleaseScriptContext(