mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Send OnTitleChange() notifications when navigating history (issue #766).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1087 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -1855,22 +1855,34 @@ void CefBrowserHostImpl::OnResponseAck(int request_id) {
|
||||
void CefBrowserHostImpl::Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) {
|
||||
DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED ||
|
||||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
|
||||
DCHECK(type == content::NOTIFICATION_LOAD_STOP ||
|
||||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE ||
|
||||
type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED);
|
||||
|
||||
if (type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
|
||||
std::pair<content::NavigationEntry*, bool>* title =
|
||||
content::Details<std::pair<content::NavigationEntry*, bool> >(
|
||||
details).ptr();
|
||||
if (type == content::NOTIFICATION_LOAD_STOP ||
|
||||
type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
|
||||
string16 title;
|
||||
|
||||
if (title->first) {
|
||||
if (client_.get()) {
|
||||
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
|
||||
if (handler.get()) {
|
||||
CefString title_str = title->first->GetTitleForDisplay("");
|
||||
handler->OnTitleChange(this, title_str);
|
||||
}
|
||||
}
|
||||
if (type == content::NOTIFICATION_LOAD_STOP) {
|
||||
content::NavigationController* controller =
|
||||
content::Source<content::NavigationController>(source).ptr();
|
||||
title = controller->GetWebContents()->GetTitle();
|
||||
} else {
|
||||
content::WebContents* web_contents =
|
||||
content::Source<content::WebContents>(source).ptr();
|
||||
title = web_contents->GetTitle();
|
||||
}
|
||||
|
||||
// Don't notify if the title hasn't changed.
|
||||
if (title == title_)
|
||||
return;
|
||||
|
||||
title_ = title;
|
||||
|
||||
if (client_.get()) {
|
||||
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
|
||||
if (handler.get())
|
||||
handler->OnTitleChange(this, title);
|
||||
}
|
||||
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
|
||||
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
|
||||
@@ -1914,6 +1926,15 @@ CefBrowserHostImpl::CefBrowserHostImpl(
|
||||
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
|
||||
content::Source<content::WebContents>(web_contents));
|
||||
|
||||
// When navigating through the history, the restored NavigationEntry's title
|
||||
// will be used. If the entry ends up having the same title after we return
|
||||
// to it, as will usually be the case, the
|
||||
// NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since the
|
||||
// NavigationEntry's title hasn't changed.
|
||||
registrar_->Add(this, content::NOTIFICATION_LOAD_STOP,
|
||||
content::Source<content::NavigationController>(
|
||||
&web_contents->GetController()));
|
||||
|
||||
response_manager_.reset(new CefResponseManager);
|
||||
|
||||
placeholder_frame_ =
|
||||
|
Reference in New Issue
Block a user