| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dock_icon.h" | 5 #import "chrome/browser/ui/cocoa/dock_icon.h" |
| 6 | 6 |
| 7 #include "base/mac/bundle_locations.h" |
| 7 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
| 8 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 9 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 9 | 10 |
| 10 // The fraction of the size of the dock icon that the badge is. | 11 // The fraction of the size of the dock icon that the badge is. |
| 11 static const float kBadgeFraction = 0.4f; | 12 static const float kBadgeFraction = 0.4f; |
| 12 | 13 |
| 13 // The indentation of the badge. | 14 // The indentation of the badge. |
| 14 static const float kBadgeIndent = 5.0f; | 15 static const float kBadgeIndent = 5.0f; |
| 15 | 16 |
| 16 // A view that draws our dock tile. | 17 // A view that draws our dock tile. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 35 | 36 |
| 36 @implementation DockTileView | 37 @implementation DockTileView |
| 37 | 38 |
| 38 @synthesize downloads = downloads_; | 39 @synthesize downloads = downloads_; |
| 39 @synthesize indeterminate = indeterminate_; | 40 @synthesize indeterminate = indeterminate_; |
| 40 @synthesize progress = progress_; | 41 @synthesize progress = progress_; |
| 41 | 42 |
| 42 - (void)drawRect:(NSRect)dirtyRect { | 43 - (void)drawRect:(NSRect)dirtyRect { |
| 43 // Not -[NSApplication applicationIconImage]; that fails to return a pasted | 44 // Not -[NSApplication applicationIconImage]; that fails to return a pasted |
| 44 // custom icon. | 45 // custom icon. |
| 45 NSString* appPath = [[NSBundle mainBundle] bundlePath]; | 46 NSString* appPath = [base::mac::MainBundle() bundlePath]; |
| 46 NSImage* appIcon = [[NSWorkspace sharedWorkspace] iconForFile:appPath]; | 47 NSImage* appIcon = [[NSWorkspace sharedWorkspace] iconForFile:appPath]; |
| 47 [appIcon drawInRect:[self bounds] | 48 [appIcon drawInRect:[self bounds] |
| 48 fromRect:NSZeroRect | 49 fromRect:NSZeroRect |
| 49 operation:NSCompositeSourceOver | 50 operation:NSCompositeSourceOver |
| 50 fraction:1.0]; | 51 fraction:1.0]; |
| 51 | 52 |
| 52 if (downloads_ == 0) | 53 if (downloads_ == 0) |
| 53 return; | 54 return; |
| 54 | 55 |
| 55 NSRect badgeRect = [self bounds]; | 56 NSRect badgeRect = [self bounds]; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 227 } |
| 227 | 228 |
| 228 - (void)setProgress:(float)progress { | 229 - (void)setProgress:(float)progress { |
| 229 NSDockTile* dockTile = [[NSApplication sharedApplication] dockTile]; | 230 NSDockTile* dockTile = [[NSApplication sharedApplication] dockTile]; |
| 230 DockTileView* dockTileView = (DockTileView*)([dockTile contentView]); | 231 DockTileView* dockTileView = (DockTileView*)([dockTile contentView]); |
| 231 | 232 |
| 232 [dockTileView setProgress:progress]; | 233 [dockTileView setProgress:progress]; |
| 233 } | 234 } |
| 234 | 235 |
| 235 @end | 236 @end |
| OLD | NEW |