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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 bool animate_; | 135 bool animate_; |
136 DISALLOW_COPY_AND_ASSIGN(ScopedNSAnimationContextGroup); | 136 DISALLOW_COPY_AND_ASSIGN(ScopedNSAnimationContextGroup); |
137 }; | 137 }; |
138 | 138 |
139 } // namespace | 139 } // namespace |
140 | 140 |
141 @interface TabStripController (Private) | 141 @interface TabStripController (Private) |
142 - (void)addSubviewToPermanentList:(NSView*)aView; | 142 - (void)addSubviewToPermanentList:(NSView*)aView; |
143 - (void)regenerateSubviewList; | 143 - (void)regenerateSubviewList; |
144 - (NSInteger)indexForContentsView:(NSView*)view; | 144 - (NSInteger)indexForContentsView:(NSView*)view; |
145 - (NSImage*)iconImageForContents:(content::WebContents*)contents; | 145 - (NSImage*)iconImageForContents:(content::WebContents*)contents |
146 atIndex:(NSInteger)modelIndex; | |
146 - (void)updateIconsForContents:(content::WebContents*)contents | 147 - (void)updateIconsForContents:(content::WebContents*)contents |
147 atIndex:(NSInteger)modelIndex; | 148 atIndex:(NSInteger)modelIndex; |
148 - (void)layoutTabsWithAnimation:(BOOL)animate | 149 - (void)layoutTabsWithAnimation:(BOOL)animate |
149 regenerateSubviews:(BOOL)doUpdate; | 150 regenerateSubviews:(BOOL)doUpdate; |
150 - (void)animationDidStop:(CAAnimation*)animation | 151 - (void)animationDidStop:(CAAnimation*)animation |
151 forController:(TabController*)controller | 152 forController:(TabController*)controller |
152 finished:(BOOL)finished; | 153 finished:(BOOL)finished; |
153 - (NSInteger)indexFromModelIndex:(NSInteger)index; | 154 - (NSInteger)indexFromModelIndex:(NSInteger)index; |
154 - (void)clickNewTabButton:(id)sender; | 155 - (void)clickNewTabButton:(id)sender; |
155 - (NSInteger)numberOfOpenTabs; | 156 - (NSInteger)numberOfOpenTabs; |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1488 // tabs. Instead, simply mark it as closing to prevent the tab from | 1489 // tabs. Instead, simply mark it as closing to prevent the tab from |
1489 // generating any drags or selections. | 1490 // generating any drags or selections. |
1490 [[tab tabView] setClosing:YES]; | 1491 [[tab tabView] setClosing:YES]; |
1491 } | 1492 } |
1492 | 1493 |
1493 [delegate_ onTabDetachedWithContents:contents]; | 1494 [delegate_ onTabDetachedWithContents:contents]; |
1494 } | 1495 } |
1495 | 1496 |
1496 // A helper routine for creating an NSImageView to hold the favicon or app icon | 1497 // A helper routine for creating an NSImageView to hold the favicon or app icon |
1497 // for |contents|. | 1498 // for |contents|. |
1498 - (NSImage*)iconImageForContents:(content::WebContents*)contents { | 1499 - (NSImage*)iconImageForContents:(content::WebContents*)contents |
1500 atIndex:(NSInteger)modelIndex { | |
1499 extensions::TabHelper* extensions_tab_helper = | 1501 extensions::TabHelper* extensions_tab_helper = |
1500 extensions::TabHelper::FromWebContents(contents); | 1502 extensions::TabHelper::FromWebContents(contents); |
1501 BOOL isApp = extensions_tab_helper->is_app(); | 1503 BOOL isApp = extensions_tab_helper->is_app(); |
1502 NSImage* image = nil; | 1504 NSImage* image = nil; |
1503 // Favicons come from the renderer, and the renderer draws everything in the | 1505 // Favicons come from the renderer, and the renderer draws everything in the |
1504 // system color space. | 1506 // system color space. |
1505 CGColorSpaceRef colorSpace = base::mac::GetSystemColorSpace(); | 1507 CGColorSpaceRef colorSpace = base::mac::GetSystemColorSpace(); |
1506 if (isApp) { | 1508 if (isApp) { |
1507 SkBitmap* icon = extensions_tab_helper->GetExtensionAppIcon(); | 1509 SkBitmap* icon = extensions_tab_helper->GetExtensionAppIcon(); |
1508 if (icon) | 1510 if (icon) |
1509 image = skia::SkBitmapToNSImageWithColorSpace(*icon, colorSpace); | 1511 image = skia::SkBitmapToNSImageWithColorSpace(*icon, colorSpace); |
1510 } else { | 1512 } else { |
1511 TabController* tab = [tabArray_ firstObject]; | 1513 TabController* tab = [tabArray_ objectAtIndex:modelIndex]; |
1512 NSColor* titleColor = [[tab tabView] titleColor]; | 1514 image = mac::FaviconForWebContents(contents, [[tab tabView] iconColor]); |
1513 NSColor* deviceColor = | |
1514 [titleColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; | |
1515 image = mac::FaviconForWebContents( | |
1516 contents, skia::NSDeviceColorToSkColor(deviceColor)); | |
1517 } | 1515 } |
1518 | 1516 |
1519 // Either we don't have a valid favicon or there was some issue converting it | 1517 // Either we don't have a valid favicon or there was some issue converting it |
1520 // from an SkBitmap. Either way, just show the default. | 1518 // from an SkBitmap. Either way, just show the default. |
1521 if (!image) | 1519 if (!image) |
1522 image = defaultFavicon_.get(); | 1520 image = defaultFavicon_.get(); |
1523 | 1521 |
1524 return image; | 1522 return image; |
1525 } | 1523 } |
1526 | 1524 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1577 [[[tabController view] window] hasDarkTheme]) { | 1575 [[[tabController view] window] hasDarkTheme]) { |
1578 throbberImage = throbberLoadingIncognitoImage; | 1576 throbberImage = throbberLoadingIncognitoImage; |
1579 } else { | 1577 } else { |
1580 throbberImage = throbberLoadingImage; | 1578 throbberImage = throbberLoadingImage; |
1581 } | 1579 } |
1582 } | 1580 } |
1583 | 1581 |
1584 if (oldState != newState) | 1582 if (oldState != newState) |
1585 [tabController setLoadingState:newState]; | 1583 [tabController setLoadingState:newState]; |
1586 | 1584 |
1585 [tabController setShouldUseDefaultFavicon:NO]; | |
Robert Sesek
2016/07/12 23:43:56
Does the TabController really need to know about w
spqchan
2016/07/13 17:16:14
The default favicon also needs to be updated at in
Robert Sesek
2016/07/13 22:37:59
Why can't the TabStripController updates the icon
| |
1586 | |
1587 // While loading, this function is called repeatedly with the same state. | 1587 // While loading, this function is called repeatedly with the same state. |
1588 // To avoid expensive unnecessary view manipulation, only make changes when | 1588 // To avoid expensive unnecessary view manipulation, only make changes when |
1589 // the state is actually changing. When loading is complete (kTabDone), | 1589 // the state is actually changing. When loading is complete (kTabDone), |
1590 // every call to this function is significant. | 1590 // every call to this function is significant. |
1591 if (newState == kTabDone || oldState != newState || | 1591 if (newState == kTabDone || oldState != newState || |
1592 oldHasIcon != newHasIcon) { | 1592 oldHasIcon != newHasIcon) { |
1593 if (newHasIcon) { | 1593 if (newHasIcon) { |
1594 if (newState == kTabDone) { | 1594 if (newState == kTabDone) { |
1595 [tabController setIconImage:[self iconImageForContents:contents]]; | 1595 [tabController setIconImage:[self iconImageForContents:contents |
1596 atIndex:modelIndex]]; | |
1597 [tabController | |
1598 setShouldUseDefaultFavicon:mac::ShouldUseDefaultFavicon(contents)]; | |
1596 } else if (newState == kTabCrashed) { | 1599 } else if (newState == kTabCrashed) { |
1597 [tabController setIconImage:sadFaviconImage withToastAnimation:YES]; | 1600 [tabController setIconImage:sadFaviconImage withToastAnimation:YES]; |
1598 } else { | 1601 } else { |
1599 [tabController setIconImage:throbberImage]; | 1602 [tabController setIconImage:throbberImage]; |
1600 } | 1603 } |
1601 } else { | 1604 } else { |
1602 [tabController setIconImage:nil]; | 1605 [tabController setIconImage:nil]; |
1603 } | 1606 } |
1604 } | 1607 } |
1605 | 1608 |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2328 | 2331 |
2329 - (void)themeDidChangeNotification:(NSNotification*)notification { | 2332 - (void)themeDidChangeNotification:(NSNotification*)notification { |
2330 [newTabButton_ setImages]; | 2333 [newTabButton_ setImages]; |
2331 } | 2334 } |
2332 | 2335 |
2333 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { | 2336 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { |
2334 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; | 2337 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; |
2335 } | 2338 } |
2336 | 2339 |
2337 @end | 2340 @end |
OLD | NEW |