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

Side by Side Diff: content/child/simple_webmimeregistry_impl.cc

Issue 2469353003: Skip base::string16 if not necessary for WebString <-> ASCII conversion (Closed)
Patch Set: minor fix Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/cache_storage/cache_storage_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/simple_webmimeregistry_impl.h" 5 #include "content/child/simple_webmimeregistry_impl.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/mime_util/mime_util.h" 11 #include "components/mime_util/mime_util.h"
12 #include "media/base/mime_util.h" 12 #include "media/base/mime_util.h"
13 #include "media/filters/stream_parser_factory.h" 13 #include "media/filters/stream_parser_factory.h"
14 #include "net/base/mime_util.h" 14 #include "net/base/mime_util.h"
15 #include "third_party/WebKit/public/platform/FilePathConversion.h" 15 #include "third_party/WebKit/public/platform/FilePathConversion.h"
16 #include "third_party/WebKit/public/platform/WebString.h" 16 #include "third_party/WebKit/public/platform/WebString.h"
17 17
18 using blink::WebString; 18 using blink::WebString;
19 using blink::WebMimeRegistry; 19 using blink::WebMimeRegistry;
20 20
21 namespace content { 21 namespace content {
22 22
23 // static 23 // static
24 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { 24 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) {
25 return base::IsStringASCII(string) 25 return string.containsOnlyASCII() ? string.ascii() : std::string();
26 ? base::UTF16ToASCII(base::StringPiece16(string))
27 : std::string();
28 } 26 }
29 27
30 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( 28 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType(
31 const WebString& mime_type) { 29 const WebString& mime_type) {
32 return mime_util::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) 30 return mime_util::IsSupportedMimeType(ToASCIIOrEmpty(mime_type))
33 ? WebMimeRegistry::IsSupported 31 ? WebMimeRegistry::IsSupported
34 : WebMimeRegistry::IsNotSupported; 32 : WebMimeRegistry::IsNotSupported;
35 } 33 }
36 34
37 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( 35 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 99
102 WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension( 100 WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension(
103 const WebString& file_extension) { 101 const WebString& file_extension) {
104 std::string mime_type; 102 std::string mime_type;
105 net::GetWellKnownMimeTypeFromExtension( 103 net::GetWellKnownMimeTypeFromExtension(
106 blink::WebStringToFilePath(file_extension).value(), &mime_type); 104 blink::WebStringToFilePath(file_extension).value(), &mime_type);
107 return WebString::fromUTF8(mime_type); 105 return WebString::fromUTF8(mime_type);
108 } 106 }
109 107
110 } // namespace content 108 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/cache_storage/cache_storage_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698