 Chromium Code Reviews
 Chromium Code Reviews Issue 1236463002:
  Vectorize download shelf progress indicators  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1236463002:
  Vectorize download shelf progress indicators  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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" | |
| 9 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" | 
| 10 #include "base/time/time.h" | 9 #include "base/time/time.h" | 
| 11 #include "build/build_config.h" | 10 #include "build/build_config.h" | 
| 12 | 11 | 
| 13 class Browser; | 12 class Browser; | 
| 14 | 13 | 
| 14 namespace base { | |
| 15 class TimeTicks; | |
| 16 } | |
| 17 | |
| 15 namespace gfx { | 18 namespace gfx { | 
| 16 class Canvas; | 19 class Canvas; | 
| 17 class ImageSkia; | 20 class ImageSkia; | 
| 18 class Rect; | 21 class Rect; | 
| 19 } | 22 } | 
| 20 | 23 | 
| 21 namespace content { | 24 namespace content { | 
| 22 class DownloadItem; | 25 class DownloadItem; | 
| 23 class DownloadManager; | 26 class DownloadManager; | 
| 24 } | 27 } | 
| 25 | 28 | 
| 29 namespace ui { | |
| 30 class ThemeProvider; | |
| 31 } | |
| 32 | |
| 26 // This is an abstract base class for platform specific download shelf | 33 // This is an abstract base class for platform specific download shelf | 
| 27 // implementations. | 34 // implementations. | 
| 28 class DownloadShelf { | 35 class DownloadShelf { | 
| 29 public: | 36 public: | 
| 30 // Reason for closing download shelf. | 37 // Reason for closing download shelf. | 
| 31 enum CloseReason { | 38 enum CloseReason { | 
| 32 // Closing the shelf automatically. E.g.: all remaining downloads in the | 39 // Closing the shelf automatically. E.g.: all remaining downloads in the | 
| 33 // shelf have been opened, last download in shelf was removed, or the | 40 // shelf have been opened, last download in shelf was removed, or the | 
| 34 // browser is switching to full-screen mode. | 41 // browser is switching to full-screen mode. | 
| 35 AUTOMATIC, | 42 AUTOMATIC, | 
| 36 | 43 | 
| 37 // Closing shelf due to a user selection. E.g.: the user clicked on the | 44 // 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 | 45 // 'close' button on the download shelf, or the shelf is being closed as a | 
| 39 // side-effect of the user opening the downloads page. | 46 // side-effect of the user opening the downloads page. | 
| 40 USER_ACTION | 47 USER_ACTION | 
| 41 }; | 48 }; | 
| 42 | 49 | 
| 43 // Download progress animations ---------------------------------------------- | 50 // Download progress animations ---------------------------------------------- | 
| 44 | 51 | 
| 45 enum { | 52 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. | 53 // Progress animation timer period, in milliseconds. | 
| 59 kProgressRateMs = 150, | 54 kProgressRateMs = 30, | 
| 60 | 55 | 
| 61 // Size of the filetype icon. | 56 // Size of the filetype icon. | 
| 62 kSmallIconSize = 16, | 57 kSmallIconSize = 16, | 
| 
Peter Kasting
2015/07/16 20:02:23
Nit: kFiletypeIconSize
 
Evan Stade
2015/07/22 16:39:45
was able to delete this one
 | |
| 63 | 58 | 
| 64 // Size of the progress asset that's painted behind the filetype icon. | 59 // Size of the progress asset that's painted behind the filetype icon. | 
| 65 kSmallProgressIconSize = 39, | 60 kSmallProgressIconSize = 39, | 
| 
Peter Kasting
2015/07/16 20:02:23
Nit:
    // Size of the overall progress indicato
 
Evan Stade
2015/07/22 16:39:45
Done.
 | |
| 66 | 61 | 
| 67 kSmallProgressIconOffset = (kSmallProgressIconSize - kSmallIconSize) / 2 | 62 kSmallProgressIconOffset = (kSmallProgressIconSize - kSmallIconSize) / 2 | 
| 
Peter Kasting
2015/07/16 20:02:23
Nit: If we want to keep this, I'd name it kFiletyp
 
Evan Stade
2015/07/22 16:39:45
Done.
 | |
| 68 }; | 63 }; | 
| 69 | 64 | 
| 70 // Type of the callback used on toolkit-views platforms for the |rtl_mirror| | |
| 71 // argument of the PaintDownload functions. It captures the View subclass | |
| 72 // 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 | |
| 74 // to mirror the position of the progress animation. The callback is | |
| 75 // guaranteed to be invoked before the paint function returns. | |
| 76 typedef base::Callback<void(gfx::Rect*)> BoundsAdjusterCallback; | |
| 77 | |
| 78 DownloadShelf(); | 65 DownloadShelf(); | 
| 79 virtual ~DownloadShelf(); | 66 virtual ~DownloadShelf(); | 
| 80 | 67 | 
| 81 // Paint the common download animation progress foreground and background, | 68 // Paint the common download animation progress foreground and background, | 
| 82 // clipping the foreground to 'percent' full. If percent is -1, then we don't | 69 // 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. | 70 // know the total size, so we just draw a rotating segment until we're done. | 
| 84 static void PaintCustomDownloadProgress( | 71 // |progress_start_time| is only used for these unknown size downloads. | 
| 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, | 72 static void PaintDownloadProgress(gfx::Canvas* canvas, | 
| 94 const BoundsAdjusterCallback& rtl_mirror, | 73 const ui::ThemeProvider& theme_provider, | 
| 95 int origin_x, | 74 const base::TimeTicks& progress_start_time, | 
| 96 int origin_y, | |
| 97 int start_angle, | |
| 98 int percent); | 75 int percent); | 
| 99 | 76 | 
| 100 static void PaintDownloadComplete(gfx::Canvas* canvas, | 77 static void PaintDownloadComplete(gfx::Canvas* canvas, | 
| 101 const BoundsAdjusterCallback& rtl_mirror, | 78 const ui::ThemeProvider& theme_provider, | 
| 102 int origin_x, | |
| 103 int origin_y, | |
| 104 double animation_progress); | 79 double animation_progress); | 
| 105 | 80 | 
| 106 static void PaintDownloadInterrupted(gfx::Canvas* canvas, | 81 static void PaintDownloadInterrupted(gfx::Canvas* canvas, | 
| 107 const BoundsAdjusterCallback& rtl_mirror, | 82 const ui::ThemeProvider& theme_provider, | 
| 108 int origin_x, | |
| 109 int origin_y, | |
| 110 double animation_progress); | 83 double animation_progress); | 
| 111 | 84 | 
| 112 // A new download has started. Add it to our shelf and show the download | 85 // A new download has started. Add it to our shelf and show the download | 
| 113 // started animation. | 86 // started animation. | 
| 114 // | 87 // | 
| 115 // Some downloads are removed from the shelf on completion (See | 88 // Some downloads are removed from the shelf on completion (See | 
| 116 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient | 89 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient | 
| 117 // downloads are added to the shelf after a delay. If the download completes | 90 // 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. | 91 // before the delay duration, it will not be added to the shelf at all. | 
| 119 void AddDownload(content::DownloadItem* download); | 92 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 | 141 // download should belong to the DownloadManager returned by | 
| 169 // GetDownloadManager(). | 142 // GetDownloadManager(). | 
| 170 void ShowDownloadById(int32 download_id); | 143 void ShowDownloadById(int32 download_id); | 
| 171 | 144 | 
| 172 bool should_show_on_unhide_; | 145 bool should_show_on_unhide_; | 
| 173 bool is_hidden_; | 146 bool is_hidden_; | 
| 174 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; | 147 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; | 
| 175 }; | 148 }; | 
| 176 | 149 | 
| 177 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 150 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 
| OLD | NEW |