Chromium Code Reviews| Index: chrome/browser/ui/cocoa/download/download_item_cell.mm |
| diff --git a/chrome/browser/ui/cocoa/download/download_item_cell.mm b/chrome/browser/ui/cocoa/download/download_item_cell.mm |
| index 6b0bda42d9da8eca8c994032d423c4b235d93ece..3d040493f05c50ee441eb086868add006d64df98 100644 |
| --- a/chrome/browser/ui/cocoa/download/download_item_cell.mm |
| +++ b/chrome/browser/ui/cocoa/download/download_item_cell.mm |
| @@ -16,10 +16,12 @@ |
| #include "grit/theme_resources.h" |
| #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h" |
| #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" |
| +#include "ui/base/default_theme_provider.h" |
| #include "ui/gfx/canvas_skia_paint.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| #include "ui/gfx/text_elider.h" |
| +#include "ui/native_theme/native_theme.h" |
| // Distance from top border to icon. |
| const CGFloat kImagePaddingTop = 7; |
| @@ -35,7 +37,7 @@ const CGFloat kImageHeight = 16; |
| // x coordinate of download name string, in view coords. |
| const CGFloat kTextPosLeft = kImagePaddingLeft + |
| - kImageWidth + DownloadShelf::kSmallProgressIconOffset; |
| + kImageWidth + DownloadShelf::kFiletypeIconOffset; |
| // Distance from end of download name string to dropdown area. |
| const CGFloat kTextPaddingRight = 3; |
| @@ -76,16 +78,6 @@ const CGFloat kInterruptedAnimationDuration = 2.5; |
| using content::DownloadItem; |
| -namespace { |
| - |
| -// Passed as a callback to DownloadShelf paint functions. On toolkit-views |
| -// platforms it will mirror the position of the download progress, but that's |
| -// not done on Mac. |
| -void DummyRTLMirror(gfx::Rect* bounds) { |
| -} |
| - |
| -} // namespace |
| - |
| // This is a helper class to animate the fading out of the status text. |
| @interface DownloadItemCellAnimation : NSAnimation { |
| @private |
| @@ -140,7 +132,6 @@ void DummyRTLMirror(gfx::Rect* bounds) { |
| isStatusTextVisible_ = NO; |
| titleY_ = kPrimaryTextOnlyPosTop; |
| statusAlpha_ = 0.0; |
| - indeterminateProgressAngle_ = DownloadShelf::kStartAngleDegrees; |
| [self setFont:[NSFont systemFontOfSize: |
| [NSFont systemFontSizeForControlSize:NSSmallControlSize]]]; |
| @@ -252,6 +243,7 @@ void DummyRTLMirror(gfx::Rect* bounds) { |
| if (!indeterminateProgressTimer_) { |
| indeterminateProgressTimer_.reset([[IndeterminateProgressTimer alloc] |
| initWithDownloadItemCell:self]); |
| + progressStartTime_ = base::TimeTicks::Now(); |
| } |
| } else { |
| percentDone_ = downloadModel->PercentComplete(); |
| @@ -553,31 +545,39 @@ void DummyRTLMirror(gfx::Rect* bounds) { |
| // Always repaint the whole disk. |
| NSPoint imagePosition = [self imageRectForBounds:cellFrame].origin; |
| - int x = imagePosition.x - DownloadShelf::kSmallProgressIconOffset; |
| - int y = imagePosition.y - DownloadShelf::kSmallProgressIconOffset; |
| + int x = imagePosition.x - DownloadShelf::kFiletypeIconOffset; |
| + int y = imagePosition.y - DownloadShelf::kFiletypeIconOffset; |
| NSRect dirtyRect = NSMakeRect( |
| x, y, |
| - DownloadShelf::kSmallProgressIconSize, |
| - DownloadShelf::kSmallProgressIconSize); |
| + DownloadShelf::kProgressIndicatorSize, |
| + DownloadShelf::kProgressIndicatorSize); |
| gfx::CanvasSkiaPaint canvas(dirtyRect, false); |
| canvas.set_composite_alpha(true); |
| + canvas.Translate(gfx::Vector2d(x, y)); |
| + |
| + ui::ThemeProvider* themeProvider = |
| + [[[self controlView] window] themeProvider]; |
| + ui::DefaultThemeProvider defaultTheme; |
| + if (!themeProvider) |
| + themeProvider = &defaultTheme; |
|
Evan Stade
2015/07/22 17:34:43
theme provider can be null during tests
asanka
2015/07/22 21:22:17
Can we instead mock the themeProvider selector on
Evan Stade
2015/07/22 21:32:20
That would be nice, except I don't have a mac buil
|
| + |
| if (completionAnimation_.get()) { |
| if ([completionAnimation_ isAnimating]) { |
| if (percentDone_ == -1) { |
| DownloadShelf::PaintDownloadComplete( |
| - &canvas, base::Bind(&DummyRTLMirror), x, y, |
| + &canvas, *themeProvider, |
| [completionAnimation_ currentValue]); |
| } else { |
| DownloadShelf::PaintDownloadInterrupted( |
| - &canvas, base::Bind(&DummyRTLMirror), x, y, |
| + &canvas, *themeProvider, |
| [completionAnimation_ currentValue]); |
| } |
| } |
| } else if (percentDone_ >= 0 || indeterminateProgressTimer_) { |
| - DownloadShelf::PaintDownloadProgress(&canvas, base::Bind(&DummyRTLMirror), |
| - x, y, indeterminateProgressAngle_, |
| - percentDone_); |
| + DownloadShelf::PaintDownloadProgress( |
| + &canvas, *themeProvider, |
| + progressStartTime_, percentDone_); |
| } |
| } |
| @@ -689,9 +689,6 @@ void DummyRTLMirror(gfx::Rect* bounds) { |
| } |
| - (void)updateIndeterminateDownload { |
| - indeterminateProgressAngle_ = |
| - (indeterminateProgressAngle_ + DownloadShelf::kUnknownIncrementDegrees) % |
| - DownloadShelf::kMaxDegrees; |
| [[self controlView] setNeedsDisplay:YES]; |
| } |