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/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 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 // While we move views (and focus) around, disable any bar visibility changes. | 560 // While we move views (and focus) around, disable any bar visibility changes. |
561 [self disableBarVisibilityUpdates]; | 561 [self disableBarVisibilityUpdates]; |
562 | 562 |
563 // Retain the tab strip view while we remove it from its superview. | 563 // Retain the tab strip view while we remove it from its superview. |
564 base::scoped_nsobject<NSView> tabStripView; | 564 base::scoped_nsobject<NSView> tabStripView; |
565 if ([self hasTabStrip]) { | 565 if ([self hasTabStrip]) { |
566 tabStripView.reset([[self tabStripView] retain]); | 566 tabStripView.reset([[self tabStripView] retain]); |
567 [tabStripView removeFromSuperview]; | 567 [tabStripView removeFromSuperview]; |
568 } | 568 } |
569 | 569 |
| 570 // Ditto for the content view. |
| 571 base::scoped_nsobject<NSView> contentView( |
| 572 [[sourceWindow contentView] retain]); |
570 // Disable autoresizing of subviews while we move views around. This prevents | 573 // Disable autoresizing of subviews while we move views around. This prevents |
571 // spurious renderer resizes. | 574 // spurious renderer resizes. |
572 [self.chromeContentView setAutoresizesSubviews:NO]; | 575 [contentView setAutoresizesSubviews:NO]; |
573 [self.chromeContentView removeFromSuperview]; | 576 [contentView removeFromSuperview]; |
574 | 577 |
575 // Have to do this here, otherwise later calls can crash because the window | 578 // Have to do this here, otherwise later calls can crash because the window |
576 // has no delegate. | 579 // has no delegate. |
577 [sourceWindow setDelegate:nil]; | 580 [sourceWindow setDelegate:nil]; |
578 [destWindow setDelegate:self]; | 581 [destWindow setDelegate:self]; |
579 | 582 |
580 // With this call, valgrind complains that a "Conditional jump or move depends | 583 // With this call, valgrind complains that a "Conditional jump or move depends |
581 // on uninitialised value(s)". The error happens in -[NSThemeFrame | 584 // on uninitialised value(s)". The error happens in -[NSThemeFrame |
582 // drawOverlayRect:]. I'm pretty convinced this is an Apple bug, but there is | 585 // drawOverlayRect:]. I'm pretty convinced this is an Apple bug, but there is |
583 // no visual impact. I have been unable to tickle it away with other window | 586 // no visual impact. I have been unable to tickle it away with other window |
584 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt. | 587 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt. |
585 [self.chromeContentView setAutoresizesSubviews:YES]; | 588 [contentView setAutoresizesSubviews:YES]; |
586 [[destWindow contentView] addSubview:self.chromeContentView | 589 [destWindow setContentView:contentView]; |
587 positioned:NSWindowBelow | |
588 relativeTo:nil]; | |
589 self.chromeContentView.frame = [[destWindow contentView] bounds]; | |
590 | 590 |
591 // Move the incognito badge if present. | 591 // Move the incognito badge if present. |
592 if ([self shouldShowAvatar]) { | 592 if ([self shouldShowAvatar]) { |
593 NSView* avatarButtonView = [avatarButtonController_ view]; | 593 NSView* avatarButtonView = [avatarButtonController_ view]; |
594 | 594 |
595 [avatarButtonView removeFromSuperview]; | 595 [avatarButtonView removeFromSuperview]; |
596 [avatarButtonView setHidden:YES]; // Will be shown in layout. | 596 [avatarButtonView setHidden:YES]; // Will be shown in layout. |
597 [[destWindow cr_windowView] addSubview:avatarButtonView]; | 597 [[destWindow cr_windowView] addSubview:avatarButtonView]; |
598 } | 598 } |
599 | 599 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 | 885 |
886 - (void)windowDidEnterFullScreen:(NSNotification*)notification { | 886 - (void)windowDidEnterFullScreen:(NSNotification*)notification { |
887 // In Yosemite, some combination of the titlebar and toolbar always show in | 887 // In Yosemite, some combination of the titlebar and toolbar always show in |
888 // full-screen mode. We do not want either to show. Search for the window that | 888 // full-screen mode. We do not want either to show. Search for the window that |
889 // contains the views, and hide it. There is no need to ever unhide the view. | 889 // contains the views, and hide it. There is no need to ever unhide the view. |
890 // http://crbug.com/380235 | 890 // http://crbug.com/380235 |
891 if (base::mac::IsOSYosemiteOrLater()) { | 891 if (base::mac::IsOSYosemiteOrLater()) { |
892 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { | 892 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { |
893 if ([window | 893 if ([window |
894 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { | 894 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { |
895 [[window contentView] setHidden:YES]; | 895 [window.contentView setHidden:YES]; |
896 } | 896 } |
897 } | 897 } |
898 } | 898 } |
899 | 899 |
900 if (notification) // For System Fullscreen when non-nil. | 900 if (notification) // For System Fullscreen when non-nil. |
901 [self deregisterForContentViewResizeNotifications]; | 901 [self deregisterForContentViewResizeNotifications]; |
902 enteringFullscreen_ = NO; | 902 enteringFullscreen_ = NO; |
903 enteringPresentationMode_ = NO; | 903 enteringPresentationMode_ = NO; |
904 | 904 |
905 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 905 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 return; | 971 return; |
972 [presentationModeController_ ensureOverlayHiddenWithAnimation:animation | 972 [presentationModeController_ ensureOverlayHiddenWithAnimation:animation |
973 delay:delay]; | 973 delay:delay]; |
974 } | 974 } |
975 | 975 |
976 - (CGFloat)toolbarDividerOpacity { | 976 - (CGFloat)toolbarDividerOpacity { |
977 return [bookmarkBarController_ toolbarDividerOpacity]; | 977 return [bookmarkBarController_ toolbarDividerOpacity]; |
978 } | 978 } |
979 | 979 |
980 - (void)updateSubviewZOrder:(BOOL)inPresentationMode { | 980 - (void)updateSubviewZOrder:(BOOL)inPresentationMode { |
981 NSView* contentView = self.chromeContentView; | 981 NSView* contentView = [[self window] contentView]; |
982 NSView* toolbarView = [toolbarController_ view]; | 982 NSView* toolbarView = [toolbarController_ view]; |
983 | 983 |
984 if (inPresentationMode) { | 984 if (inPresentationMode) { |
985 // Toolbar is above tab contents so that it can slide down from top of | 985 // Toolbar is above tab contents so that it can slide down from top of |
986 // screen. | 986 // screen. |
987 [contentView cr_ensureSubview:toolbarView | 987 [contentView cr_ensureSubview:toolbarView |
988 isPositioned:NSWindowAbove | 988 isPositioned:NSWindowAbove |
989 relativeTo:[self tabContentArea]]; | 989 relativeTo:[self tabContentArea]]; |
990 } else { | 990 } else { |
991 // Toolbar is below tab contents so that the info bar arrow can appear above | 991 // Toolbar is below tab contents so that the info bar arrow can appear above |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 devTools->SetAllowOverlappingViews(allowOverlappingViews); | 1074 devTools->SetAllowOverlappingViews(allowOverlappingViews); |
1075 } | 1075 } |
1076 | 1076 |
1077 - (void)updateInfoBarTipVisibility { | 1077 - (void)updateInfoBarTipVisibility { |
1078 // If there's no toolbar then hide the infobar tip. | 1078 // If there's no toolbar then hide the infobar tip. |
1079 [infoBarContainerController_ | 1079 [infoBarContainerController_ |
1080 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; | 1080 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; |
1081 } | 1081 } |
1082 | 1082 |
1083 @end // @implementation BrowserWindowController(Private) | 1083 @end // @implementation BrowserWindowController(Private) |
OLD | NEW |