| 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_DOWNLOAD_DOWNLOAD_SHELF_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 
| 7 | 7 | 
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" | 
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" | 
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" | 
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" | 
| 12 | 12 | 
| 13 class Browser; | 13 class Browser; | 
| 14 | 14 | 
|  | 15 namespace base { | 
|  | 16 class TimeTicks; | 
|  | 17 } | 
|  | 18 | 
| 15 namespace gfx { | 19 namespace gfx { | 
| 16 class Canvas; | 20 class Canvas; | 
| 17 class ImageSkia; | 21 class ImageSkia; | 
| 18 class Rect; | 22 class Rect; | 
| 19 } | 23 } | 
| 20 | 24 | 
| 21 namespace content { | 25 namespace content { | 
| 22 class DownloadItem; | 26 class DownloadItem; | 
| 23 class DownloadManager; | 27 class DownloadManager; | 
| 24 } | 28 } | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 36 | 40 | 
| 37     // Closing shelf due to a user selection. E.g.: the user clicked on the | 41     // Closing shelf due to a user selection. E.g.: the user clicked on the | 
| 38     // 'close' button on the download shelf, or the shelf is being closed as a | 42     // 'close' button on the download shelf, or the shelf is being closed as a | 
| 39     // side-effect of the user opening the downloads page. | 43     // side-effect of the user opening the downloads page. | 
| 40     USER_ACTION | 44     USER_ACTION | 
| 41   }; | 45   }; | 
| 42 | 46 | 
| 43   // Download progress animations ---------------------------------------------- | 47   // Download progress animations ---------------------------------------------- | 
| 44 | 48 | 
| 45   enum { | 49   enum { | 
| 46     // Arc sweep angle for use with downloads of unknown size. |  | 
| 47     kUnknownAngleDegrees = 50, |  | 
| 48 |  | 
| 49     // Rate of progress for use with downloads of unknown size. |  | 
| 50     kUnknownIncrementDegrees = 12, |  | 
| 51 |  | 
| 52     // Start angle for downloads with known size (midnight position). |  | 
| 53     kStartAngleDegrees = -90, |  | 
| 54 |  | 
| 55     // A the maximum number of degrees of a circle. |  | 
| 56     kMaxDegrees = 360, |  | 
| 57 |  | 
| 58     // Progress animation timer period, in milliseconds. | 50     // Progress animation timer period, in milliseconds. | 
| 59     kProgressRateMs = 150, | 51     kProgressRateMs = 30, | 
| 60 | 52 | 
| 61     // Size of the filetype icon. | 53     // Size of the filetype icon. | 
| 62     kSmallIconSize = 16, | 54     kSmallIconSize = 16, | 
| 63 | 55 | 
| 64     // Size of the progress asset that's painted behind the filetype icon. | 56     // Size of the progress asset that's painted behind the filetype icon. | 
| 65     kSmallProgressIconSize = 39, | 57     kSmallProgressIconSize = 39, | 
| 66 | 58 | 
| 67     kSmallProgressIconOffset = (kSmallProgressIconSize - kSmallIconSize) / 2 | 59     kSmallProgressIconOffset = (kSmallProgressIconSize - kSmallIconSize) / 2 | 
| 68   }; | 60   }; | 
| 69 | 61 | 
| 70   // Type of the callback used on toolkit-views platforms for the |rtl_mirror| | 62   // Type of the callback used on toolkit-views platforms for the |rtl_mirror| | 
| 71   // argument of the PaintDownload functions. It captures the View subclass | 63   // argument of the PaintDownload functions. It captures the View subclass | 
| 72   // within which the progress animation is drawn and is used to update the | 64   // within which the progress animation is drawn and is used to update the | 
| 73   // correct 'left' value for the given rectangle in RTL locales. This is used | 65   // correct 'left' value for the given rectangle in RTL locales. This is used | 
| 74   // to mirror the position of the progress animation. The callback is | 66   // to mirror the position of the progress animation. The callback is | 
| 75   // guaranteed to be invoked before the paint function returns. | 67   // guaranteed to be invoked before the paint function returns. | 
| 76   typedef base::Callback<void(gfx::Rect*)> BoundsAdjusterCallback; | 68   typedef base::Callback<void(gfx::Rect*)> BoundsAdjusterCallback; | 
| 77 | 69 | 
| 78   DownloadShelf(); | 70   DownloadShelf(); | 
| 79   virtual ~DownloadShelf(); | 71   virtual ~DownloadShelf(); | 
| 80 | 72 | 
| 81   // Paint the common download animation progress foreground and background, | 73   // Paint the common download animation progress foreground and background, | 
| 82   // clipping the foreground to 'percent' full. If percent is -1, then we don't | 74   // clipping the foreground to 'percent' full. If percent is -1, then we don't | 
| 83   // know the total size, so we just draw a rotating segment until we're done. | 75   // know the total size, so we just draw a rotating segment until we're done. | 
| 84   static void PaintCustomDownloadProgress( |  | 
| 85       gfx::Canvas* canvas, |  | 
| 86       const gfx::ImageSkia& background_image, |  | 
| 87       const gfx::ImageSkia& foreground_image, |  | 
| 88       int image_size, |  | 
| 89       const gfx::Rect& bounds, |  | 
| 90       int start_angle, |  | 
| 91       int percent_done); |  | 
| 92 |  | 
| 93   static void PaintDownloadProgress(gfx::Canvas* canvas, | 76   static void PaintDownloadProgress(gfx::Canvas* canvas, | 
| 94                                     const BoundsAdjusterCallback& rtl_mirror, | 77                                     const base::TimeTicks& progress_start_time, | 
| 95                                     int origin_x, |  | 
| 96                                     int origin_y, |  | 
| 97                                     int start_angle, |  | 
| 98                                     int percent); | 78                                     int percent); | 
| 99 | 79 | 
| 100   static void PaintDownloadComplete(gfx::Canvas* canvas, | 80   static void PaintDownloadComplete(gfx::Canvas* canvas, | 
| 101                                     const BoundsAdjusterCallback& rtl_mirror, |  | 
| 102                                     int origin_x, |  | 
| 103                                     int origin_y, |  | 
| 104                                     double animation_progress); | 81                                     double animation_progress); | 
| 105 | 82 | 
| 106   static void PaintDownloadInterrupted(gfx::Canvas* canvas, | 83   static void PaintDownloadInterrupted(gfx::Canvas* canvas, | 
| 107                                        const BoundsAdjusterCallback& rtl_mirror, |  | 
| 108                                        int origin_x, |  | 
| 109                                        int origin_y, |  | 
| 110                                        double animation_progress); | 84                                        double animation_progress); | 
| 111 | 85 | 
| 112   // A new download has started. Add it to our shelf and show the download | 86   // A new download has started. Add it to our shelf and show the download | 
| 113   // started animation. | 87   // started animation. | 
| 114   // | 88   // | 
| 115   // Some downloads are removed from the shelf on completion (See | 89   // Some downloads are removed from the shelf on completion (See | 
| 116   // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient | 90   // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient | 
| 117   // downloads are added to the shelf after a delay. If the download completes | 91   // downloads are added to the shelf after a delay. If the download completes | 
| 118   // before the delay duration, it will not be added to the shelf at all. | 92   // before the delay duration, it will not be added to the shelf at all. | 
| 119   void AddDownload(content::DownloadItem* download); | 93   void AddDownload(content::DownloadItem* download); | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 168   // download should belong to the DownloadManager returned by | 142   // download should belong to the DownloadManager returned by | 
| 169   // GetDownloadManager(). | 143   // GetDownloadManager(). | 
| 170   void ShowDownloadById(int32 download_id); | 144   void ShowDownloadById(int32 download_id); | 
| 171 | 145 | 
| 172   bool should_show_on_unhide_; | 146   bool should_show_on_unhide_; | 
| 173   bool is_hidden_; | 147   bool is_hidden_; | 
| 174   base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; | 148   base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; | 
| 175 }; | 149 }; | 
| 176 | 150 | 
| 177 #endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 151 #endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 
| OLD | NEW | 
|---|