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..3a2f021973e711d9e30cab67ce2e591e407a7dd8 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" |
@@ -135,11 +137,14 @@ void TabsEventRouter::TabEntry::WebContentsDestroyed() { |
TabsEventRouter::TabsEventRouter(Profile* profile) |
: profile_(profile), |
favicon_scoped_observer_(this), |
- browser_tab_strip_tracker_(this, this, this) { |
+ browser_tab_strip_tracker_(this, this, this), |
+ tab_manager_scoped_observer_(this) { |
DCHECK(!profile->IsOffTheRecord()); |
browser_tab_strip_tracker_.Init( |
BrowserTabStripTracker::InitWith::ALL_BROWERS); |
+ |
+ tab_manager_scoped_observer_.Add(g_browser_process->GetTabManager()); |
} |
TabsEventRouter::~TabsEventRouter() { |
@@ -552,4 +557,16 @@ void TabsEventRouter::OnFaviconUpdated( |
} |
} |
+void TabsEventRouter::OnDiscardedStateChange(WebContents* contents, |
+ bool is_discarded) { |
+ TabStripModel* tab_strip = nullptr; |
+ int tab_index = -1; |
+ |
+ 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 |