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 <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "content/public/browser/notification_details.h" | 12 #include "content/public/browser/notification_details.h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
16 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_contents_view.h" |
18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
19 #include "ui/base/animation/linear_animation.h" | 20 #include "ui/base/animation/linear_animation.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
22 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
23 | 24 |
24 using content::WebContents; | 25 using content::WebContents; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 95 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
95 kDownloadImage = rb.GetNativeImageNamed( | 96 kDownloadImage = rb.GetNativeImageNamed( |
96 IDR_DOWNLOAD_ANIMATION_BEGIN).ToGdkPixbuf(); | 97 IDR_DOWNLOAD_ANIMATION_BEGIN).ToGdkPixbuf(); |
97 } | 98 } |
98 | 99 |
99 width_ = gdk_pixbuf_get_width(kDownloadImage); | 100 width_ = gdk_pixbuf_get_width(kDownloadImage); |
100 height_ = gdk_pixbuf_get_height(kDownloadImage); | 101 height_ = gdk_pixbuf_get_height(kDownloadImage); |
101 | 102 |
102 // If we're too small to show the download image, then don't bother - | 103 // If we're too small to show the download image, then don't bother - |
103 // the shelf will be enough. | 104 // the shelf will be enough. |
104 web_contents_->GetContainerBounds(&web_contents_bounds_); | 105 web_contents_->GetView()->GetContainerBounds(&web_contents_bounds_); |
105 if (web_contents_bounds_.height() < height_) | 106 if (web_contents_bounds_.height() < height_) |
106 return; | 107 return; |
107 | 108 |
108 registrar_.Add( | 109 registrar_.Add( |
109 this, | 110 this, |
110 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 111 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
111 content::Source<WebContents>(web_contents_)); | 112 content::Source<WebContents>(web_contents_)); |
112 registrar_.Add( | 113 registrar_.Add( |
113 this, | 114 this, |
114 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 115 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 Close(); | 206 Close(); |
206 } | 207 } |
207 | 208 |
208 } // namespace | 209 } // namespace |
209 | 210 |
210 // static | 211 // static |
211 void DownloadStartedAnimation::Show(WebContents* web_contents) { | 212 void DownloadStartedAnimation::Show(WebContents* web_contents) { |
212 // The animation will delete itself. | 213 // The animation will delete itself. |
213 new DownloadStartedAnimationGtk(web_contents); | 214 new DownloadStartedAnimationGtk(web_contents); |
214 } | 215 } |
OLD | NEW |