| 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" | |
| 15 #include "gfx/native_widget_types.h" | 14 #include "gfx/native_widget_types.h" |
| 16 | 15 |
| 17 #if defined(TOOLKIT_VIEWS) | 16 #if defined(TOOLKIT_VIEWS) |
| 18 #include "views/view.h" | 17 #include "views/view.h" |
| 19 #endif | 18 #endif |
| 20 | 19 |
| 21 namespace gfx { | 20 namespace gfx { |
| 22 class Canvas; | 21 class Canvas; |
| 23 } | 22 } |
| 24 | 23 |
| 25 class BaseDownloadItemModel; | 24 class BaseDownloadItemModel; |
| 26 class DictionaryValue; | 25 class DictionaryValue; |
| 27 class DownloadItem; | 26 class DownloadItem; |
| 28 class FilePath; | 27 class FilePath; |
| 29 class SkBitmap; | 28 class SkBitmap; |
| 30 | 29 |
| 31 namespace download_util { | 30 namespace download_util { |
| 32 | 31 |
| 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 | |
| 50 // Download opening ------------------------------------------------------------ | 32 // Download opening ------------------------------------------------------------ |
| 51 | 33 |
| 52 // Whether it is OK to open this download. | 34 // Whether it is OK to open this download. |
| 53 bool CanOpenDownload(DownloadItem* download); | 35 bool CanOpenDownload(DownloadItem* download); |
| 54 | 36 |
| 55 // Open the file associated with this download (wait for the download to | 37 // Open the file associated with this download (wait for the download to |
| 56 // complete if it is in progress). | 38 // complete if it is in progress). |
| 57 void OpenDownload(DownloadItem* download); | 39 void OpenDownload(DownloadItem* download); |
| 58 | 40 |
| 59 // Download temporary file creation -------------------------------------------- | 41 // Download temporary file creation -------------------------------------------- |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 void AppendNumberToPath(FilePath* path, int number); | 153 void AppendNumberToPath(FilePath* path, int number); |
| 172 | 154 |
| 173 // Attempts to find a number that can be appended to that path to make it | 155 // Attempts to find a number that can be appended to that path to make it |
| 174 // unique. If |path| does not exist, 0 is returned. If it fails to find such | 156 // unique. If |path| does not exist, 0 is returned. If it fails to find such |
| 175 // a number, -1 is returned. | 157 // a number, -1 is returned. |
| 176 int GetUniquePathNumber(const FilePath& path); | 158 int GetUniquePathNumber(const FilePath& path); |
| 177 | 159 |
| 178 } // namespace download_util | 160 } // namespace download_util |
| 179 | 161 |
| 180 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 162 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
| OLD | NEW |