Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 1412083002: Indicate in the Window menu which Chrome window has an active sound playing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied changes based on the CR, and also refactor the logic Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 - (NSInteger)numberOfOpenPinnedTabs; 244 - (NSInteger)numberOfOpenPinnedTabs;
245 - (NSInteger)numberOfOpenNonPinnedTabs; 245 - (NSInteger)numberOfOpenNonPinnedTabs;
246 - (void)mouseMoved:(NSEvent*)event; 246 - (void)mouseMoved:(NSEvent*)event;
247 - (void)setTabTrackingAreasEnabled:(BOOL)enabled; 247 - (void)setTabTrackingAreasEnabled:(BOOL)enabled;
248 - (void)droppingURLsAt:(NSPoint)point 248 - (void)droppingURLsAt:(NSPoint)point
249 givesIndex:(NSInteger*)index 249 givesIndex:(NSInteger*)index
250 disposition:(WindowOpenDisposition*)disposition; 250 disposition:(WindowOpenDisposition*)disposition;
251 - (void)setNewTabButtonHoverState:(BOOL)showHover; 251 - (void)setNewTabButtonHoverState:(BOOL)showHover;
252 - (void)themeDidChangeNotification:(NSNotification*)notification; 252 - (void)themeDidChangeNotification:(NSNotification*)notification;
253 - (void)setNewTabImages; 253 - (void)setNewTabImages;
254 - (void)updateWindowMediaState:(TabMediaState)mediaState
255 on:(content::WebContents*)changed;
256 - (BOOL)isAnyOtherTab:(content::WebContents*)selected
257 withState:(TabMediaState)state;
258
254 @end 259 @end
255 260
256 // A simple view class that contains the traffic light buttons. This class 261 // A simple view class that contains the traffic light buttons. This class
257 // ensures that the buttons display the icons when the mouse hovers over 262 // ensures that the buttons display the icons when the mouse hovers over
258 // them by overriding the _mouseInGroup method. 263 // them by overriding the _mouseInGroup method.
259 @interface CustomWindowControlsView : NSView { 264 @interface CustomWindowControlsView : NSView {
260 @private 265 @private
261 BOOL mouseInside_; 266 BOOL mouseInside_;
262 } 267 }
263 268
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 } else if (newState == kTabCrashed) { 1624 } else if (newState == kTabCrashed) {
1620 [tabController setIconImage:sadFaviconImage withToastAnimation:YES]; 1625 [tabController setIconImage:sadFaviconImage withToastAnimation:YES];
1621 } else { 1626 } else {
1622 [tabController setIconImage:throbberImage]; 1627 [tabController setIconImage:throbberImage];
1623 } 1628 }
1624 } else { 1629 } else {
1625 [tabController setIconImage:nil]; 1630 [tabController setIconImage:nil];
1626 } 1631 }
1627 } 1632 }
1628 1633
1629 [tabController setMediaState:chrome::GetTabMediaStateForContents(contents)]; 1634 TabMediaState mediaState = chrome::GetTabMediaStateForContents(contents);
1635
1636 [self updateWindowMediaState:mediaState on:contents];
1637 [tabController setMediaState:mediaState];
1630 1638
1631 [tabController updateVisibility]; 1639 [tabController updateVisibility];
1632 } 1640 }
1633 1641
1634 // Called when a notification is received from the model that the given tab 1642 // Called when a notification is received from the model that the given tab
1635 // has been updated. |loading| will be YES when we only want to update the 1643 // has been updated. |loading| will be YES when we only want to update the
1636 // throbber state, not anything else about the (partially) loading tab. 1644 // throbber state, not anything else about the (partially) loading tab.
1637 - (void)tabChangedWithContents:(content::WebContents*)contents 1645 - (void)tabChangedWithContents:(content::WebContents*)contents
1638 atIndex:(NSInteger)modelIndex 1646 atIndex:(NSInteger)modelIndex
1639 changeType:(TabStripModelObserver::TabChangeType)change { 1647 changeType:(TabStripModelObserver::TabChangeType)change {
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 [[newTabButton_ cell] setImage:Overlay(background, hover, alpha) 2335 [[newTabButton_ cell] setImage:Overlay(background, hover, alpha)
2328 forButtonState:image_button_cell::kHoverStateBackground]; 2336 forButtonState:image_button_cell::kHoverStateBackground];
2329 } else { 2337 } else {
2330 [[newTabButton_ cell] setImage:nil 2338 [[newTabButton_ cell] setImage:nil
2331 forButtonState:image_button_cell::kDefaultStateBackground]; 2339 forButtonState:image_button_cell::kDefaultStateBackground];
2332 [[newTabButton_ cell] setImage:nil 2340 [[newTabButton_ cell] setImage:nil
2333 forButtonState:image_button_cell::kHoverStateBackground]; 2341 forButtonState:image_button_cell::kHoverStateBackground];
2334 } 2342 }
2335 } 2343 }
2336 2344
2345 - (void)updateWindowMediaState:(TabMediaState)mediaState
miu 2015/10/21 20:06:52 Please document this method and indicate what the
2346 on:(content::WebContents*)selected {
Robert Sesek 2015/10/22 00:01:52 nit: align the colons here, too.
2347 NSWindow* window = [tabStripView_ window];
2348 BrowserWindowController* windowController =
2349 [BrowserWindowController browserWindowControllerForWindow:window];
Robert Sesek 2015/10/22 00:01:52 nit: this is over-indented by two spaces
2350 if (mediaState == TAB_MEDIA_STATE_NONE) {
2351 if (![self isAnyOtherTab:selected
2352 withState:TAB_MEDIA_STATE_AUDIO_PLAYING] &&
2353 ![self isAnyOtherTab:selected withState:TAB_MEDIA_STATE_AUDIO_MUTING])
Robert Sesek 2015/10/22 00:01:52 nit: both the if and else bodies need {}
2354 [windowController setMediaState:TAB_MEDIA_STATE_NONE];
2355 else if ([self isAnyOtherTab:selected
2356 withState:TAB_MEDIA_STATE_AUDIO_MUTING])
2357 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING];
2358 }
2359 else if (mediaState == TAB_MEDIA_STATE_AUDIO_MUTING) {
2360 if (![self isAnyOtherTab:selected withState:TAB_MEDIA_STATE_AUDIO_PLAYING])
2361 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING];
2362 } else {
2363 [windowController setMediaState:mediaState];
2364 }
2365 }
2366
2367 - (BOOL)isAnyOtherTab:(content::WebContents*)selected
miu 2015/10/21 20:06:52 ditto: Please add a short method-level comment sum
2368 withState:(TabMediaState)state{
Robert Sesek 2015/10/22 00:01:52 nit: align the colons
2369 const int existingTabCount = tabStripModel_->count();
2370 for (int i = 0; i < existingTabCount; ++i) {
2371 content::WebContents* currentContents =
miu 2015/10/21 20:06:52 Just after this statement, add the following so th
2372 tabStripModel_->GetWebContentsAt(i);
2373 TabMediaState currentMediaStateForContents =
2374 chrome::GetTabMediaStateForContents(currentContents);
2375 if (selected != currentContents &&
miu 2015/10/21 20:06:52 (see above comment)...then you don't need the firs
2376 currentMediaStateForContents == state)
2377 return YES;
2378 }
2379 return NO;
2380 }
2381
2337 @end 2382 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698