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

Unified Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 1304943006: ProfileChooserVIew heap-use-after-free fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/views/profiles/profile_chooser_view.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/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
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698