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

Unified Diff: chrome/browser/download/download_manager.cc

Issue 164516: Revert 23340 - Merge 23118 Remove the temporary hack that considered any fil... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_manager.cc
===================================================================
--- chrome/browser/download/download_manager.cc (revision 23361)
+++ chrome/browser/download/download_manager.cc (working copy)
@@ -112,6 +112,20 @@
return (download_path == desktop_dir);
}
+// Helper to determine if a download is a Chrome extension. We should be able to
+// just use the mime type, but even our own servers are not setup to serve the
+// right headers yet, so we have a short-term file extension heuristic, too.
+static bool IsChromeExtension(const FilePath& path,
+ const std::string& mime_type) {
+ // If the server says it is an extension, it is definitely an extension.
+ if (mime_type == Extension::kMimeType)
+ return true;
+
+ // Otherwise, it is an extension if it has the right, err, extension.
+ return path.Extension().size() > 1 &&
+ path.Extension().substr(1) == chrome::kExtensionFileExtension;
+}
+
// DownloadItem implementation -------------------------------------------------
// Constructor for reading from the history service.
@@ -576,7 +590,7 @@
// b) They are an extension that is not from the gallery
if (IsDangerous(info->suggested_path.BaseName()))
info->is_dangerous = true;
- else if (info->mime_type == Extension::kMimeType &&
+ else if (IsChromeExtension(info->path, info->mime_type) &&
!ExtensionsService::IsDownloadFromGallery(info->url,
info->referrer_url)) {
info->is_dangerous = true;
@@ -856,7 +870,7 @@
extension = extension.substr(1);
// Handle chrome extensions explicitly and skip the shell execute.
- if (download->mime_type() == Extension::kMimeType) {
+ if (IsChromeExtension(download->full_path(), download->mime_type())) {
OpenChromeExtension(download->full_path(), download->url(),
download->referrer_url());
download->set_auto_opened(true);
@@ -1226,7 +1240,7 @@
gfx::NativeView parent_window) {
// Open Chrome extensions with ExtensionsService. For everything else do shell
// execute.
- if (download->mime_type() == Extension::kMimeType) {
+ if (IsChromeExtension(download->full_path(), download->mime_type())) {
OpenChromeExtension(download->full_path(), download->url(),
download->referrer_url());
} else {
Property changes on: chrome\browser\download\download_manager.cc
___________________________________________________________________
Modified: svn:mergeinfo
Reverse-merged /trunk/src/chrome/browser/download/download_manager.cc:r23118
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698