Send and receive the AtomViewHostMsg_UpdateDraggableRegions message.

This commit is contained in:
Cheng Zhao 2013-09-05 20:06:54 +08:00
Родитель 40273cf37d
Коммит 4223867dbc
8 изменённых файлов: 37 добавлений и 0 удалений

Просмотреть файл

@ -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()

Просмотреть файл

@ -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<DraggableRegion>& regions) = 0;
// Implementations of content::WebContentsDelegate.
virtual void WebContentsCreated(content::WebContents* source_contents,
int64 source_frame_id,

Просмотреть файл

@ -57,6 +57,9 @@ class NativeWindowMac : public NativeWindow {
void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); }
protected:
virtual void UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) OVERRIDE;
// Implementations of content::WebContentsDelegate.
virtual void HandleKeyboardEvent(
content::WebContents*,

Просмотреть файл

@ -324,6 +324,10 @@ gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
return window();
}
void NativeWindowMac::UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) {
}
void NativeWindowMac::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {

Просмотреть файл

@ -221,6 +221,10 @@ gfx::NativeWindow NativeWindowWin::GetNativeWindow() {
return window_->GetNativeView();
}
void NativeWindowWin::UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) {
}
void NativeWindowWin::HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {

Просмотреть файл

@ -61,6 +61,9 @@ class NativeWindowWin : public NativeWindow,
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
protected:
virtual void UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) OVERRIDE;
// Overridden from content::WebContentsDelegate:
virtual void HandleKeyboardEvent(
content::WebContents*,

Просмотреть файл

@ -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<WebKit::WebDraggableRegion> webregions =
frame->document().draggableRegions();
std::vector<DraggableRegion> 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)

Просмотреть файл

@ -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,