OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/tab_audio_indicator_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.h" |
6 | 6 |
7 #include "chrome/browser/ui/tabs/tab_audio_indicator.h" | 7 #include "chrome/browser/ui/tabs/tab_audio_indicator.h" |
8 #include "ui/gfx/canvas_skia_paint.h" | 8 #include "ui/gfx/canvas_skia_paint.h" |
| 9 #include "ui/gfx/image/image.h" |
9 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
10 | 11 |
11 class TabAudioIndicatorDelegateMac : public TabAudioIndicator::Delegate { | 12 class TabAudioIndicatorDelegateMac : public TabAudioIndicator::Delegate { |
12 public: | 13 public: |
13 explicit TabAudioIndicatorDelegateMac(TabAudioIndicatorViewMac* view) | 14 explicit TabAudioIndicatorDelegateMac(TabAudioIndicatorViewMac* view) |
14 : view_(view) { | 15 : view_(view) { |
15 } | 16 } |
16 | 17 |
17 virtual ~TabAudioIndicatorDelegateMac() {} | 18 virtual ~TabAudioIndicatorDelegateMac() {} |
18 | 19 |
(...skipping 18 matching lines...) Expand all Loading... |
37 tabAudioIndicator_.reset(new TabAudioIndicator(delegate_.get())); | 38 tabAudioIndicator_.reset(new TabAudioIndicator(delegate_.get())); |
38 } | 39 } |
39 return self; | 40 return self; |
40 } | 41 } |
41 | 42 |
42 - (void)setIsPlayingAudio:(BOOL)isPlayingAudio { | 43 - (void)setIsPlayingAudio:(BOOL)isPlayingAudio { |
43 tabAudioIndicator_->SetIsPlayingAudio(isPlayingAudio); | 44 tabAudioIndicator_->SetIsPlayingAudio(isPlayingAudio); |
44 } | 45 } |
45 | 46 |
46 - (void)setBackgroundImage:(NSImage*)backgroundImage { | 47 - (void)setBackgroundImage:(NSImage*)backgroundImage { |
47 backgroundImage_.reset([backgroundImage retain]); | 48 gfx::Image image([backgroundImage retain]); |
| 49 tabAudioIndicator_->set_favicon(*image.ToImageSkia()); |
48 } | 50 } |
49 | 51 |
50 - (BOOL)isAnimating { | 52 - (BOOL)isAnimating { |
51 return tabAudioIndicator_->IsAnimating(); | 53 return tabAudioIndicator_->IsAnimating(); |
52 } | 54 } |
53 | 55 |
54 - (void)drawRect:(NSRect)rect { | 56 - (void)drawRect:(NSRect)rect { |
55 [backgroundImage_ drawInRect:[self bounds] | |
56 fromRect:NSZeroRect | |
57 operation:NSCompositeSourceOver | |
58 fraction:1]; | |
59 | |
60 gfx::CanvasSkiaPaint canvas(rect, false); | 57 gfx::CanvasSkiaPaint canvas(rect, false); |
61 canvas.set_composite_alpha(true); | 58 canvas.set_composite_alpha(true); |
62 tabAudioIndicator_->Paint(&canvas, gfx::Rect(NSRectToCGRect([self bounds]))); | 59 tabAudioIndicator_->Paint(&canvas, gfx::Rect(NSRectToCGRect([self bounds]))); |
63 } | 60 } |
64 | 61 |
65 @end | 62 @end |
OLD | NEW |