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

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

Issue 2821011: Removes phantom tabs. (Closed)
Patch Set: Created 10 years, 6 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
« no previous file with comments | « chrome/browser/browser_browsertest.cc ('k') | chrome/browser/cocoa/tab_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/browser_window_controller.h" 5 #import "chrome/browser/cocoa/browser_window_controller.h"
6 6
7 #include <Carbon/Carbon.h> 7 #include <Carbon/Carbon.h>
8 8
9 #include "app/l10n_util_mac.h" 9 #include "app/l10n_util_mac.h"
10 #include "base/mac_util.h" 10 #include "base/mac_util.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 withObject:nil 363 withObject:nil
364 afterDelay:0]; 364 afterDelay:0];
365 } 365 }
366 366
367 // Called when the window meets the criteria to be closed (ie, 367 // Called when the window meets the criteria to be closed (ie,
368 // |-windowShouldClose:| returns YES). We must be careful to preserve the 368 // |-windowShouldClose:| returns YES). We must be careful to preserve the
369 // semantics of BrowserWindow::Close() and not call the Browser's dtor directly 369 // semantics of BrowserWindow::Close() and not call the Browser's dtor directly
370 // from this method. 370 // from this method.
371 - (void)windowWillClose:(NSNotification*)notification { 371 - (void)windowWillClose:(NSNotification*)notification {
372 DCHECK_EQ([notification object], [self window]); 372 DCHECK_EQ([notification object], [self window]);
373 DCHECK(!browser_->tabstrip_model()->HasNonPhantomTabs() || 373 DCHECK(browser_->tabstrip_model()->empty());
374 !browser_->tabstrip_model()->count());
375 [savedRegularWindow_ close]; 374 [savedRegularWindow_ close];
376 // We delete statusBubble here because we need to kill off the dependency 375 // We delete statusBubble here because we need to kill off the dependency
377 // that its window has on our window before our window goes away. 376 // that its window has on our window before our window goes away.
378 delete statusBubble_; 377 delete statusBubble_;
379 statusBubble_ = NULL; 378 statusBubble_ = NULL;
380 // We can't actually use |-autorelease| here because there's an embedded 379 // We can't actually use |-autorelease| here because there's an embedded
381 // run loop in the |-performClose:| which contains its own autorelease pool. 380 // run loop in the |-performClose:| which contains its own autorelease pool.
382 // Instead call it after a zero-length delay, which gets us back to the main 381 // Instead call it after a zero-length delay, which gets us back to the main
383 // event loop. 382 // event loop.
384 [self performSelector:@selector(autorelease) 383 [self performSelector:@selector(autorelease)
(...skipping 25 matching lines...) Expand all
410 // Give beforeunload handlers the chance to cancel the close before we hide 409 // Give beforeunload handlers the chance to cancel the close before we hide
411 // the window below. 410 // the window below.
412 if (!browser_->ShouldCloseWindow()) 411 if (!browser_->ShouldCloseWindow())
413 return NO; 412 return NO;
414 413
415 // saveWindowPositionIfNeeded: only works if we are the last active 414 // saveWindowPositionIfNeeded: only works if we are the last active
416 // window, but orderOut: ends up activating another window, so we 415 // window, but orderOut: ends up activating another window, so we
417 // have to save the window position before we call orderOut:. 416 // have to save the window position before we call orderOut:.
418 [self saveWindowPositionIfNeeded]; 417 [self saveWindowPositionIfNeeded];
419 418
420 if (browser_->tabstrip_model()->HasNonPhantomTabs()) { 419 if (!browser_->tabstrip_model()->empty()) {
421 // Tab strip isn't empty. Hide the frame (so it appears to have closed 420 // Tab strip isn't empty. Hide the frame (so it appears to have closed
422 // immediately) and close all the tabs, allowing the renderers to shut 421 // immediately) and close all the tabs, allowing the renderers to shut
423 // down. When the tab strip is empty we'll be called back again. 422 // down. When the tab strip is empty we'll be called back again.
424 [[self window] orderOut:self]; 423 [[self window] orderOut:self];
425 browser_->OnWindowClosing(); 424 browser_->OnWindowClosing();
426 return NO; 425 return NO;
427 } 426 }
428 427
429 // the tab strip is empty, it's ok to close the window 428 // the tab strip is empty, it's ok to close the window
430 return YES; 429 return YES;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 CGFloat maxWidth = NSWidth([contentView frame]); 1263 CGFloat maxWidth = NSWidth([contentView frame]);
1265 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; 1264 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth];
1266 } 1265 }
1267 1266
1268 - (NSWindow*)createFullscreenWindow { 1267 - (NSWindow*)createFullscreenWindow {
1269 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] 1268 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]]
1270 autorelease]; 1269 autorelease];
1271 } 1270 }
1272 1271
1273 - (NSInteger)numberOfTabs { 1272 - (NSInteger)numberOfTabs {
1274 // count() includes pinned tabs (both live and phantom). 1273 // count() includes pinned tabs.
1275 return browser_->tabstrip_model()->count(); 1274 return browser_->tabstrip_model()->count();
1276 } 1275 }
1277 1276
1278 - (BOOL)hasLiveTabs { 1277 - (BOOL)hasLiveTabs {
1279 return browser_->tabstrip_model()->HasNonPhantomTabs(); 1278 return !browser_->tabstrip_model()->empty();
1280 } 1279 }
1281 1280
1282 - (NSString*)selectedTabTitle { 1281 - (NSString*)selectedTabTitle {
1283 TabContents* contents = browser_->tabstrip_model()->GetSelectedTabContents(); 1282 TabContents* contents = browser_->tabstrip_model()->GetSelectedTabContents();
1284 return base::SysUTF16ToNSString(contents->GetTitle()); 1283 return base::SysUTF16ToNSString(contents->GetTitle());
1285 } 1284 }
1286 1285
1287 - (NSRect)regularWindowFrame { 1286 - (NSRect)regularWindowFrame {
1288 return [self isFullscreen] ? [savedRegularWindow_ frame] : 1287 return [self isFullscreen] ? [savedRegularWindow_ frame] :
1289 [[self window] frame]; 1288 [[self window] frame];
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 1860
1862 - (BOOL)supportsBookmarkBar { 1861 - (BOOL)supportsBookmarkBar {
1863 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 1862 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
1864 } 1863 }
1865 1864
1866 - (BOOL)isNormalWindow { 1865 - (BOOL)isNormalWindow {
1867 return browser_->type() == Browser::TYPE_NORMAL; 1866 return browser_->type() == Browser::TYPE_NORMAL;
1868 } 1867 }
1869 1868
1870 @end // @implementation BrowserWindowController(WindowType) 1869 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/browser_browsertest.cc ('k') | chrome/browser/cocoa/tab_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698