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

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

Issue 1686263008: Add utility method for WebString to base::FilePath conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase! Created 4 years, 10 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
« no previous file with comments | « base/files/file_path.cc ('k') | content/child/web_url_request_util.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 "net/base/mime_util.h" 12 #include "net/base/mime_util.h"
13 #include "third_party/WebKit/public/platform/FilePathConversion.h"
13 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
14 15
15 using blink::WebString; 16 using blink::WebString;
16 using blink::WebMimeRegistry; 17 using blink::WebMimeRegistry;
17 18
18 namespace content { 19 namespace content {
19 20
20 // static 21 // static
21 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { 22 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) {
22 return base::IsStringASCII(string) 23 return base::IsStringASCII(string)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const WebString& mime_type) { 81 const WebString& mime_type) {
81 return mime_util::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) 82 return mime_util::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type))
82 ? WebMimeRegistry::IsSupported 83 ? WebMimeRegistry::IsSupported
83 : WebMimeRegistry::IsNotSupported; 84 : WebMimeRegistry::IsNotSupported;
84 } 85 }
85 86
86 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension( 87 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension(
87 const WebString& file_extension) { 88 const WebString& file_extension) {
88 std::string mime_type; 89 std::string mime_type;
89 net::GetMimeTypeFromExtension( 90 net::GetMimeTypeFromExtension(
90 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type); 91 blink::WebStringToFilePath(file_extension).value(), &mime_type);
91 return WebString::fromUTF8(mime_type); 92 return WebString::fromUTF8(mime_type);
92 } 93 }
93 94
94 WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension( 95 WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension(
95 const WebString& file_extension) { 96 const WebString& file_extension) {
96 std::string mime_type; 97 std::string mime_type;
97 net::GetWellKnownMimeTypeFromExtension( 98 net::GetWellKnownMimeTypeFromExtension(
98 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type); 99 blink::WebStringToFilePath(file_extension).value(), &mime_type);
99 return WebString::fromUTF8(mime_type); 100 return WebString::fromUTF8(mime_type);
100 } 101 }
101 102
102 } // namespace content 103 } // namespace content
OLDNEW
« no previous file with comments | « base/files/file_path.cc ('k') | content/child/web_url_request_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698