| 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 #ifndef CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "chrome/browser/download/download_item_model.h" | 17 #include "chrome/browser/download/download_item_model.h" |
| 18 #include "chrome/browser/icon_manager.h" | 18 #include "chrome/browser/icon_manager.h" |
| 19 #include "chrome/common/cancelable_task_tracker.h" | 19 #include "chrome/common/cancelable_task_tracker.h" |
| 20 #include "content/public/browser/download_item.h" | 20 #include "content/public/browser/download_item.h" |
| 21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 23 #include "ui/base/animation/animation_delegate.h" | |
| 24 #include "ui/base/animation/slide_animation.h" | |
| 25 #include "ui/base/gtk/gtk_signal.h" | 23 #include "ui/base/gtk/gtk_signal.h" |
| 26 #include "ui/base/gtk/owned_widget_gtk.h" | 24 #include "ui/base/gtk/owned_widget_gtk.h" |
| 25 #include "ui/gfx/animation/animation_delegate.h" |
| 26 #include "ui/gfx/animation/slide_animation.h" |
| 27 | 27 |
| 28 class DownloadShelfContextMenuGtk; | 28 class DownloadShelfContextMenuGtk; |
| 29 class DownloadShelfGtk; | 29 class DownloadShelfGtk; |
| 30 class GtkThemeService; | 30 class GtkThemeService; |
| 31 class NineBox; | 31 class NineBox; |
| 32 | 32 |
| 33 namespace gfx { | 33 namespace gfx { |
| 34 class Image; | 34 class Image; |
| 35 } | |
| 36 | |
| 37 namespace ui { | |
| 38 class SlideAnimation; | 35 class SlideAnimation; |
| 39 } | 36 } |
| 40 | 37 |
| 41 class DownloadItemGtk : public content::DownloadItem::Observer, | 38 class DownloadItemGtk : public content::DownloadItem::Observer, |
| 42 public ui::AnimationDelegate, | 39 public gfx::AnimationDelegate, |
| 43 public content::NotificationObserver { | 40 public content::NotificationObserver { |
| 44 public: | 41 public: |
| 45 // DownloadItemGtk takes ownership of |download_item_model|. | 42 // DownloadItemGtk takes ownership of |download_item_model|. |
| 46 DownloadItemGtk(DownloadShelfGtk* parent_shelf, | 43 DownloadItemGtk(DownloadShelfGtk* parent_shelf, |
| 47 content::DownloadItem* download_item); | 44 content::DownloadItem* download_item); |
| 48 | 45 |
| 49 // Destroys all widgets belonging to this DownloadItemGtk. | 46 // Destroys all widgets belonging to this DownloadItemGtk. |
| 50 virtual ~DownloadItemGtk(); | 47 virtual ~DownloadItemGtk(); |
| 51 | 48 |
| 52 // content::DownloadItem::Observer implementation. | 49 // content::DownloadItem::Observer implementation. |
| 53 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; | 50 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
| 54 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; | 51 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; |
| 55 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; | 52 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; |
| 56 | 53 |
| 57 // ui::AnimationDelegate implementation. | 54 // gfx::AnimationDelegate implementation. |
| 58 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 55 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 59 | 56 |
| 60 // Overridden from content::NotificationObserver: | 57 // Overridden from content::NotificationObserver: |
| 61 virtual void Observe(int type, | 58 virtual void Observe(int type, |
| 62 const content::NotificationSource& source, | 59 const content::NotificationSource& source, |
| 63 const content::NotificationDetails& details) OVERRIDE; | 60 const content::NotificationDetails& details) OVERRIDE; |
| 64 | 61 |
| 65 // Called when the icon manager has finished loading the icon. We take | 62 // Called when the icon manager has finished loading the icon. We take |
| 66 // ownership of |icon_bitmap|. | 63 // ownership of |icon_bitmap|. |
| 67 void OnLoadSmallIconComplete(gfx::Image* image); | 64 void OnLoadSmallIconComplete(gfx::Image* image); |
| 68 void OnLoadLargeIconComplete(gfx::Image* image); | 65 void OnLoadLargeIconComplete(gfx::Image* image); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 GtkWidget* dangerous_prompt_; | 202 GtkWidget* dangerous_prompt_; |
| 206 GtkWidget* dangerous_image_; | 203 GtkWidget* dangerous_image_; |
| 207 GtkWidget* dangerous_label_; | 204 GtkWidget* dangerous_label_; |
| 208 | 205 |
| 209 // An hbox for holding components of the dangerous download dialog. | 206 // An hbox for holding components of the dangerous download dialog. |
| 210 ui::OwnedWidgetGtk dangerous_hbox_; | 207 ui::OwnedWidgetGtk dangerous_hbox_; |
| 211 int dangerous_hbox_start_width_; | 208 int dangerous_hbox_start_width_; |
| 212 int dangerous_hbox_full_width_; | 209 int dangerous_hbox_full_width_; |
| 213 | 210 |
| 214 // The animation when this item is first added to the shelf. | 211 // The animation when this item is first added to the shelf. |
| 215 scoped_ptr<ui::SlideAnimation> new_item_animation_; | 212 scoped_ptr<gfx::SlideAnimation> new_item_animation_; |
| 216 | 213 |
| 217 // Progress animation. | 214 // Progress animation. |
| 218 base::RepeatingTimer<DownloadItemGtk> progress_timer_; | 215 base::RepeatingTimer<DownloadItemGtk> progress_timer_; |
| 219 | 216 |
| 220 // Animation for download complete. | 217 // Animation for download complete. |
| 221 ui::SlideAnimation complete_animation_; | 218 gfx::SlideAnimation complete_animation_; |
| 222 | 219 |
| 223 // The file icon for the download. May be null. The small version is used | 220 // The file icon for the download. May be null. The small version is used |
| 224 // for display in the shelf; the large version is for use as a drag icon. | 221 // for display in the shelf; the large version is for use as a drag icon. |
| 225 // These icons are owned by the IconManager (owned by the BrowserProcess). | 222 // These icons are owned by the IconManager (owned by the BrowserProcess). |
| 226 gfx::Image* icon_small_; | 223 gfx::Image* icon_small_; |
| 227 gfx::Image* icon_large_; | 224 gfx::Image* icon_large_; |
| 228 | 225 |
| 229 // The last download file path for which we requested an icon. | 226 // The last download file path for which we requested an icon. |
| 230 base::FilePath icon_filepath_; | 227 base::FilePath icon_filepath_; |
| 231 | 228 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 243 | 240 |
| 244 // Whether we are currently disabled as part of opening the downloaded file. | 241 // Whether we are currently disabled as part of opening the downloaded file. |
| 245 bool disabled_while_opening_; | 242 bool disabled_while_opening_; |
| 246 | 243 |
| 247 // Method factory used to delay reenabling of the item when opening the | 244 // Method factory used to delay reenabling of the item when opening the |
| 248 // downloaded file. | 245 // downloaded file. |
| 249 base::WeakPtrFactory<DownloadItemGtk> weak_ptr_factory_; | 246 base::WeakPtrFactory<DownloadItemGtk> weak_ptr_factory_; |
| 250 }; | 247 }; |
| 251 | 248 |
| 252 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ | 249 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ |
| OLD | NEW |