Implement beforeunload event.

Unlike normal browser which would show a dialog to choose whether to
continue, you can just return a empty string in the handler to prevent
unloading.
This commit is contained in:
Cheng Zhao 2013-04-30 23:56:50 +08:00
parent bcf6cd9f1b
commit a674572dd4
5 changed files with 73 additions and 0 deletions

View file

@ -40,6 +40,8 @@ class Size;
namespace atom {
class AtomJavaScriptDialogManager;
class NativeWindow : public content::WebContentsDelegate,
public content::WebContentsObserver,
public content::NotificationObserver {
@ -115,6 +117,8 @@ class NativeWindow : public content::WebContentsDelegate,
const string16& frame_name,
const GURL& target_url,
content::WebContents* new_contents) OVERRIDE;
virtual content::JavaScriptDialogManager*
GetJavaScriptDialogManager() OVERRIDE;
// Implementations of content::WebContentsObserver.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
@ -141,6 +145,8 @@ class NativeWindow : public content::WebContentsDelegate,
// Stores all windows.
static std::vector<NativeWindow*> windows_;
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
DISALLOW_COPY_AND_ASSIGN(NativeWindow);