No need to override TitleWasSet in NativeWindow
This commit is contained in:
parent
782af41c7c
commit
8d20dda6d7
6 changed files with 5 additions and 23 deletions
|
@ -161,11 +161,6 @@ Window::~Window() {
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::OnPageTitleUpdated(bool* prevent_default,
|
|
||||||
const std::string& title) {
|
|
||||||
*prevent_default = Emit("page-title-updated", title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::WillCloseWindow(bool* prevent_default) {
|
void Window::WillCloseWindow(bool* prevent_default) {
|
||||||
*prevent_default = Emit("close");
|
*prevent_default = Emit("close");
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,6 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
// NativeWindowObserver:
|
// NativeWindowObserver:
|
||||||
void OnPageTitleUpdated(bool* prevent_default,
|
|
||||||
const std::string& title) override;
|
|
||||||
void WillCloseWindow(bool* prevent_default) override;
|
void WillCloseWindow(bool* prevent_default) override;
|
||||||
void OnWindowClosed() override;
|
void OnWindowClosed() override;
|
||||||
void OnWindowBlur() override;
|
void OnWindowBlur() override;
|
||||||
|
|
|
@ -31,6 +31,11 @@ BrowserWindow::_init = ->
|
||||||
@webContents.on 'crashed', =>
|
@webContents.on 'crashed', =>
|
||||||
@emit '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
|
# 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
|
# 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,
|
# when we first start to load URL, if we do it earlier it won't have effect,
|
||||||
|
|
|
@ -505,17 +505,6 @@ void NativeWindow::BeforeUnloadDialogCancelled() {
|
||||||
window_unresposive_closure_.Cancel();
|
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 NativeWindow::OnMessageReceived(const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
|
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
|
||||||
|
|
|
@ -262,7 +262,6 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
// content::WebContentsObserver:
|
// content::WebContentsObserver:
|
||||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||||
void BeforeUnloadDialogCancelled() override;
|
void BeforeUnloadDialogCancelled() override;
|
||||||
void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
|
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -21,10 +21,6 @@ class NativeWindowObserver {
|
||||||
public:
|
public:
|
||||||
virtual ~NativeWindowObserver() {}
|
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.
|
// Called when the web page in window wants to create a popup window.
|
||||||
virtual void WillCreatePopupWindow(const base::string16& frame_name,
|
virtual void WillCreatePopupWindow(const base::string16& frame_name,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
|
|
Loading…
Reference in a new issue