| 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 // the window below. | 579 // the window below. |
| 580 if (!browser_->ShouldCloseWindow()) | 580 if (!browser_->ShouldCloseWindow()) |
| 581 return NO; | 581 return NO; |
| 582 | 582 |
| 583 // saveWindowPositionIfNeeded: only works if we are the last active | 583 // saveWindowPositionIfNeeded: only works if we are the last active |
| 584 // window, but orderOut: ends up activating another window, so we | 584 // window, but orderOut: ends up activating another window, so we |
| 585 // have to save the window position before we call orderOut:. | 585 // have to save the window position before we call orderOut:. |
| 586 [self saveWindowPositionIfNeeded]; | 586 [self saveWindowPositionIfNeeded]; |
| 587 | 587 |
| 588 if (!browser_->tab_strip_model()->empty()) { | 588 if (!browser_->tab_strip_model()->empty()) { |
| 589 // Tab strip isn't empty. Hide the frame (so it appears to have closed |
| 590 // immediately) and close all the tabs, allowing the renderers to shut |
| 591 // down. When the tab strip is empty we'll be called back again. |
| 589 [[self window] orderOut:self]; | 592 [[self window] orderOut:self]; |
| 590 browser_->OnWindowClosing(); | 593 browser_->OnWindowClosing(); |
| 591 browser_->tab_strip_model()->CloseAllTabs(); | |
| 592 return NO; | |
| 593 } else if (!browser_->HasCompletedUnloadProcessing()) { | |
| 594 // The browser needs to finish running unload handlers. | |
| 595 // Hide the window (so it appears to have closed immediately), and | |
| 596 // the browser will call us back again when it is ready to close. | |
| 597 [[self window] orderOut:self]; | |
| 598 return NO; | 594 return NO; |
| 599 } | 595 } |
| 600 | 596 |
| 601 // the tab strip is empty, it's ok to close the window | 597 // the tab strip is empty, it's ok to close the window |
| 602 return YES; | 598 return YES; |
| 603 } | 599 } |
| 604 | 600 |
| 605 // Called right after our window became the main window. | 601 // Called right after our window became the main window. |
| 606 - (void)windowDidBecomeMain:(NSNotification*)notification { | 602 - (void)windowDidBecomeMain:(NSNotification*)notification { |
| 607 BrowserList::SetLastActive(browser_.get()); | 603 BrowserList::SetLastActive(browser_.get()); |
| (...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 | 2201 |
| 2206 - (BOOL)supportsBookmarkBar { | 2202 - (BOOL)supportsBookmarkBar { |
| 2207 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2203 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2208 } | 2204 } |
| 2209 | 2205 |
| 2210 - (BOOL)isTabbedWindow { | 2206 - (BOOL)isTabbedWindow { |
| 2211 return browser_->is_type_tabbed(); | 2207 return browser_->is_type_tabbed(); |
| 2212 } | 2208 } |
| 2213 | 2209 |
| 2214 @end // @implementation BrowserWindowController(WindowType) | 2210 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |