Commit 4096a6ff authored by yoav's avatar yoav Committed by Commit bot

Added a method to detect all supported "image/*" MIME types

Since other methods separate supported binary image MIME types from SVG,
where SVG was detected as a "non image type" along with XML, and since I
needed a method to detect MIME types that can be displayed as an image,
I've added such a method.

BUG=398443

Review URL: https://codereview.chromium.org/471913002

Cr-Commit-Position: refs/heads/master@{#291750}
parent 0ab2c722
......@@ -34,6 +34,16 @@ WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType(
WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
}
WebMimeRegistry::SupportsType
SimpleWebMimeRegistryImpl::supportsImagePrefixedMIMEType(
const WebString& mime_type) {
std::string ascii_mime_type = ToASCIIOrEmpty(mime_type);
return (net::IsSupportedImageMimeType(ascii_mime_type) ||
(StartsWithASCII(ascii_mime_type, "image/", true) &&
net::IsSupportedNonImageMimeType(ascii_mime_type))) ?
WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
}
WebMimeRegistry::SupportsType
SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
const WebString& mime_type) {
......
......@@ -28,6 +28,8 @@ class CONTENT_EXPORT SimpleWebMimeRegistryImpl :
const blink::WebString&);
virtual blink::WebMimeRegistry::SupportsType supportsImageMIMEType(
const blink::WebString&);
virtual blink::WebMimeRegistry::SupportsType supportsImagePrefixedMIMEType(
const blink::WebString&);
virtual blink::WebMimeRegistry::SupportsType supportsJavaScriptMIMEType(
const blink::WebString&);
virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Tests for SimpleWebMimeRegistryImpl.
#include "content/child/simple_webmimeregistry_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebString.h"
TEST(SimpleWebMimeRegistryImpl, mimeTypeTest)
{
content::SimpleWebMimeRegistryImpl registry;
EXPECT_TRUE(registry.supportsImagePrefixedMIMEType("image/gif"));
EXPECT_TRUE(registry.supportsImagePrefixedMIMEType("image/svg+xml"));
EXPECT_FALSE(registry.supportsImageMIMEType("image/svg+xml"));
EXPECT_TRUE(registry.supportsImageMIMEType("image/gif"));
}
......@@ -636,6 +636,7 @@
'child/npapi/plugin_lib_unittest.cc',
'child/power_monitor_broadcast_source_unittest.cc',
'child/resource_dispatcher_unittest.cc',
'child/simple_webmimeregistry_impl_unittest.cc',
'child/site_isolation_policy_unittest.cc',
'child/touch_fling_gesture_curve_unittest.cc',
'child/web_url_loader_impl_unittest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment