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

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

Issue 1827083004: UI: Rename MediaState to AlertState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-tab-indicator
Patch Set: Keep gypi ordered Created 4 years, 8 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 16 matching lines...) Expand all
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_navigator.h" 28 #include "chrome/browser/ui/browser_navigator.h"
29 #include "chrome/browser/ui/browser_navigator_params.h" 29 #include "chrome/browser/ui/browser_navigator_params.h"
30 #include "chrome/browser/ui/browser_tabstrip.h" 30 #include "chrome/browser/ui/browser_tabstrip.h"
31 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 31 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
32 #include "chrome/browser/ui/cocoa/drag_util.h" 32 #include "chrome/browser/ui/cocoa/drag_util.h"
33 #import "chrome/browser/ui/cocoa/image_button_cell.h" 33 #import "chrome/browser/ui/cocoa/image_button_cell.h"
34 #import "chrome/browser/ui/cocoa/new_tab_button.h" 34 #import "chrome/browser/ui/cocoa/new_tab_button.h"
35 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" 35 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h"
36 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 36 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
37 #import "chrome/browser/ui/cocoa/tabs/media_indicator_button_cocoa.h" 37 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h"
38 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 38 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" 39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" 40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
42 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 42 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
43 #include "chrome/browser/ui/find_bar/find_bar.h" 43 #include "chrome/browser/ui/find_bar/find_bar.h"
44 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 44 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
45 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 45 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
46 #include "chrome/browser/ui/tabs/tab_menu_model.h" 46 #include "chrome/browser/ui/tabs/tab_menu_model.h"
47 #include "chrome/browser/ui/tabs/tab_strip_model.h" 47 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 - (NSInteger)numberOfOpenPinnedTabs; 163 - (NSInteger)numberOfOpenPinnedTabs;
164 - (NSInteger)numberOfOpenNonPinnedTabs; 164 - (NSInteger)numberOfOpenNonPinnedTabs;
165 - (void)mouseMoved:(NSEvent*)event; 165 - (void)mouseMoved:(NSEvent*)event;
166 - (void)setTabTrackingAreasEnabled:(BOOL)enabled; 166 - (void)setTabTrackingAreasEnabled:(BOOL)enabled;
167 - (void)droppingURLsAt:(NSPoint)point 167 - (void)droppingURLsAt:(NSPoint)point
168 givesIndex:(NSInteger*)index 168 givesIndex:(NSInteger*)index
169 disposition:(WindowOpenDisposition*)disposition; 169 disposition:(WindowOpenDisposition*)disposition;
170 - (void)setNewTabButtonHoverState:(BOOL)showHover; 170 - (void)setNewTabButtonHoverState:(BOOL)showHover;
171 - (void)themeDidChangeNotification:(NSNotification*)notification; 171 - (void)themeDidChangeNotification:(NSNotification*)notification;
172 - (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected 172 - (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected
173 haveMediaState:(TabMediaState)state; 173 haveAlertState:(TabAlertState)state;
174 @end 174 @end
175 175
176 // A simple view class that contains the traffic light buttons. This class 176 // A simple view class that contains the traffic light buttons. This class
177 // ensures that the buttons display the icons when the mouse hovers over 177 // ensures that the buttons display the icons when the mouse hovers over
178 // them by overriding the _mouseInGroup method. 178 // them by overriding the _mouseInGroup method.
179 @interface CustomWindowControlsView : NSView { 179 @interface CustomWindowControlsView : NSView {
180 @private 180 @private
181 BOOL mouseInside_; 181 BOOL mouseInside_;
182 } 182 }
183 183
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 778 }
779 779
780 // Called when the user clicks the tab audio indicator to mute the tab. 780 // Called when the user clicks the tab audio indicator to mute the tab.
781 - (void)toggleMute:(id)sender { 781 - (void)toggleMute:(id)sender {
782 DCHECK([sender isKindOfClass:[TabView class]]); 782 DCHECK([sender isKindOfClass:[TabView class]]);
783 NSInteger index = [self modelIndexForTabView:sender]; 783 NSInteger index = [self modelIndexForTabView:sender];
784 if (!tabStripModel_->ContainsIndex(index)) 784 if (!tabStripModel_->ContainsIndex(index))
785 return; 785 return;
786 WebContents* contents = tabStripModel_->GetWebContentsAt(index); 786 WebContents* contents = tabStripModel_->GetWebContentsAt(index);
787 chrome::SetTabAudioMuted(contents, !contents->IsAudioMuted(), 787 chrome::SetTabAudioMuted(contents, !contents->IsAudioMuted(),
788 TAB_MUTED_REASON_AUDIO_INDICATOR, std::string()); 788 TabMutedReason::AUDIO_INDICATOR, std::string());
789 } 789 }
790 790
791 // Called when the user closes a tab. Asks the model to close the tab. |sender| 791 // Called when the user closes a tab. Asks the model to close the tab. |sender|
792 // is the TabView that is potentially going away. 792 // is the TabView that is potentially going away.
793 - (void)closeTab:(id)sender { 793 - (void)closeTab:(id)sender {
794 DCHECK([sender isKindOfClass:[TabView class]]); 794 DCHECK([sender isKindOfClass:[TabView class]]);
795 795
796 // Cancel any pending tab transition. 796 // Cancel any pending tab transition.
797 hoverTabSelector_->CancelTabTransition(); 797 hoverTabSelector_->CancelTabTransition();
798 798
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 // a canned string if |contents| is NULL. 1215 // a canned string if |contents| is NULL.
1216 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents { 1216 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents {
1217 base::string16 title; 1217 base::string16 title;
1218 if (contents) 1218 if (contents)
1219 title = contents->GetTitle(); 1219 title = contents->GetTitle();
1220 if (title.empty()) 1220 if (title.empty())
1221 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); 1221 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED);
1222 [tab setTitle:base::SysUTF16ToNSString(title)]; 1222 [tab setTitle:base::SysUTF16ToNSString(title)];
1223 1223
1224 const base::string16& toolTip = chrome::AssembleTabTooltipText( 1224 const base::string16& toolTip = chrome::AssembleTabTooltipText(
1225 title, [self mediaStateForContents:contents]); 1225 title, [self alertStateForContents:contents]);
1226 [tab setToolTip:base::SysUTF16ToNSString(toolTip)]; 1226 [tab setToolTip:base::SysUTF16ToNSString(toolTip)];
1227 } 1227 }
1228 1228
1229 // Called when a notification is received from the model to insert a new tab 1229 // Called when a notification is received from the model to insert a new tab
1230 // at |modelIndex|. 1230 // at |modelIndex|.
1231 - (void)insertTabWithContents:(content::WebContents*)contents 1231 - (void)insertTabWithContents:(content::WebContents*)contents
1232 atIndex:(NSInteger)modelIndex 1232 atIndex:(NSInteger)modelIndex
1233 inForeground:(bool)inForeground { 1233 inForeground:(bool)inForeground {
1234 DCHECK(contents); 1234 DCHECK(contents);
1235 DCHECK(modelIndex == TabStripModel::kNoTab || 1235 DCHECK(modelIndex == TabStripModel::kNoTab ||
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 } else if (newState == kTabCrashed) { 1565 } else if (newState == kTabCrashed) {
1566 [tabController setIconImage:sadFaviconImage withToastAnimation:YES]; 1566 [tabController setIconImage:sadFaviconImage withToastAnimation:YES];
1567 } else { 1567 } else {
1568 [tabController setIconImage:throbberImage]; 1568 [tabController setIconImage:throbberImage];
1569 } 1569 }
1570 } else { 1570 } else {
1571 [tabController setIconImage:nil]; 1571 [tabController setIconImage:nil];
1572 } 1572 }
1573 } 1573 }
1574 1574
1575 TabMediaState mediaState = [self mediaStateForContents:contents]; 1575 TabAlertState alertState = [self alertStateForContents:contents];
1576 [self updateWindowMediaState:mediaState forWebContents:contents]; 1576 [self updateWindowAlertState:alertState forWebContents:contents];
1577 [tabController setMediaState:mediaState]; 1577 [tabController setAlertState:alertState];
1578 1578
1579 [tabController updateVisibility]; 1579 [tabController updateVisibility];
1580 } 1580 }
1581 1581
1582 // Called when a notification is received from the model that the given tab 1582 // Called when a notification is received from the model that the given tab
1583 // has been updated. |loading| will be YES when we only want to update the 1583 // has been updated. |loading| will be YES when we only want to update the
1584 // throbber state, not anything else about the (partially) loading tab. 1584 // throbber state, not anything else about the (partially) loading tab.
1585 - (void)tabChangedWithContents:(content::WebContents*)contents 1585 - (void)tabChangedWithContents:(content::WebContents*)contents
1586 atIndex:(NSInteger)modelIndex 1586 atIndex:(NSInteger)modelIndex
1587 changeType:(TabStripModelObserver::TabChangeType)change { 1587 changeType:(TabStripModelObserver::TabChangeType)change {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 } 2232 }
2233 } 2233 }
2234 2234
2235 - (void)removeCustomWindowControls { 2235 - (void)removeCustomWindowControls {
2236 if (customWindowControls_) 2236 if (customWindowControls_)
2237 [permanentSubviews_ removeObject:customWindowControls_]; 2237 [permanentSubviews_ removeObject:customWindowControls_];
2238 [self regenerateSubviewList]; 2238 [self regenerateSubviewList];
2239 [customWindowControls_ setMouseInside:NO]; 2239 [customWindowControls_ setMouseInside:NO];
2240 } 2240 }
2241 2241
2242 // Gets the tab and the media state to check whether the window 2242 // Gets the tab and the alert state to check whether the window
2243 // media state should be updated or not. If the tab media state is 2243 // alert state should be updated or not. If the tab alert state is
2244 // AUDIO_PLAYING, the window media state should be set to AUDIO_PLAYING. 2244 // AUDIO_PLAYING, the window alert state should be set to AUDIO_PLAYING.
2245 // If the tab media state is AUDIO_MUTING, this method would check if the 2245 // If the tab alert state is AUDIO_MUTING, this method would check if the
2246 // window has no other tab with state AUDIO_PLAYING, then the window 2246 // window has no other tab with state AUDIO_PLAYING, then the window
2247 // media state will be set to AUDIO_MUTING. If the tab media state is NONE, 2247 // alert state will be set to AUDIO_MUTING. If the tab alert state is NONE,
2248 // this method checks if the window has no playing or muting tab, then window 2248 // this method checks if the window has no playing or muting tab, then window
2249 // media state will be set as NONE. 2249 // alert state will be set as NONE.
2250 - (void)updateWindowMediaState:(TabMediaState)mediaState 2250 - (void)updateWindowAlertState:(TabAlertState)alertState
2251 forWebContents:(content::WebContents*)selected { 2251 forWebContents:(content::WebContents*)selected {
2252 NSWindow* window = [tabStripView_ window]; 2252 NSWindow* window = [tabStripView_ window];
2253 BrowserWindowController* windowController = 2253 BrowserWindowController* windowController =
2254 [BrowserWindowController browserWindowControllerForWindow:window]; 2254 [BrowserWindowController browserWindowControllerForWindow:window];
2255 if (mediaState == TAB_MEDIA_STATE_NONE) { 2255 if (alertState == TabAlertState::NONE) {
2256 if (![self doesAnyOtherWebContents:selected 2256 if (![self doesAnyOtherWebContents:selected
2257 haveMediaState:TAB_MEDIA_STATE_AUDIO_PLAYING] && 2257 haveAlertState:TabAlertState::AUDIO_PLAYING] &&
2258 ![self doesAnyOtherWebContents:selected 2258 ![self doesAnyOtherWebContents:selected
2259 haveMediaState:TAB_MEDIA_STATE_AUDIO_MUTING]) { 2259 haveAlertState:TabAlertState::AUDIO_MUTING]) {
2260 [windowController setMediaState:TAB_MEDIA_STATE_NONE]; 2260 [windowController setAlertState:TabAlertState::NONE];
2261 } else if ([self doesAnyOtherWebContents:selected 2261 } else if ([self doesAnyOtherWebContents:selected
2262 haveMediaState:TAB_MEDIA_STATE_AUDIO_MUTING]) { 2262 haveAlertState:TabAlertState::AUDIO_MUTING]) {
2263 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING]; 2263 [windowController setAlertState:TabAlertState::AUDIO_MUTING];
2264 } 2264 }
2265 } else if (mediaState == TAB_MEDIA_STATE_AUDIO_MUTING) { 2265 } else if (alertState == TabAlertState::AUDIO_MUTING) {
2266 if (![self doesAnyOtherWebContents:selected 2266 if (![self doesAnyOtherWebContents:selected
2267 haveMediaState:TAB_MEDIA_STATE_AUDIO_PLAYING]) { 2267 haveAlertState:TabAlertState::AUDIO_PLAYING]) {
2268 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING]; 2268 [windowController setAlertState:TabAlertState::AUDIO_MUTING];
2269 } 2269 }
2270 } else { 2270 } else {
2271 [windowController setMediaState:mediaState]; 2271 [windowController setAlertState:alertState];
2272 } 2272 }
2273 } 2273 }
2274 2274
2275 // Checks if tabs (excluding selected) has media state equals to the second 2275 // Checks if tabs (excluding selected) has alert state equals to the second
2276 // parameter. It returns YES when it finds the first tab with the criterion. 2276 // parameter. It returns YES when it finds the first tab with the criterion.
2277 - (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected 2277 - (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected
2278 haveMediaState:(TabMediaState)state { 2278 haveAlertState:(TabAlertState)state {
2279 const int existingTabCount = tabStripModel_->count(); 2279 const int existingTabCount = tabStripModel_->count();
2280 for (int i = 0; i < existingTabCount; ++i) { 2280 for (int i = 0; i < existingTabCount; ++i) {
2281 content::WebContents* currentContents = tabStripModel_->GetWebContentsAt(i); 2281 content::WebContents* currentContents = tabStripModel_->GetWebContentsAt(i);
2282 if (selected == currentContents) 2282 if (selected == currentContents)
2283 continue; 2283 continue;
2284 TabMediaState currentMediaStateForContents = 2284 TabAlertState currentAlertStateForContents =
2285 [self mediaStateForContents:currentContents]; 2285 [self alertStateForContents:currentContents];
2286 if (currentMediaStateForContents == state) 2286 if (currentAlertStateForContents == state)
2287 return YES; 2287 return YES;
2288 } 2288 }
2289 return NO; 2289 return NO;
2290 } 2290 }
2291 2291
2292 - (TabMediaState)mediaStateForContents:(content::WebContents*)contents { 2292 - (TabAlertState)alertStateForContents:(content::WebContents*)contents {
2293 return chrome::GetTabMediaStateForContents(contents); 2293 return chrome::GetTabAlertStateForContents(contents);
2294 } 2294 }
2295 2295
2296 - (void)themeDidChangeNotification:(NSNotification*)notification { 2296 - (void)themeDidChangeNotification:(NSNotification*)notification {
2297 [newTabButton_ setImages]; 2297 [newTabButton_ setImages];
2298 } 2298 }
2299 2299
2300 @end 2300 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.h ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698