diff options
author | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-06 00:05:59 +0000 |
---|---|---|
committer | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-06 00:05:59 +0000 |
commit | 0b99ae575f39da34f7494723934d2a8cfeca63a8 (patch) | |
tree | c1fd8b3d1a06aef9cc498e530006ee562007b47e /chrome/browser/intents | |
parent | 694e199351b4bf1b3d74a1b6ec55f751a7df3aea (diff) | |
download | chromium_src-0b99ae575f39da34f7494723934d2a8cfeca63a8.zip chromium_src-0b99ae575f39da34f7494723934d2a8cfeca63a8.tar.gz chromium_src-0b99ae575f39da34f7494723934d2a8cfeca63a8.tar.bz2 |
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
Diffstat (limited to 'chrome/browser/intents')
-rw-r--r-- | chrome/browser/intents/web_intents_registry.cc | 32 |
1 files changed, 1 insertions, 31 deletions
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. |