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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_event_router.cc

Issue 2142413003: Adding Discarded property support for onUpdate function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@API_Discarded
Patch Set: Created 4 years, 5 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: 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

Powered by Google App Engine
This is Rietveld 408576698