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

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: " Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/download/download_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DownloadItem& download_item, 66 void GenerateFileNameFromRequest(const DownloadItem& download_item,
70 FilePath* generated_name); 67 FilePath* generated_name);
71 68
69 // Generate a filename based on the URL, a suggested name and a MIME
70 // type. Similar in operation to net::GenerateFileName(), but uses a
71 // localized default name.
72 void GenerateFileNameFromSuggestedName(const GURL& url, 72 void GenerateFileNameFromSuggestedName(const GURL& url,
73 const std::string& suggested_name, 73 const std::string& suggested_name,
74 const std::string& mime_type, 74 const std::string& mime_type,
75 FilePath* generated_name); 75 FilePath* generated_name);
76 76
77 void GenerateFileName(const GURL& url,
78 const std::string& content_disposition,
79 const std::string& referrer_charset,
80 const std::string& mime_type,
81 FilePath* generated_name);
82
83 // Used to make sure we have a safe file extension and filename for a
84 // download. |file_name| can either be just the file name or it can be a
85 // full path to a file.
86 void GenerateSafeFileName(const std::string& mime_type, FilePath* file_name);
87
88 // Download progress animations ------------------------------------------------ 77 // Download progress animations ------------------------------------------------
89 78
90 // Arc sweep angle for use with downloads of unknown size 79 // Arc sweep angle for use with downloads of unknown size
91 const int kUnknownAngleDegrees = 50; 80 const int kUnknownAngleDegrees = 50;
92 81
93 // Rate of progress for use with downloads of unknown size 82 // Rate of progress for use with downloads of unknown size
94 const int kUnknownIncrementDegrees = 12; 83 const int kUnknownIncrementDegrees = 12;
95 84
96 // Start angle for downloads with known size (midnight position) 85 // Start angle for downloads with known size (midnight position)
97 const int kStartAngleDegrees = -90; 86 const int kStartAngleDegrees = -90;
(...skipping 165 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
« no previous file with comments | « no previous file | chrome/browser/download/download_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698