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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 2679273002: [Mac] Retain location bar focus on switching to fullscreen and back. (Closed)
Patch Set: Undo previous change, add comment. Created 3 years, 7 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/browser_window_controller_unittest.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/ui/cocoa/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import "base/auto_reset.h" 9 #import "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 if ([[self.chromeContentView subviews] isEqual:subviews]) 1004 if ([[self.chromeContentView subviews] isEqual:subviews])
1005 return; 1005 return;
1006 1006
1007 // The tabContentArea isn't a subview, so just set all the subviews. 1007 // The tabContentArea isn't a subview, so just set all the subviews.
1008 NSView* tabContentArea = [self tabContentArea]; 1008 NSView* tabContentArea = [self tabContentArea];
1009 if (![[self.chromeContentView subviews] containsObject:tabContentArea]) { 1009 if (![[self.chromeContentView subviews] containsObject:tabContentArea]) {
1010 [self.chromeContentView setSubviews:subviews]; 1010 [self.chromeContentView setSubviews:subviews];
1011 return; 1011 return;
1012 } 1012 }
1013 1013
1014 // Removing the location bar from the window causes it to resign first
1015 // responder. Remember the location bar's focus state in order to restore
1016 // it before returning.
1017 BOOL locationBarHadFocus = [toolbarController_ locationBarHasFocus];
1018 FullscreenToolbarVisibilityLockController* visibilityLockController = nil;
1019 if (locationBarHadFocus) {
1020 // The location bar, by being focused, has a visibility lock on the toolbar,
1021 // and the location bar's removal from the view hierarchy will allow the
1022 // toolbar to hide. Create a temporary visibility lock on the toolbar for
1023 // the duration of the view hierarchy change.
1024 visibilityLockController = [self fullscreenToolbarVisibilityLockController];
1025 [visibilityLockController lockToolbarVisibilityForOwner:self
1026 withAnimation:NO];
1027 }
1028
1014 // Remove all subviews that aren't the tabContentArea. 1029 // Remove all subviews that aren't the tabContentArea.
1015 for (NSView* view in [[[self.chromeContentView subviews] copy] autorelease]) { 1030 for (NSView* view in [[[self.chromeContentView subviews] copy] autorelease]) {
1016 if (view != tabContentArea) 1031 if (view != tabContentArea)
1017 [view removeFromSuperview]; 1032 [view removeFromSuperview];
1018 } 1033 }
1019 1034
1020 // Add in the subviews below the tabContentArea. 1035 // Add in the subviews below the tabContentArea.
1021 NSInteger index = [subviews indexOfObject:tabContentArea]; 1036 NSInteger index = [subviews indexOfObject:tabContentArea];
1022 for (int i = index - 1; i >= 0; --i) { 1037 for (int i = index - 1; i >= 0; --i) {
1023 NSView* view = [subviews objectAtIndex:i]; 1038 NSView* view = [subviews objectAtIndex:i];
1024 [self.chromeContentView addSubview:view 1039 [self.chromeContentView addSubview:view
1025 positioned:NSWindowBelow 1040 positioned:NSWindowBelow
1026 relativeTo:nil]; 1041 relativeTo:nil];
1027 } 1042 }
1028 1043
1029 // Add in the subviews above the tabContentArea. 1044 // Add in the subviews above the tabContentArea.
1030 for (NSUInteger i = index + 1; i < [subviews count]; ++i) { 1045 for (NSUInteger i = index + 1; i < [subviews count]; ++i) {
1031 NSView* view = [subviews objectAtIndex:i]; 1046 NSView* view = [subviews objectAtIndex:i];
1032 [self.chromeContentView addSubview:view 1047 [self.chromeContentView addSubview:view
1033 positioned:NSWindowAbove 1048 positioned:NSWindowAbove
1034 relativeTo:nil]; 1049 relativeTo:nil];
1035 } 1050 }
1051
1052 // Restore the location bar's focus state and remove the temporary visibility
1053 // lock.
1054 if (locationBarHadFocus) {
1055 [self focusLocationBar:YES];
1056 [visibilityLockController releaseToolbarVisibilityForOwner:self
1057 withAnimation:NO];
1058 }
1036 } 1059 }
1037 1060
1038 + (BOOL)systemSettingsRequireMavericksAppKitFullscreenHack { 1061 + (BOOL)systemSettingsRequireMavericksAppKitFullscreenHack {
1039 if (!base::mac::IsOS10_9()) 1062 if (!base::mac::IsOS10_9())
1040 return NO; 1063 return NO;
1041 return [NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] && 1064 return [NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] &&
1042 [NSScreen screensHaveSeparateSpaces]; 1065 [NSScreen screensHaveSeparateSpaces];
1043 } 1066 }
1044 1067
1045 - (BOOL)shouldUseMavericksAppKitFullscreenHack { 1068 - (BOOL)shouldUseMavericksAppKitFullscreenHack {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 if (fullscreenLowPowerCoordinator_) 1209 if (fullscreenLowPowerCoordinator_)
1187 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false); 1210 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false);
1188 } 1211 }
1189 1212
1190 - (void)childWindowsDidChange { 1213 - (void)childWindowsDidChange {
1191 if (fullscreenLowPowerCoordinator_) 1214 if (fullscreenLowPowerCoordinator_)
1192 fullscreenLowPowerCoordinator_->ChildWindowsChanged(); 1215 fullscreenLowPowerCoordinator_->ChildWindowsChanged();
1193 } 1216 }
1194 1217
1195 @end // @implementation BrowserWindowController(Private) 1218 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698