| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/mime_util.h" |
| 7 #include "net/base/platform_mime_util.h" | 9 #include "net/base/platform_mime_util.h" |
| 8 | 10 |
| 9 namespace net { | 11 namespace net { |
| 10 | 12 |
| 11 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( | 13 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( |
| 12 const FilePath::StringType& ext, std::string* result) const { | 14 const FilePath::StringType& ext, std::string* result) const { |
| 13 // The correct thing to do is to interact somehow with the freedesktop shared | 15 FilePath::StringType dummy_path = "foo." + ext; |
| 14 // mime info cache. Since Linux (and other traditional *IX systems) don't use | 16 std::string out = mime_util::GetFileMimeType(dummy_path); |
| 15 // file extensions; they use mime types and have multiple ways of detecting | 17 // GetFileMimeType likes to return application/octet-stream |
| 16 // that; some types can be guessed from globs (*.gif), but there's a whole | 18 // for everything it doesn't know - ignore that. |
| 17 // bunch that use a magic byte test. | 19 if (out == "application/octet-stream" || !out.length()) |
| 18 // | 20 return false; |
| 19 // Since this method only is called from inside mime_util where there is | 21 *result = out; |
| 20 // already a hard coded table of mime types, we just return false because it | 22 return true; |
| 21 // doesn't matter. | |
| 22 | |
| 23 return false; | |
| 24 } | 23 } |
| 25 | 24 |
| 26 bool PlatformMimeUtil::GetPreferredExtensionForMimeType( | 25 bool PlatformMimeUtil::GetPreferredExtensionForMimeType( |
| 27 const std::string& mime_type, FilePath::StringType* ext) const { | 26 const std::string& mime_type, FilePath::StringType* ext) const { |
| 28 // Unlike GetPlatformMimeTypeFromExtension, this method doesn't have a | 27 // Unlike GetPlatformMimeTypeFromExtension, this method doesn't have a |
| 29 // default list that it uses, but for now we are also returning false since | 28 // default list that it uses, but for now we are also returning false since |
| 30 // this doesn't really matter as much under Linux. | 29 // this doesn't really matter as much under Linux. |
| 31 // | 30 // |
| 32 // If we wanted to do this properly, we would read the mime.cache file which | 31 // If we wanted to do this properly, we would read the mime.cache file which |
| 33 // has a section where they assign a glob (*.gif) to a mimetype | 32 // has a section where they assign a glob (*.gif) to a mimetype |
| 34 // (image/gif). We look up the "heaviest" glob for a certain mime type and | 33 // (image/gif). We look up the "heaviest" glob for a certain mime type and |
| 35 // then then try to chop off "*.". | 34 // then then try to chop off "*.". |
| 36 | 35 |
| 36 NOTIMPLEMENTED(); |
| 37 return false; | 37 return false; |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace net | 40 } // namespace net |
| OLD | NEW |