Chromium Code Reviews| Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| index f61db462d9c4d91c3faf440c3da8055a1d874684..02c68c7a5748491822e00baec1b27e299048c8ff 100644 |
| --- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| @@ -24,6 +24,7 @@ |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_commands.h" |
| #include "chrome/browser/ui/browser_dialogs.h" |
| +#include "chrome/browser/ui/browser_list.h" |
| #include "chrome/browser/ui/chrome_pages.h" |
| #include "chrome/browser/ui/singleton_tabs.h" |
| #include "chrome/browser/ui/user_manager.h" |
| @@ -610,13 +611,18 @@ ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
| ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| if (oauth2_token_service) |
| oauth2_token_service->AddObserver(this); |
| + |
| + BrowserList::AddObserver(this); |
|
Evan Stade
2015/09/03 19:35:22
So if we're not closing the bubble when its browse
|
| } |
| ProfileChooserView::~ProfileChooserView() { |
| - ProfileOAuth2TokenService* oauth2_token_service = |
| - ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| - if (oauth2_token_service) |
| - oauth2_token_service->RemoveObserver(this); |
| + // The browser could have already been removed by now. |
| + if (browser_) { |
| + ProfileOAuth2TokenService* oauth2_token_service = |
| + ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| + if (oauth2_token_service) |
| + oauth2_token_service->RemoveObserver(this); |
| + } |
| } |
| void ProfileChooserView::ResetView() { |
| @@ -695,6 +701,12 @@ void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { |
| ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
| } |
| +void ProfileChooserView::OnBrowserRemoved(Browser* browser) { |
| + if (browser == browser_) { |
| + browser_ = NULL; |
|
Evan Stade
2015/09/03 17:38:39
There are many places in this file that reference
|
| + } |
| +} |
| + |
| void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
| AvatarMenu* avatar_menu) { |
| // The account management view should only be displayed if the active profile |