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

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

Issue 1412803012: Revert "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: Created 5 years, 1 month 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 27 matching lines...) Expand all
38 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" 38 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" 39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
41 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 41 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
42 #include "chrome/browser/ui/find_bar/find_bar.h" 42 #include "chrome/browser/ui/find_bar/find_bar.h"
43 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 43 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
44 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 44 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
45 #include "chrome/browser/ui/tabs/tab_menu_model.h" 45 #include "chrome/browser/ui/tabs/tab_menu_model.h"
46 #include "chrome/browser/ui/tabs/tab_strip_model.h" 46 #include "chrome/browser/ui/tabs/tab_strip_model.h"
47 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 47 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
48 #include "chrome/browser/ui/tabs/tab_utils.h"
48 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
49 #include "chrome/grit/generated_resources.h" 50 #include "chrome/grit/generated_resources.h"
50 #include "components/metrics/proto/omnibox_event.pb.h" 51 #include "components/metrics/proto/omnibox_event.pb.h"
51 #include "components/omnibox/browser/autocomplete_classifier.h" 52 #include "components/omnibox/browser/autocomplete_classifier.h"
52 #include "components/omnibox/browser/autocomplete_match.h" 53 #include "components/omnibox/browser/autocomplete_match.h"
53 #include "components/url_formatter/url_fixer.h" 54 #include "components/url_formatter/url_fixer.h"
54 #include "components/web_modal/web_contents_modal_dialog_manager.h" 55 #include "components/web_modal/web_contents_modal_dialog_manager.h"
55 #include "content/public/browser/navigation_controller.h" 56 #include "content/public/browser/navigation_controller.h"
56 #include "content/public/browser/user_metrics.h" 57 #include "content/public/browser/user_metrics.h"
57 #include "content/public/browser/web_contents.h" 58 #include "content/public/browser/web_contents.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 - (NSInteger)numberOfOpenPinnedTabs; 245 - (NSInteger)numberOfOpenPinnedTabs;
245 - (NSInteger)numberOfOpenNonPinnedTabs; 246 - (NSInteger)numberOfOpenNonPinnedTabs;
246 - (void)mouseMoved:(NSEvent*)event; 247 - (void)mouseMoved:(NSEvent*)event;
247 - (void)setTabTrackingAreasEnabled:(BOOL)enabled; 248 - (void)setTabTrackingAreasEnabled:(BOOL)enabled;
248 - (void)droppingURLsAt:(NSPoint)point 249 - (void)droppingURLsAt:(NSPoint)point
249 givesIndex:(NSInteger*)index 250 givesIndex:(NSInteger*)index
250 disposition:(WindowOpenDisposition*)disposition; 251 disposition:(WindowOpenDisposition*)disposition;
251 - (void)setNewTabButtonHoverState:(BOOL)showHover; 252 - (void)setNewTabButtonHoverState:(BOOL)showHover;
252 - (void)themeDidChangeNotification:(NSNotification*)notification; 253 - (void)themeDidChangeNotification:(NSNotification*)notification;
253 - (void)setNewTabImages; 254 - (void)setNewTabImages;
254 - (BOOL)isAnyOtherTab:(content::WebContents*)selected
255 withState:(TabMediaState)state;
256
257 @end 255 @end
258 256
259 // A simple view class that contains the traffic light buttons. This class 257 // A simple view class that contains the traffic light buttons. This class
260 // ensures that the buttons display the icons when the mouse hovers over 258 // ensures that the buttons display the icons when the mouse hovers over
261 // them by overriding the _mouseInGroup method. 259 // them by overriding the _mouseInGroup method.
262 @interface CustomWindowControlsView : NSView { 260 @interface CustomWindowControlsView : NSView {
263 @private 261 @private
264 BOOL mouseInside_; 262 BOOL mouseInside_;
265 } 263 }
266 264
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 // a canned string if |contents| is NULL. 1271 // a canned string if |contents| is NULL.
1274 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents { 1272 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents {
1275 base::string16 title; 1273 base::string16 title;
1276 if (contents) 1274 if (contents)
1277 title = contents->GetTitle(); 1275 title = contents->GetTitle();
1278 if (title.empty()) 1276 if (title.empty())
1279 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); 1277 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED);
1280 [tab setTitle:base::SysUTF16ToNSString(title)]; 1278 [tab setTitle:base::SysUTF16ToNSString(title)];
1281 1279
1282 const base::string16& toolTip = chrome::AssembleTabTooltipText( 1280 const base::string16& toolTip = chrome::AssembleTabTooltipText(
1283 title, [self mediaStateForContents:contents]); 1281 title, chrome::GetTabMediaStateForContents(contents));
1284 [tab setToolTip:base::SysUTF16ToNSString(toolTip)]; 1282 [tab setToolTip:base::SysUTF16ToNSString(toolTip)];
1285 } 1283 }
1286 1284
1287 // Called when a notification is received from the model to insert a new tab 1285 // Called when a notification is received from the model to insert a new tab
1288 // at |modelIndex|. 1286 // at |modelIndex|.
1289 - (void)insertTabWithContents:(content::WebContents*)contents 1287 - (void)insertTabWithContents:(content::WebContents*)contents
1290 atIndex:(NSInteger)modelIndex 1288 atIndex:(NSInteger)modelIndex
1291 inForeground:(bool)inForeground { 1289 inForeground:(bool)inForeground {
1292 DCHECK(contents); 1290 DCHECK(contents);
1293 DCHECK(modelIndex == TabStripModel::kNoTab || 1291 DCHECK(modelIndex == TabStripModel::kNoTab ||
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 } else if (newState == kTabCrashed) { 1624 } else if (newState == kTabCrashed) {
1627 [tabController setIconImage:sadFaviconImage withToastAnimation:YES]; 1625 [tabController setIconImage:sadFaviconImage withToastAnimation:YES];
1628 } else { 1626 } else {
1629 [tabController setIconImage:throbberImage]; 1627 [tabController setIconImage:throbberImage];
1630 } 1628 }
1631 } else { 1629 } else {
1632 [tabController setIconImage:nil]; 1630 [tabController setIconImage:nil];
1633 } 1631 }
1634 } 1632 }
1635 1633
1636 TabMediaState mediaState = [self mediaStateForContents:contents]; 1634 [tabController setMediaState:chrome::GetTabMediaStateForContents(contents)];
1637
1638 [self updateWindowMediaState:mediaState on:contents];
1639 [tabController setMediaState:mediaState];
1640 1635
1641 [tabController updateVisibility]; 1636 [tabController updateVisibility];
1642 } 1637 }
1643 1638
1644 // Called when a notification is received from the model that the given tab 1639 // Called when a notification is received from the model that the given tab
1645 // has been updated. |loading| will be YES when we only want to update the 1640 // has been updated. |loading| will be YES when we only want to update the
1646 // throbber state, not anything else about the (partially) loading tab. 1641 // throbber state, not anything else about the (partially) loading tab.
1647 - (void)tabChangedWithContents:(content::WebContents*)contents 1642 - (void)tabChangedWithContents:(content::WebContents*)contents
1648 atIndex:(NSInteger)modelIndex 1643 atIndex:(NSInteger)modelIndex
1649 changeType:(TabStripModelObserver::TabChangeType)change { 1644 changeType:(TabStripModelObserver::TabChangeType)change {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 } 2289 }
2295 } 2290 }
2296 2291
2297 - (void)removeCustomWindowControls { 2292 - (void)removeCustomWindowControls {
2298 if (customWindowControls_) 2293 if (customWindowControls_)
2299 [permanentSubviews_ removeObject:customWindowControls_]; 2294 [permanentSubviews_ removeObject:customWindowControls_];
2300 [self regenerateSubviewList]; 2295 [self regenerateSubviewList];
2301 [customWindowControls_ setMouseInside:NO]; 2296 [customWindowControls_ setMouseInside:NO];
2302 } 2297 }
2303 2298
2304 // Gets the tab and the media state to check whether the window
2305 // media state should be updated or not. If the tab media state is
2306 // AUDIO_PLAYING, the window media state should be set to AUDIO_PLAYING.
2307 // If the tab media state is AUDIO_MUTING, this method would check if the
2308 // window has no other tab with state AUDIO_PLAYING, then the window
2309 // media state will be set to AUDIO_MUTING. If the tab media state is NONE,
2310 // this method checks if the window has no playing or muting tab, then window
2311 // media state will be set as NONE.
2312 - (void)updateWindowMediaState:(TabMediaState)mediaState
2313 on:(content::WebContents*)selected {
2314 NSWindow* window = [tabStripView_ window];
2315 BrowserWindowController* windowController =
2316 [BrowserWindowController browserWindowControllerForWindow:window];
2317 if (mediaState == TAB_MEDIA_STATE_NONE) {
2318 if (![self isAnyOtherTab:selected
2319 withState:TAB_MEDIA_STATE_AUDIO_PLAYING] &&
2320 ![self isAnyOtherTab:selected withState:TAB_MEDIA_STATE_AUDIO_MUTING]) {
2321 [windowController setMediaState:TAB_MEDIA_STATE_NONE];
2322 } else if ([self isAnyOtherTab:selected
2323 withState:TAB_MEDIA_STATE_AUDIO_MUTING]) {
2324 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING];
2325 }
2326 } else if (mediaState == TAB_MEDIA_STATE_AUDIO_MUTING) {
2327 if (![self isAnyOtherTab:selected withState:TAB_MEDIA_STATE_AUDIO_PLAYING])
2328 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING];
2329 } else {
2330 [windowController setMediaState:mediaState];
2331 }
2332 }
2333
2334 // Checks if tabs (excluding selected) has media state equals to the second
2335 // parameter. It returns YES when it finds the first tab with the criterion.
2336 - (BOOL)isAnyOtherTab:(content::WebContents*)selected
2337 withState:(TabMediaState)state {
2338 const int existingTabCount = tabStripModel_->count();
2339 for (int i = 0; i < existingTabCount; ++i) {
2340 content::WebContents* currentContents = tabStripModel_->GetWebContentsAt(i);
2341 if (selected == currentContents)
2342 continue;
2343 TabMediaState currentMediaStateForContents =
2344 [self mediaStateForContents:currentContents];
2345 if (currentMediaStateForContents == state)
2346 return YES;
2347 }
2348 return NO;
2349 }
2350
2351 - (TabMediaState)mediaStateForContents:(content::WebContents*)contents {
2352 return chrome::GetTabMediaStateForContents(contents);
2353 }
2354
2355 - (void)themeDidChangeNotification:(NSNotification*)notification { 2299 - (void)themeDidChangeNotification:(NSNotification*)notification {
2356 [self setNewTabImages]; 2300 [self setNewTabImages];
2357 } 2301 }
2358 2302
2359 - (void)setNewTabImages { 2303 - (void)setNewTabImages {
2360 ThemeService *theme = 2304 ThemeService *theme =
2361 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]); 2305 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]);
2362 if (!theme) 2306 if (!theme)
2363 return; 2307 return;
2364 2308
(...skipping 24 matching lines...) Expand all
2389 forButtonState:image_button_cell::kHoverStateBackground]; 2333 forButtonState:image_button_cell::kHoverStateBackground];
2390 } else { 2334 } else {
2391 [[newTabButton_ cell] setImage:nil 2335 [[newTabButton_ cell] setImage:nil
2392 forButtonState:image_button_cell::kDefaultStateBackground]; 2336 forButtonState:image_button_cell::kDefaultStateBackground];
2393 [[newTabButton_ cell] setImage:nil 2337 [[newTabButton_ cell] setImage:nil
2394 forButtonState:image_button_cell::kHoverStateBackground]; 2338 forButtonState:image_button_cell::kHoverStateBackground];
2395 } 2339 }
2396 } 2340 }
2397 2341
2398 @end 2342 @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