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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 402066: Moved a whole pile of unittests over to CocoaTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/app_controller_mac.h ('k') | chrome/browser/cocoa/about_ipc_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_controller_mac.mm
===================================================================
--- chrome/browser/app_controller_mac.mm (revision 32421)
+++ chrome/browser/app_controller_mac.mm (working copy)
@@ -166,6 +166,10 @@
// dealloc'd, it will stop the RunLoop and fall back into main().
g_browser_process->ReleaseModule();
+ // Close these off if they have open windows.
+ [prefsController_ close];
+ [aboutController_ close];
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@@ -682,12 +686,16 @@
// Called when the preferences window is closed. We use this to release the
// window controller.
-- (void)prefsWindowClosed:(NSNotification*)notify {
- [[NSNotificationCenter defaultCenter]
- removeObserver:self
- name:kUserDoneEditingPrefsNotification
- object:prefsController_.get()];
- prefsController_.reset(NULL);
+- (void)prefsWindowClosed:(NSNotification*)notification {
+ NSWindow* window = [prefsController_ window];
+ DCHECK([notification object] == window);
+ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
+ [defaultCenter removeObserver:self
+ name:NSWindowWillCloseNotification
+ object:window];
+ // PreferencesWindowControllers are autoreleased in
+ // -[PreferencesWindowController windowWillClose:].
+ prefsController_ = nil;
}
// Show the preferences window, or bring it to the front if it's already
@@ -701,45 +709,49 @@
- (void)showPreferencesWindow:(id)sender
page:(OptionsPage)page
profile:(Profile*)profile {
- if (prefsController_.get()) {
+ if (prefsController_) {
[prefsController_ switchToPage:page animate:YES];
} else {
- prefsController_.reset([[PreferencesWindowController alloc]
- initWithProfile:profile
- initialPage:page]);
+ prefsController_ =
+ [[PreferencesWindowController alloc] initWithProfile:profile
+ initialPage:page];
// Watch for a notification of when it goes away so that we can destroy
// the controller.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(prefsWindowClosed:)
- name:kUserDoneEditingPrefsNotification
- object:prefsController_.get()];
+ name:NSWindowWillCloseNotification
+ object:[prefsController_ window]];
}
[prefsController_ showPreferences:sender];
}
// Called when the about window is closed. We use this to release the
// window controller.
-- (void)aboutWindowClosed:(NSNotification*)notify {
+- (void)aboutWindowClosed:(NSNotification*)notification {
+ NSWindow* window = [aboutController_ window];
+ DCHECK(window == [notification object]);
[[NSNotificationCenter defaultCenter]
removeObserver:self
- name:kUserClosedAboutNotification
- object:aboutController_.get()];
- aboutController_.reset(nil);
+ name:NSWindowWillCloseNotification
+ object:window];
+ // AboutWindowControllers are autoreleased in
+ // -[AboutWindowController windowWillClose:].
+ aboutController_ = nil;
}
- (IBAction)orderFrontStandardAboutPanel:(id)sender {
if (!aboutController_) {
- aboutController_.reset([[AboutWindowController alloc]
- initWithProfile:[self defaultProfile]]);
+ aboutController_ =
+ [[AboutWindowController alloc] initWithProfile:[self defaultProfile]];
// Watch for a notification of when it goes away so that we can destroy
// the controller.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(aboutWindowClosed:)
- name:kUserClosedAboutNotification
- object:aboutController_.get()];
+ name:NSWindowWillCloseNotification
+ object:[aboutController_ window]];
}
if (![[aboutController_ window] isVisible])
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/cocoa/about_ipc_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698