OLD | NEW |
(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 #include "chrome/renderer/renderer_webkitclient_impl.h" |
| 6 |
| 7 #include "WebString.h" |
| 8 |
| 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/plugin/npobject_util.h" |
| 11 #include "chrome/renderer/render_thread.h" |
| 12 #include "webkit/glue/glue_util.h" |
| 13 |
| 14 using WebKit::WebString; |
| 15 |
| 16 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension( |
| 17 const WebString& file_extension) { |
| 18 if (IsPluginProcess()) |
| 19 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); |
| 20 |
| 21 // The sandbox restricts our access to the registry, so we need to proxy |
| 22 // these calls over to the browser process. |
| 23 std::string mime_type; |
| 24 RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromExtension( |
| 25 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); |
| 26 return ASCIIToUTF16(mime_type); |
| 27 |
| 28 } |
| 29 |
| 30 WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeFromFile( |
| 31 const WebString& file_path) { |
| 32 if (IsPluginProcess()) |
| 33 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); |
| 34 |
| 35 // The sandbox restricts our access to the registry, so we need to proxy |
| 36 // these calls over to the browser process. |
| 37 std::string mime_type; |
| 38 RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromFile( |
| 39 FilePath(webkit_glue::WebStringToFilePathString(file_path)), |
| 40 &mime_type)); |
| 41 return ASCIIToUTF16(mime_type); |
| 42 |
| 43 } |
| 44 |
| 45 WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType( |
| 46 const WebString& mime_type) { |
| 47 if (IsPluginProcess()) |
| 48 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type); |
| 49 |
| 50 // The sandbox restricts our access to the registry, so we need to proxy |
| 51 // these calls over to the browser process. |
| 52 FilePath::StringType file_extension; |
| 53 RenderThread::current()->Send( |
| 54 new ViewHostMsg_GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type), |
| 55 &file_extension)); |
| 56 return webkit_glue::FilePathStringToWebString(file_extension); |
| 57 } |
OLD | NEW |