| 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 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // Give beforeunload handlers the chance to cancel the close before we hide | 589 // Give beforeunload handlers the chance to cancel the close before we hide |
| 590 // the window below. | 590 // the window below. |
| 591 if (!browser_->ShouldCloseWindow()) | 591 if (!browser_->ShouldCloseWindow()) |
| 592 return NO; | 592 return NO; |
| 593 | 593 |
| 594 // saveWindowPositionIfNeeded: only works if we are the last active | 594 // saveWindowPositionIfNeeded: only works if we are the last active |
| 595 // window, but orderOut: ends up activating another window, so we | 595 // window, but orderOut: ends up activating another window, so we |
| 596 // have to save the window position before we call orderOut:. | 596 // have to save the window position before we call orderOut:. |
| 597 [self saveWindowPositionIfNeeded]; | 597 [self saveWindowPositionIfNeeded]; |
| 598 | 598 |
| 599 bool fast_tab_closing_enabled = |
| 600 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableFastUnload); |
| 601 |
| 599 if (!browser_->tab_strip_model()->empty()) { | 602 if (!browser_->tab_strip_model()->empty()) { |
| 600 // Tab strip isn't empty. Hide the frame (so it appears to have closed | 603 // Tab strip isn't empty. Hide the frame (so it appears to have closed |
| 601 // immediately) and close all the tabs, allowing the renderers to shut | 604 // immediately) and close all the tabs, allowing the renderers to shut |
| 602 // down. When the tab strip is empty we'll be called back again. | 605 // down. When the tab strip is empty we'll be called back again. |
| 603 [[self window] orderOut:self]; | 606 [[self window] orderOut:self]; |
| 604 browser_->OnWindowClosing(); | 607 browser_->OnWindowClosing(); |
| 608 if (fast_tab_closing_enabled) |
| 609 browser_->tab_strip_model()->CloseAllTabs(); |
| 610 return NO; |
| 611 } else if (fast_tab_closing_enabled && |
| 612 !browser_->HasCompletedUnloadProcessing()) { |
| 613 // The browser needs to finish running unload handlers. |
| 614 // Hide the window (so it appears to have closed immediately), and |
| 615 // the browser will call us back again when it is ready to close. |
| 616 [[self window] orderOut:self]; |
| 605 return NO; | 617 return NO; |
| 606 } | 618 } |
| 607 | 619 |
| 608 // the tab strip is empty, it's ok to close the window | 620 // the tab strip is empty, it's ok to close the window |
| 609 return YES; | 621 return YES; |
| 610 } | 622 } |
| 611 | 623 |
| 612 // Called right after our window became the main window. | 624 // Called right after our window became the main window. |
| 613 - (void)windowDidBecomeMain:(NSNotification*)notification { | 625 - (void)windowDidBecomeMain:(NSNotification*)notification { |
| 614 BrowserList::SetLastActive(browser_.get()); | 626 BrowserList::SetLastActive(browser_.get()); |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 | 2266 |
| 2255 - (BOOL)supportsBookmarkBar { | 2267 - (BOOL)supportsBookmarkBar { |
| 2256 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2268 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2257 } | 2269 } |
| 2258 | 2270 |
| 2259 - (BOOL)isTabbedWindow { | 2271 - (BOOL)isTabbedWindow { |
| 2260 return browser_->is_type_tabbed(); | 2272 return browser_->is_type_tabbed(); |
| 2261 } | 2273 } |
| 2262 | 2274 |
| 2263 @end // @implementation BrowserWindowController(WindowType) | 2275 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |