Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2158)

Unified Diff: chrome/browser/intents/web_intents_registry.cc

Issue 10448109: Move function for classifying a string as a mime type into MimeUtil (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adapt for windows unicode strings. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/mime_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/intents/web_intents_registry.cc
diff --git a/chrome/browser/intents/web_intents_registry.cc b/chrome/browser/intents/web_intents_registry.cc
index 558d91221e7775bab8af999458696e02a74dda7d..eb6fb583e01650213ec9a33d3198aadb1042d7b3 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.
« no previous file with comments | « no previous file | net/base/mime_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698