summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 23:52:32 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 23:52:32 +0000
commita0a9577b170540cf58981def1c1616070afbd06f (patch)
tree15ae29176225715048d6fc98dd0598717ae9c78a /chrome/browser/download
parent9d4d1e4dff1bb10542adbdf568b3920f2ba47a4a (diff)
downloadchromium_src-a0a9577b170540cf58981def1c1616070afbd06f.zip
chromium_src-a0a9577b170540cf58981def1c1616070afbd06f.tar.gz
chromium_src-a0a9577b170540cf58981def1c1616070afbd06f.tar.bz2
Dangerous download dialog for linux.
BUG=11780 TEST=go to cygwin.com, click "install or update now". The download shelf should appear with a dangerous download dialog, which should animate properly and without undue jank. Clicking "cancel" should delete the item and hide the shelf (since it's the only thing in the shelf). Clicking "save" should make it become a normal download item. Review URL: http://codereview.chromium.org/113920 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r--chrome/browser/download/download_exe.cc11
-rw-r--r--chrome/browser/download/download_manager.cc26
-rw-r--r--chrome/browser/download/download_util.h3
3 files changed, 27 insertions, 13 deletions
diff --git a/chrome/browser/download/download_exe.cc b/chrome/browser/download/download_exe.cc
index 994f5f0..2663b54 100644
--- a/chrome/browser/download/download_exe.cc
+++ b/chrome/browser/download/download_exe.cc
@@ -55,6 +55,7 @@ namespace download_util {
* ***** END LICENSE BLOCK ***** */
static const char* const g_executables[] = {
+#if defined(OS_WIN)
"ad",
"ade",
"adp",
@@ -136,7 +137,15 @@ static const char* const g_executables[] = {
"wsh",
"xht",
"xhtm",
- "xhtml"
+ "xhtml",
+#elif defined(OS_LINUX)
+ // TODO(estade): lengthen this list.
+ "exe",
+ "pl",
+ "py",
+ "rb",
+ "sh",
+#endif // defined(OS_LINUX)
};
void InitializeExeTypes(std::set<std::string>* exe_extensions) {
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index 4fa4de3..248df33 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -43,9 +43,13 @@
#if defined(OS_WIN)
#include "app/win_util.h"
-// TODO(port): some of these need porting.
#include "base/registry.h"
#include "base/win_util.h"
+#endif
+
+#if !defined(OS_MACOSX)
+// Used for initializing the list of dangerous extensions. We don't support it
+// yet on mac.
#include "chrome/browser/download/download_util.h"
#endif
@@ -503,8 +507,8 @@ bool DownloadManager::Init(Profile* profile) {
file_loop_->PostTask(FROM_HERE, NewRunnableFunction(
CreateDirectoryPtr, download_path()));
-#if defined(OS_WIN)
- // We use this on windows to determine possibly dangerous downloads.
+#if defined(OS_WIN) || defined(OS_LINUX)
+ // We use this to determine possibly dangerous downloads.
download_util::InitializeExeTypes(&exe_types_);
#endif
@@ -1320,19 +1324,21 @@ bool DownloadManager::IsExecutableMimeType(const std::string& mime_type) {
}
bool DownloadManager::IsExecutable(const FilePath::StringType& extension) {
-#if defined(OS_WIN)
+#if defined(OS_MACOSX)
+ // We don't have dangerous download support on mac yet.
+ return false;
+#else
if (!IsStringASCII(extension))
return false;
+#if defined(OS_WIN)
std::string ascii_extension = WideToASCII(extension);
+#elif defined(OS_LINUX)
+ std::string ascii_extension = extension;
+#endif
StringToLowerASCII(&ascii_extension);
return exe_types_.find(ascii_extension) != exe_types_.end();
-#elif defined(OS_POSIX)
- // TODO(port): we misght not want to call this function on other platforms.
- // Figure it out.
- NOTIMPLEMENTED();
- return false;
-#endif
+#endif // !defined(OS_MACOSX)
}
void DownloadManager::ResetAutoOpenFiles() {
diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h
index bd43e67..deb9468e 100644
--- a/chrome/browser/download/download_util.h
+++ b/chrome/browser/download/download_util.h
@@ -122,14 +122,13 @@ void PaintDownloadComplete(gfx::Canvas* canvas,
// Helper function for download views to use when acting as a drag source for a
// DownloadItem. If 'icon' is NULL, no image will be accompany the drag.
void DragDownload(const DownloadItem* download, SkBitmap* icon);
+#endif
// Executable file support -----------------------------------------------------
// Copy all executable file extensions.
void InitializeExeTypes(std::set<std::string>* exe_extensions);
-#endif
} // namespace download_util
-
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_