summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_controller_mac.mm
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 17:57:30 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 17:57:30 +0000
commit71c0eb9125f569d127fe0c5dedc0066628e4bb8c (patch)
tree0b47f9a6f51f8070897a2f8d956925c8f5f53e4e /chrome/browser/app_controller_mac.mm
parenta18130a5bfdeba5556c2bee55817064da72a343b (diff)
downloadchromium_src-71c0eb9125f569d127fe0c5dedc0066628e4bb8c.zip
chromium_src-71c0eb9125f569d127fe0c5dedc0066628e4bb8c.tar.gz
chromium_src-71c0eb9125f569d127fe0c5dedc0066628e4bb8c.tar.bz2
Fix Lion dictionary popup staying after tab-close via cmd-W.
This was caused by the close menu item not sending a -[performClose:], which was what the popup was looking for. Adds some unit tests and refactors some code to make it more testable. BUG=104931 TEST=Open a tab and double 3-finger tap on a word to bring up the dictionary popup. Hit cmd-W. The popup should close but they tab should stay open. Hit cmd-W again. The tab should close. Try cmd-shift-W with > 1 tab open. The window should close. Review URL: http://codereview.chromium.org/9026016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/app_controller_mac.mm')
-rw-r--r--chrome/browser/app_controller_mac.mm40
1 files changed, 31 insertions, 9 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index e94ee26..9f7e755 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -193,6 +193,13 @@ const AEEventClass kAECloudPrintUninstallClass = 'GCPu';
// the profile is loaded or any preferences have been registered). Defer any
// user-data initialization until -applicationDidFinishLaunching:.
- (void)awakeFromNib {
+}
+
+// This method is called very early in application startup (ie, before
+// the profile is loaded or any preferences have been registered), just
+// after -awakeFromNib. This is separate from -awakeFromNib: so that
+// test code can load nibs without these side effects.
+- (void)registerEventHandlersAndInitialize {
// We need to register the handlers early to catch events fired on launch.
NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
[em setEventHandler:self
@@ -250,6 +257,27 @@ const AEEventClass kAECloudPrintUninstallClass = 'GCPu';
[self initProfileMenu];
}
+- (void)unregisterEventHandlers {
+ NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
+ [em removeEventHandlerForEventClass:kInternetEventClass
+ andEventID:kAEGetURL];
+ [em removeEventHandlerForEventClass:cloud_print::kAECloudPrintClass
+ andEventID:cloud_print::kAECloudPrintClass];
+ [em removeEventHandlerForEventClass:kAECloudPrintInstallClass
+ andEventID:kAECloudPrintInstallClass];
+ [em removeEventHandlerForEventClass:kAECloudPrintUninstallClass
+ andEventID:kAECloudPrintUninstallClass];
+ [em removeEventHandlerForEventClass:'WWW!'
+ andEventID:'OURL'];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+- (void)dealloc {
+ if ([NSApp delegate] == self)
+ [NSApp setDelegate:nil];
+ [super dealloc];
+}
+
// (NSApplicationDelegate protocol) This is the Apple-approved place to override
// the default handlers.
- (void)applicationWillFinishLaunching:(NSNotification*)notification {
@@ -322,14 +350,8 @@ const AEEventClass kAECloudPrintUninstallClass = 'GCPu';
// Called when the app is shutting down. Clean-up as appropriate.
- (void)applicationWillTerminate:(NSNotification*)aNotification {
- NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
- [em removeEventHandlerForEventClass:kInternetEventClass
- andEventID:kAEGetURL];
- [em removeEventHandlerForEventClass:'WWW!'
- andEventID:'OURL'];
-
// There better be no browser windows left at this point.
- CHECK_EQ(BrowserList::size(), 0u);
+ CHECK_EQ(0u, BrowserList::size());
// Tell BrowserList not to keep the browser process alive. Once all the
// browsers get dealloc'd, it will stop the RunLoop and fall back into main().
@@ -338,7 +360,7 @@ const AEEventClass kAECloudPrintUninstallClass = 'GCPu';
// Close these off if they have open windows.
[aboutController_ close];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [self unregisterEventHandlers];
}
- (void)didEndMainMessageLoop {