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

Unified Diff: chrome/browser/extensions/browser_event_router.cc

Issue 12591008: Trigger a tab updated event if the favicon URL changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove favicon.ico (was committed separately). Created 7 years, 9 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
« no previous file with comments | « chrome/browser/extensions/browser_event_router.h ('k') | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/browser_event_router.cc
diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc
index 7b701f2ef50a5f6a44134a713bc1021fcc6302fb..56b688e06141fcf20fbca5e464f2e8d54d0e56f8 100644
--- a/chrome/browser/extensions/browser_event_router.cc
+++ b/chrome/browser/extensions/browser_event_router.cc
@@ -21,9 +21,12 @@
#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/api/extension_action/action_info.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_controller.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/web_contents.h"
@@ -128,6 +131,9 @@ void BrowserEventRouter::RegisterForTabNotifications(WebContents* contents) {
// a devtools WebContents that is opened in window, docked, then closed.
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::Source<WebContents>(contents));
+
+ registrar_.Add(this, chrome::NOTIFICATION_FAVICON_UPDATED,
+ content::Source<WebContents>(contents));
}
void BrowserEventRouter::UnregisterForTabNotifications(WebContents* contents) {
@@ -135,6 +141,8 @@ void BrowserEventRouter::UnregisterForTabNotifications(WebContents* contents) {
content::Source<NavigationController>(&contents->GetController()));
registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::Source<WebContents>(contents));
+ registrar_.Remove(this, chrome::NOTIFICATION_FAVICON_UPDATED,
+ content::Source<WebContents>(contents));
}
void BrowserEventRouter::OnBrowserRemoved(Browser* browser) {
@@ -352,6 +360,21 @@ void BrowserEventRouter::TabUpdated(WebContents* contents, bool did_navigate) {
DispatchTabUpdatedEvent(contents, changed_properties.Pass());
}
+void BrowserEventRouter::FaviconUrlUpdated(WebContents* contents,
+ const bool* icon_url_changed) {
+ if (!icon_url_changed || !*icon_url_changed)
+ return;
+ content::NavigationEntry* entry =
+ contents->GetController().GetActiveEntry();
+ if (!entry || !entry->GetFavicon().valid)
+ return;
+ scoped_ptr<DictionaryValue> changed_properties(new DictionaryValue());
+ changed_properties->SetString(
+ tab_keys::kFaviconUrlKey,
+ entry->GetFavicon().url.possibly_invalid_spec());
+ DispatchTabUpdatedEvent(contents, changed_properties.Pass());
+}
+
void BrowserEventRouter::DispatchEvent(
Profile* profile,
const char* event_name,
@@ -467,6 +490,12 @@ void BrowserEventRouter::Observe(int type,
content::Source<NavigationController>(&contents->GetController()));
registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::Source<WebContents>(contents));
+ registrar_.Remove(this, chrome::NOTIFICATION_FAVICON_UPDATED,
+ content::Source<WebContents>(contents));
+ } else if (type == chrome::NOTIFICATION_FAVICON_UPDATED) {
+ WebContents* contents = content::Source<WebContents>(source).ptr();
+ const bool* icon_url_changed = content::Details<bool>(details).ptr();
+ FaviconUrlUpdated(contents, icon_url_changed);
} else {
NOTREACHED();
}
« no previous file with comments | « chrome/browser/extensions/browser_event_router.h ('k') | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698