No need to override TitleWasSet in NativeWindow

This commit is contained in:
Cheng Zhao 2015-12-01 17:51:09 +08:00
parent 782af41c7c
commit 8d20dda6d7
6 changed files with 5 additions and 23 deletions

View file

@ -161,11 +161,6 @@ Window::~Window() {
Destroy();
}
void Window::OnPageTitleUpdated(bool* prevent_default,
const std::string& title) {
*prevent_default = Emit("page-title-updated", title);
}
void Window::WillCloseWindow(bool* prevent_default) {
*prevent_default = Emit("close");
}

View file

@ -54,8 +54,6 @@ class Window : public mate::TrackableObject<Window>,
virtual ~Window();
// NativeWindowObserver:
void OnPageTitleUpdated(bool* prevent_default,
const std::string& title) override;
void WillCloseWindow(bool* prevent_default) override;
void OnWindowClosed() override;
void OnWindowBlur() override;

View file

@ -31,6 +31,11 @@ BrowserWindow::_init = ->
@webContents.on 'crashed', =>
@emit 'crashed'
# Change window title to page title.
@webContents.on 'page-title-set', (event, title, explicitSet) =>
@emit 'page-title-updated', event, title
@setTitle title unless event.defaultPrevented
# Sometimes the webContents doesn't get focus when window is shown, so we have
# to force focusing on webContents in this case. The safest way is to focus it
# when we first start to load URL, if we do it earlier it won't have effect,