base::DictionaryValue* options)
: content::WebContentsObserver(web_contents),
has_frame_(true),
- inspectable_web_contents_(
- brightray::InspectableWebContents::Create(web_contents)),
is_closed_(false),
node_integration_("except-iframe"),
has_dialog_attached_(false),
- weak_factory_(this) {
+ weak_factory_(this),
+ inspectable_web_contents_(
+ brightray::InspectableWebContents::Create(web_contents)) {
options->GetBoolean(switches::kFrame, &has_frame_);
#if defined(OS_MACOSX)
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur());
}
+void NativeWindow::DestroyWebContents() {
+ inspectable_web_contents_.reset();
+}
+
// In atom-shell all reloads and navigations started by renderer process would
// be redirected to this method, so we can have precise control of how we
// would open the url (in our case, is to restart the renderer process). See
void NotifyWindowClosed();
void NotifyWindowBlur();
+ // Destroy the inspectable_web_contents.
+ void DestroyWebContents();
+
// Called when the window needs to update its draggable region.
virtual void UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) = 0;
// Window icon.
gfx::Image icon_;
- scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
-
private:
// Schedule a notification unresponsive event.
void ScheduleUnresponsiveEvent(int ms);
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
+ // Notice that inspectable_web_contents_ must be placed after dialog_manager_,
+ // so we can make sure inspectable_web_contents_ is destroyed before
+ // dialog_manager_, otherwise a crash would happen.
+ scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
+
// Maps url to file path, used by the file requests sent from devtools.
typedef std::map<std::string, base::FilePath> PathsMap;
PathsMap saved_files_;
NativeWindowMac::~NativeWindowMac() {
// Force InspectableWebContents to be destroyed before we destroy window,
// because it may still be observing the window at this time.
- inspectable_web_contents_.reset();
+ DestroyWebContents();
}
void NativeWindowMac::Close() {