| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // A helper class to monitor tab hidden and closed notifications. If we receive | 50 // A helper class to monitor tab hidden and closed notifications. If we receive |
| 51 // such a notification, we stop the animation. | 51 // such a notification, we stop the animation. |
| 52 class DownloadAnimationWebObserver : public content::NotificationObserver { | 52 class DownloadAnimationWebObserver : public content::NotificationObserver { |
| 53 public: | 53 public: |
| 54 DownloadAnimationWebObserver(DownloadStartedAnimationMac* owner, | 54 DownloadAnimationWebObserver(DownloadStartedAnimationMac* owner, |
| 55 WebContents* web_contents) | 55 WebContents* web_contents) |
| 56 : owner_(owner), | 56 : owner_(owner), |
| 57 web_contents_(web_contents) { | 57 web_contents_(web_contents) { |
| 58 registrar_.Add(this, | 58 registrar_.Add(this, |
| 59 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, | 59 content::NOTIFICATION_WEB_CONTENTS_VISIBLITY_CHANGED, |
| 60 content::Source<WebContents>(web_contents_)); | 60 content::Source<WebContents>(web_contents_)); |
| 61 registrar_.Add(this, | 61 registrar_.Add(this, |
| 62 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 62 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 63 content::Source<WebContents>(web_contents_)); | 63 content::Source<WebContents>(web_contents_)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Runs when a tab is hidden or destroyed. Let our owner know we should end | 66 // Runs when a tab is hidden or destroyed. Let our owner know we should end |
| 67 // the animation. | 67 // the animation. |
| 68 void Observe(int type, | 68 void Observe(int type, |
| 69 const content::NotificationSource& source, | 69 const content::NotificationSource& source, |
| 70 const content::NotificationDetails& details) { | 70 const content::NotificationDetails& details) { |
| 71 if (type == NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { |
| 72 bool visible = *Details<bool>(details).ptr(); |
| 73 if (visible) |
| 74 return; |
| 75 } |
| 71 // This ends up deleting us. | 76 // This ends up deleting us. |
| 72 [owner_ closeAnimation]; | 77 [owner_ closeAnimation]; |
| 73 } | 78 } |
| 74 | 79 |
| 75 private: | 80 private: |
| 76 // The object we need to inform when we get a notification. Weak. | 81 // The object we need to inform when we get a notification. Weak. |
| 77 DownloadStartedAnimationMac* owner_; | 82 DownloadStartedAnimationMac* owner_; |
| 78 | 83 |
| 79 // The tab we are observing. Weak. | 84 // The tab we are observing. Weak. |
| 80 WebContents* web_contents_; | 85 WebContents* web_contents_; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 198 } |
| 194 | 199 |
| 195 @end | 200 @end |
| 196 | 201 |
| 197 void DownloadStartedAnimation::Show(WebContents* web_contents) { | 202 void DownloadStartedAnimation::Show(WebContents* web_contents) { |
| 198 DCHECK(web_contents); | 203 DCHECK(web_contents); |
| 199 | 204 |
| 200 // Will be deleted when the animation is complete. | 205 // Will be deleted when the animation is complete. |
| 201 [DownloadStartedAnimationMac startAnimationWithWebContents:web_contents]; | 206 [DownloadStartedAnimationMac startAnimationWithWebContents:web_contents]; |
| 202 } | 207 } |
| OLD | NEW |