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

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

Issue 2126043002: [Material][Mac] Fix Default Favicon's Color (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaned up Created 4 years, 5 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_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/mac/bundle_locations.h" 11 #include "base/mac/bundle_locations.h"
12 #import "chrome/browser/themes/theme_properties.h" 12 #import "chrome/browser/themes/theme_properties.h"
13 #import "chrome/browser/themes/theme_service.h" 13 #import "chrome/browser/themes/theme_service.h"
14 #import "chrome/browser/ui/cocoa/sprite_view.h" 14 #import "chrome/browser/ui/cocoa/sprite_view.h"
15 #include "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h"
15 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h" 16 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h"
16 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" 17 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h"
17 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 18 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
18 #import "chrome/browser/ui/cocoa/themed_window.h" 19 #import "chrome/browser/ui/cocoa/themed_window.h"
19 #include "content/public/browser/user_metrics.h" 20 #include "content/public/browser/user_metrics.h"
20 #import "extensions/common/extension.h" 21 #import "extensions/common/extension.h"
21 #import "ui/base/cocoa/menu_controller.h" 22 #import "ui/base/cocoa/menu_controller.h"
22 #include "ui/base/material_design/material_design_controller.h" 23 #include "ui/base/material_design/material_design_controller.h"
23 24
24 @implementation TabController 25 @implementation TabController
25 26
26 @synthesize action = action_; 27 @synthesize action = action_;
27 @synthesize loadingState = loadingState_; 28 @synthesize loadingState = loadingState_;
28 @synthesize pinned = pinned_; 29 @synthesize pinned = pinned_;
29 @synthesize target = target_; 30 @synthesize target = target_;
30 @synthesize url = url_; 31 @synthesize url = url_;
32 @synthesize shouldUseDefaultFavicon = shouldUseDefaultFavicon_;
31 33
32 namespace TabControllerInternal { 34 namespace TabControllerInternal {
33 35
34 // A C++ delegate that handles enabling/disabling menu items and handling when 36 // A C++ delegate that handles enabling/disabling menu items and handling when
35 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin 37 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin
36 // tab". 38 // tab".
37 class MenuDelegate : public ui::SimpleMenuModel::Delegate { 39 class MenuDelegate : public ui::SimpleMenuModel::Delegate {
38 public: 40 public:
39 explicit MenuDelegate(id<TabControllerTarget> target, TabController* owner) 41 explicit MenuDelegate(id<TabControllerTarget> target, TabController* owner)
40 : target_(target), 42 : target_(target),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 - (void)internalSetSelected:(BOOL)selected { 166 - (void)internalSetSelected:(BOOL)selected {
165 TabView* tabView = [self tabView]; 167 TabView* tabView = [self tabView];
166 if ([self active]) { 168 if ([self active]) {
167 [tabView setState:NSOnState]; 169 [tabView setState:NSOnState];
168 [tabView cancelAlert]; 170 [tabView cancelAlert];
169 } else { 171 } else {
170 [tabView setState:selected ? NSMixedState : NSOffState]; 172 [tabView setState:selected ? NSMixedState : NSOffState];
171 } 173 }
172 [self updateVisibility]; 174 [self updateVisibility];
173 [self updateTitleColor]; 175 [self updateTitleColor];
176 [self updateDefaultFavicon];
174 } 177 }
175 178
176 // Called when Cocoa wants to display the context menu. Lazily instantiate 179 // Called when Cocoa wants to display the context menu. Lazily instantiate
177 // the menu based off of the cross-platform model. Re-create the menu and 180 // the menu based off of the cross-platform model. Re-create the menu and
178 // model every time to get the correct labels and enabling. 181 // model every time to get the correct labels and enabling.
179 - (NSMenu*)menu { 182 - (NSMenu*)menu {
180 contextMenuDelegate_.reset( 183 contextMenuDelegate_.reset(
181 new TabControllerInternal::MenuDelegate(target_, self)); 184 new TabControllerInternal::MenuDelegate(target_, self));
182 contextMenuModel_.reset( 185 contextMenuModel_.reset(
183 [target_ contextMenuModelForController:self 186 [target_ contextMenuModelForController:self
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 NSColor* titleColor = nil; 452 NSColor* titleColor = nil;
450 const ui::ThemeProvider* theme = [[[self view] window] themeProvider]; 453 const ui::ThemeProvider* theme = [[[self view] window] themeProvider];
451 if (theme && ![self selected]) 454 if (theme && ![self selected])
452 titleColor = theme->GetNSColor(ThemeProperties::COLOR_BACKGROUND_TAB_TEXT); 455 titleColor = theme->GetNSColor(ThemeProperties::COLOR_BACKGROUND_TAB_TEXT);
453 // Default to the selected text color unless told otherwise. 456 // Default to the selected text color unless told otherwise.
454 if (theme && !titleColor) 457 if (theme && !titleColor)
455 titleColor = theme->GetNSColor(ThemeProperties::COLOR_TAB_TEXT); 458 titleColor = theme->GetNSColor(ThemeProperties::COLOR_TAB_TEXT);
456 [[self tabView] setTitleColor:titleColor ? titleColor : [NSColor textColor]]; 459 [[self tabView] setTitleColor:titleColor ? titleColor : [NSColor textColor]];
457 } 460 }
458 461
462 - (void)updateDefaultFavicon {
463 if (ui::MaterialDesignController::IsModeMaterial() &&
464 shouldUseDefaultFavicon_) {
465 [self setIconImage:mac::DefaultFavicon([[self tabView] iconColor])];
466 }
467 }
468
459 - (void)themeChangedNotification:(NSNotification*)notification { 469 - (void)themeChangedNotification:(NSNotification*)notification {
460 [self updateTitleColor]; 470 [self updateTitleColor];
471 [self updateDefaultFavicon];
461 } 472 }
462 473
463 // Called by the tabs to determine whether we are in rapid (tab) closure mode. 474 // Called by the tabs to determine whether we are in rapid (tab) closure mode.
464 - (BOOL)inRapidClosureMode { 475 - (BOOL)inRapidClosureMode {
465 if ([[self target] respondsToSelector:@selector(inRapidClosureMode)]) { 476 if ([[self target] respondsToSelector:@selector(inRapidClosureMode)]) {
466 return [[self target] performSelector:@selector(inRapidClosureMode)] ? 477 return [[self target] performSelector:@selector(inRapidClosureMode)] ?
467 YES : NO; 478 YES : NO;
468 } 479 }
469 return NO; 480 return NO;
470 } 481 }
471 482
472 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { 483 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab {
473 [[target_ dragController] maybeStartDrag:event forTab:tab]; 484 [[target_ dragController] maybeStartDrag:event forTab:tab];
474 } 485 }
475 486
476 @end 487 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698