| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/worker_host/worker_service.h" | 25 #include "chrome/browser/worker_host/worker_service.h" |
| 26 #include "chrome/common/chrome_plugin_lib.h" | 26 #include "chrome/common/chrome_plugin_lib.h" |
| 27 #include "chrome/common/chrome_plugin_util.h" | 27 #include "chrome/common/chrome_plugin_util.h" |
| 28 #include "chrome/common/clipboard_service.h" | 28 #include "chrome/common/clipboard_service.h" |
| 29 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/pref_service.h" | 31 #include "chrome/common/pref_service.h" |
| 32 #include "chrome/common/render_messages.h" | 32 #include "chrome/common/render_messages.h" |
| 33 #include "net/base/cookie_monster.h" | 33 #include "net/base/cookie_monster.h" |
| 34 #include "net/base/mime_util.h" | 34 #include "net/base/mime_util.h" |
| 35 #include "net/base/load_flags.h" |
| 35 #include "net/url_request/url_request_context.h" | 36 #include "net/url_request/url_request_context.h" |
| 36 #include "webkit/glue/webkit_glue.h" | 37 #include "webkit/glue/webkit_glue.h" |
| 37 #include "webkit/glue/webplugin.h" | 38 #include "webkit/glue/webplugin.h" |
| 38 | 39 |
| 39 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
| 40 #include "chrome/browser/printing/print_job_manager.h" | 41 #include "chrome/browser/printing/print_job_manager.h" |
| 41 #include "chrome/browser/printing/printer_query.h" | 42 #include "chrome/browser/printing/printer_query.h" |
| 42 #elif defined(OS_MACOSX) || defined(OS_LINUX) | 43 #elif defined(OS_MACOSX) || defined(OS_LINUX) |
| 43 // TODO(port) remove this. | 44 // TODO(port) remove this. |
| 44 #include "chrome/common/temp_scaffolding_stubs.h" | 45 #include "chrome/common/temp_scaffolding_stubs.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 SpellChecker* spellchecker) | 108 SpellChecker* spellchecker) |
| 108 : channel_(NULL), | 109 : channel_(NULL), |
| 109 resource_dispatcher_host_(resource_dispatcher_host), | 110 resource_dispatcher_host_(resource_dispatcher_host), |
| 110 plugin_service_(plugin_service), | 111 plugin_service_(plugin_service), |
| 111 print_job_manager_(print_job_manager), | 112 print_job_manager_(print_job_manager), |
| 112 render_process_id_(-1), | 113 render_process_id_(-1), |
| 113 spellchecker_(spellchecker), | 114 spellchecker_(spellchecker), |
| 114 ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)), | 115 ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)), |
| 115 render_handle_(NULL), | 116 render_handle_(NULL), |
| 116 request_context_(profile->GetRequestContext()), | 117 request_context_(profile->GetRequestContext()), |
| 118 media_request_context_(profile->GetRequestContextForMedia()), |
| 117 profile_(profile), | 119 profile_(profile), |
| 118 render_widget_helper_(render_widget_helper), | 120 render_widget_helper_(render_widget_helper), |
| 119 audio_renderer_host_(audio_renderer_host) { | 121 audio_renderer_host_(audio_renderer_host) { |
| 120 DCHECK(request_context_.get()); | 122 DCHECK(request_context_.get()); |
| 121 DCHECK(request_context_->cookie_store()); | 123 DCHECK(request_context_->cookie_store()); |
| 124 DCHECK(media_request_context_.get()); |
| 125 DCHECK(media_request_context_->cookie_store()); |
| 122 DCHECK(audio_renderer_host_.get()); | 126 DCHECK(audio_renderer_host_.get()); |
| 123 } | 127 } |
| 124 | 128 |
| 125 ResourceMessageFilter::~ResourceMessageFilter() { | 129 ResourceMessageFilter::~ResourceMessageFilter() { |
| 126 WorkerService::GetInstance()->RendererShutdown(this); | 130 WorkerService::GetInstance()->RendererShutdown(this); |
| 127 | 131 |
| 128 if (render_handle_) | 132 if (render_handle_) |
| 129 base::CloseProcessHandle(render_handle_); | 133 base::CloseProcessHandle(render_handle_); |
| 130 | 134 |
| 131 // This function should be called on the IO thread. | 135 // This function should be called on the IO thread. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 bool msg_is_ok = true; | 185 bool msg_is_ok = true; |
| 182 IPC_BEGIN_MESSAGE_MAP_EX(ResourceMessageFilter, message, msg_is_ok) | 186 IPC_BEGIN_MESSAGE_MAP_EX(ResourceMessageFilter, message, msg_is_ok) |
| 183 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnMsgCreateWindow) | 187 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnMsgCreateWindow) |
| 184 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget) | 188 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget) |
| 185 // TODO(brettw): we should get the view ID for this so the resource | 189 // TODO(brettw): we should get the view ID for this so the resource |
| 186 // dispatcher can prioritize things based on the visible view. | 190 // dispatcher can prioritize things based on the visible view. |
| 187 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource) | 191 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource) |
| 188 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelRequest, OnCancelRequest) | 192 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelRequest, OnCancelRequest) |
| 189 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 193 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
| 190 IPC_MESSAGE_HANDLER(ViewHostMsg_DataReceived_ACK, OnDataReceivedACK) | 194 IPC_MESSAGE_HANDLER(ViewHostMsg_DataReceived_ACK, OnDataReceivedACK) |
| 195 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadProgress_ACK, OnDownloadProgressACK) |
| 191 IPC_MESSAGE_HANDLER(ViewHostMsg_UploadProgress_ACK, OnUploadProgressACK) | 196 IPC_MESSAGE_HANDLER(ViewHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
| 192 | 197 |
| 193 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad) | 198 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad) |
| 194 | 199 |
| 195 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) | 200 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) |
| 196 IPC_MESSAGE_HANDLER(ViewHostMsg_GetCookies, OnGetCookies) | 201 IPC_MESSAGE_HANDLER(ViewHostMsg_GetCookies, OnGetCookies) |
| 197 IPC_MESSAGE_HANDLER(ViewHostMsg_GetDataDir, OnGetDataDir) | 202 IPC_MESSAGE_HANDLER(ViewHostMsg_GetDataDir, OnGetDataDir) |
| 198 IPC_MESSAGE_HANDLER(ViewHostMsg_PluginMessage, OnPluginMessage) | 203 IPC_MESSAGE_HANDLER(ViewHostMsg_PluginMessage, OnPluginMessage) |
| 199 IPC_MESSAGE_HANDLER(ViewHostMsg_PluginSyncMessage, OnPluginSyncMessage) | 204 IPC_MESSAGE_HANDLER(ViewHostMsg_PluginSyncMessage, OnPluginSyncMessage) |
| 200 #if defined(OS_WIN) // This hack is Windows-specific. | 205 #if defined(OS_WIN) // This hack is Windows-specific. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 void ResourceMessageFilter::OnMsgCreateWidget(int opener_id, | 331 void ResourceMessageFilter::OnMsgCreateWidget(int opener_id, |
| 327 bool activatable, | 332 bool activatable, |
| 328 int* route_id) { | 333 int* route_id) { |
| 329 render_widget_helper_->CreateNewWidget(opener_id, activatable, route_id); | 334 render_widget_helper_->CreateNewWidget(opener_id, activatable, route_id); |
| 330 } | 335 } |
| 331 | 336 |
| 332 void ResourceMessageFilter::OnRequestResource( | 337 void ResourceMessageFilter::OnRequestResource( |
| 333 const IPC::Message& message, | 338 const IPC::Message& message, |
| 334 int request_id, | 339 int request_id, |
| 335 const ViewHostMsg_Resource_Request& request) { | 340 const ViewHostMsg_Resource_Request& request) { |
| 341 URLRequestContext* request_context = request_context_; |
| 342 // If the request has resource type of ResourceType::MEDIA and |
| 343 // LOAD_ENABLE_DOWNLOAD_FILE is set as a load flag, we use a request context |
| 344 // specific to media for handling it because these resources have specific |
| 345 // needs for caching and data passing. |
| 346 if (request.resource_type == ResourceType::MEDIA && |
| 347 (request.load_flags & net::LOAD_ENABLE_DOWNLOAD_FILE)) { |
| 348 request_context = media_request_context_; |
| 349 } |
| 350 |
| 336 resource_dispatcher_host_->BeginRequest(this, | 351 resource_dispatcher_host_->BeginRequest(this, |
| 337 ChildProcessInfo::RENDER_PROCESS, | 352 ChildProcessInfo::RENDER_PROCESS, |
| 338 render_handle_, | 353 render_handle_, |
| 339 render_process_id_, | 354 render_process_id_, |
| 340 message.routing_id(), | 355 message.routing_id(), |
| 341 request_id, | 356 request_id, |
| 342 request, | 357 request, |
| 343 request_context_, | 358 request_context, |
| 344 NULL); | 359 NULL); |
| 345 } | 360 } |
| 346 | 361 |
| 347 void ResourceMessageFilter::OnDataReceivedACK(int request_id) { | 362 void ResourceMessageFilter::OnDataReceivedACK(int request_id) { |
| 348 resource_dispatcher_host_->OnDataReceivedACK(render_process_id_, request_id); | 363 resource_dispatcher_host_->OnDataReceivedACK(render_process_id_, request_id); |
| 349 } | 364 } |
| 350 | 365 |
| 366 void ResourceMessageFilter::OnDownloadProgressACK(int request_id) { |
| 367 resource_dispatcher_host_->OnDownloadProgressACK(render_process_id_, |
| 368 request_id); |
| 369 } |
| 370 |
| 351 void ResourceMessageFilter::OnUploadProgressACK(int request_id) { | 371 void ResourceMessageFilter::OnUploadProgressACK(int request_id) { |
| 352 resource_dispatcher_host_->OnUploadProgressACK(render_process_id_, | 372 resource_dispatcher_host_->OnUploadProgressACK(render_process_id_, |
| 353 request_id); | 373 request_id); |
| 354 } | 374 } |
| 355 | 375 |
| 356 void ResourceMessageFilter::OnCancelRequest(int request_id) { | 376 void ResourceMessageFilter::OnCancelRequest(int request_id) { |
| 357 resource_dispatcher_host_->CancelRequest(render_process_id_, request_id, | 377 resource_dispatcher_host_->CancelRequest(render_process_id_, request_id, |
| 358 true); | 378 true); |
| 359 } | 379 } |
| 360 | 380 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 void ResourceMessageFilter::OnAllocTransportDIB( | 892 void ResourceMessageFilter::OnAllocTransportDIB( |
| 873 size_t size, TransportDIB::Handle* handle) { | 893 size_t size, TransportDIB::Handle* handle) { |
| 874 render_widget_helper_->AllocTransportDIB(size, handle); | 894 render_widget_helper_->AllocTransportDIB(size, handle); |
| 875 } | 895 } |
| 876 | 896 |
| 877 void ResourceMessageFilter::OnFreeTransportDIB( | 897 void ResourceMessageFilter::OnFreeTransportDIB( |
| 878 TransportDIB::Id dib_id) { | 898 TransportDIB::Id dib_id) { |
| 879 render_widget_helper_->FreeTransportDIB(dib_id); | 899 render_widget_helper_->FreeTransportDIB(dib_id); |
| 880 } | 900 } |
| 881 #endif | 901 #endif |
| OLD | NEW |