Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 11027065: Browser plugin: Implement titleChanged event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for pages with no title Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_guest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 86c3144be0facce626bb6bdd73a4a607d189416c..14fb57fb645725982d57f1b6616fa3dc068fdc8d 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -16,6 +16,7 @@
#include "content/common/browser_plugin_messages.h"
#include "content/common/view_messages.h"
#include "content/port/browser/render_view_host_delegate_view.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
@@ -63,6 +64,9 @@ BrowserPluginGuest::BrowserPluginGuest(int instance_id,
notification_registrar_.Add(
this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
content::Source<content::WebContents>(web_contents));
+ notification_registrar_.Add(
+ this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
+ content::Source<content::WebContents>(web_contents));
}
BrowserPluginGuest::~BrowserPluginGuest() {
@@ -102,6 +106,16 @@ void BrowserPluginGuest::Observe(int type,
is_top_level);
break;
}
+ case NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED: {
+ DCHECK_EQ(Source<WebContents>(source).ptr(), web_contents());
+ std::pair<NavigationEntry*, bool>* title =
+ Details<std::pair<NavigationEntry*, bool> >(details).ptr();
+ if (title->first) {
+ string16 title_text = title->first->GetTitle();
+ TitleChange(title_text);
+ }
+ break;
+ }
default:
NOTREACHED() << "Unexpected notification sent.";
break;
@@ -437,6 +451,11 @@ void BrowserPluginGuest::LoadRedirect(
instance_id(), old_url, new_url, is_top_level));
}
+void BrowserPluginGuest::TitleChange(const string16& title) {
+ SendMessageToEmbedder(
+ new BrowserPluginMsg_TitleChange(instance_id(), title));
+}
+
void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
int64 frame_id,
bool is_main_frame,
@@ -455,6 +474,11 @@ void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
SendMessageToEmbedder(
new BrowserPluginMsg_LoadCommit(instance_id(), params));
RecordAction(UserMetricsAction("BrowserPlugin.Guest.DidNavigate"));
+
+ // Also update title on commit, since the notifications only occur for
+ // changes to existing titles, not updates due to back/forward or to
+ // new pages with no titles.
+ TitleChange(web_contents()->GetTitle());
}
void BrowserPluginGuest::DidStopLoading(RenderViewHost* render_view_host) {

Powered by Google App Engine
This is Rietveld 408576698