diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-08 19:27:28 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-08 19:27:28 +0000 |
commit | dc6ee2482d239e37b1fb7e0619df2c058ce91bfd (patch) | |
tree | 6bdb36815910ee8d49a706a2ca5d7049004244c1 /net/base/mime_util.cc | |
parent | 505115c27f5454df0878407c7706c7f1c3744b0d (diff) | |
download | chromium_src-dc6ee2482d239e37b1fb7e0619df2c058ce91bfd.zip chromium_src-dc6ee2482d239e37b1fb7e0619df2c058ce91bfd.tar.gz chromium_src-dc6ee2482d239e37b1fb7e0619df2c058ce91bfd.tar.bz2 |
Break out windows specific parts of mime_util.cc into mime_util_win.cc
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@582 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/mime_util.cc')
-rw-r--r-- | net/base/mime_util.cc | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index 8595311..1277957 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -31,10 +31,7 @@ #include <string.h> #include "net/base/mime_util.h" - -#include "base/basictypes.h" #include "base/logging.h" -#include "base/registry.h" #include "base/string_util.h" using std::string; @@ -42,6 +39,11 @@ using std::wstring; namespace net { +// Helper used by GetMimeTypeFromExtension() to lookup the +// platform specific mappings. Defined in mime_util_{win,mac}.cc +bool GetPlatformMimeTypeFromExtension(const std::wstring& ext, + std::string* mime_type); + struct MimeInfo { const char* mime_type; const char* extensions; // comma separated list @@ -115,14 +117,8 @@ bool GetMimeTypeFromExtension(const wstring& ext, string* result) { return true; } - // check windows registry for file extension's mime type (registry key - // names are not case-sensitive). - wstring value, key = L"." + ext; - RegKey(HKEY_CLASSES_ROOT, key.c_str()).ReadValue(L"Content Type", &value); - if (!value.empty()) { - *result = WideToUTF8(value); + if (GetPlatformMimeTypeFromExtension(ext, result)) return true; - } mime_type = FindMimeType(secondary_mappings, arraysize(secondary_mappings), ext_utf8.c_str()); @@ -141,13 +137,6 @@ bool GetMimeTypeFromFile(const wstring& file_path, string* result) { return GetMimeTypeFromExtension(file_path.substr(dot + 1), result); } -bool GetPreferredExtensionForMimeType(const std::string& mime_type, - std::wstring* ext) { - wstring key(L"MIME\\Database\\Content Type\\" + UTF8ToWide(mime_type)); - return RegKey(HKEY_CLASSES_ROOT, key.c_str()).ReadValue(L"Extension", ext); -} - - // From WebKit's WebCore/platform/MIMETypeRegistry.cpp: static const char* supported_image_types[] = { |