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

Side by Side Diff: webkit/glue/simple_webmimeregistry_impl.cc

Issue 27222: Chrome side to implement WebMimeRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 // TODO(darin): This include should not be necessary, but for some reason the
6 // Mac build requires it.
7 #include "config.h"
8
9 #include "webkit/glue/simple_webmimeregistry_impl.h"
10
11 #include "WebString.h"
12
13 #include "base/string_util.h"
14 #include "base/sys_string_conversions.h"
15 #include "net/base/mime_util.h"
16 #include "webkit/glue/glue_util.h"
17
18 using WebKit::WebString;
19
20 namespace webkit_glue {
21
22 bool SimpleWebMimeRegistryImpl::supportsImageMIMEType(
23 const WebString& mime_type) {
24 return net::IsSupportedImageMimeType(UTF16ToASCII(mime_type).c_str());
25 }
26
27 bool SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
28 const WebString& mime_type) {
29 return net::IsSupportedJavascriptMimeType(UTF16ToASCII(mime_type).c_str());
30 }
31
32 bool SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
33 const WebString& mime_type) {
34 return net::IsSupportedNonImageMimeType(UTF16ToASCII(mime_type).c_str());
35 }
36
37 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension(
38 const WebString& file_extension) {
39 std::string mime_type;
40 net::GetMimeTypeFromExtension(
41 WebStringToFilePathString(file_extension), &mime_type);
42 return ASCIIToUTF16(mime_type);
43 }
44
45 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile(
46 const WebString& file_path) {
47 std::string mime_type;
48 net::GetMimeTypeFromFile(
49 FilePath(WebStringToFilePathString(file_path)), &mime_type);
50 return ASCIIToUTF16(mime_type);
51 }
52
53 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(
54 const WebString& mime_type) {
55 FilePath::StringType file_extension;
56 net::GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type),
57 &file_extension);
58 return FilePathStringToWebString(file_extension);
59 }
60
61 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698