summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 21:45:05 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-08 21:45:05 +0000
commit085cb5aea070d21835b750a0164b4cce0fcb12c7 (patch)
tree6a67a615602d93b622443fabcdcbc6f94a5475ff
parent2314403e94e659d586475e59975e9d84d87cbcd3 (diff)
downloadchromium_src-085cb5aea070d21835b750a0164b4cce0fcb12c7.zip
chromium_src-085cb5aea070d21835b750a0164b4cce0fcb12c7.tar.gz
chromium_src-085cb5aea070d21835b750a0164b4cce0fcb12c7.tar.bz2
Get MIME stuff working minimally to the point where we have
unit tests passing. B=1315 Review URL: http://codereview.chromium.org/1824 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1866 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/SConscript13
-rw-r--r--net/base/platform_mime_util_linux.cc40
2 files changed, 48 insertions, 5 deletions
diff --git a/net/SConscript b/net/SConscript
index 519d5ea..7b5c187 100644
--- a/net/SConscript
+++ b/net/SConscript
@@ -43,6 +43,7 @@ input_files = [
'base/gzip_header.cc',
'base/host_resolver.cc',
'base/mime_sniffer.cc',
+ 'base/mime_util.cc',
'base/net_errors.cc',
'base/net_module.cc',
'base/net_util.cc',
@@ -84,7 +85,6 @@ if env['PLATFORM'] == 'win32':
'base/directory_lister.cc',
'base/dns_resolution_observer.cc',
'base/listen_socket.cc',
- 'base/mime_util.cc',
'base/ssl_client_socket.cc',
'base/ssl_config_service.cc',
'base/tcp_client_socket.cc',
@@ -128,11 +128,15 @@ if env['PLATFORM'] == 'darwin':
'base/platform_mime_util_mac.cc',
])
+if env['PLATFORM'] == 'posix':
+ input_files.extend([
+ # TODO(tc): gnome-vfs? xdgmime? /etc/mime.types?
+ 'base/platform_mime_util_linux.cc',
+ ])
+
if env['PLATFORM'] in ('darwin', 'posix'):
input_files.extend([
'base/net_util_posix.cc',
- # TODO(tc): gnome-vfs? xdgmime? /etc/mime.types?
- #'base/platform_mime_util_linux.cc,
'disk_cache/cache_util_posix.cc',
'disk_cache/file_posix.cc',
'disk_cache/mapped_file_posix.cc',
@@ -214,6 +218,7 @@ unittest_files = [
'base/gzip_filter_unittest.cc',
'base/host_resolver_unittest.cc',
'base/mime_sniffer_unittest.cc',
+ 'base/mime_util_unittest.cc',
'base/net_util_unittest.cc',
'base/registry_controlled_domain_unittest.cc',
'base/run_all_unittests.cc',
@@ -233,7 +238,6 @@ if env['PLATFORM'] == 'win32':
unittest_files.extend([
'base/cookie_policy_unittest.cc',
'base/directory_lister_unittest.cc',
- 'base/mime_util_unittest.cc',
'base/ssl_config_service_unittest.cc',
'base/ssl_client_socket_unittest.cc',
'base/tcp_client_socket_unittest.cc',
@@ -325,4 +329,3 @@ if env['PLATFORM'] == 'win32':
else:
icudata = '../icudt38l.dat'
env.Alias('net', ['.', installed_tests, icudata])
-
diff --git a/net/base/platform_mime_util_linux.cc b/net/base/platform_mime_util_linux.cc
new file mode 100644
index 0000000..1d7dccc
--- /dev/null
+++ b/net/base/platform_mime_util_linux.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "net/base/platform_mime_util.h"
+
+namespace net {
+
+bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
+ const std::wstring& ext, std::string* result) const {
+ // The correct thing to do is to interact somehow with the freedesktop shared
+ // mime info cache. Since Linux (and other traditional *IX systems) don't use
+ // file extensions; they use mime types and have multiple ways of detecting
+ // that; some types can be guessed from globs (*.gif), but there's a whole
+ // bunch that use a magic byte test.
+ //
+ // Since this method only is called from inside mime_util where there is
+ // already a hard coded table of mime types, we just return false because it
+ // doesn't matter.
+
+ return false;
+}
+
+bool PlatformMimeUtil::GetPreferredExtensionForMimeType(
+ const std::string& mime_type, std::wstring* ext) const {
+ // Unlike GetPlatformMimeTypeFromExtension, this method doesn't have a
+ // default list that it uses, but for now we are also returning false since
+ // this doesn't really matter as much under Linux.
+ //
+ // If we wanted to do this properly, we would read the mime.cache file which
+ // has a section where they assign a glob (*.gif) to a mimetype
+ // (image/gif). We look up the "heaviest" glob for a certain mime type and
+ // then then try to chop off "*.".
+
+ return false;
+}
+
+} // namespace net