OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/app_controller_mac.h" | 5 #import "chrome/browser/app_controller_mac.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/l10n_util_mac.h" | 8 #include "app/l10n_util_mac.h" |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1188 // Explicitly bring to the foreground when creating new windows from the dock. | 1188 // Explicitly bring to the foreground when creating new windows from the dock. |
1189 - (void)commandFromDock:(id)sender { | 1189 - (void)commandFromDock:(id)sender { |
1190 [NSApp activateIgnoringOtherApps:YES]; | 1190 [NSApp activateIgnoringOtherApps:YES]; |
1191 [self commandDispatch:sender]; | 1191 [self commandDispatch:sender]; |
1192 } | 1192 } |
1193 | 1193 |
1194 - (NSMenu*)applicationDockMenu:(NSApplication*)sender { | 1194 - (NSMenu*)applicationDockMenu:(NSApplication*)sender { |
1195 NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease]; | 1195 NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease]; |
1196 Profile* profile = [self defaultProfile]; | 1196 Profile* profile = [self defaultProfile]; |
1197 | 1197 |
1198 // TODO(rickcam): Mock out BackgroundApplicationListModel, then add unit | |
1199 // tests which use the mock in place of the profile-initialized model. | |
1200 | |
1201 // Avoid breaking unit tests which have no profile. | |
1202 if (profile) { | |
1203 int position = 0; | |
1204 BackgroundApplicationListModel applications(profile); | |
1205 for (ExtensionList::const_iterator cursor = applications.begin(); | |
1206 cursor != applications.end(); | |
1207 ++cursor, ++position) { | |
1208 DCHECK(position == applications.GetPosition(*cursor)); | |
1209 scoped_nsobject<NSMenuItem> appItem([[NSMenuItem alloc] | |
1210 initWithTitle:base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name())) | |
1211 action:@selector(commandFromDock:) | |
1212 keyEquivalent:@""]); | |
1213 [appItem setTarget:self]; | |
1214 [appItem setTag:position]; | |
1215 [dockMenu addItem:appItem]; | |
1216 } | |
1217 if (applications.begin() != applications.end()) { | |
1218 NSMenuItem* sepItem = [[NSMenuItem separatorItem] init]; | |
1219 [dockMenu addItem:sepItem]; | |
1220 } | |
1221 } | |
1222 | |
1223 NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC); | 1198 NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC); |
1224 scoped_nsobject<NSMenuItem> item([[NSMenuItem alloc] | 1199 scoped_nsobject<NSMenuItem> item([[NSMenuItem alloc] |
1225 initWithTitle:titleStr | 1200 initWithTitle:titleStr |
1226 action:@selector(commandFromDock:) | 1201 action:@selector(commandFromDock:) |
1227 keyEquivalent:@""]); | 1202 keyEquivalent:@""]); |
John Gregg
2011/01/20 23:00:21
super nitpicky, but I don't think this is formatte
| |
1228 [item setTarget:self]; | 1203 [item setTarget:self]; |
1229 [item setTag:IDC_NEW_WINDOW]; | 1204 [item setTag:IDC_NEW_WINDOW]; |
1230 [dockMenu addItem:item]; | 1205 [dockMenu addItem:item]; |
1231 | 1206 |
1232 titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC); | 1207 titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC); |
1233 item.reset([[NSMenuItem alloc] initWithTitle:titleStr | 1208 item.reset([[NSMenuItem alloc] initWithTitle:titleStr |
1234 action:@selector(commandFromDock:) | 1209 action:@selector(commandFromDock:) |
1235 keyEquivalent:@""]); | 1210 keyEquivalent:@""]); |
1236 [item setTarget:self]; | 1211 [item setTarget:self]; |
1237 [item setTag:IDC_NEW_INCOGNITO_WINDOW]; | 1212 [item setTag:IDC_NEW_INCOGNITO_WINDOW]; |
1238 [dockMenu addItem:item]; | 1213 [dockMenu addItem:item]; |
1239 | 1214 |
1215 // TODO(rickcam): Mock out BackgroundApplicationListModel, then add unit | |
1216 // tests which use the mock in place of the profile-initialized model. | |
1217 | |
1218 // Avoid breaking unit tests which have no profile. | |
1219 if (profile) { | |
1220 BackgroundApplicationListModel applications(profile); | |
1221 if (applications.size()) { | |
1222 int position = 0; | |
1223 NSString* menuStr = | |
1224 l10n_util::GetNSStringWithFixup(IDS_BACKGROUND_APPS_MAC); | |
1225 scoped_nsobject<NSMenu> appMenu([[NSMenu alloc] initWithTitle:menuStr]); | |
1226 for (ExtensionList::const_iterator cursor = applications.begin(); | |
1227 cursor != applications.end(); | |
1228 ++cursor, ++position) { | |
1229 DCHECK(position == applications.GetPosition(*cursor)); | |
1230 NSString* itemStr = | |
1231 base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name())); | |
1232 scoped_nsobject<NSMenuItem> appItem([[NSMenuItem alloc] | |
1233 initWithTitle:itemStr | |
1234 action:@selector(commandFromDock:) | |
1235 keyEquivalent:@""]); | |
1236 [appItem setTarget:self]; | |
1237 [appItem setTag:position]; | |
1238 [appMenu addItem:appItem]; | |
1239 } | |
1240 scoped_nsobject<NSMenuItem> appMenuItem([[NSMenuItem alloc] | |
1241 initWithTitle:menuStr | |
1242 action:@selector(commandFromDock:) | |
1243 keyEquivalent:@""]); | |
1244 [appMenuItem setTarget:self]; | |
1245 [appMenuItem setTag:position]; | |
1246 [appMenuItem setSubmenu:appMenu]; | |
1247 [dockMenu addItem:appMenuItem]; | |
1248 } | |
1249 } | |
1250 | |
1240 return dockMenu; | 1251 return dockMenu; |
1241 } | 1252 } |
1242 | 1253 |
1243 - (const std::vector<GURL>&)startupUrls { | 1254 - (const std::vector<GURL>&)startupUrls { |
1244 return startupUrls_; | 1255 return startupUrls_; |
1245 } | 1256 } |
1246 | 1257 |
1247 - (void)clearStartupUrls { | 1258 - (void)clearStartupUrls { |
1248 startupUrls_.clear(); | 1259 startupUrls_.clear(); |
1249 } | 1260 } |
(...skipping 10 matching lines...) Expand all Loading... | |
1260 [appController showPreferencesWindow:nil page:page profile:profile]; | 1271 [appController showPreferencesWindow:nil page:page profile:profile]; |
1261 } | 1272 } |
1262 | 1273 |
1263 namespace app_controller_mac { | 1274 namespace app_controller_mac { |
1264 | 1275 |
1265 bool IsOpeningNewWindow() { | 1276 bool IsOpeningNewWindow() { |
1266 return g_is_opening_new_window; | 1277 return g_is_opening_new_window; |
1267 } | 1278 } |
1268 | 1279 |
1269 } // namespace app_controller_mac | 1280 } // namespace app_controller_mac |
OLD | NEW |