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..598467d69052f47d4edaf3e723ad35c6b53616a6 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, |
+ bool* icon_url_changed) { |
+ if (!icon_url_changed || !*icon_url_changed) |
pkotwicz
2013/03/13 17:44:49
Nit: 2 spaces of indent for the function body
Timo Reimann
2013/03/13 19:42:13
Done.
|
+ return; |
+ scoped_ptr<DictionaryValue> changed_properties(new DictionaryValue()); |
pkotwicz
2013/03/13 17:44:49
Nit: Move the creation of |changed_properties| aft
Timo Reimann
2013/03/13 19:42:13
Done.
|
+ content::NavigationEntry* entry = |
+ contents->GetController().GetActiveEntry(); |
pkotwicz
2013/03/13 17:44:49
Nit: 4 spaces of indent for the wrapped line
Timo Reimann
2013/03/13 19:42:13
Done.
|
+ if (!entry || !entry->GetFavicon().valid) |
+ return; |
+ changed_properties->SetString(tab_keys::kFaviconUrlKey, |
+ entry->GetFavicon().url.spec()); |
+ DispatchTabUpdatedEvent(contents, changed_properties.Pass()); |
+} |
+ |
void BrowserEventRouter::DispatchEvent( |
Profile* profile, |
const char* event_name, |
@@ -460,6 +483,10 @@ void BrowserEventRouter::Observe(int type, |
NavigationController* source_controller = |
content::Source<NavigationController>(source).ptr(); |
TabUpdated(source_controller->GetWebContents(), true); |
+ } else if (type == chrome::NOTIFICATION_FAVICON_UPDATED) { |
+ WebContents* contents = content::Source<WebContents>(source).ptr(); |
+ bool* icon_url_changed = content::Details<bool>(details).ptr(); |
+ FaviconUrlUpdated(contents, icon_url_changed); |
} else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
// Tab was destroyed after being detached (without being re-attached). |
WebContents* contents = content::Source<WebContents>(source).ptr(); |
@@ -467,6 +494,8 @@ 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)); |
pkotwicz
2013/03/13 17:44:49
Style Nit: Check type == chrome::NOTIFICATION_FAVI
Timo Reimann
2013/03/13 19:42:13
Done.
|
} else { |
NOTREACHED(); |
} |