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

@ -0,0 +1,22 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "browser/atom_javascript_dialog_manager.h"
#include "base/utf_string_conversions.h"
namespace atom {
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
content::WebContents* web_contents,
const string16& message_text,
bool is_reload,
const DialogClosedCallback& callback) {
bool prevent_reload = message_text.empty() ||
message_text == ASCIIToUTF16("false");
callback.Run(!prevent_reload, message_text);
}
} // namespace atom