}
void NativeWindow::CloseWebContents() {
+ bool prevent_default = false;
+ FOR_EACH_OBSERVER(NativeWindowObserver,
+ observers_,
+ WillCloseWindow(&prevent_default));
+ if (prevent_default)
+ return;
+
content::WebContents* web_contents(GetWebContents());
if (web_contents->NeedToFireBeforeUnload())
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.
- // In this way, it would be safe to manage windows via smart pointers.
+ // In this way, it would be safe to manage windows via smart pointers. If you
+ // want to free memory when the window is closed, you can do deleting by
+ // overriding WillCloseWindow method in the observer.
CloseImmediately();
+
+ FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed());
}
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
[atom_window setShell:this];
window_ = atom_window;
- [window() setReleasedWhenClosed:NO];
[window() setDelegate:[[AtomNSWindowDelegate alloc] initWithShell:this]];
// Disable fullscreen button when 'fullscreen' is specified to false.
}
NativeWindowMac::~NativeWindowMac() {
- [window() release];
}
void NativeWindowMac::Close() {
// Called when the web page of the window has updated it's document title.
virtual void OnPageTitleUpdated(bool* prevent_default,
- const std::string& title) = 0;
+ const std::string& title) {}
+
+ // Called when the window is gonna closed.
+ virtual void WillCloseWindow(bool* prevent_default) {}
+
+ // Called when the window is closed.
+ virtual void OnWindowClosed() {}
};
} // namespace atom