summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/app_controller_mac.mm26
-rw-r--r--chrome/browser/app_controller_mac_unittest.mm5
2 files changed, 15 insertions, 16 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index aee634b..3a65d3e 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -652,27 +652,25 @@
}
- (NSMenu*)applicationDockMenu:(id)sender {
- NSMenu* result = [[[NSMenu alloc] initWithTitle: @""] autorelease];
- NSString* titleStr;
- id item;
-
- titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC);
- item = [[[NSMenuItem alloc] initWithTitle:titleStr
- action:@selector(commandDispatch:)
- keyEquivalent:@""] autorelease];
+ NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease];
+ NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC);
+ scoped_nsobject<NSMenuItem> item([[NSMenuItem alloc]
+ initWithTitle:titleStr
+ action:@selector(commandDispatch:)
+ keyEquivalent:@""]);
[item setTarget:self];
[item setTag:IDC_NEW_WINDOW];
- [result addItem:item];
+ [dockMenu addItem:item];
titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC);
- item = [[[NSMenuItem alloc] initWithTitle:titleStr
- action:@selector(commandDispatch:)
- keyEquivalent:@""] autorelease];
+ item.reset([[NSMenuItem alloc] initWithTitle:titleStr
+ action:@selector(commandDispatch:)
+ keyEquivalent:@""]);
[item setTarget:self];
[item setTag:IDC_NEW_INCOGNITO_WINDOW];
- [result addItem:item];
+ [dockMenu addItem:item];
- return result;
+ return dockMenu;
}
@end
diff --git a/chrome/browser/app_controller_mac_unittest.mm b/chrome/browser/app_controller_mac_unittest.mm
index 399e44f..fdc444a 100644
--- a/chrome/browser/app_controller_mac_unittest.mm
+++ b/chrome/browser/app_controller_mac_unittest.mm
@@ -4,6 +4,7 @@
#import <Cocoa/Cocoa.h>
+#include "base/scoped_nsobject.h"
#include "chrome/app/chrome_dll_resource.h"
#import "chrome/browser/app_controller_mac.h"
#include "testing/platform_test.h"
@@ -12,7 +13,7 @@ class AppControllerTest : public PlatformTest {
};
TEST_F(AppControllerTest, DockMenu) {
- AppController* ac = [[[AppController alloc] init] autorelease];
+ scoped_nsobject<AppController> ac([[AppController alloc] init]);
NSMenu* menu = [ac applicationDockMenu:NSApp];
NSMenuItem* item;
@@ -20,7 +21,7 @@ TEST_F(AppControllerTest, DockMenu) {
EXPECT_NE(-1, [menu indexOfItemWithTag:IDC_NEW_WINDOW]);
EXPECT_NE(-1, [menu indexOfItemWithTag:IDC_NEW_INCOGNITO_WINDOW]);
for (item in [menu itemArray]) {
- EXPECT_EQ(ac, [item target]);
+ EXPECT_EQ(ac.get(), [item target]);
EXPECT_EQ(@selector(commandDispatch:), [item action]);
}
}