Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/alert_indicator_button_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 [super setAction:@selector(handleClick:)]; | 65 [super setAction:@selector(handleClick:)]; |
| 66 } | 66 } |
| 67 return self; | 67 return self; |
| 68 } | 68 } |
| 69 | 69 |
| 70 - (void)removeFromSuperview { | 70 - (void)removeFromSuperview { |
| 71 fadeAnimation_.reset(); | 71 fadeAnimation_.reset(); |
| 72 [super removeFromSuperview]; | 72 [super removeFromSuperview]; |
| 73 } | 73 } |
| 74 | 74 |
| 75 - (void)updateIconForState:(TabAlertState)aState { | |
| 76 if (aState != TabAlertState::NONE) { | |
| 77 TabView* const tabView = base::mac::ObjCCast<TabView>([self superview]); | |
| 78 SkColor iconColor = [tabView closeButtonColor]; | |
| 79 NSImage* tabIndicatorImage = | |
| 80 chrome::GetTabAlertIndicatorImage(aState, iconColor).ToNSImage(); | |
| 81 [self setImage:tabIndicatorImage]; | |
| 82 affordanceImage_.reset([tabIndicatorImage retain]); | |
|
Avi (use Gerrit)
2016/04/14 02:35:08
You can do
affordanceImage_.reset(tabIndicatorIma
| |
| 83 } | |
| 84 } | |
| 85 | |
| 75 - (void)transitionToAlertState:(TabAlertState)nextState { | 86 - (void)transitionToAlertState:(TabAlertState)nextState { |
| 76 if (nextState == alertState_) | 87 if (nextState == alertState_) |
| 77 return; | 88 return; |
| 78 | 89 |
| 79 if (nextState != TabAlertState::NONE) { | 90 [self updateIconForState:nextState]; |
| 80 [self | |
| 81 setImage:chrome::GetTabAlertIndicatorImage(nextState, 0).ToNSImage()]; | |
| 82 affordanceImage_.reset( | |
| 83 [chrome::GetTabAlertIndicatorAffordanceImage(nextState, 0) | |
| 84 .ToNSImage() retain]); | |
| 85 } | |
| 86 | 91 |
| 87 if ((alertState_ == TabAlertState::AUDIO_PLAYING && | 92 if ((alertState_ == TabAlertState::AUDIO_PLAYING && |
| 88 nextState == TabAlertState::AUDIO_MUTING) || | 93 nextState == TabAlertState::AUDIO_MUTING) || |
| 89 (alertState_ == TabAlertState::AUDIO_MUTING && | 94 (alertState_ == TabAlertState::AUDIO_MUTING && |
| 90 nextState == TabAlertState::AUDIO_PLAYING) || | 95 nextState == TabAlertState::AUDIO_PLAYING) || |
| 91 (alertState_ == TabAlertState::AUDIO_MUTING && | 96 (alertState_ == TabAlertState::AUDIO_MUTING && |
| 92 nextState == TabAlertState::NONE)) { | 97 nextState == TabAlertState::NONE)) { |
| 93 // Instant user feedback: No fade animation. | 98 // Instant user feedback: No fade animation. |
| 94 showingAlertState_ = nextState; | 99 showingAlertState_ = nextState; |
| 95 fadeAnimation_.reset(); | 100 fadeAnimation_.reset(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 TabView* const tabView = base::mac::ObjCCast<TabView>([self superview]); | 235 TabView* const tabView = base::mac::ObjCCast<TabView>([self superview]); |
| 231 if (enable && tabView && ([tabView state] != NSOnState)) { | 236 if (enable && tabView && ([tabView state] != NSOnState)) { |
| 232 const int requiredWidth = | 237 const int requiredWidth = |
| 233 NSWidth([self frame]) * kMinMouseSelectableAreaPercent / 100; | 238 NSWidth([self frame]) * kMinMouseSelectableAreaPercent / 100; |
| 234 enable = ([tabView widthOfLargestSelectableRegion] >= requiredWidth); | 239 enable = ([tabView widthOfLargestSelectableRegion] >= requiredWidth); |
| 235 } | 240 } |
| 236 | 241 |
| 237 [self setEnabled:enable]; | 242 [self setEnabled:enable]; |
| 238 } | 243 } |
| 239 | 244 |
| 245 // ThemedWindowDrawing protocol support. | |
| 246 | |
| 247 - (void)windowDidChangeTheme { | |
| 248 // Force the alert icon to update because the icon color may change based | |
| 249 // on the current theme. | |
| 250 [self updateIconForState:alertState_]; | |
| 251 } | |
| 252 | |
| 253 - (void)windowDidChangeActive { | |
| 254 } | |
| 255 | |
| 240 @end | 256 @end |
| OLD | NEW |