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 18 matching lines...) Expand all Loading... | |
29 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
30 #include "chrome/browser/ui/browser_navigator.h" | 30 #include "chrome/browser/ui/browser_navigator.h" |
31 #include "chrome/browser/ui/browser_tabstrip.h" | 31 #include "chrome/browser/ui/browser_tabstrip.h" |
32 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 32 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
33 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" | 33 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" |
34 #include "chrome/browser/ui/cocoa/drag_util.h" | 34 #include "chrome/browser/ui/cocoa/drag_util.h" |
35 #import "chrome/browser/ui/cocoa/image_button_cell.h" | 35 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
36 #import "chrome/browser/ui/cocoa/new_tab_button.h" | 36 #import "chrome/browser/ui/cocoa/new_tab_button.h" |
37 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" | 37 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" |
38 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 38 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
39 #import "chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.h" | |
40 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | 39 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
41 #import "chrome/browser/ui/cocoa/tabs/tab_projecting_image_view.h" | 40 #import "chrome/browser/ui/cocoa/tabs/tab_projecting_image_view.h" |
42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" | 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" |
43 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
44 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 43 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
45 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 44 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
46 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" | 45 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" |
47 #import "chrome/browser/ui/cocoa/tabs/throbbing_image_view.h" | 46 #import "chrome/browser/ui/cocoa/tabs/throbbing_image_view.h" |
48 #include "chrome/browser/ui/find_bar/find_bar.h" | 47 #include "chrome/browser/ui/find_bar/find_bar.h" |
49 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 48 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 if (oldState != newState) | 1604 if (oldState != newState) |
1606 [tabController setLoadingState:newState]; | 1605 [tabController setLoadingState:newState]; |
1607 | 1606 |
1608 // While loading, this function is called repeatedly with the same state. | 1607 // While loading, this function is called repeatedly with the same state. |
1609 // To avoid expensive unnecessary view manipulation, only make changes when | 1608 // To avoid expensive unnecessary view manipulation, only make changes when |
1610 // the state is actually changing. When loading is complete (kTabDone), | 1609 // the state is actually changing. When loading is complete (kTabDone), |
1611 // every call to this function is significant. | 1610 // every call to this function is significant. |
1612 if (newState == kTabDone || oldState != newState || | 1611 if (newState == kTabDone || oldState != newState || |
1613 oldHasIcon != newHasIcon) { | 1612 oldHasIcon != newHasIcon) { |
1614 NSView* iconView = nil; | 1613 NSView* iconView = nil; |
1614 NSImageView* audioIndicatorView = nil; | |
1615 if (newHasIcon) { | 1615 if (newHasIcon) { |
1616 if (newState == kTabDone) { | 1616 if (newState == kTabDone) { |
1617 NSImageView* imageView = [self iconImageViewForContents:contents]; | 1617 NSImageView* imageView = [self iconImageViewForContents:contents]; |
1618 TabAudioIndicatorViewMac* tabAudioIndicatorViewMac = | |
1619 base::mac::ObjCCast<TabAudioIndicatorViewMac>( | |
1620 [tabController iconView]); | |
1621 | 1618 |
1622 ui::ThemeProvider* theme = [[tabStripView_ window] themeProvider]; | 1619 ui::ThemeProvider* theme = [[tabStripView_ window] themeProvider]; |
1623 if (theme && [tabController projecting]) { | 1620 if (theme && [tabController projecting]) { |
1624 NSImage* projectorGlow = | 1621 NSImage* projectorGlow = |
1625 theme->GetNSImageNamed(IDR_TAB_CAPTURE_GLOW); | 1622 theme->GetNSImageNamed(IDR_TAB_CAPTURE_GLOW); |
1626 NSImage* projector = theme->GetNSImageNamed(IDR_TAB_CAPTURE); | 1623 NSImage* projector = theme->GetNSImageNamed(IDR_TAB_CAPTURE); |
1627 | 1624 |
1628 NSRect frame = NSMakeRect(0, | 1625 NSRect frame = NSMakeRect(0, |
1629 0, | 1626 0, |
1630 kProjectingIconWidthAndHeight, | 1627 kProjectingIconWidthAndHeight, |
(...skipping 20 matching lines...) Expand all Loading... | |
1651 ThrobbingImageView* recordingView = | 1648 ThrobbingImageView* recordingView = |
1652 [[[ThrobbingImageView alloc] | 1649 [[[ThrobbingImageView alloc] |
1653 initWithFrame:frame | 1650 initWithFrame:frame |
1654 backgroundImage:favIconMasked | 1651 backgroundImage:favIconMasked |
1655 throbImage:recording | 1652 throbImage:recording |
1656 durationMS:kRecordingDurationMs | 1653 durationMS:kRecordingDurationMs |
1657 throbPosition:kThrobPositionBottomRight | 1654 throbPosition:kThrobPositionBottomRight |
1658 animationContainer:animationContainer_.get()] autorelease]; | 1655 animationContainer:animationContainer_.get()] autorelease]; |
1659 | 1656 |
1660 iconView = recordingView; | 1657 iconView = recordingView; |
1661 } else if (chrome::IsPlayingAudio(contents) || | |
1662 [tabAudioIndicatorViewMac isAnimating]) { | |
1663 if (!tabAudioIndicatorViewMac) { | |
1664 NSRect frame = | |
1665 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); | |
1666 tabAudioIndicatorViewMac = [[[TabAudioIndicatorViewMac alloc] | |
1667 initWithFrame:frame] autorelease]; | |
1668 [tabAudioIndicatorViewMac | |
1669 setAnimationContainer:animationContainer_.get()]; | |
1670 } | |
1671 [tabAudioIndicatorViewMac | |
1672 setIsPlayingAudio:chrome::IsPlayingAudio(contents)]; | |
1673 [tabAudioIndicatorViewMac setBackgroundImage:[imageView image]]; | |
1674 iconView = tabAudioIndicatorViewMac; | |
1675 } else { | 1658 } else { |
1676 iconView = imageView; | 1659 iconView = imageView; |
1660 | |
1661 if (theme && chrome::IsPlayingAudio(contents)) { | |
1662 NSImage* const image = | |
1663 theme->GetNSImageNamed(IDR_TAB_AUDIO_INDICATOR); | |
1664 if (image) { | |
1665 NSRect frame; | |
sail
2013/09/11 22:21:55
initialize to NSZeroRect
| |
1666 frame.size = [image size]; | |
1667 audioIndicatorView = | |
1668 [[[NSImageView alloc] initWithFrame:frame] autorelease]; | |
1669 [audioIndicatorView setImage:image]; | |
1670 } | |
1671 } | |
1677 } | 1672 } |
1678 } else if (newState == kTabCrashed) { | 1673 } else if (newState == kTabCrashed) { |
1679 NSImage* oldImage = [[self iconImageViewForContents:contents] image]; | 1674 NSImage* oldImage = [[self iconImageViewForContents:contents] image]; |
1680 NSRect frame = | 1675 NSRect frame = |
1681 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); | 1676 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); |
1682 iconView = [ThrobberView toastThrobberViewWithFrame:frame | 1677 iconView = [ThrobberView toastThrobberViewWithFrame:frame |
1683 beforeImage:oldImage | 1678 beforeImage:oldImage |
1684 afterImage:sadFaviconImage]; | 1679 afterImage:sadFaviconImage]; |
1685 } else { | 1680 } else { |
1686 NSRect frame = | 1681 NSRect frame = |
1687 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); | 1682 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); |
1688 iconView = [ThrobberView filmstripThrobberViewWithFrame:frame | 1683 iconView = [ThrobberView filmstripThrobberViewWithFrame:frame |
1689 image:throbberImage]; | 1684 image:throbberImage]; |
1690 } | 1685 } |
1691 } | 1686 } |
1692 | 1687 |
1693 [tabController setIconView:iconView]; | 1688 [tabController setIconView:iconView]; |
1694 if (iconView && ![tabController projecting]) { | 1689 if (iconView && ![tabController projecting]) { |
1695 // See the comment above kTabOverlap for why these DCHECKs exist. | 1690 // See the comment above kTabOverlap for why these DCHECKs exist. |
1696 DCHECK_GE(NSMinX([iconView frame]), kTabOverlap); | 1691 DCHECK_GE(NSMinX([iconView frame]), kTabOverlap); |
1697 // TODO(thakis): Ideally, this would be true too, but it's not true in | 1692 // TODO(thakis): Ideally, this would be true too, but it's not true in |
1698 // some tests. | 1693 // some tests. |
1699 //DCHECK_LE(NSMaxX([iconView frame]), | 1694 //DCHECK_LE(NSMaxX([iconView frame]), |
1700 // NSWidth([[tabController view] frame]) - kTabOverlap); | 1695 // NSWidth([[tabController view] frame]) - kTabOverlap); |
1701 } | 1696 } |
1697 [tabController setAudioIndicatorView:audioIndicatorView]; | |
1702 } | 1698 } |
1703 } | 1699 } |
1704 | 1700 |
1705 // Called when a notification is received from the model that the given tab | 1701 // Called when a notification is received from the model that the given tab |
1706 // has been updated. |loading| will be YES when we only want to update the | 1702 // has been updated. |loading| will be YES when we only want to update the |
1707 // throbber state, not anything else about the (partially) loading tab. | 1703 // throbber state, not anything else about the (partially) loading tab. |
1708 - (void)tabChangedWithContents:(content::WebContents*)contents | 1704 - (void)tabChangedWithContents:(content::WebContents*)contents |
1709 atIndex:(NSInteger)modelIndex | 1705 atIndex:(NSInteger)modelIndex |
1710 changeType:(TabStripModelObserver::TabChangeType)change { | 1706 changeType:(TabStripModelObserver::TabChangeType)change { |
1711 // Take closing tabs into account. | 1707 // Take closing tabs into account. |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2301 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { | 2297 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { |
2302 // View hierarchy of the contents view: | 2298 // View hierarchy of the contents view: |
2303 // NSView -- switchView, same for all tabs | 2299 // NSView -- switchView, same for all tabs |
2304 // +- NSView -- TabContentsController's view | 2300 // +- NSView -- TabContentsController's view |
2305 // +- TabContentsViewCocoa | 2301 // +- TabContentsViewCocoa |
2306 // | 2302 // |
2307 // Changing it? Do not forget to modify | 2303 // Changing it? Do not forget to modify |
2308 // -[TabStripController swapInTabAtIndex:] too. | 2304 // -[TabStripController swapInTabAtIndex:] too. |
2309 return [web_contents->GetView()->GetNativeView() superview]; | 2305 return [web_contents->GetView()->GetNativeView() superview]; |
2310 } | 2306 } |
OLD | NEW |