Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / mojo / services / html_viewer / webmimeregistry_impl.cc
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
3 // found in the LICENSE file.
4
5 #include "mojo/services/html_viewer/webmimeregistry_impl.h"
6
7 #include "base/files/file_path.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "net/base/mime_util.h"
12 #include "third_party/WebKit/public/platform/WebString.h"
13
14 namespace mojo {
15 namespace {
16
17 std::string ToASCIIOrEmpty(const blink::WebString& string) {
18   return base::IsStringASCII(string) ? base::UTF16ToASCII(string)
19                                      : std::string();
20 }
21
22 }  // namespace
23
24 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMIMEType(
25     const blink::WebString& mime_type) {
26   return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ?
27       blink::WebMimeRegistry::IsSupported :
28       blink::WebMimeRegistry::IsNotSupported;
29 }
30
31 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsImageMIMEType(
32     const blink::WebString& mime_type) {
33   return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ?
34       blink::WebMimeRegistry::IsSupported :
35       blink::WebMimeRegistry::IsNotSupported;
36 }
37
38 blink::WebMimeRegistry::SupportsType
39     WebMimeRegistryImpl::supportsJavaScriptMIMEType(
40     const blink::WebString& mime_type) {
41   return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
42       blink::WebMimeRegistry::IsSupported :
43       blink::WebMimeRegistry::IsNotSupported;
44 }
45
46 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType(
47     const blink::WebString& mime_type,
48     const blink::WebString& codecs,
49     const blink::WebString& key_system) {
50   NOTIMPLEMENTED();
51   return IsNotSupported;
52 }
53
54 bool WebMimeRegistryImpl::supportsMediaSourceMIMEType(
55     const blink::WebString& mime_type,
56     const blink::WebString& codecs) {
57   NOTIMPLEMENTED();
58   return false;
59 }
60
61 bool WebMimeRegistryImpl::supportsEncryptedMediaMIMEType(
62     const blink::WebString& key_system,
63     const blink::WebString& mime_type,
64     const blink::WebString& codecs) {
65   NOTIMPLEMENTED();
66   return false;
67 }
68
69 blink::WebMimeRegistry::SupportsType
70     WebMimeRegistryImpl::supportsNonImageMIMEType(
71     const blink::WebString& mime_type) {
72   return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ?
73       blink::WebMimeRegistry::IsSupported :
74       blink::WebMimeRegistry::IsNotSupported;
75 }
76
77 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension(
78     const blink::WebString& file_extension) {
79   NOTIMPLEMENTED();
80   return blink::WebString();
81 }
82
83 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension(
84     const blink::WebString& file_extension) {
85   NOTIMPLEMENTED();
86   return blink::WebString();
87 }
88
89 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile(
90     const blink::WebString& file_path) {
91   NOTIMPLEMENTED();
92   return blink::WebString();
93 }
94
95 }  // namespace mojo