From: Cheng Zhao Date: Wed, 15 May 2013 05:56:25 +0000 (+0800) Subject: Implement window.moveTo and window.ResizeTo. Fix #2. X-Git-Tag: v0.1.0~172 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=349ed4fd73b6f826052bd452f024486b774d8e0a;p=electron.git Implement window.moveTo and window.ResizeTo. Fix #2. --- diff --git a/browser/native_window.cc b/browser/native_window.cc index 02421c37..5542863b 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -196,6 +196,12 @@ void NativeWindow::BeforeUnloadFired(content::WebContents* tab, WindowList::WindowCloseCancelled(this); } +void NativeWindow::MoveContents(content::WebContents* source, + const gfx::Rect& pos) { + SetPosition(pos.origin()); + SetSize(pos.size()); +} + void NativeWindow::CloseContents(content::WebContents* source) { // When the web contents is gone, close the window immediately, but the // memory will not be freed until you call delete. @@ -207,6 +213,11 @@ void NativeWindow::CloseContents(content::WebContents* source) { NotifyWindowClosed(); } +bool NativeWindow::IsPopupOrPanel(const content::WebContents* source) const { + // Only popup window can use things like window.moveTo. + return true; +} + bool NativeWindow::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(NativeWindow, message) diff --git a/browser/native_window.h b/browser/native_window.h index 52680901..72da57c5 100644 --- a/browser/native_window.h +++ b/browser/native_window.h @@ -131,7 +131,11 @@ class NativeWindow : public content::WebContentsDelegate, virtual void BeforeUnloadFired(content::WebContents* tab, bool proceed, bool* proceed_to_fire_unload) OVERRIDE; + virtual void MoveContents(content::WebContents* source, + const gfx::Rect& pos) OVERRIDE; virtual void CloseContents(content::WebContents* source) OVERRIDE; + virtual bool IsPopupOrPanel( + const content::WebContents* source) const OVERRIDE; // Implementations of content::WebContentsObserver. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;