diff --git a/browser/native_window.cc b/browser/native_window.cc index 18954736ad..34bdefd6ac 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -298,6 +298,8 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(NativeWindow, message) IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage) IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message_Sync, OnRendererMessageSync) + IPC_MESSAGE_HANDLER(AtomViewHostMsg_UpdateDraggableRegions, + UpdateDraggableRegions) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() diff --git a/browser/native_window.h b/browser/native_window.h index b41fd4bdf3..cde0ce1f49 100644 --- a/browser/native_window.h +++ b/browser/native_window.h @@ -38,6 +38,7 @@ class Size; namespace atom { class AtomJavaScriptDialogManager; +struct DraggableRegion; class NativeWindow : public brightray::DefaultWebContentsDelegate, public content::WebContentsObserver, @@ -125,6 +126,10 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, void NotifyWindowClosed(); void NotifyWindowBlur(); + // Called when the window needs to update its draggable region. + virtual void UpdateDraggableRegions( + const std::vector& regions) = 0; + // Implementations of content::WebContentsDelegate. virtual void WebContentsCreated(content::WebContents* source_contents, int64 source_frame_id, diff --git a/browser/native_window_mac.h b/browser/native_window_mac.h index d268473545..a35e53d329 100644 --- a/browser/native_window_mac.h +++ b/browser/native_window_mac.h @@ -57,6 +57,9 @@ class NativeWindowMac : public NativeWindow { void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); } protected: + virtual void UpdateDraggableRegions( + const std::vector& regions) OVERRIDE; + // Implementations of content::WebContentsDelegate. virtual void HandleKeyboardEvent( content::WebContents*, diff --git a/browser/native_window_mac.mm b/browser/native_window_mac.mm index 194b38b7d3..acddd0c83b 100644 --- a/browser/native_window_mac.mm +++ b/browser/native_window_mac.mm @@ -324,6 +324,10 @@ gfx::NativeWindow NativeWindowMac::GetNativeWindow() { return window(); } +void NativeWindowMac::UpdateDraggableRegions( + const std::vector& regions) { +} + void NativeWindowMac::HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) { diff --git a/browser/native_window_win.cc b/browser/native_window_win.cc index 0a84afd4d7..a3589158ab 100644 --- a/browser/native_window_win.cc +++ b/browser/native_window_win.cc @@ -221,6 +221,10 @@ gfx::NativeWindow NativeWindowWin::GetNativeWindow() { return window_->GetNativeView(); } +void NativeWindowWin::UpdateDraggableRegions( + const std::vector& regions) { +} + void NativeWindowWin::HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) { diff --git a/browser/native_window_win.h b/browser/native_window_win.h index 3d09615e59..19d9a55529 100644 --- a/browser/native_window_win.h +++ b/browser/native_window_win.h @@ -61,6 +61,9 @@ class NativeWindowWin : public NativeWindow, virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; protected: + virtual void UpdateDraggableRegions( + const std::vector& regions) OVERRIDE; + // Overridden from content::WebContentsDelegate: virtual void HandleKeyboardEvent( content::WebContents*, diff --git a/renderer/atom_render_view_observer.cc b/renderer/atom_render_view_observer.cc index 0c2c611d03..6a394e4473 100644 --- a/renderer/atom_render_view_observer.cc +++ b/renderer/atom_render_view_observer.cc @@ -12,6 +12,8 @@ #include "ipc/ipc_message_macros.h" #include "renderer/api/atom_renderer_bindings.h" #include "renderer/atom_renderer_client.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDraggableRegion.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "v8/include/v8.h" @@ -76,6 +78,19 @@ void AtomRenderViewObserver::FrameWillClose(WebFrame* frame) { vec.erase(std::remove(vec.begin(), vec.end(), frame), vec.end()); } +void AtomRenderViewObserver::DraggableRegionsChanged(WebKit::WebFrame* frame) { + WebKit::WebVector webregions = + frame->document().draggableRegions(); + std::vector regions; + for (size_t i = 0; i < webregions.size(); ++i) { + DraggableRegion region; + region.bounds = webregions[i].bounds; + region.draggable = webregions[i].draggable; + regions.push_back(region); + } + Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions)); +} + bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message) diff --git a/renderer/atom_render_view_observer.h b/renderer/atom_render_view_observer.h index 55f1cdfb65..fd984d0124 100644 --- a/renderer/atom_render_view_observer.h +++ b/renderer/atom_render_view_observer.h @@ -32,6 +32,7 @@ class AtomRenderViewObserver : content::RenderViewObserver { private: // content::RenderViewObserver implementation. + virtual void DraggableRegionsChanged(WebKit::WebFrame* frame) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; void OnBrowserMessage(const std::string& channel,