| 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 "net/base/mime_util.h" | 7 #include "net/base/mime_util.h" |
| 8 #include "net/base/platform_mime_util.h" | 8 #include "net/base/platform_mime_util.h" |
| 9 | 9 |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 bool MimeUtil::IsSupportedJavascriptMimeType(const char* mime_type) const { | 235 bool MimeUtil::IsSupportedJavascriptMimeType(const char* mime_type) const { |
| 236 return javascript_map_.find(mime_type) != javascript_map_.end(); | 236 return javascript_map_.find(mime_type) != javascript_map_.end(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 bool MimeUtil::IsViewSourceMimeType(const char* mime_type) const { | 239 bool MimeUtil::IsViewSourceMimeType(const char* mime_type) const { |
| 240 return view_source_map_.find(mime_type) != view_source_map_.end(); | 240 return view_source_map_.find(mime_type) != view_source_map_.end(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 // Mirrors WebViewImpl::CanShowMIMEType() | 243 // Mirrors WebViewImpl::CanShowMIMEType() |
| 244 bool MimeUtil::IsSupportedMimeType(const std::string& mime_type) const { | 244 bool MimeUtil::IsSupportedMimeType(const std::string& mime_type) const { |
| 245 if (mime_type.compare(0, 5, "text/") == 0 || | 245 return (mime_type.compare(0, 6, "image/") == 0 && |
| 246 (mime_type.compare(0, 6, "image/") == 0 && | 246 IsSupportedImageMimeType(mime_type.c_str())) || |
| 247 IsSupportedImageMimeType(mime_type.c_str())) || | 247 IsSupportedNonImageMimeType(mime_type.c_str()); |
| 248 IsSupportedNonImageMimeType(mime_type.c_str())) | |
| 249 return true; | |
| 250 return false; | |
| 251 } | 248 } |
| 252 | 249 |
| 253 bool MimeUtil::MatchesMimeType(const std::string &mime_type_pattern, | 250 bool MimeUtil::MatchesMimeType(const std::string &mime_type_pattern, |
| 254 const std::string &mime_type) const { | 251 const std::string &mime_type) const { |
| 255 // verify caller is passing lowercase | 252 // verify caller is passing lowercase |
| 256 DCHECK(mime_type_pattern == StringToLowerASCII(mime_type_pattern)); | 253 DCHECK(mime_type_pattern == StringToLowerASCII(mime_type_pattern)); |
| 257 DCHECK(mime_type == StringToLowerASCII(mime_type)); | 254 DCHECK(mime_type == StringToLowerASCII(mime_type)); |
| 258 | 255 |
| 259 // This comparison handles absolute maching and also basic | 256 // This comparison handles absolute maching and also basic |
| 260 // wildcards. The plugin mime types could be: | 257 // wildcards. The plugin mime types could be: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 return GetMimeUtil()->IsSupportedMimeType(mime_type); | 325 return GetMimeUtil()->IsSupportedMimeType(mime_type); |
| 329 } | 326 } |
| 330 | 327 |
| 331 bool MatchesMimeType(const std::string &mime_type_pattern, | 328 bool MatchesMimeType(const std::string &mime_type_pattern, |
| 332 const std::string &mime_type) { | 329 const std::string &mime_type) { |
| 333 return GetMimeUtil()->MatchesMimeType(mime_type_pattern, mime_type); | 330 return GetMimeUtil()->MatchesMimeType(mime_type_pattern, mime_type); |
| 334 } | 331 } |
| 335 | 332 |
| 336 } // namespace net | 333 } // namespace net |
| 337 | 334 |
| OLD | NEW |