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

Unified Diff: chrome/browser/extensions/platform_app_launcher.cc

Issue 14254002: Treat unknown MIME type as application/octet-stream when launching apps. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 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
Index: chrome/browser/extensions/platform_app_launcher.cc
diff --git a/chrome/browser/extensions/platform_app_launcher.cc b/chrome/browser/extensions/platform_app_launcher.cc
index 2ad1d776afc7f36e46907c0d4df65efd9e71de8e..66466ff4130a45e8650dac77673ee1e231c8fe20 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/chrome/browser/extensions/platform_app_launcher.cc
@@ -56,6 +56,8 @@ namespace extensions {
namespace {
+const char kFallbackMimeType[] = "application/octet-stream";
+
bool MakePathAbsolute(const base::FilePath& current_directory,
base::FilePath* file_path) {
DCHECK(file_path);
@@ -154,14 +156,8 @@ class PlatformAppPathLauncher
}
std::string mime_type;
- // If we cannot obtain the MIME type, launch with no launch data.
- if (!net::GetMimeTypeFromFile(file_path_, &mime_type)) {
- LOG(WARNING) << "Could not obtain MIME type for "
- << file_path_.value();
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
- &PlatformAppPathLauncher::LaunchWithNoLaunchData, this));
- return;
- }
+ if (!net::GetMimeTypeFromFile(file_path_, &mime_type))
+ mime_type = kFallbackMimeType;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
&PlatformAppPathLauncher::LaunchWithMimeType, this, mime_type));
@@ -189,13 +185,12 @@ class PlatformAppPathLauncher
drive::DriveFileType file_type) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (error != drive::DRIVE_FILE_OK || mime_type.empty() ||
- file_type != drive::REGULAR_FILE) {
+ if (error != drive::DRIVE_FILE_OK || file_type != drive::REGULAR_FILE) {
LaunchWithNoLaunchData();
return;
}
- LaunchWithMimeType(mime_type);
+ LaunchWithMimeType(mime_type.empty() ? kFallbackMimeType : mime_type);
}
#endif // defined(OS_CHROMEOS)

Powered by Google App Engine
This is Rietveld 408576698