}
Window::~Window() {
+ window_->RemoveObserver(this);
}
void Window::OnPageTitleUpdated(bool* prevent_default,
const std::string& title) {
- scoped_ptr<base::ListValue> args(new base::ListValue);
- args->AppendString(title);
- *prevent_default = Emit("page-title-updated", args.get());
+ base::ListValue args;
+ args.AppendString(title);
+ *prevent_default = Emit("page-title-updated", &args);
+}
+
+void Window::WillCloseWindow(bool* prevent_default) {
+ base::ListValue args;
+ *prevent_default = Emit("close", &args);
+}
+
+void Window::OnWindowClosed() {
+ // Free memory immediately when window is closed.
+ delete this;
}
// static
// Implementations of NativeWindowObserver.
virtual void OnPageTitleUpdated(bool* prevent_default,
const std::string& title) OVERRIDE;
+ virtual void WillCloseWindow(bool* prevent_default) OVERRIDE;
+ virtual void OnWindowClosed() OVERRIDE;
private:
static v8::Handle<v8::Value> New(const v8::Arguments &args);
// memory will not be freed until you call delete.
// 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.
+ // overriding the WillCloseWindow method in the observer.
CloseImmediately();
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed());
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
- bool window_going_to_destroy_;
-
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
};
virtual void SetKiosk(bool kiosk) OVERRIDE;
virtual bool IsKiosk() OVERRIDE;
- NSWindow* window() const { return window_; }
+ NSWindow*& window() { return window_; }
protected:
void SetNonLionFullscreen(bool fullscreen);
}
- (void)windowWillClose:(NSNotification *)notification {
+ shell_->window() = nil;
[self autorelease];
}
}
NativeWindowMac::~NativeWindowMac() {
+ if (window())
+ [window() release];
}
void NativeWindowMac::Close() {
}
void NativeWindowMac::CloseImmediately() {
+ [window() orderOut:nil];
[window() close];
}
-Subproject commit 65af4131fc8d5b3450f89950dddc08be8a720860
+Subproject commit a51999007ff325562a7c5a73a76c198a080b37a8