'browser/atom_browser_main_parts.h',
'browser/atom_event_processing_window.h',
'browser/atom_event_processing_window.mm',
+ 'browser/atom_javascript_dialog_manager.cc',
+ 'browser/atom_javascript_dialog_manager.h',
'browser/native_window.cc',
'browser/native_window.h',
'browser/native_window_mac.h',
--- /dev/null
+// 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
--- /dev/null
+// 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.
+
+#ifndef ATOM_BROSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
+#define ATOM_BROSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
+
+#include "content/public/browser/javascript_dialog_manager.h"
+
+namespace atom {
+
+class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
+ public:
+ // content::JavaScriptDialogManager implementations.
+ virtual void RunJavaScriptDialog(
+ content::WebContents* web_contents,
+ const GURL& origin_url,
+ const std::string& accept_lang,
+ content::JavaScriptMessageType javascript_message_type,
+ const string16& message_text,
+ const string16& default_prompt_text,
+ const DialogClosedCallback& callback,
+ bool* did_suppress_message) OVERRIDE {}
+ virtual void RunBeforeUnloadDialog(
+ content::WebContents* web_contents,
+ const string16& message_text,
+ bool is_reload,
+ const DialogClosedCallback& callback) OVERRIDE;
+ virtual void ResetJavaScriptState(
+ content::WebContents* web_contents) OVERRIDE {}
+};
+
+} // namespace atom
+
+#endif // ATOM_BROSER_ATOM_JAVASCRIPT_DIALOG_MANAGER_H_
#include "browser/api/atom_browser_bindings.h"
#include "browser/atom_browser_context.h"
#include "browser/atom_browser_main_parts.h"
+#include "browser/atom_javascript_dialog_manager.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
window->InitFromOptions(options.get());
}
+content::JavaScriptDialogManager* NativeWindow::GetJavaScriptDialogManager() {
+ if (!dialog_manager_)
+ dialog_manager_.reset(new AtomJavaScriptDialogManager);
+
+ return dialog_manager_.get();
+}
+
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
namespace atom {
+class AtomJavaScriptDialogManager;
+
class NativeWindow : public content::WebContentsDelegate,
public content::WebContentsObserver,
public content::NotificationObserver {
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;
// 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);