| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/tabs/tab_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 tabContentsArray_.reset([[NSMutableArray alloc] init]); | 367 tabContentsArray_.reset([[NSMutableArray alloc] init]); |
| 368 tabArray_.reset([[NSMutableArray alloc] init]); | 368 tabArray_.reset([[NSMutableArray alloc] init]); |
| 369 NSWindow* browserWindow = [view window]; | 369 NSWindow* browserWindow = [view window]; |
| 370 | 370 |
| 371 // Important note: any non-tab subviews not added to |permanentSubviews_| | 371 // Important note: any non-tab subviews not added to |permanentSubviews_| |
| 372 // (see |-addSubviewToPermanentList:|) will be wiped out. | 372 // (see |-addSubviewToPermanentList:|) will be wiped out. |
| 373 permanentSubviews_.reset([[NSMutableArray alloc] init]); | 373 permanentSubviews_.reset([[NSMutableArray alloc] init]); |
| 374 | 374 |
| 375 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 375 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 376 defaultFavicon_.reset( | 376 defaultFavicon_.reset( |
| 377 [rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) retain]); | 377 rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).CopyNSImage()); |
| 378 | 378 |
| 379 [self setLeftIndentForControls:[[self class] defaultLeftIndentForControls]]; | 379 [self setLeftIndentForControls:[[self class] defaultLeftIndentForControls]]; |
| 380 [self setRightIndentForControls:0]; | 380 [self setRightIndentForControls:0]; |
| 381 | 381 |
| 382 // TODO(viettrungluu): WTF? "For some reason, if the view is present in the | 382 // TODO(viettrungluu): WTF? "For some reason, if the view is present in the |
| 383 // nib a priori, it draws correctly. If we create it in code and add it to | 383 // nib a priori, it draws correctly. If we create it in code and add it to |
| 384 // the tab view, it draws with all sorts of crazy artifacts." | 384 // the tab view, it draws with all sorts of crazy artifacts." |
| 385 newTabButton_ = [view getNewTabButton]; | 385 newTabButton_ = [view getNewTabButton]; |
| 386 [self addSubviewToPermanentList:newTabButton_]; | 386 [self addSubviewToPermanentList:newTabButton_]; |
| 387 [newTabButton_ setTarget:self]; | 387 [newTabButton_ setTarget:self]; |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 // Updates the current loading state, replacing the icon view with a favicon, | 1446 // Updates the current loading state, replacing the icon view with a favicon, |
| 1447 // a throbber, the default icon, or nothing at all. | 1447 // a throbber, the default icon, or nothing at all. |
| 1448 - (void)updateFaviconForContents:(TabContents*)contents | 1448 - (void)updateFaviconForContents:(TabContents*)contents |
| 1449 atIndex:(NSInteger)modelIndex { | 1449 atIndex:(NSInteger)modelIndex { |
| 1450 if (!contents) | 1450 if (!contents) |
| 1451 return; | 1451 return; |
| 1452 | 1452 |
| 1453 static NSImage* throbberWaitingImage = | 1453 static NSImage* throbberWaitingImage = |
| 1454 [ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 1454 ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 1455 IDR_THROBBER_WAITING) retain]; | 1455 IDR_THROBBER_WAITING).CopyNSImage(); |
| 1456 static NSImage* throbberLoadingImage = | 1456 static NSImage* throbberLoadingImage = |
| 1457 [ResourceBundle::GetSharedInstance().GetNativeImageNamed(IDR_THROBBER) | 1457 ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 1458 retain]; | 1458 IDR_THROBBER).CopyNSImage(); |
| 1459 static NSImage* sadFaviconImage = | 1459 static NSImage* sadFaviconImage = |
| 1460 [ResourceBundle::GetSharedInstance().GetNativeImageNamed(IDR_SAD_FAVICON) | 1460 ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 1461 retain]; | 1461 IDR_SAD_FAVICON).CopyNSImage(); |
| 1462 | 1462 |
| 1463 // Take closing tabs into account. | 1463 // Take closing tabs into account. |
| 1464 NSInteger index = [self indexFromModelIndex:modelIndex]; | 1464 NSInteger index = [self indexFromModelIndex:modelIndex]; |
| 1465 TabController* tabController = [tabArray_ objectAtIndex:index]; | 1465 TabController* tabController = [tabArray_ objectAtIndex:index]; |
| 1466 | 1466 |
| 1467 bool oldHasIcon = [tabController iconView] != nil; | 1467 bool oldHasIcon = [tabController iconView] != nil; |
| 1468 bool newHasIcon = contents->favicon_tab_helper()->ShouldDisplayFavicon() || | 1468 bool newHasIcon = contents->favicon_tab_helper()->ShouldDisplayFavicon() || |
| 1469 tabStripModel_->IsMiniTab(modelIndex); // Always show icon if mini. | 1469 tabStripModel_->IsMiniTab(modelIndex); // Always show icon if mini. |
| 1470 | 1470 |
| 1471 TabLoadingState oldState = [tabController loadingState]; | 1471 TabLoadingState oldState = [tabController loadingState]; |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 NSView* GetSheetParentViewForTabContents(TabContents* tab_contents) { | 2102 NSView* GetSheetParentViewForTabContents(TabContents* tab_contents) { |
| 2103 // View hierarchy of the contents view: | 2103 // View hierarchy of the contents view: |
| 2104 // NSView -- switchView, same for all tabs | 2104 // NSView -- switchView, same for all tabs |
| 2105 // +- NSView -- TabContentsController's view | 2105 // +- NSView -- TabContentsController's view |
| 2106 // +- TabContentsViewCocoa | 2106 // +- TabContentsViewCocoa |
| 2107 // | 2107 // |
| 2108 // Changing it? Do not forget to modify | 2108 // Changing it? Do not forget to modify |
| 2109 // -[TabStripController swapInTabAtIndex:] too. | 2109 // -[TabStripController swapInTabAtIndex:] too. |
| 2110 return [tab_contents->web_contents()->GetNativeView() superview]; | 2110 return [tab_contents->web_contents()->GetNativeView() superview]; |
| 2111 } | 2111 } |
| OLD | NEW |