OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/renderer_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 : public SimpleWebMimeRegistryImpl { | 178 : public SimpleWebMimeRegistryImpl { |
179 public: | 179 public: |
180 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( | 180 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
181 const blink::WebString& mime_type, | 181 const blink::WebString& mime_type, |
182 const blink::WebString& codecs, | 182 const blink::WebString& codecs, |
183 const blink::WebString& key_system) override; | 183 const blink::WebString& key_system) override; |
184 bool supportsMediaSourceMIMEType(const blink::WebString& mime_type, | 184 bool supportsMediaSourceMIMEType(const blink::WebString& mime_type, |
185 const blink::WebString& codecs) override; | 185 const blink::WebString& codecs) override; |
186 blink::WebString mimeTypeForExtension( | 186 blink::WebString mimeTypeForExtension( |
187 const blink::WebString& file_extension) override; | 187 const blink::WebString& file_extension) override; |
188 blink::WebString mimeTypeFromFile(const blink::WebString& file_path) override; | |
189 }; | 188 }; |
190 | 189 |
191 class RendererBlinkPlatformImpl::FileUtilities : public WebFileUtilitiesImpl { | 190 class RendererBlinkPlatformImpl::FileUtilities : public WebFileUtilitiesImpl { |
192 public: | 191 public: |
193 explicit FileUtilities(ThreadSafeSender* sender) | 192 explicit FileUtilities(ThreadSafeSender* sender) |
194 : thread_safe_sender_(sender) {} | 193 : thread_safe_sender_(sender) {} |
195 bool getFileInfo(const WebString& path, WebFileInfo& result) override; | 194 bool getFileInfo(const WebString& path, WebFileInfo& result) override; |
196 | 195 |
197 private: | 196 private: |
198 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const; | 197 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 505 |
507 // The sandbox restricts our access to the registry, so we need to proxy | 506 // The sandbox restricts our access to the registry, so we need to proxy |
508 // these calls over to the browser process. | 507 // these calls over to the browser process. |
509 std::string mime_type; | 508 std::string mime_type; |
510 RenderThread::Get()->Send( | 509 RenderThread::Get()->Send( |
511 new MimeRegistryMsg_GetMimeTypeFromExtension( | 510 new MimeRegistryMsg_GetMimeTypeFromExtension( |
512 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type)); | 511 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type)); |
513 return base::ASCIIToUTF16(mime_type); | 512 return base::ASCIIToUTF16(mime_type); |
514 } | 513 } |
515 | 514 |
516 WebString RendererBlinkPlatformImpl::MimeRegistry::mimeTypeFromFile( | |
517 const WebString& file_path) { | |
518 if (IsPluginProcess()) | |
519 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); | |
520 | |
521 // The sandbox restricts our access to the registry, so we need to proxy | |
522 // these calls over to the browser process. | |
523 std::string mime_type; | |
524 RenderThread::Get()->Send(new MimeRegistryMsg_GetMimeTypeFromFile( | |
525 base::FilePath::FromUTF16Unsafe(file_path), | |
526 &mime_type)); | |
527 return base::ASCIIToUTF16(mime_type); | |
528 } | |
529 | |
530 //------------------------------------------------------------------------------ | 515 //------------------------------------------------------------------------------ |
531 | 516 |
532 bool RendererBlinkPlatformImpl::FileUtilities::getFileInfo( | 517 bool RendererBlinkPlatformImpl::FileUtilities::getFileInfo( |
533 const WebString& path, | 518 const WebString& path, |
534 WebFileInfo& web_file_info) { | 519 WebFileInfo& web_file_info) { |
535 base::File::Info file_info; | 520 base::File::Info file_info; |
536 base::File::Error status = base::File::FILE_ERROR_MAX; | 521 base::File::Error status = base::File::FILE_ERROR_MAX; |
537 if (!SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileInfo( | 522 if (!SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileInfo( |
538 base::FilePath::FromUTF16Unsafe(path), &file_info, &status)) || | 523 base::FilePath::FromUTF16Unsafe(path), &file_info, &status)) || |
539 status != base::File::FILE_OK) { | 524 status != base::File::FILE_OK) { |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 //------------------------------------------------------------------------------ | 1275 //------------------------------------------------------------------------------ |
1291 | 1276 |
1292 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( | 1277 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( |
1293 const blink::WebBatteryStatus& status) { | 1278 const blink::WebBatteryStatus& status) { |
1294 if (!g_test_battery_status_listener) | 1279 if (!g_test_battery_status_listener) |
1295 return; | 1280 return; |
1296 g_test_battery_status_listener->updateBatteryStatus(status); | 1281 g_test_battery_status_listener->updateBatteryStatus(status); |
1297 } | 1282 } |
1298 | 1283 |
1299 } // namespace content | 1284 } // namespace content |
OLD | NEW |