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

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm

Issue 12648004: Audio indicator: Mac UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebas Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm b/chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..ed8297846382fb071da19fa4dae4cc6153083c61
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm
@@ -0,0 +1,65 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.h"
+
+#include "chrome/browser/ui/tabs/tab_audio_indicator.h"
+#include "ui/gfx/canvas_skia_paint.h"
+#include "ui/gfx/rect.h"
+
+class TabAudioIndicatorDelegateMac : public TabAudioIndicator::Delegate {
+ public:
+ explicit TabAudioIndicatorDelegateMac(TabAudioIndicatorViewMac* view)
+ : view_(view) {
+ }
+
+ virtual ~TabAudioIndicatorDelegateMac() {}
+
+ virtual void ScheduleAudioIndicatorPaint() OVERRIDE {
+ [view_ setNeedsDisplay:YES];
+ }
+
+ private:
+ TabAudioIndicatorViewMac* view_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabAudioIndicatorDelegateMac);
+};
+
+@interface TabAudioIndicatorViewMac ()
+@end
+
+@implementation TabAudioIndicatorViewMac
+
+- (id)initWithFrame:(NSRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ delegate_.reset(new TabAudioIndicatorDelegateMac(self));
+ tabAudioIndicator_.reset(new TabAudioIndicator(delegate_.get()));
+ }
+ return self;
+}
+
+- (void)setIsPlayingAudio:(BOOL)isPlayingAudio {
+ tabAudioIndicator_->SetIsPlayingAudio(isPlayingAudio);
+}
+
+- (void)setBackgroundImage:(NSImage*)backgroundImage {
+ backgroundImage_.reset([backgroundImage retain]);
+}
+
+- (BOOL)isAnimating {
+ return tabAudioIndicator_->IsAnimating();
+}
+
+- (void)drawRect:(NSRect)rect {
+ [backgroundImage_ drawInRect:[self bounds]
+ fromRect:NSZeroRect
+ operation:NSCompositeSourceOver
+ fraction:1];
+
+ gfx::CanvasSkiaPaint canvas(rect, false);
+ canvas.set_composite_alpha(true);
+ tabAudioIndicator_->Paint(&canvas, gfx::Rect(NSRectToCGRect([self bounds])));
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698