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

Unified Diff: chrome/browser/extensions/api/sessions/sessions_api.cc

Issue 1642583002: Fix bug with invalid chrome.sessions.onChanged listener. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 11 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/sessions/sessions_api.cc
diff --git a/chrome/browser/extensions/api/sessions/sessions_api.cc b/chrome/browser/extensions/api/sessions/sessions_api.cc
index 6d6810a2f8f3c688839d2b3dc215c23b18b25f12..6fe3b8b4f231bd996d8abe5f6526e53b126d2afb 100644
--- a/chrome/browser/extensions/api/sessions/sessions_api.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_api.cc
@@ -607,8 +607,10 @@ bool SessionsRestoreFunction::RunSync() {
: RestoreLocalSession(*session_id, browser);
}
-SessionsEventRouter::SessionsEventRouter(Profile* profile)
+SessionsEventRouter::SessionsEventRouter(Profile* profile,
+ EventRouter::Observer* observer)
: profile_(profile),
+ observer_(observer),
tab_restore_service_(TabRestoreServiceFactory::GetForProfile(profile)) {
// TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in
// incognito mode)
@@ -634,6 +636,8 @@ void SessionsEventRouter::TabRestoreServiceChanged(
void SessionsEventRouter::TabRestoreServiceDestroyed(
sessions::TabRestoreService* service) {
tab_restore_service_ = NULL;
+ EventRouter::Get(profile_)->RegisterObserver(
+ observer_, api::sessions::OnChanged::kEventName);
}
SessionsAPI::SessionsAPI(content::BrowserContext* context)
@@ -659,7 +663,8 @@ SessionsAPI::GetFactoryInstance() {
void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) {
sessions_event_router_.reset(
- new SessionsEventRouter(Profile::FromBrowserContext(browser_context_)));
+ new SessionsEventRouter(Profile::FromBrowserContext(browser_context_),
+ this));
EventRouter::Get(browser_context_)->UnregisterObserver(this);
}
« no previous file with comments | « chrome/browser/extensions/api/sessions/sessions_api.h ('k') | chrome/browser/extensions/api/sessions/sessions_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698