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/message_loop.h" | 11 #include "base/message_loop/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 "content/public/browser/web_contents_view.h" |
19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
20 #include "ui/base/animation/linear_animation.h" | |
21 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/animation/linear_animation.h" |
22 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
23 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
24 | 24 |
25 using content::WebContents; | 25 using content::WebContents; |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // How long to spend moving downwards and fading out after waiting. | 29 // How long to spend moving downwards and fading out after waiting. |
30 const int kMoveTimeMs = 600; | 30 const int kMoveTimeMs = 600; |
31 | 31 |
32 // The animation framerate. | 32 // The animation framerate. |
33 const int kFrameRateHz = 60; | 33 const int kFrameRateHz = 60; |
34 | 34 |
35 // What fraction of the frame height to move downward from the frame center. | 35 // What fraction of the frame height to move downward from the frame center. |
36 // Note that setting this greater than 0.5 will mean moving past the bottom of | 36 // Note that setting this greater than 0.5 will mean moving past the bottom of |
37 // the frame. | 37 // the frame. |
38 const double kMoveFraction = 1.0 / 3.0; | 38 const double kMoveFraction = 1.0 / 3.0; |
39 | 39 |
40 class DownloadStartedAnimationGtk : public ui::LinearAnimation, | 40 class DownloadStartedAnimationGtk : public gfx::LinearAnimation, |
41 public content::NotificationObserver { | 41 public content::NotificationObserver { |
42 public: | 42 public: |
43 explicit DownloadStartedAnimationGtk(WebContents* web_contents); | 43 explicit DownloadStartedAnimationGtk(WebContents* web_contents); |
44 | 44 |
45 // DownloadStartedAnimation will delete itself, but this is public so | 45 // DownloadStartedAnimation will delete itself, but this is public so |
46 // that we can use DeleteSoon(). | 46 // that we can use DeleteSoon(). |
47 virtual ~DownloadStartedAnimationGtk(); | 47 virtual ~DownloadStartedAnimationGtk(); |
48 | 48 |
49 private: | 49 private: |
50 // Move the arrow to wherever it should currently be. | 50 // Move the arrow to wherever it should currently be. |
(...skipping 29 matching lines...) Expand all Loading... |
80 gfx::Rect web_contents_bounds_; | 80 gfx::Rect web_contents_bounds_; |
81 | 81 |
82 // A scoped container for notification registries. | 82 // A scoped container for notification registries. |
83 content::NotificationRegistrar registrar_; | 83 content::NotificationRegistrar registrar_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationGtk); | 85 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationGtk); |
86 }; | 86 }; |
87 | 87 |
88 DownloadStartedAnimationGtk::DownloadStartedAnimationGtk( | 88 DownloadStartedAnimationGtk::DownloadStartedAnimationGtk( |
89 WebContents* web_contents) | 89 WebContents* web_contents) |
90 : ui::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), | 90 : gfx::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), |
91 popup_(NULL), | 91 popup_(NULL), |
92 web_contents_(web_contents) { | 92 web_contents_(web_contents) { |
93 static GdkPixbuf* kDownloadImage = NULL; | 93 static GdkPixbuf* kDownloadImage = NULL; |
94 if (!kDownloadImage) { | 94 if (!kDownloadImage) { |
95 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 95 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
96 kDownloadImage = rb.GetNativeImageNamed( | 96 kDownloadImage = rb.GetNativeImageNamed( |
97 IDR_DOWNLOAD_ANIMATION_BEGIN).ToGdkPixbuf(); | 97 IDR_DOWNLOAD_ANIMATION_BEGIN).ToGdkPixbuf(); |
98 } | 98 } |
99 | 99 |
100 width_ = gdk_pixbuf_get_width(kDownloadImage); | 100 width_ = gdk_pixbuf_get_width(kDownloadImage); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 Close(); | 206 Close(); |
207 } | 207 } |
208 | 208 |
209 } // namespace | 209 } // namespace |
210 | 210 |
211 // static | 211 // static |
212 void DownloadStartedAnimation::Show(WebContents* web_contents) { | 212 void DownloadStartedAnimation::Show(WebContents* web_contents) { |
213 // The animation will delete itself. | 213 // The animation will delete itself. |
214 new DownloadStartedAnimationGtk(web_contents); | 214 new DownloadStartedAnimationGtk(web_contents); |
215 } | 215 } |
OLD | NEW |