OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Download utilities. | 5 // Download utilities. |
6 | 6 |
7 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 7 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
8 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 8 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/task.h" |
14 #include "gfx/native_widget_types.h" | 15 #include "gfx/native_widget_types.h" |
15 | 16 |
16 #if defined(TOOLKIT_VIEWS) | 17 #if defined(TOOLKIT_VIEWS) |
17 #include "views/view.h" | 18 #include "views/view.h" |
18 #endif | 19 #endif |
19 | 20 |
20 namespace gfx { | 21 namespace gfx { |
21 class Canvas; | 22 class Canvas; |
22 } | 23 } |
23 | 24 |
24 class BaseDownloadItemModel; | 25 class BaseDownloadItemModel; |
25 class DictionaryValue; | 26 class DictionaryValue; |
26 class DownloadItem; | 27 class DownloadItem; |
27 class FilePath; | 28 class FilePath; |
28 class SkBitmap; | 29 class SkBitmap; |
29 | 30 |
30 namespace download_util { | 31 namespace download_util { |
31 | 32 |
| 33 // DownloadProgressTask -------------------------------------------------------- |
| 34 |
| 35 // A class for managing the timed progress animations for a download view. The |
| 36 // view must implement an UpdateDownloadProgress() method. |
| 37 template<class DownloadView> |
| 38 class DownloadProgressTask : public Task { |
| 39 public: |
| 40 explicit DownloadProgressTask(DownloadView* view) : view_(view) {} |
| 41 virtual ~DownloadProgressTask() {} |
| 42 virtual void Run() { |
| 43 view_->UpdateDownloadProgress(); |
| 44 } |
| 45 private: |
| 46 DownloadView* view_; |
| 47 DISALLOW_COPY_AND_ASSIGN(DownloadProgressTask); |
| 48 }; |
| 49 |
32 // Download opening ------------------------------------------------------------ | 50 // Download opening ------------------------------------------------------------ |
33 | 51 |
34 // Whether it is OK to open this download. | 52 // Whether it is OK to open this download. |
35 bool CanOpenDownload(DownloadItem* download); | 53 bool CanOpenDownload(DownloadItem* download); |
36 | 54 |
37 // Open the file associated with this download (wait for the download to | 55 // Open the file associated with this download (wait for the download to |
38 // complete if it is in progress). | 56 // complete if it is in progress). |
39 void OpenDownload(DownloadItem* download); | 57 void OpenDownload(DownloadItem* download); |
40 | 58 |
41 // Download temporary file creation -------------------------------------------- | 59 // Download temporary file creation -------------------------------------------- |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 void AppendNumberToPath(FilePath* path, int number); | 171 void AppendNumberToPath(FilePath* path, int number); |
154 | 172 |
155 // Attempts to find a number that can be appended to that path to make it | 173 // Attempts to find a number that can be appended to that path to make it |
156 // unique. If |path| does not exist, 0 is returned. If it fails to find such | 174 // unique. If |path| does not exist, 0 is returned. If it fails to find such |
157 // a number, -1 is returned. | 175 // a number, -1 is returned. |
158 int GetUniquePathNumber(const FilePath& path); | 176 int GetUniquePathNumber(const FilePath& path); |
159 | 177 |
160 } // namespace download_util | 178 } // namespace download_util |
161 | 179 |
162 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 180 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
OLD | NEW |