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

Side by Side Diff: components/html_viewer/web_mime_registry_impl.cc

Issue 1259673002: Make UTF16ToASCII and UTF16TOUTF8 take a StringPiece (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
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 "components/html_viewer/web_mime_registry_impl.h" 5 #include "components/html_viewer/web_mime_registry_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/key_systems.h" 12 #include "media/base/key_systems.h"
13 #include "media/base/mime_util.h" 13 #include "media/base/mime_util.h"
14 #include "media/filters/stream_parser_factory.h" 14 #include "media/filters/stream_parser_factory.h"
15 #include "net/base/mime_util.h" 15 #include "net/base/mime_util.h"
16 #include "third_party/WebKit/public/platform/WebString.h" 16 #include "third_party/WebKit/public/platform/WebString.h"
17 17
18 namespace html_viewer { 18 namespace html_viewer {
19 namespace { 19 namespace {
20 20
21 std::string ToASCIIOrEmpty(const blink::WebString& string) { 21 std::string ToASCIIOrEmpty(const blink::WebString& string) {
22 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) 22 return base::IsStringASCII(string)
23 : std::string(); 23 ? base::UTF16ToASCII(base::StringPiece16(string))
24 : std::string();
24 } 25 }
25 26
26 } // namespace 27 } // namespace
27 28
28 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMIMEType( 29 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMIMEType(
29 const blink::WebString& mime_type) { 30 const blink::WebString& mime_type) {
30 return mime_util::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) 31 return mime_util::IsSupportedMimeType(ToASCIIOrEmpty(mime_type))
31 ? blink::WebMimeRegistry::IsSupported 32 ? blink::WebMimeRegistry::IsSupported
32 : blink::WebMimeRegistry::IsNotSupported; 33 : blink::WebMimeRegistry::IsNotSupported;
33 } 34 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 131
131 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( 132 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile(
132 const blink::WebString& file_path) { 133 const blink::WebString& file_path) {
133 std::string mime_type; 134 std::string mime_type;
134 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), 135 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path),
135 &mime_type); 136 &mime_type);
136 return blink::WebString::fromUTF8(mime_type); 137 return blink::WebString::fromUTF8(mime_type);
137 } 138 }
138 139
139 } // namespace html_viewer 140 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/form_cache.cc ('k') | content/child/browser_font_resource_trusted.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698