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");
}
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;
@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,
window_unresposive_closure_.Cancel();
}
-void NativeWindow::TitleWasSet(content::NavigationEntry* entry,
- bool explicit_set) {
- bool prevent_default = false;
- std::string text = entry ? base::UTF16ToUTF8(entry->GetTitle()) : "";
- FOR_EACH_OBSERVER(NativeWindowObserver,
- observers_,
- OnPageTitleUpdated(&prevent_default, text));
- if (!prevent_default && !is_closed_)
- SetTitle(text);
-}
-
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
// content::WebContentsObserver:
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void BeforeUnloadDialogCancelled() override;
- void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
bool OnMessageReceived(const IPC::Message& message) override;
private:
public:
virtual ~NativeWindowObserver() {}
- // Called when the web page of the window has updated it's document title.
- virtual void OnPageTitleUpdated(bool* prevent_default,
- const std::string& title) {}
-
// Called when the web page in window wants to create a popup window.
virtual void WillCreatePopupWindow(const base::string16& frame_name,
const GURL& target_url,