| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease]; | 1219 NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease]; |
| 1220 Profile* profile = [self lastProfile]; | 1220 Profile* profile = [self lastProfile]; |
| 1221 | 1221 |
| 1222 BOOL profilesAdded = [profileMenuController_ insertItemsIntoMenu:dockMenu | 1222 BOOL profilesAdded = [profileMenuController_ insertItemsIntoMenu:dockMenu |
| 1223 atOffset:0 | 1223 atOffset:0 |
| 1224 fromDock:YES]; | 1224 fromDock:YES]; |
| 1225 if (profilesAdded) | 1225 if (profilesAdded) |
| 1226 [dockMenu addItem:[NSMenuItem separatorItem]]; | 1226 [dockMenu addItem:[NSMenuItem separatorItem]]; |
| 1227 | 1227 |
| 1228 NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC); | 1228 NSString* titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_WINDOW_MAC); |
| 1229 scoped_nsobject<NSMenuItem> item( | 1229 base::scoped_nsobject<NSMenuItem> item( |
| 1230 [[NSMenuItem alloc] initWithTitle:titleStr | 1230 [[NSMenuItem alloc] initWithTitle:titleStr |
| 1231 action:@selector(commandFromDock:) | 1231 action:@selector(commandFromDock:) |
| 1232 keyEquivalent:@""]); | 1232 keyEquivalent:@""]); |
| 1233 [item setTarget:self]; | 1233 [item setTarget:self]; |
| 1234 [item setTag:IDC_NEW_WINDOW]; | 1234 [item setTag:IDC_NEW_WINDOW]; |
| 1235 [item setEnabled:[self validateUserInterfaceItem:item]]; | 1235 [item setEnabled:[self validateUserInterfaceItem:item]]; |
| 1236 [dockMenu addItem:item]; | 1236 [dockMenu addItem:item]; |
| 1237 | 1237 |
| 1238 titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC); | 1238 titleStr = l10n_util::GetNSStringWithFixup(IDS_NEW_INCOGNITO_WINDOW_MAC); |
| 1239 item.reset( | 1239 item.reset( |
| 1240 [[NSMenuItem alloc] initWithTitle:titleStr | 1240 [[NSMenuItem alloc] initWithTitle:titleStr |
| 1241 action:@selector(commandFromDock:) | 1241 action:@selector(commandFromDock:) |
| 1242 keyEquivalent:@""]); | 1242 keyEquivalent:@""]); |
| 1243 [item setTarget:self]; | 1243 [item setTarget:self]; |
| 1244 [item setTag:IDC_NEW_INCOGNITO_WINDOW]; | 1244 [item setTag:IDC_NEW_INCOGNITO_WINDOW]; |
| 1245 [item setEnabled:[self validateUserInterfaceItem:item]]; | 1245 [item setEnabled:[self validateUserInterfaceItem:item]]; |
| 1246 [dockMenu addItem:item]; | 1246 [dockMenu addItem:item]; |
| 1247 | 1247 |
| 1248 // TODO(rickcam): Mock out BackgroundApplicationListModel, then add unit | 1248 // TODO(rickcam): Mock out BackgroundApplicationListModel, then add unit |
| 1249 // tests which use the mock in place of the profile-initialized model. | 1249 // tests which use the mock in place of the profile-initialized model. |
| 1250 | 1250 |
| 1251 // Avoid breaking unit tests which have no profile. | 1251 // Avoid breaking unit tests which have no profile. |
| 1252 if (profile) { | 1252 if (profile) { |
| 1253 BackgroundApplicationListModel applications(profile); | 1253 BackgroundApplicationListModel applications(profile); |
| 1254 if (applications.size()) { | 1254 if (applications.size()) { |
| 1255 int position = 0; | 1255 int position = 0; |
| 1256 NSString* menuStr = | 1256 NSString* menuStr = |
| 1257 l10n_util::GetNSStringWithFixup(IDS_BACKGROUND_APPS_MAC); | 1257 l10n_util::GetNSStringWithFixup(IDS_BACKGROUND_APPS_MAC); |
| 1258 scoped_nsobject<NSMenu> appMenu([[NSMenu alloc] initWithTitle:menuStr]); | 1258 base::scoped_nsobject<NSMenu> appMenu( |
| 1259 [[NSMenu alloc] initWithTitle:menuStr]); |
| 1259 for (extensions::ExtensionList::const_iterator cursor = | 1260 for (extensions::ExtensionList::const_iterator cursor = |
| 1260 applications.begin(); | 1261 applications.begin(); |
| 1261 cursor != applications.end(); | 1262 cursor != applications.end(); |
| 1262 ++cursor, ++position) { | 1263 ++cursor, ++position) { |
| 1263 DCHECK_EQ(applications.GetPosition(*cursor), position); | 1264 DCHECK_EQ(applications.GetPosition(*cursor), position); |
| 1264 NSString* itemStr = | 1265 NSString* itemStr = |
| 1265 base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name())); | 1266 base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name())); |
| 1266 scoped_nsobject<NSMenuItem> appItem([[NSMenuItem alloc] | 1267 base::scoped_nsobject<NSMenuItem> appItem( |
| 1267 initWithTitle:itemStr | 1268 [[NSMenuItem alloc] initWithTitle:itemStr |
| 1268 action:@selector(executeApplication:) | 1269 action:@selector(executeApplication:) |
| 1269 keyEquivalent:@""]); | 1270 keyEquivalent:@""]); |
| 1270 [appItem setTarget:self]; | 1271 [appItem setTarget:self]; |
| 1271 [appItem setTag:position]; | 1272 [appItem setTag:position]; |
| 1272 [appMenu addItem:appItem]; | 1273 [appMenu addItem:appItem]; |
| 1273 } | 1274 } |
| 1274 } | 1275 } |
| 1275 } | 1276 } |
| 1276 | 1277 |
| 1277 return dockMenu; | 1278 return dockMenu; |
| 1278 } | 1279 } |
| 1279 | 1280 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 | 1314 |
| 1314 //--------------------------------------------------------------------------- | 1315 //--------------------------------------------------------------------------- |
| 1315 | 1316 |
| 1316 namespace app_controller_mac { | 1317 namespace app_controller_mac { |
| 1317 | 1318 |
| 1318 bool IsOpeningNewWindow() { | 1319 bool IsOpeningNewWindow() { |
| 1319 return g_is_opening_new_window; | 1320 return g_is_opening_new_window; |
| 1320 } | 1321 } |
| 1321 | 1322 |
| 1322 } // namespace app_controller_mac | 1323 } // namespace app_controller_mac |
| OLD | NEW |