summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2013-06-25 18:15:53 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-06-25 18:38:59 +0200
commit211f7b2b56db66f7ec2979404d3a51419f9019c0 (patch)
tree02d78b44ad048f36b886ad024d94da0f3efa7767
parente3de43ff09c06d478b7be46706deae737894dd83 (diff)
Use WebContentsViewQt::SetPageTitle for title change notifications
Using the NotificationObserver mechanism for this purpose seams to be a bit of overkill so remove the inheritance from WebContentsDelegateQt. We can re-add it later if we find useful notifications. Change-Id: I4dff59f66893cd36ed8c0700fa492a3eeb99f87b Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
-rw-r--r--lib/web_contents_delegate_qt.cpp14
-rw-r--r--lib/web_contents_delegate_qt.h3
-rw-r--r--lib/web_contents_view_qt.cpp6
-rw-r--r--lib/web_contents_view_qt.h2
4 files changed, 7 insertions, 18 deletions
diff --git a/lib/web_contents_delegate_qt.cpp b/lib/web_contents_delegate_qt.cpp
index 222d6f1bc..22725bdc7 100644
--- a/lib/web_contents_delegate_qt.cpp
+++ b/lib/web_contents_delegate_qt.cpp
@@ -77,20 +77,6 @@ WebContentsDelegateQt::WebContentsDelegateQt(content::BrowserContext* browser_co
m_webContents->GetRenderViewHost()->SyncRendererPrefs();
m_webContents->SetDelegate(this);
- m_registrar.Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, content::Source<content::WebContents>(m_webContents.get()));
-}
-
-void WebContentsDelegateQt::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details)
-{
- if (type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
- std::pair<content::NavigationEntry*, bool>* title = content::Details<std::pair<content::NavigationEntry*, bool> >(details).ptr();
-
- if (title->first) {
- string16 text = title->first->GetTitle();
- QString title = QString::fromUtf16(text.data());
- Q_EMIT titleChanged(title);
- }
- }
}
void WebContentsDelegateQt::NavigationStateChanged(const content::WebContents* source, unsigned changed_flags)
diff --git a/lib/web_contents_delegate_qt.h b/lib/web_contents_delegate_qt.h
index 2ffaf2d33..817c219cb 100644
--- a/lib/web_contents_delegate_qt.h
+++ b/lib/web_contents_delegate_qt.h
@@ -57,14 +57,12 @@ namespace content {
class WebContentsDelegateQt : public QObject
, public content::WebContentsDelegate
- , public content::NotificationObserver
{
Q_OBJECT
public:
WebContentsDelegateQt(content::BrowserContext*, content::SiteInstance*, int routing_id, const gfx::Size& initial_size);
content::WebContents* web_contents();
- virtual void Observe(int type, const content::NotificationSource&, const content::NotificationDetails&);
virtual void NavigationStateChanged(const content::WebContents* source, unsigned changed_flags);
virtual void LoadingStateChanged(content::WebContents* source);
@@ -75,7 +73,6 @@ Q_SIGNALS:
private:
scoped_ptr<content::WebContents> m_webContents;
- content::NotificationRegistrar m_registrar;
};
#endif
diff --git a/lib/web_contents_view_qt.cpp b/lib/web_contents_view_qt.cpp
index dedf85f01..51af43d5e 100644
--- a/lib/web_contents_view_qt.cpp
+++ b/lib/web_contents_view_qt.cpp
@@ -60,3 +60,9 @@ content::RenderWidgetHostView* WebContentsViewQt::CreateViewForWidget(content::R
return view;
}
+
+void WebContentsViewQt::SetPageTitle(const string16& title)
+{
+ QString string = QString::fromUtf16(title.data());
+ Q_EMIT m_client->webContentsDelegate->titleChanged(string);
+}
diff --git a/lib/web_contents_view_qt.h b/lib/web_contents_view_qt.h
index dbdd3cc9c..5f59d4934 100644
--- a/lib/web_contents_view_qt.h
+++ b/lib/web_contents_view_qt.h
@@ -79,7 +79,7 @@ public:
virtual content::RenderWidgetHostView* CreateViewForPopupWidget(content::RenderWidgetHost* render_widget_host) { return 0; }
- virtual void SetPageTitle(const string16& title) { QT_NOT_YET_IMPLEMENTED }
+ virtual void SetPageTitle(const string16& title);
virtual void RenderViewCreated(content::RenderViewHost* host) { QT_NOT_YET_IMPLEMENTED }