Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
index 266864322ee0e9846f397b02f27f1029d27eeeaa..48cec90ec7298a0e6d2f4493ee7813cf710b15c6 100644 |
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
@@ -38,6 +38,7 @@ |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_commands.h" |
#include "chrome/browser/ui/browser_list.h" |
+#include "chrome/browser/ui/browser_list_observer.h" |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/chrome_pages.h" |
#import "chrome/browser/ui/cocoa/browser_window_utils.h" |
@@ -325,7 +326,7 @@ void GaiaWebContentsDelegate::HandleKeyboardEvent( |
// Class that listens to changes to the OAuth2Tokens for the active profile, |
// changes to the avatar menu model or browser close notifications. |
class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- public content::NotificationObserver, |
+ public chrome::BrowserListObserver, |
public OAuth2TokenService::Observer { |
public: |
ActiveProfileObserverBridge(ProfileChooserController* controller, |
@@ -333,8 +334,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
: controller_(controller), |
browser_(browser), |
token_observer_registered_(false) { |
- registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
- content::NotificationService::AllSources()); |
+ BrowserList::AddObserver(this); |
if (!browser_->profile()->IsGuestSession()) |
AddTokenServiceObserver(); |
} |
@@ -394,12 +394,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
} |
} |
- // content::NotificationObserver: |
- void Observe(int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) override { |
- DCHECK_EQ(chrome::NOTIFICATION_BROWSER_CLOSING, type); |
- if (browser_ == content::Source<Browser>(source).ptr()) { |
+ // chrome::BrowserListObserver: |
+ void OnBrowserCloseStarted(Browser* browser) override { |
+ if (browser_ == browser) { |
RemoveTokenServiceObserver(); |
// Clean up the bubble's WebContents (used by the Gaia embedded view), to |
// make sure the guest profile doesn't have any dangling host renderers. |
@@ -412,7 +409,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
ProfileChooserController* controller_; // Weak; owns this. |
Browser* browser_; // Weak. |
- content::NotificationRegistrar registrar_; |
// The observer can be removed both when closing the browser, and by just |
// closing the avatar bubble. However, in the case of closing the browser, |