| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <numeric> | 10 #include <numeric> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 @interface NSWindow (NSPrivateApis) | 149 @interface NSWindow (NSPrivateApis) |
| 150 // Note: These functions are private, use -[NSObject respondsToSelector:] | 150 // Note: These functions are private, use -[NSObject respondsToSelector:] |
| 151 // before calling them. | 151 // before calling them. |
| 152 | 152 |
| 153 - (void)setBottomCornerRounded:(BOOL)rounded; | 153 - (void)setBottomCornerRounded:(BOOL)rounded; |
| 154 | 154 |
| 155 - (NSRect)_growBoxRect; | 155 - (NSRect)_growBoxRect; |
| 156 | 156 |
| 157 @end | 157 @end |
| 158 | 158 |
| 159 // Provide the forward-declarations of new 10.7 SDK symbols so they can be | 159 // Replicate specific 10.7 SDK declarations for building with prior SDKs. |
| 160 // called when building with the 10.5 SDK. | |
| 161 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 160 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| 162 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 161 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
| 163 | 162 |
| 164 enum { | 163 enum { |
| 165 NSWindowAnimationBehaviorDefault = 0, | 164 NSWindowAnimationBehaviorDefault = 0, |
| 166 NSWindowAnimationBehaviorNone = 2, | 165 NSWindowAnimationBehaviorNone = 2, |
| 167 NSWindowAnimationBehaviorDocumentWindow = 3, | 166 NSWindowAnimationBehaviorDocumentWindow = 3, |
| 168 NSWindowAnimationBehaviorUtilityWindow = 4, | 167 NSWindowAnimationBehaviorUtilityWindow = 4, |
| 169 NSWindowAnimationBehaviorAlertPanel = 5 | 168 NSWindowAnimationBehaviorAlertPanel = 5 |
| 170 }; | 169 }; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // can override it in a unit test. | 215 // can override it in a unit test. |
| 217 NSString* nibpath = [base::mac::MainAppBundle() | 216 NSString* nibpath = [base::mac::MainAppBundle() |
| 218 pathForResource:@"BrowserWindow" | 217 pathForResource:@"BrowserWindow" |
| 219 ofType:@"nib"]; | 218 ofType:@"nib"]; |
| 220 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | 219 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
| 221 DCHECK(browser); | 220 DCHECK(browser); |
| 222 initializing_ = YES; | 221 initializing_ = YES; |
| 223 browser_.reset(browser); | 222 browser_.reset(browser); |
| 224 ownsBrowser_ = ownIt; | 223 ownsBrowser_ = ownIt; |
| 225 NSWindow* window = [self window]; | 224 NSWindow* window = [self window]; |
| 226 windowShim_.reset(new BrowserWindowCocoa(browser, self, window)); | 225 windowShim_.reset(new BrowserWindowCocoa(browser, self)); |
| 227 | 226 |
| 228 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully | 227 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully |
| 229 // be big enough to hold all locks that'll ever be needed. | 228 // be big enough to hold all locks that'll ever be needed. |
| 230 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); | 229 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); |
| 231 | 230 |
| 232 // Sets the window to not have rounded corners, which prevents | 231 // Sets the window to not have rounded corners, which prevents |
| 233 // the resize control from being inset slightly and looking ugly. | 232 // the resize control from being inset slightly and looking ugly. |
| 234 if ([window respondsToSelector:@selector(setBottomCornerRounded:)]) | 233 if ([window respondsToSelector:@selector(setBottomCornerRounded:)]) |
| 235 [window setBottomCornerRounded:NO]; | 234 [window setBottomCornerRounded:NO]; |
| 236 | 235 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // We need to deactivate the controls (in the "WebView"). To do this, get the | 606 // We need to deactivate the controls (in the "WebView"). To do this, get the |
| 608 // selected TabContents's RenderWidgetHostView and tell it to deactivate. | 607 // selected TabContents's RenderWidgetHostView and tell it to deactivate. |
| 609 if (TabContents* contents = browser_->GetSelectedTabContents()) { | 608 if (TabContents* contents = browser_->GetSelectedTabContents()) { |
| 610 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | 609 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 611 rwhv->SetActive(false); | 610 rwhv->SetActive(false); |
| 612 } | 611 } |
| 613 } | 612 } |
| 614 | 613 |
| 615 // Called when we have been minimized. | 614 // Called when we have been minimized. |
| 616 - (void)windowDidMiniaturize:(NSNotification *)notification { | 615 - (void)windowDidMiniaturize:(NSNotification *)notification { |
| 616 [self saveWindowPositionIfNeeded]; |
| 617 |
| 617 // Let the selected RenderWidgetHostView know, so that it can tell plugins. | 618 // Let the selected RenderWidgetHostView know, so that it can tell plugins. |
| 618 if (TabContents* contents = browser_->GetSelectedTabContents()) { | 619 if (TabContents* contents = browser_->GetSelectedTabContents()) { |
| 619 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | 620 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 620 rwhv->SetWindowVisibility(false); | 621 rwhv->SetWindowVisibility(false); |
| 621 } | 622 } |
| 622 } | 623 } |
| 623 | 624 |
| 624 // Called when we have been unminimized. | 625 // Called when we have been unminimized. |
| 625 - (void)windowDidDeminiaturize:(NSNotification *)notification { | 626 - (void)windowDidDeminiaturize:(NSNotification *)notification { |
| 626 // Let the selected RenderWidgetHostView know, so that it can tell plugins. | 627 // Let the selected RenderWidgetHostView know, so that it can tell plugins. |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 | 1757 |
| 1757 if (command && browser_->command_updater()->IsCommandEnabled(command)) { | 1758 if (command && browser_->command_updater()->IsCommandEnabled(command)) { |
| 1758 currentZoomStepDelta_ += (command == IDC_ZOOM_PLUS) ? 1 : -1; | 1759 currentZoomStepDelta_ += (command == IDC_ZOOM_PLUS) ? 1 : -1; |
| 1759 browser_->ExecuteCommandWithDisposition(command, | 1760 browser_->ExecuteCommandWithDisposition(command, |
| 1760 event_utils::WindowOpenDispositionFromNSEvent(event)); | 1761 event_utils::WindowOpenDispositionFromNSEvent(event)); |
| 1761 } | 1762 } |
| 1762 } | 1763 } |
| 1763 | 1764 |
| 1764 // Delegate method called when window is resized. | 1765 // Delegate method called when window is resized. |
| 1765 - (void)windowDidResize:(NSNotification*)notification { | 1766 - (void)windowDidResize:(NSNotification*)notification { |
| 1767 [self saveWindowPositionIfNeeded]; |
| 1768 |
| 1766 // Resize (and possibly move) the status bubble. Note that we may get called | 1769 // Resize (and possibly move) the status bubble. Note that we may get called |
| 1767 // when the status bubble does not exist. | 1770 // when the status bubble does not exist. |
| 1768 if (statusBubble_) { | 1771 if (statusBubble_) { |
| 1769 statusBubble_->UpdateSizeAndPosition(); | 1772 statusBubble_->UpdateSizeAndPosition(); |
| 1770 } | 1773 } |
| 1771 | 1774 |
| 1772 // Let the selected RenderWidgetHostView know, so that it can tell plugins. | 1775 // Let the selected RenderWidgetHostView know, so that it can tell plugins. |
| 1773 if (TabContents* contents = browser_->GetSelectedTabContents()) { | 1776 if (TabContents* contents = browser_->GetSelectedTabContents()) { |
| 1774 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | 1777 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 1775 rwhv->WindowFrameChanged(); | 1778 rwhv->WindowFrameChanged(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1796 google_util::AppendGoogleLocaleParam(GURL(chrome::kCrashReasonURL)); | 1799 google_util::AppendGoogleLocaleParam(GURL(chrome::kCrashReasonURL)); |
| 1797 tab_contents->OpenURL(helpUrl, GURL(), CURRENT_TAB, PageTransition::LINK); | 1800 tab_contents->OpenURL(helpUrl, GURL(), CURRENT_TAB, PageTransition::LINK); |
| 1798 } | 1801 } |
| 1799 } | 1802 } |
| 1800 } | 1803 } |
| 1801 | 1804 |
| 1802 // Delegate method called when window did move. (See below for why we don't use | 1805 // Delegate method called when window did move. (See below for why we don't use |
| 1803 // |-windowWillMove:|, which is called less frequently than |-windowDidMove| | 1806 // |-windowWillMove:|, which is called less frequently than |-windowDidMove| |
| 1804 // instead.) | 1807 // instead.) |
| 1805 - (void)windowDidMove:(NSNotification*)notification { | 1808 - (void)windowDidMove:(NSNotification*)notification { |
| 1809 [self saveWindowPositionIfNeeded]; |
| 1810 |
| 1806 NSWindow* window = [self window]; | 1811 NSWindow* window = [self window]; |
| 1807 NSRect windowFrame = [window frame]; | 1812 NSRect windowFrame = [window frame]; |
| 1808 NSRect workarea = [[window screen] visibleFrame]; | 1813 NSRect workarea = [[window screen] visibleFrame]; |
| 1809 | 1814 |
| 1810 // We reset the window growth state whenever the window is moved out of the | 1815 // We reset the window growth state whenever the window is moved out of the |
| 1811 // work area or away (up or down) from the bottom or top of the work area. | 1816 // work area or away (up or down) from the bottom or top of the work area. |
| 1812 // Unfortunately, Cocoa sends |-windowWillMove:| too frequently (including | 1817 // Unfortunately, Cocoa sends |-windowWillMove:| too frequently (including |
| 1813 // when clicking on the title bar to activate), and of course | 1818 // when clicking on the title bar to activate), and of course |
| 1814 // |-windowWillMove| is called too early for us to apply our heuristic. (The | 1819 // |-windowWillMove| is called too early for us to apply our heuristic. (The |
| 1815 // heuristic we use for detecting window movement is that if |windowTopGrowth_ | 1820 // heuristic we use for detecting window movement is that if |windowTopGrowth_ |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 | 2185 |
| 2181 - (BOOL)supportsBookmarkBar { | 2186 - (BOOL)supportsBookmarkBar { |
| 2182 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2187 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2183 } | 2188 } |
| 2184 | 2189 |
| 2185 - (BOOL)isTabbedWindow { | 2190 - (BOOL)isTabbedWindow { |
| 2186 return browser_->is_type_tabbed(); | 2191 return browser_->is_type_tabbed(); |
| 2187 } | 2192 } |
| 2188 | 2193 |
| 2189 @end // @implementation BrowserWindowController(WindowType) | 2194 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |