| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 VisitedLinkCommon::Fingerprints pending_; | 233 VisitedLinkCommon::Fingerprints pending_; |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 namespace { | 236 namespace { |
| 237 | 237 |
| 238 // Helper class that we pass to ResourceMessageFilter so that it can find the | 238 // Helper class that we pass to ResourceMessageFilter so that it can find the |
| 239 // right net::URLRequestContext for a request. | 239 // right net::URLRequestContext for a request. |
| 240 class RendererURLRequestContextOverride | 240 class RendererURLRequestContextOverride |
| 241 : public ResourceMessageFilter::URLRequestContextOverride { | 241 : public ResourceMessageFilter::URLRequestContextOverride { |
| 242 public: | 242 public: |
| 243 explicit RendererURLRequestContextOverride(Profile* profile) | 243 RendererURLRequestContextOverride(Profile* profile, |
| 244 : request_context_(profile->GetRequestContext()), | 244 const Extension* installed_app) |
| 245 : request_context_(profile->GetRequestContextForPossibleApp( |
| 246 installed_app)), |
| 245 media_request_context_(profile->GetRequestContextForMedia()) { | 247 media_request_context_(profile->GetRequestContextForMedia()) { |
| 246 } | 248 } |
| 247 | 249 |
| 248 virtual net::URLRequestContext* GetRequestContext( | 250 virtual net::URLRequestContext* GetRequestContext( |
| 249 const ResourceHostMsg_Request& resource_request) { | 251 const ResourceHostMsg_Request& resource_request) { |
| 250 URLRequestContextGetter* request_context = request_context_; | 252 URLRequestContextGetter* request_context = request_context_; |
| 251 // If the request has resource type of ResourceType::MEDIA, we use a request | 253 // If the request has resource type of ResourceType::MEDIA, we use a request |
| 252 // context specific to media for handling it because these resources have | 254 // context specific to media for handling it because these resources have |
| 253 // specific needs for caching. | 255 // specific needs for caching. |
| 254 if (resource_request.resource_type == ResourceType::MEDIA) | 256 if (resource_request.resource_type == ResourceType::MEDIA) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // We may have some unsent messages at this point, but that's OK. | 331 // We may have some unsent messages at this point, but that's OK. |
| 330 channel_.reset(); | 332 channel_.reset(); |
| 331 while (!queued_messages_.empty()) { | 333 while (!queued_messages_.empty()) { |
| 332 delete queued_messages_.front(); | 334 delete queued_messages_.front(); |
| 333 queued_messages_.pop(); | 335 queued_messages_.pop(); |
| 334 } | 336 } |
| 335 | 337 |
| 336 ClearTransportDIBCache(); | 338 ClearTransportDIBCache(); |
| 337 } | 339 } |
| 338 | 340 |
| 339 bool BrowserRenderProcessHost::Init( | 341 bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled, |
| 340 bool is_accessibility_enabled, bool is_extensions_process) { | 342 bool is_extensions_process, |
| 343 const Extension* installed_app) { |
| 341 // calling Init() more than once does nothing, this makes it more convenient | 344 // calling Init() more than once does nothing, this makes it more convenient |
| 342 // for the view host which may not be sure in some cases | 345 // for the view host which may not be sure in some cases |
| 343 if (channel_.get()) | 346 if (channel_.get()) |
| 344 return true; | 347 return true; |
| 345 | 348 |
| 346 accessibility_enabled_ = is_accessibility_enabled; | 349 accessibility_enabled_ = is_accessibility_enabled; |
| 347 | 350 |
| 348 // It is possible for an extension process to be reused for non-extension | 351 // It is possible for an extension process to be reused for non-extension |
| 349 // content, e.g. if an extension calls window.open. | 352 // content, e.g. if an extension calls window.open. |
| 350 extension_process_ = extension_process_ || is_extensions_process; | 353 extension_process_ = extension_process_ || is_extensions_process; |
| 351 | 354 |
| 355 // Keep track of the installed app for this process, if any. |
| 356 installed_app_ = installed_app; |
| 357 |
| 352 // run the IPC channel on the shared IO thread. | 358 // run the IPC channel on the shared IO thread. |
| 353 base::Thread* io_thread = g_browser_process->io_thread(); | 359 base::Thread* io_thread = g_browser_process->io_thread(); |
| 354 | 360 |
| 355 CommandLine::StringType renderer_prefix; | 361 CommandLine::StringType renderer_prefix; |
| 356 #if defined(OS_POSIX) | 362 #if defined(OS_POSIX) |
| 357 // A command prefix is something prepended to the command line of the spawned | 363 // A command prefix is something prepended to the command line of the spawned |
| 358 // process. It is supported only on POSIX systems. | 364 // process. It is supported only on POSIX systems. |
| 359 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 365 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 360 renderer_prefix = | 366 renderer_prefix = |
| 361 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 367 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 436 } |
| 431 | 437 |
| 432 return true; | 438 return true; |
| 433 } | 439 } |
| 434 | 440 |
| 435 void BrowserRenderProcessHost::CreateMessageFilters() { | 441 void BrowserRenderProcessHost::CreateMessageFilters() { |
| 436 scoped_refptr<RenderMessageFilter> render_message_filter( | 442 scoped_refptr<RenderMessageFilter> render_message_filter( |
| 437 new RenderMessageFilter(id(), | 443 new RenderMessageFilter(id(), |
| 438 PluginService::GetInstance(), | 444 PluginService::GetInstance(), |
| 439 profile(), | 445 profile(), |
| 440 widget_helper_)); | 446 widget_helper_, |
| 447 installed_app_)); |
| 441 channel_->AddFilter(render_message_filter); | 448 channel_->AddFilter(render_message_filter); |
| 442 | 449 |
| 443 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( | 450 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( |
| 444 new RendererURLRequestContextOverride(profile())); | 451 new RendererURLRequestContextOverride(profile(), installed_app_)); |
| 445 | 452 |
| 446 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 453 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
| 447 id(), ChildProcessInfo::RENDER_PROCESS, | 454 id(), ChildProcessInfo::RENDER_PROCESS, |
| 448 g_browser_process->resource_dispatcher_host()); | 455 g_browser_process->resource_dispatcher_host()); |
| 449 resource_message_filter->set_url_request_context_override( | 456 resource_message_filter->set_url_request_context_override( |
| 450 url_request_context_override); | 457 url_request_context_override); |
| 451 channel_->AddFilter(resource_message_filter); | 458 channel_->AddFilter(resource_message_filter); |
| 452 | 459 |
| 453 channel_->AddFilter(new AudioRendererHost()); | 460 channel_->AddFilter(new AudioRendererHost()); |
| 454 channel_->AddFilter( | 461 channel_->AddFilter( |
| (...skipping 831 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 |