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

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: nit fixed 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..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
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_event_router.h ('k') | chrome/browser/extensions/extension_tabs_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698