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

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

Issue 1432803002: Removed emojis from generated_resources.grd and update the code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the unit test build failure by casting NSNotFound 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"
49 #include "chrome/common/chrome_switches.h" 48 #include "chrome/common/chrome_switches.h"
50 #include "chrome/grit/generated_resources.h" 49 #include "chrome/grit/generated_resources.h"
51 #include "components/metrics/proto/omnibox_event.pb.h" 50 #include "components/metrics/proto/omnibox_event.pb.h"
52 #include "components/omnibox/browser/autocomplete_classifier.h" 51 #include "components/omnibox/browser/autocomplete_classifier.h"
53 #include "components/omnibox/browser/autocomplete_match.h" 52 #include "components/omnibox/browser/autocomplete_match.h"
54 #include "components/url_formatter/url_fixer.h" 53 #include "components/url_formatter/url_fixer.h"
55 #include "components/web_modal/web_contents_modal_dialog_manager.h" 54 #include "components/web_modal/web_contents_modal_dialog_manager.h"
56 #include "content/public/browser/navigation_controller.h" 55 #include "content/public/browser/navigation_controller.h"
57 #include "content/public/browser/user_metrics.h" 56 #include "content/public/browser/user_metrics.h"
58 #include "content/public/browser/web_contents.h" 57 #include "content/public/browser/web_contents.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 - (NSInteger)numberOfOpenPinnedTabs; 243 - (NSInteger)numberOfOpenPinnedTabs;
245 - (NSInteger)numberOfOpenNonPinnedTabs; 244 - (NSInteger)numberOfOpenNonPinnedTabs;
246 - (void)mouseMoved:(NSEvent*)event; 245 - (void)mouseMoved:(NSEvent*)event;
247 - (void)setTabTrackingAreasEnabled:(BOOL)enabled; 246 - (void)setTabTrackingAreasEnabled:(BOOL)enabled;
248 - (void)droppingURLsAt:(NSPoint)point 247 - (void)droppingURLsAt:(NSPoint)point
249 givesIndex:(NSInteger*)index 248 givesIndex:(NSInteger*)index
250 disposition:(WindowOpenDisposition*)disposition; 249 disposition:(WindowOpenDisposition*)disposition;
251 - (void)setNewTabButtonHoverState:(BOOL)showHover; 250 - (void)setNewTabButtonHoverState:(BOOL)showHover;
252 - (void)themeDidChangeNotification:(NSNotification*)notification; 251 - (void)themeDidChangeNotification:(NSNotification*)notification;
253 - (void)setNewTabImages; 252 - (void)setNewTabImages;
253 - (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected
254 haveMediaState:(TabMediaState)state;
255
Robert Sesek 2015/11/21 03:39:01 nit: remove blank line
254 @end 256 @end
255 257
256 // A simple view class that contains the traffic light buttons. This class 258 // 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 259 // ensures that the buttons display the icons when the mouse hovers over
258 // them by overriding the _mouseInGroup method. 260 // them by overriding the _mouseInGroup method.
259 @interface CustomWindowControlsView : NSView { 261 @interface CustomWindowControlsView : NSView {
260 @private 262 @private
261 BOOL mouseInside_; 263 BOOL mouseInside_;
262 } 264 }
263 265
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 // a canned string if |contents| is NULL. 1269 // a canned string if |contents| is NULL.
1268 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents { 1270 - (void)setTabTitle:(TabController*)tab withContents:(WebContents*)contents {
1269 base::string16 title; 1271 base::string16 title;
1270 if (contents) 1272 if (contents)
1271 title = contents->GetTitle(); 1273 title = contents->GetTitle();
1272 if (title.empty()) 1274 if (title.empty())
1273 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); 1275 title = l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED);
1274 [tab setTitle:base::SysUTF16ToNSString(title)]; 1276 [tab setTitle:base::SysUTF16ToNSString(title)];
1275 1277
1276 const base::string16& toolTip = chrome::AssembleTabTooltipText( 1278 const base::string16& toolTip = chrome::AssembleTabTooltipText(
1277 title, chrome::GetTabMediaStateForContents(contents)); 1279 title, [self mediaStateForContents:contents]);
1278 [tab setToolTip:base::SysUTF16ToNSString(toolTip)]; 1280 [tab setToolTip:base::SysUTF16ToNSString(toolTip)];
1279 } 1281 }
1280 1282
1281 // Called when a notification is received from the model to insert a new tab 1283 // Called when a notification is received from the model to insert a new tab
1282 // at |modelIndex|. 1284 // at |modelIndex|.
1283 - (void)insertTabWithContents:(content::WebContents*)contents 1285 - (void)insertTabWithContents:(content::WebContents*)contents
1284 atIndex:(NSInteger)modelIndex 1286 atIndex:(NSInteger)modelIndex
1285 inForeground:(bool)inForeground { 1287 inForeground:(bool)inForeground {
1286 DCHECK(contents); 1288 DCHECK(contents);
1287 DCHECK(modelIndex == TabStripModel::kNoTab || 1289 DCHECK(modelIndex == TabStripModel::kNoTab ||
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 } else if (newState == kTabCrashed) { 1621 } else if (newState == kTabCrashed) {
1620 [tabController setIconImage:sadFaviconImage withToastAnimation:YES]; 1622 [tabController setIconImage:sadFaviconImage withToastAnimation:YES];
1621 } else { 1623 } else {
1622 [tabController setIconImage:throbberImage]; 1624 [tabController setIconImage:throbberImage];
1623 } 1625 }
1624 } else { 1626 } else {
1625 [tabController setIconImage:nil]; 1627 [tabController setIconImage:nil];
1626 } 1628 }
1627 } 1629 }
1628 1630
1629 [tabController setMediaState:chrome::GetTabMediaStateForContents(contents)]; 1631 TabMediaState mediaState = [self mediaStateForContents:contents];
1632 [self updateWindowMediaState:mediaState forWebContents:contents];
1633 [tabController setMediaState:mediaState];
1630 1634
1631 [tabController updateVisibility]; 1635 [tabController updateVisibility];
1632 } 1636 }
1633 1637
1634 // Called when a notification is received from the model that the given tab 1638 // 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 1639 // 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. 1640 // throbber state, not anything else about the (partially) loading tab.
1637 - (void)tabChangedWithContents:(content::WebContents*)contents 1641 - (void)tabChangedWithContents:(content::WebContents*)contents
1638 atIndex:(NSInteger)modelIndex 1642 atIndex:(NSInteger)modelIndex
1639 changeType:(TabStripModelObserver::TabChangeType)change { 1643 changeType:(TabStripModelObserver::TabChangeType)change {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 } 2288 }
2285 } 2289 }
2286 2290
2287 - (void)removeCustomWindowControls { 2291 - (void)removeCustomWindowControls {
2288 if (customWindowControls_) 2292 if (customWindowControls_)
2289 [permanentSubviews_ removeObject:customWindowControls_]; 2293 [permanentSubviews_ removeObject:customWindowControls_];
2290 [self regenerateSubviewList]; 2294 [self regenerateSubviewList];
2291 [customWindowControls_ setMouseInside:NO]; 2295 [customWindowControls_ setMouseInside:NO];
2292 } 2296 }
2293 2297
2298 // Gets the tab and the media state to check whether the window
2299 // media state should be updated or not. If the tab media state is
2300 // AUDIO_PLAYING, the window media state should be set to AUDIO_PLAYING.
2301 // If the tab media state is AUDIO_MUTING, this method would check if the
2302 // window has no other tab with state AUDIO_PLAYING, then the window
2303 // media state will be set to AUDIO_MUTING. If the tab media state is NONE,
2304 // this method checks if the window has no playing or muting tab, then window
2305 // media state will be set as NONE.
2306 - (void)updateWindowMediaState:(TabMediaState)mediaState
2307 forWebContents:(content::WebContents*)selected {
2308 NSWindow* window = [tabStripView_ window];
2309 BrowserWindowController* windowController =
2310 [BrowserWindowController browserWindowControllerForWindow:window];
2311 if (mediaState == TAB_MEDIA_STATE_NONE) {
2312 if (![self doesAnyOtherWebContents:selected
2313 haveMediaState:TAB_MEDIA_STATE_AUDIO_PLAYING] &&
2314 ![self doesAnyOtherWebContents:selected
2315 haveMediaState:TAB_MEDIA_STATE_AUDIO_MUTING]) {
2316 [windowController setMediaState:TAB_MEDIA_STATE_NONE];
2317 } else if ([self doesAnyOtherWebContents:selected
2318 haveMediaState:TAB_MEDIA_STATE_AUDIO_MUTING]) {
2319 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING];
2320 }
2321 } else if (mediaState == TAB_MEDIA_STATE_AUDIO_MUTING) {
2322 if (![self doesAnyOtherWebContents:selected
2323 haveMediaState:TAB_MEDIA_STATE_AUDIO_PLAYING])
Robert Sesek 2015/11/21 03:39:01 nit: needs {}
2324 [windowController setMediaState:TAB_MEDIA_STATE_AUDIO_MUTING];
2325 } else {
2326 [windowController setMediaState:mediaState];
2327 }
2328 }
2329
2330 // Checks if tabs (excluding selected) has media state equals to the second
2331 // parameter. It returns YES when it finds the first tab with the criterion.
2332 - (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected
2333 haveMediaState:(TabMediaState)state {
2334 const int existingTabCount = tabStripModel_->count();
2335 for (int i = 0; i < existingTabCount; ++i) {
2336 content::WebContents* currentContents = tabStripModel_->GetWebContentsAt(i);
2337 if (selected == currentContents)
2338 continue;
2339 TabMediaState currentMediaStateForContents =
2340 [self mediaStateForContents:currentContents];
2341 if (currentMediaStateForContents == state)
2342 return YES;
2343 }
2344 return NO;
2345 }
2346
2347 - (TabMediaState)mediaStateForContents:(content::WebContents*)contents {
2348 return chrome::GetTabMediaStateForContents(contents);
2349 }
2350
2294 - (void)themeDidChangeNotification:(NSNotification*)notification { 2351 - (void)themeDidChangeNotification:(NSNotification*)notification {
2295 [self setNewTabImages]; 2352 [self setNewTabImages];
2296 } 2353 }
2297 2354
2298 - (void)setNewTabImages { 2355 - (void)setNewTabImages {
2299 ThemeService *theme = 2356 ThemeService *theme =
2300 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]); 2357 static_cast<ThemeService*>([[tabStripView_ window] themeProvider]);
2301 if (!theme) 2358 if (!theme)
2302 return; 2359 return;
2303 2360
(...skipping 24 matching lines...) Expand all
2328 forButtonState:image_button_cell::kHoverStateBackground]; 2385 forButtonState:image_button_cell::kHoverStateBackground];
2329 } else { 2386 } else {
2330 [[newTabButton_ cell] setImage:nil 2387 [[newTabButton_ cell] setImage:nil
2331 forButtonState:image_button_cell::kDefaultStateBackground]; 2388 forButtonState:image_button_cell::kDefaultStateBackground];
2332 [[newTabButton_ cell] setImage:nil 2389 [[newTabButton_ cell] setImage:nil
2333 forButtonState:image_button_cell::kHoverStateBackground]; 2390 forButtonState:image_button_cell::kHoverStateBackground];
2334 } 2391 }
2335 } 2392 }
2336 2393
2337 @end 2394 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698