Commit 8c6b029d authored by rickcam@chromium.org's avatar rickcam@chromium.org

Moving Background App support on the Mac Dock menu into its own submenu

BUG=69448
TEST=manual

Review URL: http://codereview.chromium.org/6241009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72217 0039d316-1c4b-4281-b951-d872f2087c98
parent 580a047f
......@@ -8641,6 +8641,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_NEW_INCOGNITO_WINDOW_MAC" desc="The Mac menu item for opening a new incognito window in the file menu.">
New Incognito Window
</message>
<message name="IDS_BACKGROUND_APPS_MAC" desc="The Mac submenu for opening Background Apps.">
Background Apps
</message>
<message name="IDS_REOPEN_CLOSED_TABS_MAC" desc="The Mac menu item reopen recently closed tabs in the file menu.">
Reopen Closed Tab
</message>
......
......@@ -1194,47 +1194,58 @@ void RecordLastRunAppBundlePath() {
NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease];
Profile* profile = [self defaultProfile];
NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC);
scoped_nsobject<NSMenuItem> item(
[[NSMenuItem alloc] initWithTitle:titleStr
action:@selector(commandFromDock:)
keyEquivalent:@""]);
[item setTarget:self];
[item setTag:IDC_NEW_WINDOW];
[dockMenu addItem:item];
titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC);
item.reset([[NSMenuItem alloc] initWithTitle:titleStr
action:@selector(commandFromDock:)
keyEquivalent:@""]);
[item setTarget:self];
[item setTag:IDC_NEW_INCOGNITO_WINDOW];
[dockMenu addItem:item];
// TODO(rickcam): Mock out BackgroundApplicationListModel, then add unit
// tests which use the mock in place of the profile-initialized model.
// Avoid breaking unit tests which have no profile.
if (profile) {
int position = 0;
BackgroundApplicationListModel applications(profile);
if (applications.size()) {
int position = 0;
NSString* menuStr =
l10n_util::GetNSStringWithFixup(IDS_BACKGROUND_APPS_MAC);
scoped_nsobject<NSMenu> appMenu([[NSMenu alloc] initWithTitle:menuStr]);
for (ExtensionList::const_iterator cursor = applications.begin();
cursor != applications.end();
++cursor, ++position) {
DCHECK(position == applications.GetPosition(*cursor));
NSString* itemStr =
base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name()));
scoped_nsobject<NSMenuItem> appItem([[NSMenuItem alloc]
initWithTitle:base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name()))
initWithTitle:itemStr
action:@selector(commandFromDock:)
keyEquivalent:@""]);
[appItem setTarget:self];
[appItem setTag:position];
[dockMenu addItem:appItem];
[appMenu addItem:appItem];
}
if (applications.begin() != applications.end()) {
NSMenuItem* sepItem = [[NSMenuItem separatorItem] init];
[dockMenu addItem:sepItem];
}
}
NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC);
scoped_nsobject<NSMenuItem> item([[NSMenuItem alloc]
initWithTitle:titleStr
scoped_nsobject<NSMenuItem> appMenuItem([[NSMenuItem alloc]
initWithTitle:menuStr
action:@selector(commandFromDock:)
keyEquivalent:@""]);
[item setTarget:self];
[item setTag:IDC_NEW_WINDOW];
[dockMenu addItem:item];
titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC);
item.reset([[NSMenuItem alloc] initWithTitle:titleStr
action:@selector(commandFromDock:)
keyEquivalent:@""]);
[item setTarget:self];
[item setTag:IDC_NEW_INCOGNITO_WINDOW];
[dockMenu addItem:item];
[appMenuItem setTarget:self];
[appMenuItem setTag:position];
[appMenuItem setSubmenu:appMenu];
[dockMenu addItem:appMenuItem];
}
}
return dockMenu;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment