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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 // the window below. | 587 // the window below. |
588 if (!browser_->ShouldCloseWindow()) | 588 if (!browser_->ShouldCloseWindow()) |
589 return NO; | 589 return NO; |
590 | 590 |
591 // saveWindowPositionIfNeeded: only works if we are the last active | 591 // saveWindowPositionIfNeeded: only works if we are the last active |
592 // window, but orderOut: ends up activating another window, so we | 592 // window, but orderOut: ends up activating another window, so we |
593 // have to save the window position before we call orderOut:. | 593 // have to save the window position before we call orderOut:. |
594 [self saveWindowPositionIfNeeded]; | 594 [self saveWindowPositionIfNeeded]; |
595 | 595 |
596 if (!browser_->tab_strip_model()->empty()) { | 596 if (!browser_->tab_strip_model()->empty()) { |
597 // Tab strip isn't empty. Hide the frame (so it appears to have closed | 597 // Tab strip isn't empty. Hide the window (so it appears to have closed |
598 // immediately) and close all the tabs, allowing the renderers to shut | 598 // immediately) and close all the tabs, allowing the renderers to shut |
599 // down. When the tab strip is empty we'll be called back again. | 599 // down. When the tab strip is empty we'll be called back again. |
600 [[self window] orderOut:self]; | 600 [[self window] orderOut:self]; |
601 browser_->OnWindowClosing(); | 601 browser_->OnWindowClosing(); |
| 602 browser_->tab_strip_model()->CloseAllTabs(); |
| 603 return NO; |
| 604 } else if (!browser_->HasCompletedUnloadProcessing()) { |
| 605 // The browser needs to finish running unload handlers. |
| 606 // Hide the window (so it appears to have closed immediately), and |
| 607 // the browser will call us back again when it is ready to close. |
| 608 [[self window] orderOut:self]; |
602 return NO; | 609 return NO; |
603 } | 610 } |
604 | 611 |
605 // the tab strip is empty, it's ok to close the window | 612 // the tab strip is empty, it's ok to close the window |
606 return YES; | 613 return YES; |
607 } | 614 } |
608 | 615 |
609 // Called right after our window became the main window. | 616 // Called right after our window became the main window. |
610 - (void)windowDidBecomeMain:(NSNotification*)notification { | 617 - (void)windowDidBecomeMain:(NSNotification*)notification { |
611 BrowserList::SetLastActive(browser_.get()); | 618 BrowserList::SetLastActive(browser_.get()); |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 | 2246 |
2240 - (BOOL)supportsBookmarkBar { | 2247 - (BOOL)supportsBookmarkBar { |
2241 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2248 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2242 } | 2249 } |
2243 | 2250 |
2244 - (BOOL)isTabbedWindow { | 2251 - (BOOL)isTabbedWindow { |
2245 return browser_->is_type_tabbed(); | 2252 return browser_->is_type_tabbed(); |
2246 } | 2253 } |
2247 | 2254 |
2248 @end // @implementation BrowserWindowController(WindowType) | 2255 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |