| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by | 190 // Returns true if the Tab Detaching in Fullscreen is enabled. It's enabled by |
| 191 // default. | 191 // default. |
| 192 bool IsTabDetachingInFullscreenEnabled() { | 192 bool IsTabDetachingInFullscreenEnabled() { |
| 193 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 193 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 194 switches::kDisableFullscreenTabDetaching); | 194 switches::kDisableFullscreenTabDetaching); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace | 197 } // namespace |
| 198 | 198 |
| 199 @interface NSWindow (NSPrivateApis) | |
| 200 // Note: These functions are private, use -[NSObject respondsToSelector:] | |
| 201 // before calling them. | |
| 202 - (NSRect)_growBoxRect; | |
| 203 @end | |
| 204 | |
| 205 @implementation BrowserWindowController | 199 @implementation BrowserWindowController |
| 206 | 200 |
| 207 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { | 201 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { |
| 208 while (window) { | 202 while (window) { |
| 209 id controller = [window windowController]; | 203 id controller = [window windowController]; |
| 210 if ([controller isKindOfClass:[BrowserWindowController class]]) | 204 if ([controller isKindOfClass:[BrowserWindowController class]]) |
| 211 return (BrowserWindowController*)controller; | 205 return (BrowserWindowController*)controller; |
| 212 window = [window parentWindow]; | 206 window = [window parentWindow]; |
| 213 } | 207 } |
| 214 return nil; | 208 return nil; |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 // the window height only in two cases: | 938 // the window height only in two cases: |
| 945 // 1) We are adjusting the height of the bookmark bar and it is currently | 939 // 1) We are adjusting the height of the bookmark bar and it is currently |
| 946 // animating either open or closed. | 940 // animating either open or closed. |
| 947 // 2) We are adjusting the height of the download shelf. | 941 // 2) We are adjusting the height of the download shelf. |
| 948 // | 942 // |
| 949 // We do not adjust the window height for bookmark bar changes on the NTP. | 943 // We do not adjust the window height for bookmark bar changes on the NTP. |
| 950 BOOL shouldAdjustBookmarkHeight = | 944 BOOL shouldAdjustBookmarkHeight = |
| 951 [bookmarkBarController_ isAnimatingBetweenState:BookmarkBar::HIDDEN | 945 [bookmarkBarController_ isAnimatingBetweenState:BookmarkBar::HIDDEN |
| 952 andState:BookmarkBar::SHOW]; | 946 andState:BookmarkBar::SHOW]; |
| 953 | 947 |
| 954 BOOL resizeRectDirty = NO; | |
| 955 if ((shouldAdjustBookmarkHeight && view == [bookmarkBarController_ view]) || | 948 if ((shouldAdjustBookmarkHeight && view == [bookmarkBarController_ view]) || |
| 956 view == [downloadShelfController_ view]) { | 949 view == [downloadShelfController_ view]) { |
| 957 CGFloat deltaH = height - NSHeight(frame); | 950 CGFloat deltaH = height - NSHeight(frame); |
| 958 if ([self adjustWindowHeightBy:deltaH] && | 951 [self adjustWindowHeightBy:deltaH]; |
| 959 view == [downloadShelfController_ view]) { | |
| 960 // If the window height didn't change, the download shelf will change the | |
| 961 // size of the contents. If the contents size doesn't change, send it | |
| 962 // an explicit grow box invalidation (else, the resize message does that.) | |
| 963 resizeRectDirty = YES; | |
| 964 } | |
| 965 } | 952 } |
| 966 | 953 |
| 967 frame.size.height = height; | 954 frame.size.height = height; |
| 968 // TODO(rohitrao): Determine if calling setFrame: twice is bad. | 955 // TODO(rohitrao): Determine if calling setFrame: twice is bad. |
| 969 [view setFrame:frame]; | 956 [view setFrame:frame]; |
| 970 [self layoutSubviews]; | 957 [self layoutSubviews]; |
| 971 | 958 |
| 972 if (resizeRectDirty) { | |
| 973 // Send new resize rect to foreground tab. | |
| 974 if (WebContents* contents = [self webContents]) { | |
| 975 if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) { | |
| 976 rvh->GetWidget()->ResizeRectChanged( | |
| 977 windowShim_->GetRootWindowResizerRect()); | |
| 978 } | |
| 979 } | |
| 980 } | |
| 981 } | 959 } |
| 982 | 960 |
| 983 - (BOOL)handledByExtensionCommand:(NSEvent*)event | 961 - (BOOL)handledByExtensionCommand:(NSEvent*)event |
| 984 priority:(ui::AcceleratorManager::HandlerPriority)priority { | 962 priority:(ui::AcceleratorManager::HandlerPriority)priority { |
| 985 return extensionKeybindingRegistry_->ProcessKeyEvent( | 963 return extensionKeybindingRegistry_->ProcessKeyEvent( |
| 986 content::NativeWebKeyboardEvent(event), priority); | 964 content::NativeWebKeyboardEvent(event), priority); |
| 987 } | 965 } |
| 988 | 966 |
| 989 // StatusBubble delegate method: tell the status bubble the frame it should | 967 // StatusBubble delegate method: tell the status bubble the frame it should |
| 990 // position itself in. | 968 // position itself in. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 bool willFocusLocationBar = | 1008 bool willFocusLocationBar = |
| 1031 newContents && newContents->FocusLocationBarByDefault(); | 1009 newContents && newContents->FocusLocationBarByDefault(); |
| 1032 if ([self isInAnyFullscreenMode] && !willFocusLocationBar) | 1010 if ([self isInAnyFullscreenMode] && !willFocusLocationBar) |
| 1033 [[self fullscreenToolbarController] revealToolbarForTabStripChanges]; | 1011 [[self fullscreenToolbarController] revealToolbarForTabStripChanges]; |
| 1034 } | 1012 } |
| 1035 | 1013 |
| 1036 - (void)zoomChangedForActiveTab:(BOOL)canShowBubble { | 1014 - (void)zoomChangedForActiveTab:(BOOL)canShowBubble { |
| 1037 [toolbarController_ zoomChangedForActiveTab:canShowBubble]; | 1015 [toolbarController_ zoomChangedForActiveTab:canShowBubble]; |
| 1038 } | 1016 } |
| 1039 | 1017 |
| 1040 // Return the rect, in WebKit coordinates (flipped), of the window's grow box | |
| 1041 // in the coordinate system of the content area of the currently selected tab. | |
| 1042 // |windowGrowBox| needs to be in the window's coordinate system. | |
| 1043 - (NSRect)selectedTabGrowBoxRect { | |
| 1044 NSWindow* window = [self window]; | |
| 1045 if (![window respondsToSelector:@selector(_growBoxRect)]) | |
| 1046 return NSZeroRect; | |
| 1047 | |
| 1048 // Before we return a rect, we need to convert it from window coordinates | |
| 1049 // to tab content area coordinates and flip the coordinate system. | |
| 1050 NSRect growBoxRect = | |
| 1051 [[self tabContentArea] convertRect:[window _growBoxRect] fromView:nil]; | |
| 1052 growBoxRect.origin.y = | |
| 1053 NSHeight([[self tabContentArea] frame]) - NSMaxY(growBoxRect); | |
| 1054 return growBoxRect; | |
| 1055 } | |
| 1056 | |
| 1057 // Accept tabs from a BrowserWindowController with the same Profile. | 1018 // Accept tabs from a BrowserWindowController with the same Profile. |
| 1058 - (BOOL)canReceiveFrom:(TabWindowController*)source { | 1019 - (BOOL)canReceiveFrom:(TabWindowController*)source { |
| 1059 BrowserWindowController* realSource = | 1020 BrowserWindowController* realSource = |
| 1060 base::mac::ObjCCast<BrowserWindowController>(source); | 1021 base::mac::ObjCCast<BrowserWindowController>(source); |
| 1061 if (!realSource || browser_->profile() != realSource->browser_->profile()) { | 1022 if (!realSource || browser_->profile() != realSource->browser_->profile()) { |
| 1062 return NO; | 1023 return NO; |
| 1063 } | 1024 } |
| 1064 | 1025 |
| 1065 // Can't drag a tab from a normal browser to a pop-up | 1026 // Can't drag a tab from a normal browser to a pop-up |
| 1066 if (browser_->type() != realSource->browser_->type()) { | 1027 if (browser_->type() != realSource->browser_->type()) { |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 | 2010 |
| 2050 - (NSRect)savedRegularWindowFrame { | 2011 - (NSRect)savedRegularWindowFrame { |
| 2051 return savedRegularWindowFrame_; | 2012 return savedRegularWindowFrame_; |
| 2052 } | 2013 } |
| 2053 | 2014 |
| 2054 - (BOOL)isFullscreenTransitionInProgress { | 2015 - (BOOL)isFullscreenTransitionInProgress { |
| 2055 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; | 2016 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; |
| 2056 } | 2017 } |
| 2057 | 2018 |
| 2058 @end // @implementation BrowserWindowController(WindowType) | 2019 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |