| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file contains the Mac implementation the download animation, displayed | 5 // This file contains the Mac implementation the download animation, displayed |
| 6 // at the start of a download. The animation produces an arrow pointing | 6 // at the start of a download. The animation produces an arrow pointing |
| 7 // downwards and animates towards the bottom of the window where the new | 7 // downwards and animates towards the bottom of the window where the new |
| 8 // download appears in the download shelf. | 8 // download appears in the download shelf. |
| 9 | 9 |
| 10 #include "chrome/browser/download/download_started_animation.h" | 10 #include "chrome/browser/download/download_started_animation.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(DownloadAnimationWebObserver); | 90 DISALLOW_COPY_AND_ASSIGN(DownloadAnimationWebObserver); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 @implementation DownloadStartedAnimationMac | 93 @implementation DownloadStartedAnimationMac |
| 94 | 94 |
| 95 - (id)initWithWebContents:(WebContents*)webContents { | 95 - (id)initWithWebContents:(WebContents*)webContents { |
| 96 if ((self = [super init])) { | 96 if ((self = [super init])) { |
| 97 // Load the image of the download arrow. | 97 // Load the image of the download arrow. |
| 98 ResourceBundle& bundle = ResourceBundle::GetSharedInstance(); | 98 ResourceBundle& bundle = ResourceBundle::GetSharedInstance(); |
| 99 NSImage* image = bundle.GetNativeImageNamed(IDR_DOWNLOAD_ANIMATION_BEGIN); | 99 NSImage* image = |
| 100 bundle.GetNativeImageNamed(IDR_DOWNLOAD_ANIMATION_BEGIN).ToNSImage(); |
| 100 | 101 |
| 101 // Figure out the positioning in the current tab. Try to position the layer | 102 // Figure out the positioning in the current tab. Try to position the layer |
| 102 // against the left edge, and three times the download image's height from | 103 // against the left edge, and three times the download image's height from |
| 103 // the bottom of the tab, assuming there is enough room. If there isn't | 104 // the bottom of the tab, assuming there is enough room. If there isn't |
| 104 // enough, don't show the animation and let the shelf speak for itself. | 105 // enough, don't show the animation and let the shelf speak for itself. |
| 105 gfx::Rect bounds; | 106 gfx::Rect bounds; |
| 106 webContents->GetContainerBounds(&bounds); | 107 webContents->GetContainerBounds(&bounds); |
| 107 imageWidth_ = [image size].width; | 108 imageWidth_ = [image size].width; |
| 108 CGFloat imageHeight = [image size].height; | 109 CGFloat imageHeight = [image size].height; |
| 109 | 110 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 199 } |
| 199 | 200 |
| 200 @end | 201 @end |
| 201 | 202 |
| 202 void DownloadStartedAnimation::Show(WebContents* web_contents) { | 203 void DownloadStartedAnimation::Show(WebContents* web_contents) { |
| 203 DCHECK(web_contents); | 204 DCHECK(web_contents); |
| 204 | 205 |
| 205 // Will be deleted when the animation is complete. | 206 // Will be deleted when the animation is complete. |
| 206 [DownloadStartedAnimationMac startAnimationWithWebContents:web_contents]; | 207 [DownloadStartedAnimationMac startAnimationWithWebContents:web_contents]; |
| 207 } | 208 } |
| OLD | NEW |