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

Unified Diff: chrome/browser/ui/tabs/pinned_tab_service.cc

Issue 2793443003: Removed NOTIFICATION_BROWSER_CLOSING notification (Closed)
Patch Set: Update CL basing on review comments (rebase) Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/tabs/pinned_tab_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tabs/pinned_tab_service.cc
diff --git a/chrome/browser/ui/tabs/pinned_tab_service.cc b/chrome/browser/ui/tabs/pinned_tab_service.cc
index 5f56a5ecf9a5c511250eb07a09b41f2f46188a2a..ad016fdf93e7e0c4a8d8c0110790ddd8373bad89 100644
--- a/chrome/browser/ui/tabs/pinned_tab_service.cc
+++ b/chrome/browser/ui/tabs/pinned_tab_service.cc
@@ -30,17 +30,19 @@ bool IsOnlyNormalBrowser(Browser* browser) {
PinnedTabService::PinnedTabService(Profile* profile)
: profile_(profile),
save_pinned_tabs_(true),
- has_normal_browser_(false) {
+ has_normal_browser_(false),
+ browser_list_observer_(this) {
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED,
content::NotificationService::AllBrowserContextsAndSources());
- registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING,
- content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
+ browser_list_observer_.Add(BrowserList::GetInstance());
}
+PinnedTabService::~PinnedTabService() {}
+
void PinnedTabService::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -77,18 +79,6 @@ void PinnedTabService::Observe(int type,
break;
}
- case chrome::NOTIFICATION_BROWSER_CLOSING: {
- Browser* browser = content::Source<Browser>(source).ptr();
- if (has_normal_browser_ && save_pinned_tabs_ &&
- browser->profile() == profile_) {
- if (IsOnlyNormalBrowser(browser)) {
- has_normal_browser_ = false;
- PinnedTabCodec::WritePinnedTabs(profile_);
- }
- }
- break;
- }
-
case chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST: {
if (has_normal_browser_ && save_pinned_tabs_) {
PinnedTabCodec::WritePinnedTabs(profile_);
@@ -101,3 +91,11 @@ void PinnedTabService::Observe(int type,
NOTREACHED();
}
}
+
+void PinnedTabService::OnBrowserClosing(Browser* browser) {
+ if (has_normal_browser_ && save_pinned_tabs_ &&
+ browser->profile() == profile_ && IsOnlyNormalBrowser(browser)) {
+ has_normal_browser_ = false;
+ PinnedTabCodec::WritePinnedTabs(profile_);
+ }
+}
« no previous file with comments | « chrome/browser/ui/tabs/pinned_tab_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698