#import "chrome/browser/ui/cocoa/new_tab_button.h"
#import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h"
#import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
-#import "chrome/browser/ui/cocoa/tabs/media_indicator_view.h"
+#import "chrome/browser/ui/cocoa/tabs/media_indicator_button.h"
#import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/ui/tabs/tab_utils.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/omnibox/autocomplete_match.h"
}
}
+// Called when the user clicks the tab audio indicator to mute the tab.
+- (void)toggleMute:(id)sender {
+ DCHECK([sender isKindOfClass:[TabView class]]);
+ NSInteger index = [self modelIndexForTabView:sender];
+ if (!tabStripModel_->ContainsIndex(index))
+ return;
+ WebContents* contents = tabStripModel_->GetWebContentsAt(index);
+ chrome::SetTabAudioMuted(contents, !chrome::IsTabAudioMuted(contents));
+}
+
// Called when the user closes a tab. Asks the model to close the tab. |sender|
// is the TabView that is potentially going away.
- (void)closeTab:(id)sender {
if (newHasIcon) {
if (newState == kTabDone) {
[tabController setIconImage:[self iconImageForContents:contents]];
- const TabMediaState mediaState =
- chrome::GetTabMediaStateForContents(contents);
- // Create MediaIndicatorView upon first use.
- if (mediaState != TAB_MEDIA_STATE_NONE &&
- ![tabController mediaIndicatorView]) {
- MediaIndicatorView* const mediaIndicatorView =
- [[[MediaIndicatorView alloc] init] autorelease];
- [tabController setMediaIndicatorView:mediaIndicatorView];
- }
- [[tabController mediaIndicatorView] updateIndicator:mediaState];
} else if (newState == kTabCrashed) {
[tabController setIconImage:sadFaviconImage withToastAnimation:YES];
- [[tabController mediaIndicatorView]
- updateIndicator:TAB_MEDIA_STATE_NONE];
} else {
[tabController setIconImage:throbberImage];
}
[tabController setIconImage:nil];
}
}
+
+ [tabController setMediaState:chrome::GetTabMediaStateForContents(contents)];
+
+ [tabController updateVisibility];
}
// Called when a notification is received from the model that the given tab
return [tabContentsArray_ objectAtIndex:index];
}
-- (void)addWindowControls {
- if (!fullscreenWindowControls_) {
+- (void)addCustomWindowControls {
+ if (!customWindowControls_) {
// Make the container view.
CGFloat height = NSHeight([tabStripView_ frame]);
NSRect frame = NSMakeRect(0, 0, [self leftIndentForControls], height);
- fullscreenWindowControls_.reset([[NSView alloc] initWithFrame:frame]);
- [fullscreenWindowControls_
+ customWindowControls_.reset([[NSView alloc] initWithFrame:frame]);
+ [customWindowControls_
setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable];
// Add the traffic light buttons. The horizontal layout was determined by
// Vertically center the buttons in the tab strip.
CGFloat buttonY = floor((height - NSHeight([closeButton bounds])) / 2);
[closeButton setFrameOrigin:NSMakePoint(closeButtonX, buttonY)];
- [fullscreenWindowControls_ addSubview:closeButton];
+ [customWindowControls_ addSubview:closeButton];
NSButton* miniaturizeButton =
[NSWindow standardWindowButton:NSWindowMiniaturizeButton
forStyleMask:styleMask];
[miniaturizeButton setFrameOrigin:NSMakePoint(miniButtonX, buttonY)];
[miniaturizeButton setEnabled:NO];
- [fullscreenWindowControls_ addSubview:miniaturizeButton];
+ [customWindowControls_ addSubview:miniaturizeButton];
NSButton* zoomButton =
[NSWindow standardWindowButton:NSWindowZoomButton
forStyleMask:styleMask];
- [fullscreenWindowControls_ addSubview:zoomButton];
+ [customWindowControls_ addSubview:zoomButton];
[zoomButton setFrameOrigin:NSMakePoint(zoomButtonX, buttonY)];
}
- if (![permanentSubviews_ containsObject:fullscreenWindowControls_]) {
- [self addSubviewToPermanentList:fullscreenWindowControls_];
+ if (![permanentSubviews_ containsObject:customWindowControls_]) {
+ [self addSubviewToPermanentList:customWindowControls_];
[self regenerateSubviewList];
}
}
-- (void)removeWindowControls {
- if (fullscreenWindowControls_)
- [permanentSubviews_ removeObject:fullscreenWindowControls_];
+- (void)removeCustomWindowControls {
+ if (customWindowControls_)
+ [permanentSubviews_ removeObject:customWindowControls_];
[self regenerateSubviewList];
}
// the devtools view is always in the hierarchy even if it is not open or it
// is detached.
NSView* devtools_view = [[[view superview] superview] superview];
- return [devtools_view convertRect:[devtools_view bounds] toView:nil];
+ if (devtools_view) {
+ return [devtools_view convertRect:[devtools_view bounds] toView:nil];
+ } else {
+ return [view convertRect:[view bounds] toView:nil];
+ }
}