| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/resource_message_filter.h" | 5 #include "chrome/browser/renderer_host/resource_message_filter.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/clipboard.h" | 11 #include "base/clipboard.h" |
| 12 #include "base/gfx/native_widget_types.h" | 12 #include "base/gfx/native_widget_types.h" |
| 13 #include "base/histogram.h" | 13 #include "base/histogram.h" |
| 14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 15 #include "base/thread.h" | 15 #include "base/thread.h" |
| 16 #include "chrome/browser/chrome_plugin_browsing_context.h" | 16 #include "chrome/browser/chrome_plugin_browsing_context.h" |
| 17 #include "chrome/browser/chrome_thread.h" | 17 #include "chrome/browser/chrome_thread.h" |
| 18 #include "chrome/browser/net/dns_global.h" | 18 #include "chrome/browser/net/dns_global.h" |
| 19 #include "chrome/browser/plugin_service.h" | 19 #include "chrome/browser/plugin_service.h" |
| 20 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
| 21 #include "chrome/browser/renderer_host/audio_renderer_host.h" | 21 #include "chrome/browser/renderer_host/audio_renderer_host.h" |
| 22 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 22 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 23 #include "chrome/browser/renderer_host/render_widget_helper.h" | 23 #include "chrome/browser/renderer_host/render_widget_helper.h" |
| 24 #include "chrome/browser/spellchecker.h" | 24 #include "chrome/browser/spellchecker.h" |
| 25 #include "chrome/browser/worker_host/worker_service.h" |
| 25 #include "chrome/common/chrome_plugin_lib.h" | 26 #include "chrome/common/chrome_plugin_lib.h" |
| 26 #include "chrome/common/chrome_plugin_util.h" | 27 #include "chrome/common/chrome_plugin_util.h" |
| 27 #include "chrome/common/notification_service.h" | 28 #include "chrome/common/notification_service.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/pref_service.h" | 30 #include "chrome/common/pref_service.h" |
| 30 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
| 31 #include "net/base/cookie_monster.h" | 32 #include "net/base/cookie_monster.h" |
| 32 #include "net/base/mime_util.h" | 33 #include "net/base/mime_util.h" |
| 33 #include "net/url_request/url_request_context.h" | 34 #include "net/url_request/url_request_context.h" |
| 34 #include "webkit/glue/webkit_glue.h" | 35 #include "webkit/glue/webkit_glue.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 request_context_(profile->GetRequestContext()), | 117 request_context_(profile->GetRequestContext()), |
| 117 profile_(profile), | 118 profile_(profile), |
| 118 render_widget_helper_(render_widget_helper), | 119 render_widget_helper_(render_widget_helper), |
| 119 audio_renderer_host_(audio_renderer_host) { | 120 audio_renderer_host_(audio_renderer_host) { |
| 120 DCHECK(request_context_.get()); | 121 DCHECK(request_context_.get()); |
| 121 DCHECK(request_context_->cookie_store()); | 122 DCHECK(request_context_->cookie_store()); |
| 122 DCHECK(audio_renderer_host_.get()); | 123 DCHECK(audio_renderer_host_.get()); |
| 123 } | 124 } |
| 124 | 125 |
| 125 ResourceMessageFilter::~ResourceMessageFilter() { | 126 ResourceMessageFilter::~ResourceMessageFilter() { |
| 127 WorkerService::GetInstance()->RendererShutdown(this); |
| 128 |
| 126 if (render_handle_) | 129 if (render_handle_) |
| 127 base::CloseProcessHandle(render_handle_); | 130 base::CloseProcessHandle(render_handle_); |
| 128 | 131 |
| 129 // This function should be called on the IO thread. | 132 // This function should be called on the IO thread. |
| 130 DCHECK(MessageLoop::current() == | 133 DCHECK(MessageLoop::current() == |
| 131 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 134 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
| 132 NotificationService::current()->RemoveObserver( | 135 NotificationService::current()->RemoveObserver( |
| 133 this, | 136 this, |
| 134 NotificationType::SPELLCHECKER_REINITIALIZED, | 137 NotificationType::SPELLCHECKER_REINITIALIZED, |
| 135 Source<Profile>(static_cast<Profile*>(profile_))); | 138 Source<Profile>(static_cast<Profile*>(profile_))); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont) | 197 IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont) |
| 195 #endif | 198 #endif |
| 196 IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnGetScreenInfo) | 199 IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnGetScreenInfo) |
| 197 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPlugins, OnGetPlugins) | 200 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPlugins, OnGetPlugins) |
| 198 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginPath, OnGetPluginPath) | 201 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginPath, OnGetPluginPath) |
| 199 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) | 202 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) |
| 200 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ContextMenu, | 203 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ContextMenu, |
| 201 OnReceiveContextMenuMsg(message)) | 204 OnReceiveContextMenuMsg(message)) |
| 202 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin, | 205 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin, |
| 203 OnOpenChannelToPlugin) | 206 OnOpenChannelToPlugin) |
| 207 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateDedicatedWorker, |
| 208 OnCreateDedicatedWorker) |
| 209 IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker, |
| 210 OnForwardToWorker) |
| 204 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SpellCheck, OnSpellCheck) | 211 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SpellCheck, OnSpellCheck) |
| 205 IPC_MESSAGE_HANDLER(ViewHostMsg_DnsPrefetch, OnDnsPrefetch) | 212 IPC_MESSAGE_HANDLER(ViewHostMsg_DnsPrefetch, OnDnsPrefetch) |
| 206 IPC_MESSAGE_HANDLER(ViewHostMsg_RendererHistograms, | 213 IPC_MESSAGE_HANDLER(ViewHostMsg_RendererHistograms, |
| 207 OnRendererHistograms) | 214 OnRendererHistograms) |
| 208 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_PaintRect, | 215 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_PaintRect, |
| 209 render_widget_helper_->DidReceivePaintMsg(message)) | 216 render_widget_helper_->DidReceivePaintMsg(message)) |
| 210 IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardWriteObjectsAsync, | 217 IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardWriteObjectsAsync, |
| 211 OnClipboardWriteObjects) | 218 OnClipboardWriteObjects) |
| 212 IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardWriteObjectsSync, | 219 IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardWriteObjectsSync, |
| 213 OnClipboardWriteObjects) | 220 OnClipboardWriteObjects) |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 492 |
| 486 void ResourceMessageFilter::OnOpenChannelToPlugin(const GURL& url, | 493 void ResourceMessageFilter::OnOpenChannelToPlugin(const GURL& url, |
| 487 const std::string& mime_type, | 494 const std::string& mime_type, |
| 488 const std::string& clsid, | 495 const std::string& clsid, |
| 489 const std::wstring& locale, | 496 const std::wstring& locale, |
| 490 IPC::Message* reply_msg) { | 497 IPC::Message* reply_msg) { |
| 491 plugin_service_->OpenChannelToPlugin(this, url, mime_type, clsid, | 498 plugin_service_->OpenChannelToPlugin(this, url, mime_type, clsid, |
| 492 locale, reply_msg); | 499 locale, reply_msg); |
| 493 } | 500 } |
| 494 | 501 |
| 502 void ResourceMessageFilter::OnCreateDedicatedWorker(const GURL& url, |
| 503 int* route_id) { |
| 504 *route_id = render_widget_helper_->GetNextRoutingID(); |
| 505 WorkerService::GetInstance()->CreateDedicatedWorker(url, this, *route_id); |
| 506 } |
| 507 |
| 508 void ResourceMessageFilter::OnForwardToWorker(const IPC::Message& message) { |
| 509 WorkerService::GetInstance()->ForwardMessage(message); |
| 510 } |
| 511 |
| 495 void ResourceMessageFilter::OnDownloadUrl(const IPC::Message& message, | 512 void ResourceMessageFilter::OnDownloadUrl(const IPC::Message& message, |
| 496 const GURL& url, | 513 const GURL& url, |
| 497 const GURL& referrer) { | 514 const GURL& referrer) { |
| 498 resource_dispatcher_host_->BeginDownload(url, | 515 resource_dispatcher_host_->BeginDownload(url, |
| 499 referrer, | 516 referrer, |
| 500 render_process_host_id_, | 517 render_process_host_id_, |
| 501 message.routing_id(), | 518 message.routing_id(), |
| 502 request_context_); | 519 request_context_); |
| 503 } | 520 } |
| 504 | 521 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 void ResourceMessageFilter::OnAllocTransportDIB( | 872 void ResourceMessageFilter::OnAllocTransportDIB( |
| 856 size_t size, IPC::Maybe<TransportDIB::Handle>* handle) { | 873 size_t size, IPC::Maybe<TransportDIB::Handle>* handle) { |
| 857 render_widget_helper_->AllocTransportDIB(size, handle); | 874 render_widget_helper_->AllocTransportDIB(size, handle); |
| 858 } | 875 } |
| 859 | 876 |
| 860 void ResourceMessageFilter::OnFreeTransportDIB( | 877 void ResourceMessageFilter::OnFreeTransportDIB( |
| 861 TransportDIB::Id dib_id) { | 878 TransportDIB::Id dib_id) { |
| 862 render_widget_helper_->FreeTransportDIB(dib_id); | 879 render_widget_helper_->FreeTransportDIB(dib_id); |
| 863 } | 880 } |
| 864 #endif | 881 #endif |
| OLD | NEW |