Index: chrome/browser/extensions/api/tabs/tabs_event_router.cc |
diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.cc b/chrome/browser/extensions/api/tabs/tabs_event_router.cc |
index 80c495c96736c1de6aa06d668eb52bdbe8adad82..3f4c205e8f3ca8dc9ab8798d13ac95a060e78e47 100644 |
--- a/chrome/browser/extensions/api/tabs/tabs_event_router.cc |
+++ b/chrome/browser/extensions/api/tabs/tabs_event_router.cc |
@@ -11,10 +11,12 @@ |
#include "base/memory/ptr_util.h" |
#include "base/values.h" |
+#include "chrome/browser/browser_process.h" |
#include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
#include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
#include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
#include "chrome/browser/extensions/extension_tab_util.h" |
+#include "chrome/browser/memory/tab_manager.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_list.h" |
@@ -140,9 +142,14 @@ TabsEventRouter::TabsEventRouter(Profile* profile) |
browser_tab_strip_tracker_.Init( |
BrowserTabStripTracker::InitWith::ALL_BROWERS); |
+ |
+ if (g_browser_process->GetTabManager()) |
+ g_browser_process->GetTabManager()->AddObserver(this); |
} |
TabsEventRouter::~TabsEventRouter() { |
+ if (g_browser_process->GetTabManager()) |
+ g_browser_process->GetTabManager()->RemoveObserver(this); |
} |
bool TabsEventRouter::ShouldTrackBrowser(Browser* browser) { |
@@ -552,4 +559,16 @@ void TabsEventRouter::OnFaviconUpdated( |
} |
} |
+void TabsEventRouter::OnDiscardedStateChange(WebContents* contents, |
+ bool is_discarded) { |
+ TabStripModel* tab_strip = NULL; |
Georges Khalil
2016/07/13 15:52:10
nit: nullptr
Anderson Silva
2016/07/14 15:13:13
Done.
|
+ int tab_index; |
Georges Khalil
2016/07/13 15:52:10
nit: initialize.
Anderson Silva
2016/07/14 15:13:13
Done.
|
+ |
+ if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { |
+ std::set<std::string> changed_property_names; |
+ changed_property_names.insert(tabs_constants::kDiscardedKey); |
+ DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
+ } |
+} |
+ |
} // namespace extensions |