summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 22:23:44 +0000
committersgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 22:23:44 +0000
commit018a396fc1650116ecc1df0ad7e5b65ec5ad7bec (patch)
tree62925bb9a560367a8005a59d734fae3875e6ce6d /chrome
parente4865191dc123219b81b2905f1a8d23a86ab9573 (diff)
downloadchromium_src-018a396fc1650116ecc1df0ad7e5b65ec5ad7bec.zip
chromium_src-018a396fc1650116ecc1df0ad7e5b65ec5ad7bec.tar.gz
chromium_src-018a396fc1650116ecc1df0ad7e5b65ec5ad7bec.tar.bz2
Stylistic fixes in the new dock menu code:
* Initialize variables when declared. * Descriptive name (dock_menu) for the returned value. * Use a scoped_nsobject in the unit test, not autorelease. BUG=none TEST=AppControllerTest.DockMenu Review URL: http://codereview.chromium.org/200126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26507 0039d316-1c4b-4281-b951-d872f2087c98
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]);
}
}