OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 else | 1111 else |
1112 NOTREACHED() << "Nothing to open!"; | 1112 NOTREACHED() << "Nothing to open!"; |
1113 | 1113 |
1114 [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; | 1114 [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; |
1115 } | 1115 } |
1116 | 1116 |
1117 // Called when the preferences window is closed. We use this to release the | 1117 // Called when the preferences window is closed. We use this to release the |
1118 // window controller. | 1118 // window controller. |
1119 - (void)prefsWindowClosed:(NSNotification*)notification { | 1119 - (void)prefsWindowClosed:(NSNotification*)notification { |
1120 NSWindow* window = [prefsController_ window]; | 1120 NSWindow* window = [prefsController_ window]; |
1121 DCHECK([notification object] == window); | 1121 DCHECK_EQ([notification object], window); |
1122 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; | 1122 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; |
1123 [defaultCenter removeObserver:self | 1123 [defaultCenter removeObserver:self |
1124 name:NSWindowWillCloseNotification | 1124 name:NSWindowWillCloseNotification |
1125 object:window]; | 1125 object:window]; |
1126 // PreferencesWindowControllers are autoreleased in | 1126 // PreferencesWindowControllers are autoreleased in |
1127 // -[PreferencesWindowController windowWillClose:]. | 1127 // -[PreferencesWindowController windowWillClose:]. |
1128 prefsController_ = nil; | 1128 prefsController_ = nil; |
1129 } | 1129 } |
1130 | 1130 |
1131 // Show the preferences window, or bring it to the front if it's already | 1131 // Show the preferences window, or bring it to the front if it's already |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 name:NSWindowWillCloseNotification | 1164 name:NSWindowWillCloseNotification |
1165 object:[prefsController_ window]]; | 1165 object:[prefsController_ window]]; |
1166 } | 1166 } |
1167 [prefsController_ showPreferences:sender]; | 1167 [prefsController_ showPreferences:sender]; |
1168 } | 1168 } |
1169 | 1169 |
1170 // Called when the about window is closed. We use this to release the | 1170 // Called when the about window is closed. We use this to release the |
1171 // window controller. | 1171 // window controller. |
1172 - (void)aboutWindowClosed:(NSNotification*)notification { | 1172 - (void)aboutWindowClosed:(NSNotification*)notification { |
1173 NSWindow* window = [aboutController_ window]; | 1173 NSWindow* window = [aboutController_ window]; |
1174 DCHECK(window == [notification object]); | 1174 DCHECK_EQ(window, [notification object]); |
1175 [[NSNotificationCenter defaultCenter] | 1175 [[NSNotificationCenter defaultCenter] |
1176 removeObserver:self | 1176 removeObserver:self |
1177 name:NSWindowWillCloseNotification | 1177 name:NSWindowWillCloseNotification |
1178 object:window]; | 1178 object:window]; |
1179 // AboutWindowControllers are autoreleased in | 1179 // AboutWindowControllers are autoreleased in |
1180 // -[AboutWindowController windowWillClose:]. | 1180 // -[AboutWindowController windowWillClose:]. |
1181 aboutController_ = nil; | 1181 aboutController_ = nil; |
1182 } | 1182 } |
1183 | 1183 |
1184 - (IBAction)orderFrontStandardAboutPanel:(id)sender { | 1184 - (IBAction)orderFrontStandardAboutPanel:(id)sender { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 if (profile) { | 1232 if (profile) { |
1233 BackgroundApplicationListModel applications(profile); | 1233 BackgroundApplicationListModel applications(profile); |
1234 if (applications.size()) { | 1234 if (applications.size()) { |
1235 int position = 0; | 1235 int position = 0; |
1236 NSString* menuStr = | 1236 NSString* menuStr = |
1237 l10n_util::GetNSStringWithFixup(IDS_BACKGROUND_APPS_MAC); | 1237 l10n_util::GetNSStringWithFixup(IDS_BACKGROUND_APPS_MAC); |
1238 scoped_nsobject<NSMenu> appMenu([[NSMenu alloc] initWithTitle:menuStr]); | 1238 scoped_nsobject<NSMenu> appMenu([[NSMenu alloc] initWithTitle:menuStr]); |
1239 for (ExtensionList::const_iterator cursor = applications.begin(); | 1239 for (ExtensionList::const_iterator cursor = applications.begin(); |
1240 cursor != applications.end(); | 1240 cursor != applications.end(); |
1241 ++cursor, ++position) { | 1241 ++cursor, ++position) { |
1242 DCHECK(position == applications.GetPosition(*cursor)); | 1242 DCHECK_EQ(position, applications.GetPosition(*cursor)); |
1243 NSString* itemStr = | 1243 NSString* itemStr = |
1244 base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name())); | 1244 base::SysUTF16ToNSString(UTF8ToUTF16((*cursor)->name())); |
1245 scoped_nsobject<NSMenuItem> appItem([[NSMenuItem alloc] | 1245 scoped_nsobject<NSMenuItem> appItem([[NSMenuItem alloc] |
1246 initWithTitle:itemStr | 1246 initWithTitle:itemStr |
1247 action:@selector(commandFromDock:) | 1247 action:@selector(commandFromDock:) |
1248 keyEquivalent:@""]); | 1248 keyEquivalent:@""]); |
1249 [appItem setTarget:self]; | 1249 [appItem setTarget:self]; |
1250 [appItem setTag:position]; | 1250 [appItem setTag:position]; |
1251 [appMenu addItem:appItem]; | 1251 [appMenu addItem:appItem]; |
1252 } | 1252 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 [appController showPreferencesWindow:nil page:page profile:profile]; | 1284 [appController showPreferencesWindow:nil page:page profile:profile]; |
1285 } | 1285 } |
1286 | 1286 |
1287 namespace app_controller_mac { | 1287 namespace app_controller_mac { |
1288 | 1288 |
1289 bool IsOpeningNewWindow() { | 1289 bool IsOpeningNewWindow() { |
1290 return g_is_opening_new_window; | 1290 return g_is_opening_new_window; |
1291 } | 1291 } |
1292 | 1292 |
1293 } // namespace app_controller_mac | 1293 } // namespace app_controller_mac |
OLD | NEW |