| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 VisitedLinkCommon::Fingerprints pending_; | 226 VisitedLinkCommon::Fingerprints pending_; |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 namespace { | 229 namespace { |
| 230 | 230 |
| 231 // Helper class that we pass to ResourceMessageFilter so that it can find the | 231 // Helper class that we pass to ResourceMessageFilter so that it can find the |
| 232 // right URLRequestContext for a request. | 232 // right URLRequestContext for a request. |
| 233 class RendererURLRequestContextOverride | 233 class RendererURLRequestContextOverride |
| 234 : public ResourceMessageFilter::URLRequestContextOverride { | 234 : public ResourceMessageFilter::URLRequestContextOverride { |
| 235 public: | 235 public: |
| 236 explicit RendererURLRequestContextOverride(Profile* profile) | 236 explicit RendererURLRequestContextOverride(Profile* profile, |
| 237 : request_context_(profile->GetRequestContext()), | 237 const Extension* installed_app) |
| 238 : request_context_(profile->GetRequestContext(installed_app)), |
| 238 media_request_context_(profile->GetRequestContextForMedia()) { | 239 media_request_context_(profile->GetRequestContextForMedia()) { |
| 239 } | 240 } |
| 240 | 241 |
| 241 virtual URLRequestContext* GetRequestContext( | 242 virtual URLRequestContext* GetRequestContext( |
| 242 uint32 request_id, ResourceType::Type resource_type) { | 243 uint32 request_id, ResourceType::Type resource_type) { |
| 243 URLRequestContextGetter* request_context = request_context_; | 244 URLRequestContextGetter* request_context = request_context_; |
| 244 // If the request has resource type of ResourceType::MEDIA, we use a request | 245 // If the request has resource type of ResourceType::MEDIA, we use a request |
| 245 // context specific to media for handling it because these resources have | 246 // context specific to media for handling it because these resources have |
| 246 // specific needs for caching. | 247 // specific needs for caching. |
| 247 if (resource_type == ResourceType::MEDIA) | 248 if (resource_type == ResourceType::MEDIA) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 channel_.reset(); | 324 channel_.reset(); |
| 324 while (!queued_messages_.empty()) { | 325 while (!queued_messages_.empty()) { |
| 325 delete queued_messages_.front(); | 326 delete queued_messages_.front(); |
| 326 queued_messages_.pop(); | 327 queued_messages_.pop(); |
| 327 } | 328 } |
| 328 | 329 |
| 329 ClearTransportDIBCache(); | 330 ClearTransportDIBCache(); |
| 330 } | 331 } |
| 331 | 332 |
| 332 bool BrowserRenderProcessHost::Init( | 333 bool BrowserRenderProcessHost::Init( |
| 333 bool is_accessibility_enabled, bool is_extensions_process) { | 334 bool is_accessibility_enabled, bool is_extensions_process, |
| 335 const Extension* installed_app) { |
| 334 // calling Init() more than once does nothing, this makes it more convenient | 336 // calling Init() more than once does nothing, this makes it more convenient |
| 335 // for the view host which may not be sure in some cases | 337 // for the view host which may not be sure in some cases |
| 336 if (channel_.get()) | 338 if (channel_.get()) |
| 337 return true; | 339 return true; |
| 338 | 340 |
| 339 accessibility_enabled_ = is_accessibility_enabled; | 341 accessibility_enabled_ = is_accessibility_enabled; |
| 340 | 342 |
| 341 // It is possible for an extension process to be reused for non-extension | 343 // It is possible for an extension process to be reused for non-extension |
| 342 // content, e.g. if an extension calls window.open. | 344 // content, e.g. if an extension calls window.open. |
| 343 extension_process_ = extension_process_ || is_extensions_process; | 345 extension_process_ = extension_process_ || is_extensions_process; |
| 344 | 346 |
| 347 // Keep track of the installed app for this process, if any. |
| 348 installed_app_ = installed_app; |
| 349 |
| 345 // run the IPC channel on the shared IO thread. | 350 // run the IPC channel on the shared IO thread. |
| 346 base::Thread* io_thread = g_browser_process->io_thread(); | 351 base::Thread* io_thread = g_browser_process->io_thread(); |
| 347 | 352 |
| 348 CommandLine::StringType renderer_prefix; | 353 CommandLine::StringType renderer_prefix; |
| 349 #if defined(OS_POSIX) | 354 #if defined(OS_POSIX) |
| 350 // A command prefix is something prepended to the command line of the spawned | 355 // A command prefix is something prepended to the command line of the spawned |
| 351 // process. It is supported only on POSIX systems. | 356 // process. It is supported only on POSIX systems. |
| 352 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 357 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 353 renderer_prefix = | 358 renderer_prefix = |
| 354 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 359 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 428 } |
| 424 | 429 |
| 425 return true; | 430 return true; |
| 426 } | 431 } |
| 427 | 432 |
| 428 void BrowserRenderProcessHost::CreateMessageFilters() { | 433 void BrowserRenderProcessHost::CreateMessageFilters() { |
| 429 scoped_refptr<RenderMessageFilter> render_message_filter( | 434 scoped_refptr<RenderMessageFilter> render_message_filter( |
| 430 new RenderMessageFilter(id(), | 435 new RenderMessageFilter(id(), |
| 431 PluginService::GetInstance(), | 436 PluginService::GetInstance(), |
| 432 profile(), | 437 profile(), |
| 433 widget_helper_)); | 438 widget_helper_, |
| 439 installed_app_)); |
| 434 channel_->AddFilter(render_message_filter); | 440 channel_->AddFilter(render_message_filter); |
| 435 | 441 |
| 436 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( | 442 scoped_refptr<RendererURLRequestContextOverride> url_request_context_override( |
| 437 new RendererURLRequestContextOverride(profile())); | 443 new RendererURLRequestContextOverride(profile(), installed_app_)); |
| 438 | 444 |
| 439 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( | 445 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( |
| 440 id(), ChildProcessInfo::RENDER_PROCESS, | 446 id(), ChildProcessInfo::RENDER_PROCESS, |
| 441 g_browser_process->resource_dispatcher_host()); | 447 g_browser_process->resource_dispatcher_host()); |
| 442 resource_message_filter->set_url_request_context_override( | 448 resource_message_filter->set_url_request_context_override( |
| 443 url_request_context_override); | 449 url_request_context_override); |
| 444 channel_->AddFilter(resource_message_filter); | 450 channel_->AddFilter(resource_message_filter); |
| 445 | 451 |
| 446 channel_->AddFilter(new AudioRendererHost()); | 452 channel_->AddFilter(new AudioRendererHost()); |
| 447 channel_->AddFilter( | 453 channel_->AddFilter( |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 IPC::PlatformFileForTransit file; | 1293 IPC::PlatformFileForTransit file; |
| 1288 #if defined(OS_POSIX) | 1294 #if defined(OS_POSIX) |
| 1289 file = base::FileDescriptor(model_file, false); | 1295 file = base::FileDescriptor(model_file, false); |
| 1290 #elif defined(OS_WIN) | 1296 #elif defined(OS_WIN) |
| 1291 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, | 1297 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, |
| 1292 false, DUPLICATE_SAME_ACCESS); | 1298 false, DUPLICATE_SAME_ACCESS); |
| 1293 #endif | 1299 #endif |
| 1294 Send(new ViewMsg_SetPhishingModel(file)); | 1300 Send(new ViewMsg_SetPhishingModel(file)); |
| 1295 } | 1301 } |
| 1296 } | 1302 } |
| OLD | NEW |