| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 VisitedLinkCommon::Fingerprints pending_; | 232 VisitedLinkCommon::Fingerprints pending_; |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 namespace { | 235 namespace { |
| 236 | 236 |
| 237 // Helper class that we pass to ResourceMessageFilter so that it can find the | 237 // Helper class that we pass to ResourceMessageFilter so that it can find the |
| 238 // right net::URLRequestContext for a request. | 238 // right net::URLRequestContext for a request. |
| 239 class RendererURLRequestContextOverride | 239 class RendererURLRequestContextOverride |
| 240 : public ResourceMessageFilter::URLRequestContextOverride { | 240 : public ResourceMessageFilter::URLRequestContextOverride { |
| 241 public: | 241 public: |
| 242 explicit RendererURLRequestContextOverride(Profile* profile) | 242 RendererURLRequestContextOverride(Profile* profile, |
| 243 : request_context_(profile->GetRequestContext()), | 243 const Extension* installed_app) |
| 244 : request_context_(profile->GetRequestContextForPossibleApp( |
| 245 installed_app)), |
| 244 media_request_context_(profile->GetRequestContextForMedia()) { | 246 media_request_context_(profile->GetRequestContextForMedia()) { |
| 245 } | 247 } |
| 246 | 248 |
| 247 virtual net::URLRequestContext* GetRequestContext( | 249 virtual net::URLRequestContext* GetRequestContext( |
| 248 const ViewHostMsg_Resource_Request& resource_request) { | 250 const ViewHostMsg_Resource_Request& resource_request) { |
| 249 URLRequestContextGetter* request_context = request_context_; | 251 URLRequestContextGetter* request_context = request_context_; |
| 250 // If the request has resource type of ResourceType::MEDIA, we use a request | 252 // If the request has resource type of ResourceType::MEDIA, we use a request |
| 251 // context specific to media for handling it because these resources have | 253 // context specific to media for handling it because these resources have |
| 252 // specific needs for caching. | 254 // specific needs for caching. |
| 253 if (resource_request.resource_type == ResourceType::MEDIA) | 255 if (resource_request.resource_type == ResourceType::MEDIA) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // We may have some unsent messages at this point, but that's OK. | 330 // We may have some unsent messages at this point, but that's OK. |
| 329 channel_.reset(); | 331 channel_.reset(); |
| 330 while (!queued_messages_.empty()) { | 332 while (!queued_messages_.empty()) { |
| 331 delete queued_messages_.front(); | 333 delete queued_messages_.front(); |
| 332 queued_messages_.pop(); | 334 queued_messages_.pop(); |
| 333 } | 335 } |
| 334 | 336 |
| 335 ClearTransportDIBCache(); | 337 ClearTransportDIBCache(); |
| 336 } | 338 } |
| 337 | 339 |
| 338 bool BrowserRenderProcessHost::Init( | 340 bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled, |
| 339 bool is_accessibility_enabled, bool is_extensions_process) { | 341 bool is_extensions_process, |
| 342 const Extension* installed_app) { |
| 340 // calling Init() more than once does nothing, this makes it more convenient | 343 // calling Init() more than once does nothing, this makes it more convenient |
| 341 // for the view host which may not be sure in some cases | 344 // for the view host which may not be sure in some cases |
| 342 if (channel_.get()) | 345 if (channel_.get()) |
| 343 return true; | 346 return true; |
| 344 | 347 |
| 345 accessibility_enabled_ = is_accessibility_enabled; | 348 accessibility_enabled_ = is_accessibility_enabled; |
| 346 | 349 |
| 347 // It is possible for an extension process to be reused for non-extension | 350 // It is possible for an extension process to be reused for non-extension |
| 348 // content, e.g. if an extension calls window.open. | 351 // content, e.g. if an extension calls window.open. |
| 349 extension_process_ = extension_process_ || is_extensions_process; | 352 extension_process_ = extension_process_ || is_extensions_process; |
| 350 | 353 |
| 354 // Keep track of the installed app for this process, if any. |
| 355 installed_app_ = installed_app; |
| 356 |
| 351 // run the IPC channel on the shared IO thread. | 357 // run the IPC channel on the shared IO thread. |
| 352 base::Thread* io_thread = g_browser_process->io_thread(); | 358 base::Thread* io_thread = g_browser_process->io_thread(); |
| 353 | 359 |
| 354 CommandLine::StringType renderer_prefix; | 360 CommandLine::StringType renderer_prefix; |
| 355 #if defined(OS_POSIX) | 361 #if defined(OS_POSIX) |
| 356 // A command prefix is something prepended to the command line of the spawned | 362 // A command prefix is something prepended to the command line of the spawned |
| 357 // process. It is supported only on POSIX systems. | 363 // process. It is supported only on POSIX systems. |
| 358 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 364 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 359 renderer_prefix = | 365 renderer_prefix = |
| 360 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 366 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 435 } |
| 430 | 436 |
| 431 return true; | 437 return true; |
| 432 } | 438 } |
| 433 | 439 |
| 434 void BrowserRenderProcessHost::CreateMessageFilters() { | 440 void BrowserRenderProcessHost::CreateMessageFilters() { |
| 435 scoped_refptr<RenderMessageFilter> render_message_filter( | 441 scoped_refptr<RenderMessageFilter> render_message_filter( |
| 436 new RenderMessageFilter(id(), | 442 new RenderMessageFilter(id(), |
| 437 PluginService::GetInstance(), | 443 PluginService::GetInstance(), |
| 438 profile(), | 444 profile(), |
| 439 widget_helper_)); | 445 widget_helper_, |
| 446 installed_app_)); |
| 440 channel_->AddFilter(render_message_filter); | 447 channel_->AddFilter(render_message_filter); |
| 441 | 448 |
| 442 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( | 449 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( |
| 443 new RendererURLRequestContextOverride(profile())); | 450 new RendererURLRequestContextOverride(profile(), installed_app_)); |
| 444 | 451 |
| 445 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 452 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
| 446 id(), ChildProcessInfo::RENDER_PROCESS, | 453 id(), ChildProcessInfo::RENDER_PROCESS, |
| 447 g_browser_process->resource_dispatcher_host()); | 454 g_browser_process->resource_dispatcher_host()); |
| 448 resource_message_filter->set_url_request_context_override( | 455 resource_message_filter->set_url_request_context_override( |
| 449 url_request_context_override); | 456 url_request_context_override); |
| 450 channel_->AddFilter(resource_message_filter); | 457 channel_->AddFilter(resource_message_filter); |
| 451 | 458 |
| 452 channel_->AddFilter(new AudioRendererHost()); | 459 channel_->AddFilter(new AudioRendererHost()); |
| 453 channel_->AddFilter( | 460 channel_->AddFilter( |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 IPC::PlatformFileForTransit file; | 1293 IPC::PlatformFileForTransit file; |
| 1287 #if defined(OS_POSIX) | 1294 #if defined(OS_POSIX) |
| 1288 file = base::FileDescriptor(model_file, false); | 1295 file = base::FileDescriptor(model_file, false); |
| 1289 #elif defined(OS_WIN) | 1296 #elif defined(OS_WIN) |
| 1290 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, | 1297 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, |
| 1291 false, DUPLICATE_SAME_ACCESS); | 1298 false, DUPLICATE_SAME_ACCESS); |
| 1292 #endif | 1299 #endif |
| 1293 Send(new ViewMsg_SetPhishingModel(file)); | 1300 Send(new ViewMsg_SetPhishingModel(file)); |
| 1294 } | 1301 } |
| 1295 } | 1302 } |
| OLD | NEW |