Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: chrome/browser/chrome_browser_application_mac.mm

Issue 1040993005: [Mac] A more robust way to ensure panels avoid key status on window close (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: static Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chrome_browser_application_mac.h" 5 #import "chrome/browser/chrome_browser_application_mac.h"
6 6
7 #import "base/auto_reset.h" 7 #import "base/auto_reset.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #import "base/logging.h" 10 #import "base/logging.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 - (void)_cycleWindowsReversed:(BOOL)arg1 { 644 - (void)_cycleWindowsReversed:(BOOL)arg1 {
645 base::AutoReset<BOOL> pin(&cyclingWindows_, YES); 645 base::AutoReset<BOOL> pin(&cyclingWindows_, YES);
646 [super _cycleWindowsReversed:arg1]; 646 [super _cycleWindowsReversed:arg1];
647 } 647 }
648 648
649 - (BOOL)isCyclingWindows { 649 - (BOOL)isCyclingWindows {
650 return cyclingWindows_; 650 return cyclingWindows_;
651 } 651 }
652 652
653 - (id)_removeWindow:(NSWindow*)window { 653 - (id)_removeWindow:(NSWindow*)window {
654 // Note _removeWindow is called from -[NSWindow dealloc], which can happen at
655 // unpredictable times due to reference counting. Just update state.
654 { 656 {
655 base::AutoLock lock(previousKeyWindowsLock_); 657 base::AutoLock lock(previousKeyWindowsLock_);
656 [self removePreviousKeyWindow:window]; 658 [self removePreviousKeyWindow:window];
657 } 659 }
658 id result = [super _removeWindow:window]; 660 return [super _removeWindow:window];
659
660 // Ensure app has a key window after a window is removed.
661 // OS wants to make a panel browser window key after closing an app window
662 // because panels use a higher priority window level, but panel windows may
663 // refuse to become key, leaving the app with no key window. The OS does
664 // not seem to consider other windows after the first window chosen refuses
665 // to become key. Force consideration of other windows here.
666 if ([self isActive] && [self keyWindow] == nil) {
667 NSWindow* key =
668 [self makeWindowsPerform:@selector(canBecomeKeyWindow) inOrder:YES];
669 [key makeKeyWindow];
670 }
671
672 // Return result from the super class. It appears to be the app that
673 // owns the removed window (determined via experimentation).
674 return result;
675 } 661 }
676 662
677 - (id)_setKeyWindow:(NSWindow*)window { 663 - (id)_setKeyWindow:(NSWindow*)window {
678 // |window| is nil when the current key window is being closed. 664 // |window| is nil when the current key window is being closed.
679 // A separate call follows with a new value when a new key window is set. 665 // A separate call follows with a new value when a new key window is set.
680 // Closed windows are not tracked in previousKeyWindows_. 666 // Closed windows are not tracked in previousKeyWindows_.
681 if (window != nil) { 667 if (window != nil) {
682 base::AutoLock lock(previousKeyWindowsLock_); 668 base::AutoLock lock(previousKeyWindowsLock_);
683 [self removePreviousKeyWindow:window]; 669 [self removePreviousKeyWindow:window];
684 NSWindow* currentKeyWindow = [self keyWindow]; 670 NSWindow* currentKeyWindow = [self keyWindow];
(...skipping 14 matching lines...) Expand all
699 std::vector<NSWindow*>::iterator window_iterator = 685 std::vector<NSWindow*>::iterator window_iterator =
700 std::find(previousKeyWindows_.begin(), 686 std::find(previousKeyWindows_.begin(),
701 previousKeyWindows_.end(), 687 previousKeyWindows_.end(),
702 window); 688 window);
703 if (window_iterator != previousKeyWindows_.end()) { 689 if (window_iterator != previousKeyWindows_.end()) {
704 previousKeyWindows_.erase(window_iterator); 690 previousKeyWindows_.erase(window_iterator);
705 } 691 }
706 } 692 }
707 693
708 @end 694 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698