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..be00f58798398de11a33e4ae8f6a54f86674d958 100644 |
--- a/chrome/browser/ui/tabs/pinned_tab_service.cc |
+++ b/chrome/browser/ui/tabs/pinned_tab_service.cc |
@@ -8,6 +8,7 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_list.h" |
+#include "chrome/browser/ui/browser_list_observer.h" |
#include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
#include "content/public/browser/notification_service.h" |
@@ -33,12 +34,11 @@ PinnedTabService::PinnedTabService(Profile* profile) |
has_normal_browser_(false) { |
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()); |
+ BrowserList::AddObserver(this); |
} |
void PinnedTabService::Observe(int type, |
@@ -77,18 +77,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 +89,13 @@ void PinnedTabService::Observe(int type, |
NOTREACHED(); |
} |
} |
+ |
+void PinnedTabService::OnBrowserCloseStarted(Browser* browser) { |
+ if (has_normal_browser_ && save_pinned_tabs_ && |
+ browser->profile() == profile_) { |
+ if (IsOnlyNormalBrowser(browser)) { |
+ has_normal_browser_ = false; |
+ PinnedTabCodec::WritePinnedTabs(profile_); |
+ } |
+ } |
+} |