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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 14923004: [Mac] AppController needs to update its "last profile" pointer when the active profile is deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index feb0f95f782cfa782706dee63350095316590490..79903716cb0ad1bca5a315d1b81d52605fe7ed2c 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -585,6 +585,11 @@ void RecordLastRunAppBundlePath() {
EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile],
encodingMenu);
+ // Instantiate the ProfileInfoCache observer so that we can get
+ // notified when a profile is deleted.
+ profileInfoCacheObserver_ = new AppControllerProfileObserver(
+ g_browser_process->profile_manager(), self);
+
// Since Chrome is localized to more languages than the OS, tell Cocoa which
// menu is the Help so it can add the search item to it.
[NSApp setHelpMenu:helpMenu_];
@@ -714,6 +719,19 @@ void RecordLastRunAppBundlePath() {
return service && !service->entries().empty();
}
+- (void)profileWasRemoved:(const string16&)profileName {
+ Profile* lastProfile = [self lastProfile];
+ string16 lastProfileName = UTF8ToUTF16(lastProfile->GetPrefs()->GetString(
+ prefs::kProfileName));
+
+ // If the last profile has been deleted, we must NULL out our pointer
+ // otherwise we will try to start up a browser window with a pointer
+ // to the old profile.
+ if (profileName == lastProfileName) {
+ lastProfile_ = NULL;
+ }
+}
+
// Returns true if there is a modal window (either window- or application-
// modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
// sheets) will not count as blocking the browser. But things like open/save

Powered by Google App Engine
This is Rietveld 408576698