| 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.h" | 15 #include "base/time.h" |
| 16 #include "base/timer.h" | 16 #include "base/timer.h" |
| 17 #include "chrome/browser/icon_manager.h" | 17 #include "chrome/browser/icon_manager.h" |
| 18 #include "chrome/common/cancelable_task_tracker.h" |
| 18 #include "content/public/browser/download_item.h" | 19 #include "content/public/browser/download_item.h" |
| 19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 21 #include "ui/base/animation/animation_delegate.h" | 22 #include "ui/base/animation/animation_delegate.h" |
| 22 #include "ui/base/animation/slide_animation.h" | 23 #include "ui/base/animation/slide_animation.h" |
| 23 #include "ui/base/gtk/gtk_signal.h" | 24 #include "ui/base/gtk/gtk_signal.h" |
| 24 #include "ui/base/gtk/owned_widget_gtk.h" | 25 #include "ui/base/gtk/owned_widget_gtk.h" |
| 25 | 26 |
| 26 class DownloadItemModel; | 27 class DownloadItemModel; |
| 27 class DownloadShelfContextMenuGtk; | 28 class DownloadShelfContextMenuGtk; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 56 // ui::AnimationDelegate implementation. | 57 // ui::AnimationDelegate implementation. |
| 57 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 58 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 58 | 59 |
| 59 // Overridden from content::NotificationObserver: | 60 // Overridden from content::NotificationObserver: |
| 60 virtual void Observe(int type, | 61 virtual void Observe(int type, |
| 61 const content::NotificationSource& source, | 62 const content::NotificationSource& source, |
| 62 const content::NotificationDetails& details) OVERRIDE; | 63 const content::NotificationDetails& details) OVERRIDE; |
| 63 | 64 |
| 64 // Called when the icon manager has finished loading the icon. We take | 65 // Called when the icon manager has finished loading the icon. We take |
| 65 // ownership of |icon_bitmap|. | 66 // ownership of |icon_bitmap|. |
| 66 void OnLoadSmallIconComplete(IconManager::Handle handle, | 67 void OnLoadSmallIconComplete(gfx::Image* image); |
| 67 gfx::Image* image); | 68 void OnLoadLargeIconComplete(gfx::Image* image); |
| 68 void OnLoadLargeIconComplete(IconManager::Handle handle, | |
| 69 gfx::Image* image); | |
| 70 | 69 |
| 71 // Returns the DownloadItem model object belonging to this item. | 70 // Returns the DownloadItem model object belonging to this item. |
| 72 content::DownloadItem* get_download(); | 71 content::DownloadItem* get_download(); |
| 73 | 72 |
| 74 private: | 73 private: |
| 75 friend class DownloadShelfContextMenuGtk; | 74 friend class DownloadShelfContextMenuGtk; |
| 76 | 75 |
| 77 // Functions for controlling the progress animation. | 76 // Functions for controlling the progress animation. |
| 78 // Repaint the download progress. | 77 // Repaint the download progress. |
| 79 void UpdateDownloadProgress(); | 78 void UpdateDownloadProgress(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 228 |
| 230 // The last download file path for which we requested an icon. | 229 // The last download file path for which we requested an icon. |
| 231 FilePath icon_filepath_; | 230 FilePath icon_filepath_; |
| 232 | 231 |
| 233 content::NotificationRegistrar registrar_; | 232 content::NotificationRegistrar registrar_; |
| 234 | 233 |
| 235 // The time at which we were insantiated. | 234 // The time at which we were insantiated. |
| 236 base::Time creation_time_; | 235 base::Time creation_time_; |
| 237 | 236 |
| 238 // For canceling an in progress icon request. | 237 // For canceling an in progress icon request. |
| 239 CancelableRequestConsumerT<int, 0> icon_consumer_; | 238 CancelableTaskTracker cancelable_task_tracker_; |
| 240 | 239 |
| 241 // Indicates when the download has completed, so we don't redo | 240 // Indicates when the download has completed, so we don't redo |
| 242 // on-completion actions. | 241 // on-completion actions. |
| 243 bool download_complete_; | 242 bool download_complete_; |
| 244 | 243 |
| 245 // Whether we are currently disabled as part of opening the downloaded file. | 244 // Whether we are currently disabled as part of opening the downloaded file. |
| 246 bool disabled_while_opening_; | 245 bool disabled_while_opening_; |
| 247 | 246 |
| 248 // Method factory used to delay reenabling of the item when opening the | 247 // Method factory used to delay reenabling of the item when opening the |
| 249 // downloaded file. | 248 // downloaded file. |
| 250 base::WeakPtrFactory<DownloadItemGtk> weak_ptr_factory_; | 249 base::WeakPtrFactory<DownloadItemGtk> weak_ptr_factory_; |
| 251 }; | 250 }; |
| 252 | 251 |
| 253 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ | 252 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ |
| OLD | NEW |