Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/download/download_util.h

Issue 7300005: Move filename determination to net_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 9 #pragma once
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Return the default download directory. 53 // Return the default download directory.
54 const FilePath& GetDefaultDownloadDirectory(); 54 const FilePath& GetDefaultDownloadDirectory();
55 55
56 // Create a temporary file for a download in the user's default download 56 // Create a temporary file for a download in the user's default download
57 // directory and return true if was successful in creating the file. 57 // directory and return true if was successful in creating the file.
58 bool CreateTemporaryFileForDownload(FilePath* path); 58 bool CreateTemporaryFileForDownload(FilePath* path);
59 59
60 // Return true if the |download_path| is dangerous path. 60 // Return true if the |download_path| is dangerous path.
61 bool DownloadPathIsDangerous(const FilePath& download_path); 61 bool DownloadPathIsDangerous(const FilePath& download_path);
62 62
63 // Create an extension based on the file name and mime type. 63 // Generate a filename based on the response from the server. Similar
64 void GenerateExtension(const FilePath& file_name, 64 // in operation to net::GenerateFileName(), but uses a localized
65 const std::string& mime_type, 65 // default name.
66 FilePath::StringType* generated_extension);
67
68 // Create a file name based on the response from the server.
69 void GenerateFileNameFromRequest(const GURL& url, 66 void GenerateFileNameFromRequest(const GURL& url,
70 const std::string& content_disposition, 67 const std::string& content_disposition,
71 const std::string& referrer_charset, 68 const std::string& referrer_charset,
72 const std::string& mime_type, 69 const std::string& mime_type,
73 FilePath* generated_name); 70 FilePath* generated_name);
74 71
72 // Generate a filename based on the URL, a suggested name and a MIME
73 // type. Similar in operation to net::GenerateFileName(), but uses a
74 // localized default name.
75 void GenerateFileNameFromSuggestedName(const GURL& url, 75 void GenerateFileNameFromSuggestedName(const GURL& url,
76 const std::string& suggested_name, 76 const std::string& suggested_name,
77 const std::string& mime_type, 77 const std::string& mime_type,
78 FilePath* generated_name); 78 FilePath* generated_name);
79 79
80 void GenerateFileName(const GURL& url,
81 const std::string& content_disposition,
82 const std::string& referrer_charset,
83 const std::string& mime_type,
84 FilePath* generated_name);
85
86 // Used to make sure we have a safe file extension and filename for a
87 // download. |file_name| can either be just the file name or it can be a
88 // full path to a file.
89 void GenerateSafeFileName(const std::string& mime_type, FilePath* file_name);
90
91 // Download progress animations ------------------------------------------------ 80 // Download progress animations ------------------------------------------------
92 81
93 // Arc sweep angle for use with downloads of unknown size 82 // Arc sweep angle for use with downloads of unknown size
94 const int kUnknownAngleDegrees = 50; 83 const int kUnknownAngleDegrees = 50;
95 84
96 // Rate of progress for use with downloads of unknown size 85 // Rate of progress for use with downloads of unknown size
97 const int kUnknownIncrementDegrees = 12; 86 const int kUnknownIncrementDegrees = 12;
98 87
99 // Start angle for downloads with known size (midnight position) 88 // Start angle for downloads with known size (midnight position)
100 const int kStartAngleDegrees = -90; 89 const int kStartAngleDegrees = -90;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // Sends a notification on downloads being initiated 252 // Sends a notification on downloads being initiated
264 // Must be called on the UI thread. 253 // Must be called on the UI thread.
265 void NotifyDownloadInitiated(int render_process_id, int render_view_id); 254 void NotifyDownloadInitiated(int render_process_id, int render_view_id);
266 255
267 // Same as GetUniquePathNumber, except that it also checks the existence 256 // Same as GetUniquePathNumber, except that it also checks the existence
268 // of its .crdownload intermediate path. 257 // of its .crdownload intermediate path.
269 // If |path| does not exist, 0 is returned. If it fails to find such 258 // If |path| does not exist, 0 is returned. If it fails to find such
270 // a number, -1 is returned. 259 // a number, -1 is returned.
271 int GetUniquePathNumberWithCrDownload(const FilePath& path); 260 int GetUniquePathNumberWithCrDownload(const FilePath& path);
272 261
273 // Erases all downloaded files with the specified path and name prefix.
274 // Used by download UI tests to clean up the download directory.
275 void EraseUniqueDownloadFiles(const FilePath& path_prefix);
276
277 // Returns a .crdownload intermediate path for the |suggested_path|. 262 // Returns a .crdownload intermediate path for the |suggested_path|.
278 FilePath GetCrDownloadPath(const FilePath& suggested_path); 263 FilePath GetCrDownloadPath(const FilePath& suggested_path);
279 264
280 } // namespace download_util 265 } // namespace download_util
281 266
282 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ 267 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698