Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/mac_util.h" | 9 #include "base/mac_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 } | 266 } |
| 267 BOOL windowWithMultipleTabs = | 267 BOOL windowWithMultipleTabs = |
| 268 (tabController && [tabController numberOfTabs] > 1); | 268 (tabController && [tabController numberOfTabs] > 1); |
| 269 [self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs]; | 269 [self adjustCloseWindowMenuItemKeyEquivalent:windowWithMultipleTabs]; |
| 270 [self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs]; | 270 [self adjustCloseTabMenuItemKeyEquivalent:windowWithMultipleTabs]; |
| 271 fileMenuUpdatePending_ = NO; | 271 fileMenuUpdatePending_ = NO; |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Fix up the "close tab/close window" command-key equivalents. We do this | 274 // Fix up the "close tab/close window" command-key equivalents. We do this |
| 275 // after a delay to ensure that window layer state has been set by the time | 275 // after a delay to ensure that window layer state has been set by the time |
| 276 // we do the enabling. | 276 // we do the enabling. This should only be called on the main thread, code that |
| 277 // calls this (even as a side-effect) from other threads needs to be fixed. | |
| 277 - (void)delayedFixCloseMenuItemKeyEquivalents { | 278 - (void)delayedFixCloseMenuItemKeyEquivalents { |
| 279 DCHECK([NSThread currentThread] == [NSThread mainThread]); | |
|
TVL
2010/01/21 16:03:33
why not just [NSThread isMainThread]?
| |
| 278 if (!fileMenuUpdatePending_) { | 280 if (!fileMenuUpdatePending_) { |
| 279 // The OS prefers keypresses to timers, so it's possible that a cmd-w | 281 // The OS prefers keypresses to timers, so it's possible that a cmd-w |
| 280 // can sneak in before this timer fires. In order to prevent that from | 282 // can sneak in before this timer fires. In order to prevent that from |
| 281 // having any bad consequences, just clear the keys combos altogether. They | 283 // having any bad consequences, just clear the keys combos altogether. They |
| 282 // will be reset when the timer eventually fires. | 284 // will be reset when the timer eventually fires. |
| 283 [self clearCloseMenuItemKeyEquivalents]; | 285 [self clearCloseMenuItemKeyEquivalents]; |
| 284 [self performSelector:@selector(fixCloseMenuItemKeyEquivalents) | 286 [self performSelectorOnMainThread:@selector(fixCloseMenuItemKeyEquivalents) |
| 285 withObject:nil | 287 withObject:nil |
| 286 afterDelay:0]; | 288 waitUntilDone:NO]; |
| 287 fileMenuUpdatePending_ = YES; | 289 fileMenuUpdatePending_ = YES; |
| 288 } | 290 } |
| 289 } | 291 } |
| 290 | 292 |
| 291 // Called when we get a notification about the window layering changing to | 293 // Called when we get a notification about the window layering changing to |
| 292 // update the UI based on the new main window. | 294 // update the UI based on the new main window. |
| 293 - (void)windowLayeringDidChange:(NSNotification*)notify { | 295 - (void)windowLayeringDidChange:(NSNotification*)notify { |
| 294 [self delayedFixCloseMenuItemKeyEquivalents]; | 296 [self delayedFixCloseMenuItemKeyEquivalents]; |
| 295 | 297 |
| 296 // TODO(pinkerton): If we have other things here, such as inspector panels | 298 // TODO(pinkerton): If we have other things here, such as inspector panels |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 [appController showPreferencesWindow:nil page:page profile:profile]; | 881 [appController showPreferencesWindow:nil page:page profile:profile]; |
| 880 } | 882 } |
| 881 | 883 |
| 882 namespace app_controller_mac { | 884 namespace app_controller_mac { |
| 883 | 885 |
| 884 bool IsOpeningNewWindow() { | 886 bool IsOpeningNewWindow() { |
| 885 return g_is_opening_new_window; | 887 return g_is_opening_new_window; |
| 886 } | 888 } |
| 887 | 889 |
| 888 } // namespace app_controller_mac | 890 } // namespace app_controller_mac |
| OLD | NEW |