| OLD | NEW |
| 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 #include "net/base/platform_mime_util.h" | 5 #include "net/base/platform_mime_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 | 11 |
| 12 #if defined(OS_ANDROID) | 12 #if defined(OS_ANDROID) |
| 13 #include "net/android/network_library.h" | 13 #include "net/android/network_library.h" |
| 14 #else | 14 #else |
| 15 #include "base/mime_util.h" | 15 #include "base/nix/mime_util_xdg.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 #if defined(OS_ANDROID) | 20 #if defined(OS_ANDROID) |
| 21 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( | 21 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( |
| 22 const FilePath::StringType& ext, std::string* result) const { | 22 const FilePath::StringType& ext, std::string* result) const { |
| 23 return android::GetMimeTypeFromExtension(ext, result); | 23 return android::GetMimeTypeFromExtension(ext, result); |
| 24 } | 24 } |
| 25 #else | 25 #else |
| 26 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( | 26 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( |
| 27 const FilePath::StringType& ext, std::string* result) const { | 27 const FilePath::StringType& ext, std::string* result) const { |
| 28 // TODO(thestig) This is a temporary hack until we can fix this | 28 // TODO(thestig) This is a temporary hack until we can fix this |
| 29 // properly in test shell / webkit. | 29 // properly in test shell / webkit. |
| 30 // We have to play dumb and not return application/x-perl here | 30 // We have to play dumb and not return application/x-perl here |
| 31 // to make the reload-subframe-object layout test happy. | 31 // to make the reload-subframe-object layout test happy. |
| 32 if (ext == "pl") | 32 if (ext == "pl") |
| 33 return false; | 33 return false; |
| 34 | 34 |
| 35 FilePath dummy_path("foo." + ext); | 35 FilePath dummy_path("foo." + ext); |
| 36 std::string out = mime_util::GetFileMimeType(dummy_path); | 36 std::string out = base::nix::GetFileMimeType(dummy_path); |
| 37 | 37 |
| 38 // GetFileMimeType likes to return application/octet-stream | 38 // GetFileMimeType likes to return application/octet-stream |
| 39 // for everything it doesn't know - ignore that. | 39 // for everything it doesn't know - ignore that. |
| 40 if (out == "application/octet-stream" || out.empty()) | 40 if (out == "application/octet-stream" || out.empty()) |
| 41 return false; | 41 return false; |
| 42 | 42 |
| 43 // GetFileMimeType returns image/x-ico because that's what's in the XDG | 43 // GetFileMimeType returns image/x-ico because that's what's in the XDG |
| 44 // mime database. That database is the merger of the Gnome and KDE mime | 44 // mime database. That database is the merger of the Gnome and KDE mime |
| 45 // databases. Apparently someone working on KDE in 2001 decided .ico | 45 // databases. Apparently someone working on KDE in 2001 decided .ico |
| 46 // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. | 46 // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // | 92 // |
| 93 // If we wanted to do this properly, we would read the mime.cache file which | 93 // If we wanted to do this properly, we would read the mime.cache file which |
| 94 // has a section where they assign a glob (*.gif) to a mimetype | 94 // has a section where they assign a glob (*.gif) to a mimetype |
| 95 // (image/gif). We look up the "heaviest" glob for a certain mime type and | 95 // (image/gif). We look up the "heaviest" glob for a certain mime type and |
| 96 // then then try to chop off "*.". | 96 // then then try to chop off "*.". |
| 97 | 97 |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace net | 101 } // namespace net |
| OLD | NEW |