| 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 #include "chrome/browser/download/download_started_animation.h" | 5 #include "chrome/browser/download/download_started_animation.h" |
| 6 | 6 |
| 7 #include "content/public/browser/notification_details.h" | 7 #include "content/public/browser/notification_details.h" |
| 8 #include "content/public/browser/notification_observer.h" | 8 #include "content/public/browser/notification_observer.h" |
| 9 #include "content/public/browser/notification_registrar.h" | 9 #include "content/public/browser/notification_registrar.h" |
| 10 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 // If we're too small to show the download image, then don't bother - | 91 // If we're too small to show the download image, then don't bother - |
| 92 // the shelf will be enough. | 92 // the shelf will be enough. |
| 93 web_contents_->GetContainerBounds(&web_contents_bounds_); | 93 web_contents_->GetContainerBounds(&web_contents_bounds_); |
| 94 if (web_contents_bounds_.height() < kDownloadImage->height()) | 94 if (web_contents_bounds_.height() < kDownloadImage->height()) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 registrar_.Add( | 97 registrar_.Add( |
| 98 this, | 98 this, |
| 99 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, | 99 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
| 100 content::Source<WebContents>(web_contents_)); | 100 content::Source<WebContents>(web_contents_)); |
| 101 registrar_.Add( | 101 registrar_.Add( |
| 102 this, | 102 this, |
| 103 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 103 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 104 content::Source<WebContents>(web_contents_)); | 104 content::Source<WebContents>(web_contents_)); |
| 105 | 105 |
| 106 SetImage(kDownloadImage); | 106 SetImage(kDownloadImage); |
| 107 | 107 |
| 108 popup_ = new views::Widget; | 108 popup_ = new views::Widget; |
| 109 | 109 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 static_cast<double>(1.0)); | 164 static_cast<double>(1.0)); |
| 165 | 165 |
| 166 popup_->SetOpacity(static_cast<unsigned char>(opacity * 255.0)); | 166 popup_->SetOpacity(static_cast<unsigned char>(opacity * 255.0)); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 void DownloadStartedAnimationWin::Observe( | 170 void DownloadStartedAnimationWin::Observe( |
| 171 int type, | 171 int type, |
| 172 const content::NotificationSource& source, | 172 const content::NotificationSource& source, |
| 173 const content::NotificationDetails& details) { | 173 const content::NotificationDetails& details) { |
| 174 if (type == NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { |
| 175 bool visible = *Details<bool>(details).ptr(); |
| 176 if (visible) |
| 177 return; |
| 178 } |
| 174 Close(); | 179 Close(); |
| 175 } | 180 } |
| 176 | 181 |
| 177 } // namespace | 182 } // namespace |
| 178 | 183 |
| 179 // static | 184 // static |
| 180 void DownloadStartedAnimation::Show(WebContents* web_contents) { | 185 void DownloadStartedAnimation::Show(WebContents* web_contents) { |
| 181 // The animation will delete itself when it's finished or when the tab | 186 // The animation will delete itself when it's finished or when the tab |
| 182 // contents is hidden or destroyed. | 187 // contents is hidden or destroyed. |
| 183 new DownloadStartedAnimationWin(web_contents); | 188 new DownloadStartedAnimationWin(web_contents); |
| 184 } | 189 } |
| OLD | NEW |