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

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

Issue 7621061: Restoring a session should restore window minimization state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pushing MAC_OS_X_VERSION_10_7 defines back down into .mm files. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // can override it in a unit test. 216 // can override it in a unit test.
217 NSString* nibpath = [base::mac::MainAppBundle() 217 NSString* nibpath = [base::mac::MainAppBundle()
218 pathForResource:@"BrowserWindow" 218 pathForResource:@"BrowserWindow"
219 ofType:@"nib"]; 219 ofType:@"nib"];
220 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { 220 if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
221 DCHECK(browser); 221 DCHECK(browser);
222 initializing_ = YES; 222 initializing_ = YES;
223 browser_.reset(browser); 223 browser_.reset(browser);
224 ownsBrowser_ = ownIt; 224 ownsBrowser_ = ownIt;
225 NSWindow* window = [self window]; 225 NSWindow* window = [self window];
226 windowShim_.reset(new BrowserWindowCocoa(browser, self, window)); 226 windowShim_.reset(new BrowserWindowCocoa(browser, self));
227 227
228 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully 228 // 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. 229 // be big enough to hold all locks that'll ever be needed.
230 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); 230 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]);
231 231
232 // Sets the window to not have rounded corners, which prevents 232 // Sets the window to not have rounded corners, which prevents
233 // the resize control from being inset slightly and looking ugly. 233 // the resize control from being inset slightly and looking ugly.
234 if ([window respondsToSelector:@selector(setBottomCornerRounded:)]) 234 if ([window respondsToSelector:@selector(setBottomCornerRounded:)])
235 [window setBottomCornerRounded:NO]; 235 [window setBottomCornerRounded:NO];
236 236
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // We need to deactivate the controls (in the "WebView"). To do this, get the 607 // We need to deactivate the controls (in the "WebView"). To do this, get the
608 // selected TabContents's RenderWidgetHostView and tell it to deactivate. 608 // selected TabContents's RenderWidgetHostView and tell it to deactivate.
609 if (TabContents* contents = browser_->GetSelectedTabContents()) { 609 if (TabContents* contents = browser_->GetSelectedTabContents()) {
610 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 610 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
611 rwhv->SetActive(false); 611 rwhv->SetActive(false);
612 } 612 }
613 } 613 }
614 614
615 // Called when we have been minimized. 615 // Called when we have been minimized.
616 - (void)windowDidMiniaturize:(NSNotification *)notification { 616 - (void)windowDidMiniaturize:(NSNotification *)notification {
617 [self saveWindowPositionIfNeeded];
618
617 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 619 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
618 if (TabContents* contents = browser_->GetSelectedTabContents()) { 620 if (TabContents* contents = browser_->GetSelectedTabContents()) {
619 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 621 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
620 rwhv->SetWindowVisibility(false); 622 rwhv->SetWindowVisibility(false);
621 } 623 }
622 } 624 }
623 625
624 // Called when we have been unminimized. 626 // Called when we have been unminimized.
625 - (void)windowDidDeminiaturize:(NSNotification *)notification { 627 - (void)windowDidDeminiaturize:(NSNotification *)notification {
626 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 628 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 1758
1757 if (command && browser_->command_updater()->IsCommandEnabled(command)) { 1759 if (command && browser_->command_updater()->IsCommandEnabled(command)) {
1758 currentZoomStepDelta_ += (command == IDC_ZOOM_PLUS) ? 1 : -1; 1760 currentZoomStepDelta_ += (command == IDC_ZOOM_PLUS) ? 1 : -1;
1759 browser_->ExecuteCommandWithDisposition(command, 1761 browser_->ExecuteCommandWithDisposition(command,
1760 event_utils::WindowOpenDispositionFromNSEvent(event)); 1762 event_utils::WindowOpenDispositionFromNSEvent(event));
1761 } 1763 }
1762 } 1764 }
1763 1765
1764 // Delegate method called when window is resized. 1766 // Delegate method called when window is resized.
1765 - (void)windowDidResize:(NSNotification*)notification { 1767 - (void)windowDidResize:(NSNotification*)notification {
1768 [self saveWindowPositionIfNeeded];
1769
1766 // Resize (and possibly move) the status bubble. Note that we may get called 1770 // Resize (and possibly move) the status bubble. Note that we may get called
1767 // when the status bubble does not exist. 1771 // when the status bubble does not exist.
1768 if (statusBubble_) { 1772 if (statusBubble_) {
1769 statusBubble_->UpdateSizeAndPosition(); 1773 statusBubble_->UpdateSizeAndPosition();
1770 } 1774 }
1771 1775
1772 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 1776 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
1773 if (TabContents* contents = browser_->GetSelectedTabContents()) { 1777 if (TabContents* contents = browser_->GetSelectedTabContents()) {
1774 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 1778 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
1775 rwhv->WindowFrameChanged(); 1779 rwhv->WindowFrameChanged();
(...skipping 20 matching lines...) Expand all
1796 google_util::AppendGoogleLocaleParam(GURL(chrome::kCrashReasonURL)); 1800 google_util::AppendGoogleLocaleParam(GURL(chrome::kCrashReasonURL));
1797 tab_contents->OpenURL(helpUrl, GURL(), CURRENT_TAB, PageTransition::LINK); 1801 tab_contents->OpenURL(helpUrl, GURL(), CURRENT_TAB, PageTransition::LINK);
1798 } 1802 }
1799 } 1803 }
1800 } 1804 }
1801 1805
1802 // Delegate method called when window did move. (See below for why we don't use 1806 // Delegate method called when window did move. (See below for why we don't use
1803 // |-windowWillMove:|, which is called less frequently than |-windowDidMove| 1807 // |-windowWillMove:|, which is called less frequently than |-windowDidMove|
1804 // instead.) 1808 // instead.)
1805 - (void)windowDidMove:(NSNotification*)notification { 1809 - (void)windowDidMove:(NSNotification*)notification {
1810 [self saveWindowPositionIfNeeded];
1811
1806 NSWindow* window = [self window]; 1812 NSWindow* window = [self window];
1807 NSRect windowFrame = [window frame]; 1813 NSRect windowFrame = [window frame];
1808 NSRect workarea = [[window screen] visibleFrame]; 1814 NSRect workarea = [[window screen] visibleFrame];
1809 1815
1810 // We reset the window growth state whenever the window is moved out of the 1816 // 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. 1817 // work area or away (up or down) from the bottom or top of the work area.
1812 // Unfortunately, Cocoa sends |-windowWillMove:| too frequently (including 1818 // Unfortunately, Cocoa sends |-windowWillMove:| too frequently (including
1813 // when clicking on the title bar to activate), and of course 1819 // when clicking on the title bar to activate), and of course
1814 // |-windowWillMove| is called too early for us to apply our heuristic. (The 1820 // |-windowWillMove| is called too early for us to apply our heuristic. (The
1815 // heuristic we use for detecting window movement is that if |windowTopGrowth_ 1821 // heuristic we use for detecting window movement is that if |windowTopGrowth_
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 2186
2181 - (BOOL)supportsBookmarkBar { 2187 - (BOOL)supportsBookmarkBar {
2182 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2188 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2183 } 2189 }
2184 2190
2185 - (BOOL)isTabbedWindow { 2191 - (BOOL)isTabbedWindow {
2186 return browser_->is_type_tabbed(); 2192 return browser_->is_type_tabbed();
2187 } 2193 }
2188 2194
2189 @end // @implementation BrowserWindowController(WindowType) 2195 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698