| 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/browser/renderer_host/render_message_filter.h" | 5 #include "content/browser/renderer_host/render_message_filter.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "content/browser/renderer_host/pepper/pepper_security_helper.h" | 25 #include "content/browser/renderer_host/pepper/pepper_security_helper.h" |
| 26 #include "content/browser/renderer_host/render_process_host_impl.h" | 26 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 27 #include "content/browser/renderer_host/render_view_host_delegate.h" | 27 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 28 #include "content/browser/renderer_host/render_widget_helper.h" | 28 #include "content/browser/renderer_host/render_widget_helper.h" |
| 29 #include "content/browser/renderer_host/render_widget_resize_helper.h" | 29 #include "content/browser/renderer_host/render_widget_resize_helper.h" |
| 30 #include "content/common/child_process_host_impl.h" | 30 #include "content/common/child_process_host_impl.h" |
| 31 #include "content/common/child_process_messages.h" | 31 #include "content/common/child_process_messages.h" |
| 32 #include "content/common/content_constants_internal.h" | 32 #include "content/common/content_constants_internal.h" |
| 33 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 33 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 34 #include "content/common/host_shared_bitmap_manager.h" | 34 #include "content/common/host_shared_bitmap_manager.h" |
| 35 #include "content/common/render_process_messages.h" |
| 35 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
| 36 #include "content/public/browser/browser_child_process_host.h" | 37 #include "content/public/browser/browser_child_process_host.h" |
| 37 #include "content/public/browser/browser_context.h" | 38 #include "content/public/browser/browser_context.h" |
| 38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/content_browser_client.h" | 40 #include "content/public/browser/content_browser_client.h" |
| 40 #include "content/public/browser/download_save_info.h" | 41 #include "content/public/browser/download_save_info.h" |
| 41 #include "content/public/browser/resource_context.h" | 42 #include "content/public/browser/resource_context.h" |
| 42 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
| 43 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" |
| 44 #include "content/public/common/context_menu_params.h" | 45 #include "content/public/common/context_menu_params.h" |
| 45 #include "content/public/common/url_constants.h" | 46 #include "content/public/common/url_constants.h" |
| 46 #include "ipc/ipc_channel_handle.h" | 47 #include "ipc/ipc_channel_handle.h" |
| 47 #include "ipc/ipc_platform_file.h" | 48 #include "ipc/ipc_platform_file.h" |
| 48 #include "media/audio/audio_manager.h" | 49 #include "media/audio/audio_manager.h" |
| 49 #include "media/audio/audio_manager_base.h" | 50 #include "media/audio/audio_manager_base.h" |
| 50 #include "media/audio/audio_parameters.h" | 51 #include "media/audio/audio_parameters.h" |
| 51 #include "media/base/media_log_event.h" | 52 #include "media/base/media_log_event.h" |
| 52 #include "net/base/io_buffer.h" | 53 #include "net/base/io_buffer.h" |
| 54 #include "net/base/keygen_handler.h" |
| 53 #include "net/base/mime_util.h" | 55 #include "net/base/mime_util.h" |
| 54 #include "net/base/request_priority.h" | 56 #include "net/base/request_priority.h" |
| 55 #include "net/http/http_cache.h" | 57 #include "net/http/http_cache.h" |
| 56 #include "net/url_request/url_request_context.h" | 58 #include "net/url_request/url_request_context.h" |
| 57 #include "net/url_request/url_request_context_getter.h" | 59 #include "net/url_request/url_request_context_getter.h" |
| 58 #include "ppapi/shared_impl/file_type_conversion.h" | 60 #include "ppapi/shared_impl/file_type_conversion.h" |
| 59 #include "ui/gfx/color_profile.h" | 61 #include "ui/gfx/color_profile.h" |
| 60 #include "url/gurl.h" | 62 #include "url/gurl.h" |
| 61 | 63 |
| 62 #if defined(OS_POSIX) | 64 #if defined(OS_POSIX) |
| 63 #include "base/file_descriptor_posix.h" | 65 #include "base/file_descriptor_posix.h" |
| 64 #endif | 66 #endif |
| 65 #if defined(OS_ANDROID) | 67 #if defined(OS_ANDROID) |
| 66 #include "media/base/android/webaudio_media_codec_bridge.h" | 68 #include "media/base/android/webaudio_media_codec_bridge.h" |
| 67 #endif | 69 #endif |
| 68 | 70 |
| 69 namespace content { | 71 namespace content { |
| 70 namespace { | 72 namespace { |
| 71 | 73 |
| 72 const uint32 kFilteredMessageClasses[] = { | 74 const uint32 kFilteredMessageClasses[] = { |
| 73 ChildProcessMsgStart, | 75 ChildProcessMsgStart, |
| 76 RenderProcessMsgStart, |
| 74 ViewMsgStart, | 77 ViewMsgStart, |
| 75 }; | 78 }; |
| 76 | 79 |
| 77 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
| 78 // On Windows, |g_color_profile| can run on an arbitrary background thread. | 81 // On Windows, |g_color_profile| can run on an arbitrary background thread. |
| 79 // We avoid races by using LazyInstance's constructor lock to initialize the | 82 // We avoid races by using LazyInstance's constructor lock to initialize the |
| 80 // object. | 83 // object. |
| 81 base::LazyInstance<gfx::ColorProfile>::Leaky g_color_profile = | 84 base::LazyInstance<gfx::ColorProfile>::Leaky g_color_profile = |
| 82 LAZY_INSTANCE_INITIALIZER; | 85 LAZY_INSTANCE_INITIALIZER; |
| 83 #endif | 86 #endif |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 OnDeletedGpuMemoryBuffer) | 158 OnDeletedGpuMemoryBuffer) |
| 156 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_AllocatedSharedBitmap, | 159 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_AllocatedSharedBitmap, |
| 157 OnAllocatedSharedBitmap) | 160 OnAllocatedSharedBitmap) |
| 158 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedSharedBitmap, | 161 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedSharedBitmap, |
| 159 OnDeletedSharedBitmap) | 162 OnDeletedSharedBitmap) |
| 160 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 163 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 161 ChildProcessHostMsg_SyncAllocateLockedDiscardableSharedMemory, | 164 ChildProcessHostMsg_SyncAllocateLockedDiscardableSharedMemory, |
| 162 OnAllocateLockedDiscardableSharedMemory) | 165 OnAllocateLockedDiscardableSharedMemory) |
| 163 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedDiscardableSharedMemory, | 166 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedDiscardableSharedMemory, |
| 164 OnDeletedDiscardableSharedMemory) | 167 OnDeletedDiscardableSharedMemory) |
| 168 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_Keygen, OnKeygen) |
| 165 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata, | 169 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata, |
| 166 OnCacheableMetadataAvailable) | 170 OnCacheableMetadataAvailable) |
| 167 IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioHardwareConfig, | 171 IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioHardwareConfig, |
| 168 OnGetAudioHardwareConfig) | 172 OnGetAudioHardwareConfig) |
| 169 #if defined(OS_WIN) | 173 #if defined(OS_WIN) |
| 170 IPC_MESSAGE_HANDLER(ViewHostMsg_GetMonitorColorProfile, | 174 IPC_MESSAGE_HANDLER(ViewHostMsg_GetMonitorColorProfile, |
| 171 OnGetMonitorColorProfile) | 175 OnGetMonitorColorProfile) |
| 172 #endif | 176 #endif |
| 173 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvents, OnMediaLogEvents) | 177 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvents, OnMediaLogEvents) |
| 174 #if defined(OS_ANDROID) | 178 #if defined(OS_ANDROID) |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // corresponds to net::LOW (see ConvertWebKitPriorityToNetPriority() | 487 // corresponds to net::LOW (see ConvertWebKitPriorityToNetPriority() |
| 484 // in weburlloader_impl.cc). | 488 // in weburlloader_impl.cc). |
| 485 const net::RequestPriority kPriority = net::LOW; | 489 const net::RequestPriority kPriority = net::LOW; |
| 486 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(data.size())); | 490 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(data.size())); |
| 487 if (!data.empty()) | 491 if (!data.empty()) |
| 488 memcpy(buf->data(), &data.front(), data.size()); | 492 memcpy(buf->data(), &data.front(), data.size()); |
| 489 cache->WriteMetadata(url, kPriority, expected_response_time, buf.get(), | 493 cache->WriteMetadata(url, kPriority, expected_response_time, buf.get(), |
| 490 data.size()); | 494 data.size()); |
| 491 } | 495 } |
| 492 | 496 |
| 497 void RenderMessageFilter::OnKeygen(uint32 key_size_index, |
| 498 const std::string& challenge_string, |
| 499 const GURL& url, |
| 500 IPC::Message* reply_msg) { |
| 501 // Map displayed strings indicating level of keysecurity in the <keygen> |
| 502 // menu to the key size in bits. (See SSLKeyGeneratorChromium.cpp in WebCore.) |
| 503 int key_size_in_bits; |
| 504 switch (key_size_index) { |
| 505 case 0: |
| 506 key_size_in_bits = 2048; |
| 507 break; |
| 508 case 1: |
| 509 key_size_in_bits = 1024; |
| 510 break; |
| 511 default: |
| 512 DCHECK(false) << "Illegal key_size_index " << key_size_index; |
| 513 RenderProcessHostMsg_Keygen::WriteReplyParams(reply_msg, std::string()); |
| 514 Send(reply_msg); |
| 515 return; |
| 516 } |
| 517 |
| 518 resource_context_->CreateKeygenHandler( |
| 519 key_size_in_bits, |
| 520 challenge_string, |
| 521 url, |
| 522 base::Bind( |
| 523 &RenderMessageFilter::PostKeygenToWorkerThread, this, reply_msg)); |
| 524 } |
| 525 |
| 526 void RenderMessageFilter::PostKeygenToWorkerThread( |
| 527 IPC::Message* reply_msg, |
| 528 scoped_ptr<net::KeygenHandler> keygen_handler) { |
| 529 VLOG(1) << "Dispatching keygen task to worker pool."; |
| 530 // Dispatch to worker pool, so we do not block the IO thread. |
| 531 if (!base::WorkerPool::PostTask( |
| 532 FROM_HERE, |
| 533 base::Bind(&RenderMessageFilter::OnKeygenOnWorkerThread, |
| 534 this, |
| 535 base::Passed(&keygen_handler), |
| 536 reply_msg), |
| 537 true)) { |
| 538 NOTREACHED() << "Failed to dispatch keygen task to worker pool"; |
| 539 RenderProcessHostMsg_Keygen::WriteReplyParams(reply_msg, std::string()); |
| 540 Send(reply_msg); |
| 541 } |
| 542 } |
| 543 |
| 544 void RenderMessageFilter::OnKeygenOnWorkerThread( |
| 545 scoped_ptr<net::KeygenHandler> keygen_handler, |
| 546 IPC::Message* reply_msg) { |
| 547 DCHECK(reply_msg); |
| 548 |
| 549 // Generate a signed public key and challenge, then send it back. |
| 550 RenderProcessHostMsg_Keygen::WriteReplyParams( |
| 551 reply_msg, |
| 552 keygen_handler->GenKeyAndSignChallenge()); |
| 553 Send(reply_msg); |
| 554 } |
| 555 |
| 493 void RenderMessageFilter::OnMediaLogEvents( | 556 void RenderMessageFilter::OnMediaLogEvents( |
| 494 const std::vector<media::MediaLogEvent>& events) { | 557 const std::vector<media::MediaLogEvent>& events) { |
| 495 // OnMediaLogEvents() is always dispatched to the UI thread for handling. | 558 // OnMediaLogEvents() is always dispatched to the UI thread for handling. |
| 496 // See OverrideThreadForMessage(). | 559 // See OverrideThreadForMessage(). |
| 497 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 560 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 498 if (media_internals_) | 561 if (media_internals_) |
| 499 media_internals_->OnMediaEvents(render_process_id_, events); | 562 media_internals_->OnMediaEvents(render_process_id_, events); |
| 500 } | 563 } |
| 501 | 564 |
| 502 #if defined(OS_ANDROID) | 565 #if defined(OS_ANDROID) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 void RenderMessageFilter::OnDeletedGpuMemoryBuffer( | 613 void RenderMessageFilter::OnDeletedGpuMemoryBuffer( |
| 551 gfx::GpuMemoryBufferId id, | 614 gfx::GpuMemoryBufferId id, |
| 552 uint32 sync_point) { | 615 uint32 sync_point) { |
| 553 DCHECK(BrowserGpuMemoryBufferManager::current()); | 616 DCHECK(BrowserGpuMemoryBufferManager::current()); |
| 554 | 617 |
| 555 BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer( | 618 BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer( |
| 556 id, PeerHandle(), render_process_id_, sync_point); | 619 id, PeerHandle(), render_process_id_, sync_point); |
| 557 } | 620 } |
| 558 | 621 |
| 559 } // namespace content | 622 } // namespace content |
| OLD | NEW |