diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-10 02:55:27 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-10 02:55:27 +0000 |
commit | 4c1b9d4ed541c28e0f7e8b99025f37f4d210c90e (patch) | |
tree | 61dc9bdef50b2e7c5d96a4e3915d65a460cda8f4 | |
parent | f57f28bc5f898518083c10a05f779e31275b7b31 (diff) | |
download | chromium_src-4c1b9d4ed541c28e0f7e8b99025f37f4d210c90e.zip chromium_src-4c1b9d4ed541c28e0f7e8b99025f37f4d210c90e.tar.gz chromium_src-4c1b9d4ed541c28e0f7e8b99025f37f4d210c90e.tar.bz2 |
Add a stubbed-out platform_mime_util_mac.mm
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@636 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/mime_util.cc | 11 | ||||
-rw-r--r-- | net/base/mime_util_unittest.cc | 3 | ||||
-rw-r--r-- | net/base/platform_mime_util_mac.mm | 50 | ||||
-rw-r--r-- | net/base/platform_mime_util_win.cc | 2 |
4 files changed, 61 insertions, 5 deletions
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index 0221fc8..9e98145 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -27,12 +27,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <hash_set> -#include <string.h> +#include <string> #include "net/base/mime_util.h" #include "net/base/platform_mime_util.h" +#include "base/hash_tables.h" #include "base/logging.h" #include "base/singleton.h" #include "base/string_util.h" @@ -71,7 +71,7 @@ private: // For faster lookup, keep hash sets. void InitializeMimeTypeMaps(); - typedef stdext::hash_set<std::string> MimeMappings; + typedef base::hash_set<std::string> MimeMappings; MimeMappings image_map_; MimeMappings non_image_map_; MimeMappings javascript_map_; @@ -124,7 +124,8 @@ static const char* FindMimeType(const MimeInfo* mappings, const char* extensions = mappings[i].extensions; for (;;) { size_t end_pos = strcspn(extensions, ","); - if (end_pos == ext_len && _strnicmp(extensions, ext, ext_len) == 0) + if (end_pos == ext_len && + base::strncasecmp(extensions, ext, ext_len) == 0) return mappings[i].mime_type; extensions += end_pos; if (!*extensions) @@ -168,6 +169,8 @@ bool MimeUtil::GetMimeTypeFromExtension(const wstring& ext, bool MimeUtil::GetMimeTypeFromFile(const wstring& file_path, string* result) const { + // TODO(ericroman): this doesn't work properly with paths like + // /home/foo/.ssh/known_hosts wstring::size_type dot = file_path.find_last_of('.'); if (dot == wstring::npos) return false; diff --git a/net/base/mime_util_unittest.cc b/net/base/mime_util_unittest.cc index 468e2c7..548601a 100644 --- a/net/base/mime_util_unittest.cc +++ b/net/base/mime_util_unittest.cc @@ -68,6 +68,9 @@ TEST(MimeUtilTest, FileTest) { } tests[] = { { L"c:\\foo\\bar.css", "text/css", true }, { L"c:\\blah", "", false }, + { L"/usr/local/bin/mplayer", "", false }, + { L"/home/foo/bar.css", "text/css", true }, + { L"/blah.", "", false }, { L"c:\\blah.", "", false }, }; diff --git a/net/base/platform_mime_util_mac.mm b/net/base/platform_mime_util_mac.mm new file mode 100644 index 0000000..8cc3794 --- /dev/null +++ b/net/base/platform_mime_util_mac.mm @@ -0,0 +1,50 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import <Cocoa/Cocoa.h> +#include <string> + +#include "net/base/platform_mime_util.h" +#include "base/notimplemented.h" + +namespace net { + +bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( + const std::wstring& ext, std::string* result) const { + NOTIMPLEMENTED(); + return false; +} + +bool PlatformMimeUtil::GetPreferredExtensionForMimeType( + const std::string& mime_type, std::wstring* ext) const { + NOTIMPLEMENTED(); + return false; +} + +} // namespace net diff --git a/net/base/platform_mime_util_win.cc b/net/base/platform_mime_util_win.cc index 325c4e96..965be8a 100644 --- a/net/base/platform_mime_util_win.cc +++ b/net/base/platform_mime_util_win.cc @@ -27,7 +27,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <string.h> +#include <string> #include "net/base/platform_mime_util.h" |