summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 21:20:05 +0000
committersgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 21:20:05 +0000
commit8e304832e919812661960afbee292892788b628f (patch)
tree9ae0d56f8c3177bbfdcee3330c11172fc9243483 /chrome/browser
parentb7e273f8fc7448ecd476ecdb563a3566eb9bce1e (diff)
downloadchromium_src-8e304832e919812661960afbee292892788b628f.zip
chromium_src-8e304832e919812661960afbee292892788b628f.tar.gz
chromium_src-8e304832e919812661960afbee292892788b628f.tar.bz2
Add "New Window" and "New Incognito Window" items to the Dock Menu.
Add a unit test module for AppController with a simple DockMenu test. BUG=none TEST=none Review URL: http://codereview.chromium.org/199031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/app_controller_mac.mm27
-rw-r--r--chrome/browser/app_controller_mac_unittest.mm26
2 files changed, 53 insertions, 0 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index e3f88e9..fcefabd 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -48,6 +48,7 @@
- (void)windowLayeringDidChange:(NSNotification*)inNotification;
- (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount;
- (BOOL)shouldQuitWithInProgressDownloads;
+- (NSMenu*)applicationDockMenu:(NSApplication*)sender;
@end
@implementation AppController
@@ -666,4 +667,30 @@
[aboutController_ showWindow:self];
}
+- (NSMenu*)applicationDockMenu:(id)sender {
+ NSMenu* result = [[[NSMenu alloc] initWithTitle: @""] autorelease];
+ NSString* titleStr;
+ id item;
+
+ titleStr = base::SysWideToNSString(
+ l10n_util::GetString(IDS_NEW_WINDOW_MAC));
+ item = [[[NSMenuItem alloc] initWithTitle:titleStr
+ action:@selector(commandDispatch:)
+ keyEquivalent:@""] autorelease];
+ [item setTarget:self];
+ [item setTag:IDC_NEW_WINDOW];
+ [result addItem:item];
+
+ titleStr = base::SysWideToNSString(
+ l10n_util::GetString(IDS_NEW_INCOGNITO_WINDOW_MAC));
+ item = [[[NSMenuItem alloc] initWithTitle:titleStr
+ action:@selector(commandDispatch:)
+ keyEquivalent:@""] autorelease];
+ [item setTarget:self];
+ [item setTag:IDC_NEW_INCOGNITO_WINDOW];
+ [result addItem:item];
+
+ return result;
+}
+
@end
diff --git a/chrome/browser/app_controller_mac_unittest.mm b/chrome/browser/app_controller_mac_unittest.mm
new file mode 100644
index 0000000..49067a0
--- /dev/null
+++ b/chrome/browser/app_controller_mac_unittest.mm
@@ -0,0 +1,26 @@
+// Copyright (c) 2009 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.
+
+#import <Cocoa/Cocoa.h>
+
+#include "chrome/app/chrome_dll_resource.h"
+#import "chrome/browser/app_controller_mac.h"
+#include "testing/platform_test.h"
+
+class AppControllerTest : public PlatformTest {
+};
+
+TEST_F(AppControllerTest, DockMenu) {
+ AppController* ac = [[AppController alloc] init];
+ NSMenu* menu = [ac applicationDockMenu:NSApp];
+ NSMenuItem* item;
+
+ EXPECT_TRUE(menu);
+ 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(@selector(commandDispatch:), [item action]);
+ }
+}