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

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

Issue 23513039: Replace animated tab audio indicator with static tab audio indicator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments from sky@. Also, rebased. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.h"
6
7 #include "chrome/browser/ui/tabs/tab_audio_indicator.h"
8 #include "ui/gfx/canvas_skia_paint.h"
9 #include "ui/gfx/image/image.h"
10 #include "ui/gfx/rect.h"
11
12 class TabAudioIndicatorDelegateMac : public TabAudioIndicator::Delegate {
13 public:
14 explicit TabAudioIndicatorDelegateMac(TabAudioIndicatorViewMac* view)
15 : view_(view) {
16 }
17
18 virtual ~TabAudioIndicatorDelegateMac() {}
19
20 virtual void ScheduleAudioIndicatorPaint() OVERRIDE {
21 [view_ setNeedsDisplay:YES];
22 }
23
24 private:
25 TabAudioIndicatorViewMac* view_;
26
27 DISALLOW_COPY_AND_ASSIGN(TabAudioIndicatorDelegateMac);
28 };
29
30 @interface TabAudioIndicatorViewMac ()
31 @end
32
33 @implementation TabAudioIndicatorViewMac
34
35 - (id)initWithFrame:(NSRect)frame {
36 if ((self = [super initWithFrame:frame])) {
37 delegate_.reset(new TabAudioIndicatorDelegateMac(self));
38 tabAudioIndicator_.reset(new TabAudioIndicator(delegate_.get()));
39 }
40 return self;
41 }
42
43 - (void)setIsPlayingAudio:(BOOL)isPlayingAudio {
44 tabAudioIndicator_->SetIsPlayingAudio(isPlayingAudio);
45 }
46
47 - (void)setBackgroundImage:(NSImage*)backgroundImage {
48 gfx::Image image([backgroundImage retain]);
49 tabAudioIndicator_->set_favicon(*image.ToImageSkia());
50 }
51
52 - (void)setAnimationContainer:(gfx::AnimationContainer*)animationContainer {
53 tabAudioIndicator_->SetAnimationContainer(animationContainer);
54 }
55
56 - (BOOL)isAnimating {
57 return tabAudioIndicator_->IsAnimating();
58 }
59
60 - (void)drawRect:(NSRect)rect {
61 gfx::CanvasSkiaPaint canvas(rect, false);
62 canvas.set_composite_alpha(true);
63 tabAudioIndicator_->Paint(&canvas, gfx::Rect(NSRectToCGRect([self bounds])));
64 }
65
66 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698