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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "chrome/common/pref_names.h" | 58 #include "chrome/common/pref_names.h" |
59 #include "content/public/browser/navigation_controller.h" | 59 #include "content/public/browser/navigation_controller.h" |
60 #include "content/public/browser/user_metrics.h" | 60 #include "content/public/browser/user_metrics.h" |
61 #include "content/public/browser/web_contents.h" | 61 #include "content/public/browser/web_contents.h" |
62 #include "content/public/browser/web_contents_view.h" | 62 #include "content/public/browser/web_contents_view.h" |
63 #include "grit/generated_resources.h" | 63 #include "grit/generated_resources.h" |
64 #include "grit/theme_resources.h" | 64 #include "grit/theme_resources.h" |
65 #include "grit/ui_resources.h" | 65 #include "grit/ui_resources.h" |
66 #include "skia/ext/skia_utils_mac.h" | 66 #include "skia/ext/skia_utils_mac.h" |
67 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 67 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
| 68 #import "ui/base/animation/animation_container.h" |
68 #import "ui/base/cocoa/tracking_area.h" | 69 #import "ui/base/cocoa/tracking_area.h" |
69 #include "ui/base/l10n/l10n_util.h" | 70 #include "ui/base/l10n/l10n_util.h" |
70 #include "ui/base/models/list_selection_model.h" | 71 #include "ui/base/models/list_selection_model.h" |
71 #include "ui/base/resource/resource_bundle.h" | 72 #include "ui/base/resource/resource_bundle.h" |
72 #include "ui/base/theme_provider.h" | 73 #include "ui/base/theme_provider.h" |
73 #include "ui/gfx/image/image.h" | 74 #include "ui/gfx/image/image.h" |
74 | 75 |
75 using content::OpenURLParams; | 76 using content::OpenURLParams; |
76 using content::Referrer; | 77 using content::Referrer; |
77 using content::UserMetricsAction; | 78 using content::UserMetricsAction; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 switchView_ = switchView; | 494 switchView_ = switchView; |
494 browser_ = browser; | 495 browser_ = browser; |
495 tabStripModel_ = browser_->tab_strip_model(); | 496 tabStripModel_ = browser_->tab_strip_model(); |
496 hoverTabSelector_.reset(new HoverTabSelector(tabStripModel_)); | 497 hoverTabSelector_.reset(new HoverTabSelector(tabStripModel_)); |
497 delegate_ = delegate; | 498 delegate_ = delegate; |
498 bridge_.reset(new TabStripModelObserverBridge(tabStripModel_, self)); | 499 bridge_.reset(new TabStripModelObserverBridge(tabStripModel_, self)); |
499 dragController_.reset( | 500 dragController_.reset( |
500 [[TabStripDragController alloc] initWithTabStripController:self]); | 501 [[TabStripDragController alloc] initWithTabStripController:self]); |
501 tabContentsArray_.reset([[NSMutableArray alloc] init]); | 502 tabContentsArray_.reset([[NSMutableArray alloc] init]); |
502 tabArray_.reset([[NSMutableArray alloc] init]); | 503 tabArray_.reset([[NSMutableArray alloc] init]); |
| 504 animationContainer_ = new ui::AnimationContainer; |
503 NSWindow* browserWindow = [view window]; | 505 NSWindow* browserWindow = [view window]; |
504 | 506 |
505 // Important note: any non-tab subviews not added to |permanentSubviews_| | 507 // Important note: any non-tab subviews not added to |permanentSubviews_| |
506 // (see |-addSubviewToPermanentList:|) will be wiped out. | 508 // (see |-addSubviewToPermanentList:|) will be wiped out. |
507 permanentSubviews_.reset([[NSMutableArray alloc] init]); | 509 permanentSubviews_.reset([[NSMutableArray alloc] init]); |
508 | 510 |
509 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 511 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
510 defaultFavicon_.reset( | 512 defaultFavicon_.reset( |
511 rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).CopyNSImage()); | 513 rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).CopyNSImage()); |
512 | 514 |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 if (theme && [tabController projecting]) { | 1618 if (theme && [tabController projecting]) { |
1617 NSImage* projectorGlow = | 1619 NSImage* projectorGlow = |
1618 theme->GetNSImageNamed(IDR_TAB_CAPTURE_GLOW, true); | 1620 theme->GetNSImageNamed(IDR_TAB_CAPTURE_GLOW, true); |
1619 NSImage* projector = theme->GetNSImageNamed(IDR_TAB_CAPTURE, true); | 1621 NSImage* projector = theme->GetNSImageNamed(IDR_TAB_CAPTURE, true); |
1620 | 1622 |
1621 NSRect frame = NSMakeRect(0, | 1623 NSRect frame = NSMakeRect(0, |
1622 0, | 1624 0, |
1623 kProjectingIconWidthAndHeight, | 1625 kProjectingIconWidthAndHeight, |
1624 kProjectingIconWidthAndHeight); | 1626 kProjectingIconWidthAndHeight); |
1625 TabProjectingImageView* projectingView = | 1627 TabProjectingImageView* projectingView = |
1626 [[[TabProjectingImageView alloc] initWithFrame:frame | 1628 [[[TabProjectingImageView alloc] |
1627 backgroundImage:[imageView image] | 1629 initWithFrame:frame |
1628 projectorImage:projector | 1630 backgroundImage:[imageView image] |
1629 throbImage:projectorGlow | 1631 projectorImage:projector |
1630 durationMS:kRecordingDurationMs] | 1632 throbImage:projectorGlow |
1631 autorelease]; | 1633 durationMS:kRecordingDurationMs |
| 1634 animationContainer:animationContainer_] autorelease]; |
1632 | 1635 |
1633 iconView = projectingView; | 1636 iconView = projectingView; |
1634 } else if (theme && chrome::ShouldShowRecordingIndicator(contents)) { | 1637 } else if (theme && chrome::ShouldShowRecordingIndicator(contents)) { |
1635 // Create a masked favicon. | 1638 // Create a masked favicon. |
1636 NSImage* mask = theme->GetNSImageNamed(IDR_TAB_RECORDING_MASK, true); | 1639 NSImage* mask = theme->GetNSImageNamed(IDR_TAB_RECORDING_MASK, true); |
1637 NSImage* recording = theme->GetNSImageNamed(IDR_TAB_RECORDING, true); | 1640 NSImage* recording = theme->GetNSImageNamed(IDR_TAB_RECORDING, true); |
1638 NSImage* favIconMasked = CreateMaskedFaviconForRecording( | 1641 NSImage* favIconMasked = CreateMaskedFaviconForRecording( |
1639 [imageView image], mask, recording); | 1642 [imageView image], mask, recording); |
1640 | 1643 |
1641 NSRect frame = | 1644 NSRect frame = |
1642 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); | 1645 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); |
1643 ThrobbingImageView* recordingView = | 1646 ThrobbingImageView* recordingView = |
1644 [[[ThrobbingImageView alloc] | 1647 [[[ThrobbingImageView alloc] |
1645 initWithFrame:frame | 1648 initWithFrame:frame |
1646 backgroundImage:favIconMasked | 1649 backgroundImage:favIconMasked |
1647 throbImage:recording | 1650 throbImage:recording |
1648 durationMS:kRecordingDurationMs | 1651 durationMS:kRecordingDurationMs |
1649 throbPosition:kThrobPositionBottomRight] autorelease]; | 1652 throbPosition:kThrobPositionBottomRight |
| 1653 animationContainer:animationContainer_] autorelease]; |
1650 | 1654 |
1651 iconView = recordingView; | 1655 iconView = recordingView; |
1652 } else if (chrome::IsPlayingAudio(contents) || | 1656 } else if (chrome::IsPlayingAudio(contents) || |
1653 [tabAudioIndicatorViewMac isAnimating]) { | 1657 [tabAudioIndicatorViewMac isAnimating]) { |
1654 if (!tabAudioIndicatorViewMac) { | 1658 if (!tabAudioIndicatorViewMac) { |
1655 NSRect frame = | 1659 NSRect frame = |
1656 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); | 1660 NSMakeRect(0, 0, kIconWidthAndHeight, kIconWidthAndHeight); |
1657 tabAudioIndicatorViewMac = [[[TabAudioIndicatorViewMac alloc] | 1661 tabAudioIndicatorViewMac = [[[TabAudioIndicatorViewMac alloc] |
1658 initWithFrame:frame] autorelease]; | 1662 initWithFrame:frame] autorelease]; |
| 1663 [tabAudioIndicatorViewMac |
| 1664 setAnimationContainer:animationContainer_]; |
1659 } | 1665 } |
1660 [tabAudioIndicatorViewMac | 1666 [tabAudioIndicatorViewMac |
1661 setIsPlayingAudio:chrome::IsPlayingAudio(contents)]; | 1667 setIsPlayingAudio:chrome::IsPlayingAudio(contents)]; |
1662 [tabAudioIndicatorViewMac setBackgroundImage:[imageView image]]; | 1668 [tabAudioIndicatorViewMac setBackgroundImage:[imageView image]]; |
1663 iconView = tabAudioIndicatorViewMac; | 1669 iconView = tabAudioIndicatorViewMac; |
1664 } else { | 1670 } else { |
1665 iconView = imageView; | 1671 iconView = imageView; |
1666 } | 1672 } |
1667 } else if (newState == kTabCrashed) { | 1673 } else if (newState == kTabCrashed) { |
1668 NSImage* oldImage = [[self iconImageViewForContents:contents] image]; | 1674 NSImage* oldImage = [[self iconImageViewForContents:contents] image]; |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { | 2295 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { |
2290 // View hierarchy of the contents view: | 2296 // View hierarchy of the contents view: |
2291 // NSView -- switchView, same for all tabs | 2297 // NSView -- switchView, same for all tabs |
2292 // +- NSView -- TabContentsController's view | 2298 // +- NSView -- TabContentsController's view |
2293 // +- TabContentsViewCocoa | 2299 // +- TabContentsViewCocoa |
2294 // | 2300 // |
2295 // Changing it? Do not forget to modify | 2301 // Changing it? Do not forget to modify |
2296 // -[TabStripController swapInTabAtIndex:] too. | 2302 // -[TabStripController swapInTabAtIndex:] too. |
2297 return [web_contents->GetView()->GetNativeView() superview]; | 2303 return [web_contents->GetView()->GetNativeView() superview]; |
2298 } | 2304 } |
OLD | NEW |