Chromium Code Reviews| 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_webkitplatformsupport_impl.h" | 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 8 #include <vector> | |
| 9 | |
| 7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 10 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 11 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 12 #include "base/shared_memory.h" | 15 #include "base/shared_memory.h" |
| 13 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 14 #include "content/common/database_util.h" | 17 #include "content/common/database_util.h" |
| 15 #include "content/common/fileapi/webblobregistry_impl.h" | 18 #include "content/common/fileapi/webblobregistry_impl.h" |
| 16 #include "content/common/fileapi/webfilesystem_impl.h" | 19 #include "content/common/fileapi/webfilesystem_impl.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 WebIDBFactory* RendererWebKitPlatformSupportImpl::idbFactory() { | 339 WebIDBFactory* RendererWebKitPlatformSupportImpl::idbFactory() { |
| 337 if (!web_idb_factory_.get()) { | 340 if (!web_idb_factory_.get()) { |
| 338 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | 341 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
| 339 web_idb_factory_.reset(WebIDBFactory::create()); | 342 web_idb_factory_.reset(WebIDBFactory::create()); |
| 340 else | 343 else |
| 341 web_idb_factory_.reset(new RendererWebIDBFactoryImpl()); | 344 web_idb_factory_.reset(new RendererWebIDBFactoryImpl()); |
| 342 } | 345 } |
| 343 return web_idb_factory_.get(); | 346 return web_idb_factory_.get(); |
| 344 } | 347 } |
| 345 | 348 |
| 346 void RendererWebKitPlatformSupportImpl::createIDBKeysFromSerializedValuesAndKeyP ath( | 349 void |
| 350 RendererWebKitPlatformSupportImpl::createIDBKeysFromSerializedValuesAndKeyPath( | |
| 347 const WebVector<WebSerializedScriptValue>& values, | 351 const WebVector<WebSerializedScriptValue>& values, |
| 348 const WebIDBKeyPath& keyPath, | 352 const WebIDBKeyPath& keyPath, |
| 349 WebVector<WebIDBKey>& keys_out) { | 353 WebVector<WebIDBKey>& keys_out) { |
| 350 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); | 354 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); |
| 351 WebVector<WebIDBKey> keys(values.size()); | 355 WebVector<WebIDBKey> keys(values.size()); |
| 352 for (size_t i = 0; i < values.size(); ++i) { | 356 for (size_t i = 0; i < values.size(); ++i) { |
| 353 keys[i] = WebIDBKey::createFromValueAndKeyPath( | 357 keys[i] = WebIDBKey::createFromValueAndKeyPath( |
| 354 values[i], keyPath); | 358 values[i], keyPath); |
| 355 } | 359 } |
| 356 keys_out.swap(keys); | 360 keys_out.swap(keys); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 382 if (IsPluginProcess()) | 386 if (IsPluginProcess()) |
| 383 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); | 387 return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension); |
| 384 | 388 |
| 385 // The sandbox restricts our access to the registry, so we need to proxy | 389 // The sandbox restricts our access to the registry, so we need to proxy |
| 386 // these calls over to the browser process. | 390 // these calls over to the browser process. |
| 387 std::string mime_type; | 391 std::string mime_type; |
| 388 RenderThreadImpl::current()->Send( | 392 RenderThreadImpl::current()->Send( |
| 389 new MimeRegistryMsg_GetMimeTypeFromExtension( | 393 new MimeRegistryMsg_GetMimeTypeFromExtension( |
| 390 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); | 394 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); |
| 391 return ASCIIToUTF16(mime_type); | 395 return ASCIIToUTF16(mime_type); |
| 392 | |
| 393 } | 396 } |
| 394 | 397 |
| 395 WebString RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeFromFile( | 398 WebString RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeFromFile( |
| 396 const WebString& file_path) { | 399 const WebString& file_path) { |
| 397 if (IsPluginProcess()) | 400 if (IsPluginProcess()) |
| 398 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); | 401 return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path); |
| 399 | 402 |
| 400 // The sandbox restricts our access to the registry, so we need to proxy | 403 // The sandbox restricts our access to the registry, so we need to proxy |
| 401 // these calls over to the browser process. | 404 // these calls over to the browser process. |
| 402 std::string mime_type; | 405 std::string mime_type; |
| 403 RenderThreadImpl::current()->Send(new MimeRegistryMsg_GetMimeTypeFromFile( | 406 RenderThreadImpl::current()->Send(new MimeRegistryMsg_GetMimeTypeFromFile( |
| 404 FilePath(webkit_glue::WebStringToFilePathString(file_path)), | 407 FilePath(webkit_glue::WebStringToFilePathString(file_path)), |
| 405 &mime_type)); | 408 &mime_type)); |
| 406 return ASCIIToUTF16(mime_type); | 409 return ASCIIToUTF16(mime_type); |
| 407 | |
| 408 } | 410 } |
| 409 | 411 |
| 410 WebString | 412 WebString |
| 411 RendererWebKitPlatformSupportImpl::MimeRegistry::preferredExtensionForMIMEType( | 413 RendererWebKitPlatformSupportImpl::MimeRegistry::preferredExtensionForMIMEType( |
| 412 const WebString& mime_type) { | 414 const WebString& mime_type) { |
| 413 if (IsPluginProcess()) | 415 if (IsPluginProcess()) |
| 414 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type); | 416 return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type); |
| 415 | 417 |
| 416 // The sandbox restricts our access to the registry, so we need to proxy | 418 // The sandbox restricts our access to the registry, so we need to proxy |
| 417 // these calls over to the browser process. | 419 // these calls over to the browser process. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 layout = CHANNEL_LAYOUT_7_1; | 632 layout = CHANNEL_LAYOUT_7_1; |
| 631 break; | 633 break; |
| 632 default: | 634 default: |
| 633 layout = CHANNEL_LAYOUT_STEREO; | 635 layout = CHANNEL_LAYOUT_STEREO; |
| 634 } | 636 } |
| 635 | 637 |
| 636 media::AudioParameters params( | 638 media::AudioParameters params( |
| 637 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout, | 639 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout, |
| 638 static_cast<int>(sampleRate), 16, bufferSize); | 640 static_cast<int>(sampleRate), 16, bufferSize); |
| 639 | 641 |
| 640 return new RendererWebAudioDeviceImpl(params, callback); | 642 // Get access to the RenderView to be able to inject the audio-device |
| 643 // factory. | |
| 644 WebFrame* web_frame = WebFrame::frameForCurrentContext(); | |
|
piman
2012/06/14 17:00:50
This sounds like this method needs to be a member
henrika (OOO until Aug 14)
2012/06/14 17:18:29
I can try to refactor if you think it is required.
piman
2012/06/14 17:29:32
TBH I don't think the other uses in this file are
| |
| 645 if (!web_frame) | |
| 646 return NULL; | |
| 647 | |
| 648 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | |
| 649 if (!render_view) | |
| 650 return NULL; | |
| 651 | |
| 652 return new RendererWebAudioDeviceImpl( | |
| 653 render_view->audio_device_factory(), params, callback); | |
| 641 } | 654 } |
| 642 | 655 |
| 643 //------------------------------------------------------------------------------ | 656 //------------------------------------------------------------------------------ |
| 644 | 657 |
| 645 WebKit::WebString | 658 WebKit::WebString |
| 646 RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( | 659 RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( |
| 647 unsigned key_size_index, | 660 unsigned key_size_index, |
| 648 const WebKit::WebString& challenge, | 661 const WebKit::WebString& challenge, |
| 649 const WebKit::WebURL& url) { | 662 const WebKit::WebURL& url) { |
| 650 std::string signed_public_key; | 663 std::string signed_public_key; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 669 //------------------------------------------------------------------------------ | 682 //------------------------------------------------------------------------------ |
| 670 | 683 |
| 671 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { | 684 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { |
| 672 if (!gamepad_shared_memory_reader_.get()) | 685 if (!gamepad_shared_memory_reader_.get()) |
| 673 gamepad_shared_memory_reader_.reset(new content::GamepadSharedMemoryReader); | 686 gamepad_shared_memory_reader_.reset(new content::GamepadSharedMemoryReader); |
| 674 gamepad_shared_memory_reader_->SampleGamepads(gamepads); | 687 gamepad_shared_memory_reader_->SampleGamepads(gamepads); |
| 675 } | 688 } |
| 676 | 689 |
| 677 WebKit::WebString RendererWebKitPlatformSupportImpl::userAgent( | 690 WebKit::WebString RendererWebKitPlatformSupportImpl::userAgent( |
| 678 const WebKit::WebURL& url) { | 691 const WebKit::WebURL& url) { |
| 679 return WebKitPlatformSupportImpl::userAgent(url); | 692 return WebKitPlatformSupportImpl::userAgent(url); |
| 680 } | 693 } |
| 681 | 694 |
| 682 void RendererWebKitPlatformSupportImpl::GetPlugins( | 695 void RendererWebKitPlatformSupportImpl::GetPlugins( |
| 683 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { | 696 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { |
| 684 if (!RenderThreadImpl::current()->plugin_refresh_allowed()) | 697 if (!RenderThreadImpl::current()->plugin_refresh_allowed()) |
| 685 refresh = false; | 698 refresh = false; |
| 686 RenderThreadImpl::current()->Send( | 699 RenderThreadImpl::current()->Send( |
| 687 new ViewHostMsg_GetPlugins(refresh, plugins)); | 700 new ViewHostMsg_GetPlugins(refresh, plugins)); |
| 688 } | 701 } |
| 689 | 702 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 bool enable) { | 743 bool enable) { |
| 731 bool was_enabled = g_sandbox_enabled; | 744 bool was_enabled = g_sandbox_enabled; |
| 732 g_sandbox_enabled = enable; | 745 g_sandbox_enabled = enable; |
| 733 return was_enabled; | 746 return was_enabled; |
| 734 } | 747 } |
| 735 | 748 |
| 736 GpuChannelHostFactory* | 749 GpuChannelHostFactory* |
| 737 RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() { | 750 RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() { |
| 738 return RenderThreadImpl::current(); | 751 return RenderThreadImpl::current(); |
| 739 } | 752 } |
| OLD | NEW |