From 0b99ae575f39da34f7494723934d2a8cfeca63a8 Mon Sep 17 00:00:00 2001 From: "gbillock@chromium.org" Date: Wed, 6 Jun 2012 00:05:59 +0000 Subject: Move function for classifying a string as a mime type into MimeUtil R=rvargas@chromium.org BUG=None TEST=MimeUtilTest.* Review URL: https://chromiumcodereview.appspot.com/10448109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140657 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/intents/web_intents_registry.cc | 32 +------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'chrome/browser/intents') diff --git a/chrome/browser/intents/web_intents_registry.cc b/chrome/browser/intents/web_intents_registry.cc index 558d912..eb6fb58 100644 --- a/chrome/browser/intents/web_intents_registry.cc +++ b/chrome/browser/intents/web_intents_registry.cc @@ -41,37 +41,7 @@ bool MimeTypesAreEqual(const string16& type1, const string16& type2) { // "*" is also accepted as a valid MIME type. // The passed |type_str| should have no leading or trailing whitespace. bool IsMimeType(const string16& type_str) { - // MIME types are always ASCII and case-insensitive (at least, the top-level - // and secondary types we care about). - if (!IsStringASCII(type_str)) - return false; - std::string raw_type = UTF16ToASCII(type_str); - StringToLowerASCII(&raw_type); - - // See http://www.iana.org/assignments/media-types/index.html - if (StartsWithASCII(raw_type, "application/", false) || - StartsWithASCII(raw_type, "audio/", false) || - StartsWithASCII(raw_type, "example/", false) || - StartsWithASCII(raw_type, "image/", false) || - StartsWithASCII(raw_type, "message/", false) || - StartsWithASCII(raw_type, "model/", false) || - StartsWithASCII(raw_type, "multipart/", false) || - StartsWithASCII(raw_type, "text/", false) || - StartsWithASCII(raw_type, "video/", false) || - raw_type == "*/*" || raw_type == "*") { - return true; - } - - // If there's a "/" separator character, and the token before it is - // "x-" + (ascii characters), it is also a MIME type. - size_t slash = raw_type.find('/'); - if (slash < 3 || slash == std::string::npos || slash == raw_type.length() - 1) - return false; - - if (StartsWithASCII(raw_type, "x-", false)) - return true; - - return false; + return net::IsMimeType(UTF16ToUTF8(type_str)); } // Compares two web intents type specifiers to see if there is a match. -- cgit v1.1