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 |